/* ============================================================================
   POKÉSPIRE · UNIFIED FULL-SCREEN BATTLE SELECTION & SCRY (PORCELAIN ACRYLIC)
   ============================================================================ */

.battle-screen.is-selecting-cards {
  --selection-card-width: clamp(92px, 13vw, 156px);
  --selection-top: calc(var(--run-hud-size, 76px) + 12px);
}

.battle-selection-confirm[hidden] {
  display: none;
}

.battle-selection-confirm {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 108px;
  min-height: 48px;
  padding: 8px 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 12px 26px -8px rgba(37, 99, 235, 0.50);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.battle-selection-confirm:hover:not(:disabled),
.battle-selection-confirm:focus-visible:not(:disabled) {
  background: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 16px 32px -8px rgba(37, 99, 235, 0.62);
  transform: translateY(-2px);
  outline: 2px solid #bae6fd;
  outline-offset: 3px;
}

.battle-selection-confirm:active:not(:disabled) {
  transform: translateY(0);
}

.battle-selection-confirm:disabled {
  background: rgba(226, 232, 240, 0.92);
  color: #64748b;
  border: 1px solid rgba(148, 163, 184, 0.42);
  box-shadow: 0 4px 12px -6px rgba(15, 23, 42, 0.16);
  cursor: not-allowed;
}

.bsel-cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.44);
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 8px 20px -8px rgba(15, 23, 42, 0.22);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.bsel-cancel-btn:hover,
.bsel-cancel-btn:focus-visible {
  background: #ffffff;
  border-color: #64748b;
  color: #0f172a;
  transform: translateY(-2px);
  outline: none;
}

/* ============================================================================
   FULL-SCREEN PORCELAIN SELECTION STAGE (SCRY & ALL CARD CHOICES)
   ============================================================================ */

#app[data-screen="battle"] .battle-screen.is-scry-selection .hand-dock {
  opacity: 0.42;
  filter: saturate(0.75);
  transition: opacity 0.24s ease, filter 0.24s ease;
}

#app[data-screen="battle"] .battle-screen.is-scry-selection.is-peeking .hand-dock {
  opacity: 1;
  filter: none;
  position: relative;
  z-index: 68;
}

.battle-scry-overlay {
  --bsel-pill-bg: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  --bsel-pill-shadow: rgba(109, 40, 217, 0.48);
  --bsel-ambient-a: rgba(139, 92, 246, 0.14);
  --bsel-ambient-b: rgba(56, 189, 248, 0.08);
  --bsel-accent: #0284c7;
  --bsel-accent-light: #38bdf8;
  --bsel-accent-ring: rgba(56, 189, 248, 0.24);
  --bsel-accent-shadow: rgba(2, 132, 199, 0.42);
  --bsel-stamp-bg: rgba(220, 38, 38, 0.94);
  --bsel-stamp-shadow: rgba(127, 29, 29, 0.48);

  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.8vh, 20px);
  padding: calc(var(--run-hud-size, 84px) + 14px) clamp(14px, 3vw, 40px) clamp(18px, 3vh, 34px);
  background: radial-gradient(
    ellipse 74% 62% at 50% 48%,
    rgba(241, 245, 255, 0.34),
    rgba(226, 236, 248, 0.22) 48%,
    rgba(15, 23, 42, 0.56) 100%
  );
  backdrop-filter: blur(10px) saturate(1.18);
  -webkit-backdrop-filter: blur(10px) saturate(1.18);
  pointer-events: auto;
  overflow: hidden;
  transition: background 0.22s ease, backdrop-filter 0.22s ease;
}

.battle-scry-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 46% 36% at 50% 50%, var(--bsel-ambient-a), var(--bsel-ambient-b) 55%, transparent 78%);
  transition: opacity 0.2s ease;
}

.battle-scry-overlay.is-peeking {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
}

.battle-scry-overlay.is-peeking::before {
  opacity: 0;
}

.battle-scry-overlay .scry-header,
.battle-scry-overlay .battle-scry-stage,
.battle-scry-overlay .scry-footer {
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.battle-scry-overlay.is-peeking :is(.scry-header, .battle-scry-stage, .scry-footer) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.96);
}

/* Per-Mode Semantic Color Tokens */
.battle-scry-overlay[data-sel-theme="undercurrent"] {
  --bsel-pill-bg: linear-gradient(135deg, #06b6d4 0%, #2563eb 100%);
  --bsel-pill-shadow: rgba(2, 132, 199, 0.48);
  --bsel-ambient-a: rgba(6, 182, 212, 0.14);
  --bsel-ambient-b: rgba(37, 99, 235, 0.08);
}

.battle-scry-overlay[data-sel-theme="discard"] {
  --bsel-pill-bg: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --bsel-pill-shadow: rgba(220, 38, 38, 0.45);
  --bsel-ambient-a: rgba(239, 68, 68, 0.13);
  --bsel-ambient-b: rgba(249, 115, 22, 0.06);
  --bsel-accent: #dc2626;
  --bsel-accent-light: #ef4444;
  --bsel-accent-ring: rgba(239, 68, 68, 0.22);
  --bsel-accent-shadow: rgba(185, 28, 28, 0.4);
  --bsel-stamp-bg: rgba(220, 38, 38, 0.94);
  --bsel-stamp-shadow: rgba(127, 29, 29, 0.48);
}

.battle-scry-overlay[data-sel-theme="exhaust"] {
  --bsel-pill-bg: linear-gradient(135deg, #f97316 0%, #dc2626 100%);
  --bsel-pill-shadow: rgba(234, 88, 12, 0.48);
  --bsel-ambient-a: rgba(249, 115, 22, 0.15);
  --bsel-ambient-b: rgba(220, 38, 38, 0.08);
  --bsel-accent: #ea580c;
  --bsel-accent-light: #fb923c;
  --bsel-accent-ring: rgba(249, 115, 22, 0.24);
  --bsel-accent-shadow: rgba(194, 65, 12, 0.44);
  --bsel-stamp-bg: linear-gradient(135deg, #ea580c 0%, #dc2626 100%);
  --bsel-stamp-shadow: rgba(154, 52, 18, 0.5);
}

.battle-scry-overlay[data-sel-theme="retain"] {
  --bsel-pill-bg: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --bsel-pill-shadow: rgba(5, 150, 105, 0.45);
  --bsel-ambient-a: rgba(16, 185, 129, 0.14);
  --bsel-ambient-b: rgba(14, 165, 233, 0.08);
  --bsel-accent: #059669;
  --bsel-accent-light: #34d399;
  --bsel-accent-ring: rgba(16, 185, 129, 0.24);
  --bsel-accent-shadow: rgba(5, 150, 105, 0.42);
  --bsel-stamp-bg: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --bsel-stamp-shadow: rgba(6, 95, 70, 0.45);
}

.battle-scry-overlay[data-sel-theme="copy"] {
  --bsel-pill-bg: linear-gradient(135deg, #8b5cf6 0%, #4f46e5 100%);
  --bsel-pill-shadow: rgba(99, 102, 241, 0.46);
  --bsel-ambient-a: rgba(139, 92, 246, 0.15);
  --bsel-ambient-b: rgba(99, 102, 241, 0.08);
  --bsel-accent: #6366f1;
  --bsel-accent-light: #a78bfa;
  --bsel-accent-ring: rgba(139, 92, 246, 0.26);
  --bsel-accent-shadow: rgba(79, 70, 229, 0.42);
  --bsel-stamp-bg: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  --bsel-stamp-shadow: rgba(67, 56, 202, 0.45);
}

.battle-scry-overlay[data-sel-theme="retrieve"],
.battle-scry-overlay[data-sel-theme="choose"] {
  --bsel-pill-bg: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  --bsel-pill-shadow: rgba(37, 99, 235, 0.46);
  --bsel-ambient-a: rgba(14, 165, 233, 0.14);
  --bsel-ambient-b: rgba(37, 99, 235, 0.08);
  --bsel-accent: #0284c7;
  --bsel-accent-light: #38bdf8;
  --bsel-accent-ring: rgba(56, 189, 248, 0.26);
  --bsel-accent-shadow: rgba(2, 132, 199, 0.42);
  --bsel-stamp-bg: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  --bsel-stamp-shadow: rgba(30, 64, 175, 0.45);
}

.battle-scry-overlay.is-entering {
  animation: scryOverlayIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.battle-scry-overlay.is-entering .scry-header {
  animation: scryHeaderIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.battle-scry-overlay.is-entering .scry-footer {
  animation: scryFooterIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) 0.06s both;
}

@keyframes scryOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scryHeaderIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes scryFooterIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Official Item Icons */
.bsel-ico {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.25));
}

/* Header Card (Porcelain Acrylic) */
.scry-header {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: min(720px, 100%);
  padding: 11px 22px 10px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px) saturate(1.38);
  -webkit-backdrop-filter: blur(18px) saturate(1.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 16px 34px -14px rgba(15, 42, 78, 0.22),
    0 4px 10px rgba(15, 23, 42, 0.06);
  color: #0f172a;
  text-align: center;
}

.scry-header:focus {
  outline: none;
}

.scry-header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
}

.scry-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px 3px 8px;
  border-radius: 999px;
  background: var(--bsel-pill-bg);
  box-shadow: 0 4px 12px -4px var(--bsel-pill-shadow);
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #ffffff;
}

.scry-header h2 {
  margin: 0;
  font-size: clamp(16px, 1.9vw, 21px);
  font-weight: 900;
  color: #0f172a;
  line-height: 1.2;
}

.scry-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 12.5px;
  font-weight: 800;
}

.scry-header-sub {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  font-size: clamp(11.5px, 1.05vw, 13px);
  font-weight: 600;
  color: #475569;
  line-height: 1.35;
}

.scry-bonus-chip {
  font-style: normal;
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.28);
  color: #0369a1;
  font-size: 11.5px;
  font-weight: 800;
}

/* Main Center Stage */
.battle-scry-stage {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.8vh, 18px);
}

/* Deck-Top Order Bar */
.scry-order-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(680px, 92%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 22px -10px rgba(15, 23, 42, 0.22);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.scry-order-anchor {
  flex: none;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.scry-order-anchor.is-top {
  color: #0284c7;
}

.scry-order-anchor.is-tail {
  color: #64748b;
  font-weight: 800;
}

.scry-order-line {
  position: relative;
  flex: 1;
  min-width: 48px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0284c7 0%, #38bdf8 55%, rgba(148, 163, 184, 0.55) 100%);
}

.scry-order-line::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-top: 2px solid #94a3b8;
  border-right: 2px solid #94a3b8;
  transform: translateY(-50%) rotate(45deg);
}

.scry-order-bar.is-all-discard {
  background: rgba(254, 242, 242, 0.92);
  border-color: rgba(254, 202, 202, 0.9);
}

.scry-order-bar.is-all-discard .scry-order-anchor.is-top {
  color: #dc2626;
}

.scry-order-bar.is-all-discard .scry-order-line {
  opacity: 0.35;
}

/* Cards Row & Multi-Card Grid */
.scry-cards-row {
  --scry-card-width: clamp(138px, min(17.5vw, 30vh), 192px);
  display: flex;
  align-items: flex-start;
  gap: clamp(14px, 2.2vw, 28px);
  width: 100%;
  max-width: 100%;
  padding: 14px clamp(12px, 2vw, 24px) 16px;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  scrollbar-color: rgba(148, 163, 184, 0.7) transparent;
}

.scry-cards-row[data-scry-count="5"] {
  --scry-card-width: clamp(124px, min(15.2vw, 27.5vh), 174px);
}

.scry-cards-row[data-scry-count="6"],
.scry-cards-row[data-scry-count="7"] {
  --scry-card-width: clamp(114px, min(13.2vw, 25vh), 156px);
  gap: clamp(10px, 1.5vw, 18px);
}

.scry-cards-row[data-sel-layout="row"] > :first-child { margin-inline-start: auto; }
.scry-cards-row[data-sel-layout="row"] > :last-child { margin-inline-end: auto; }

.scry-cards-row[data-sel-layout="grid"] {
  --scry-card-width: clamp(112px, min(13.5vw, 24vh), 154px);
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 16px clamp(12px, 1.8vw, 22px);
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px clamp(14px, 2.5vw, 32px) 20px;
}

/* Individual Card Slot */
.scry-slot {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: var(--scry-card-width);
}

.scry-order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.18s ease,
    box-shadow 0.2s ease;
}

.scry-order-badge.is-top {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: #ffffff;
  box-shadow: 0 8px 18px -6px rgba(37, 99, 235, 0.55);
}

.scry-order-badge.is-keep {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.38);
  color: #0f172a;
  box-shadow: 0 6px 14px -6px rgba(15, 23, 42, 0.18);
}

.scry-order-badge.is-discard {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: 1px solid rgba(254, 202, 202, 0.72);
  color: #ffffff;
  box-shadow: 0 8px 18px -6px rgba(220, 38, 38, 0.45);
}

.scry-order-badge.is-picked {
  background: var(--bsel-stamp-bg);
  border: 1px solid rgba(255, 255, 255, 0.75);
  color: #ffffff;
  box-shadow: 0 8px 18px -6px var(--bsel-stamp-shadow);
}

.scry-slot.is-rank-promoted .scry-order-badge.is-top {
  animation: scryTopPromote 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes scryTopPromote {
  0% { transform: scale(0.88); }
  55% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Bulletproof Card Holder: flattens 3D card context inside z-index: 1 so stamps stay at z-index: 80 */
.bsel-card-holder {
  position: relative;
  width: var(--scry-card-width);
  border-radius: 14px;
  isolation: isolate;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), filter 0.22s ease;
}

.bsel-card-inner {
  position: relative;
  z-index: 1;
  isolation: isolate;
  transform: translateZ(0);
  border-radius: inherit;
}

#app .bsel-card-inner > .poke-card.ptcg-v2,
#app .bsel-card-inner > .poke-card.ptcg-v2:hover,
#app .bsel-card-inner > .poke-card.ptcg-v2.is-tilting {
  z-index: 1 !important;
}

#app .battle-scry-stage .poke-card.ptcg-v2.is-card3d {
  width: var(--scry-card-width) !important;
  height: auto !important;
  aspect-ratio: 0.718 !important;
  margin: 0 !important;
  flex: none !important;
  cursor: pointer;
  touch-action: manipulation;
  transform: none !important;
  transition:
    box-shadow 0.22s ease,
    outline-color 0.2s ease,
    filter 0.22s ease,
    opacity 0.22s ease !important;
}

#app .battle-scry-stage [data-battle-choice]::before {
  display: none !important;
}

.scry-slot.is-top .bsel-card-holder {
  transform: translateY(-4px);
}

.scry-slot.is-top .poke-card.ptcg-v2 {
  outline: 2.5px solid rgba(56, 189, 248, 0.92);
  outline-offset: 2px;
  box-shadow:
    0 0 0 5px rgba(56, 189, 248, 0.2),
    0 18px 34px -10px rgba(2, 132, 199, 0.42);
}

.scry-slot:is(.is-keep, .is-idle) .poke-card.ptcg-v2 {
  outline: 1.5px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
  box-shadow: 0 16px 30px -12px rgba(15, 23, 42, 0.34);
}

.scry-slot:not(.is-selected):has(.poke-card:is(:hover, :focus-visible)) .bsel-card-holder {
  transform: translateY(-10px) scale(1.045);
  z-index: 6;
}

.scry-slot:not(.is-selected) .poke-card.ptcg-v2:is(:hover, :focus-visible) {
  outline: 3px solid var(--bsel-accent-light);
  outline-offset: 3px;
  box-shadow:
    0 0 0 6px var(--bsel-accent-ring),
    0 24px 40px -12px var(--bsel-accent-shadow);
}

/* Destructive Selected Cards (Scry Discard, Discard Hand, Exhaust Hand) */
.battle-scry-overlay:is([data-sel-theme="scry"], [data-sel-theme="undercurrent"], [data-sel-theme="discard"], [data-sel-theme="exhaust"])
  .scry-slot.is-selected .bsel-card-holder {
  transform: translateY(10px) scale(0.94) rotate(-1.5deg);
}

.battle-scry-overlay:is([data-sel-theme="scry"], [data-sel-theme="undercurrent"], [data-sel-theme="discard"], [data-sel-theme="exhaust"])
  .scry-slot.is-selected .poke-card.ptcg-v2 {
  outline: 3px solid var(--bsel-accent-light);
  outline-offset: 2px;
  filter: grayscale(0.42) brightness(0.86) saturate(0.75);
  box-shadow:
    0 0 0 4px var(--bsel-accent-ring),
    0 12px 24px -10px var(--bsel-stamp-shadow);
}

.battle-scry-overlay:is([data-sel-theme="scry"], [data-sel-theme="undercurrent"], [data-sel-theme="discard"], [data-sel-theme="exhaust"])
  .scry-slot.is-selected:has(.poke-card:is(:hover, :focus-visible)) .bsel-card-holder {
  transform: translateY(4px) scale(0.97) rotate(-0.6deg);
}

/* Positive Selected Cards (Retain Hand, Copy Hand, Retrieve Pile) */
.battle-scry-overlay:is([data-sel-theme="retain"], [data-sel-theme="copy"], [data-sel-theme="retrieve"])
  .scry-slot.is-selected .bsel-card-holder {
  transform: translateY(-10px) scale(1.045);
  z-index: 6;
}

.battle-scry-overlay:is([data-sel-theme="retain"], [data-sel-theme="copy"], [data-sel-theme="retrieve"])
  .scry-slot.is-selected .poke-card.ptcg-v2 {
  outline: 3px solid var(--bsel-accent-light);
  outline-offset: 3px;
  box-shadow:
    0 0 0 6px var(--bsel-accent-ring),
    0 24px 40px -12px var(--bsel-accent-shadow);
}

/* Overlay Stamp Badge (Always above card via z-index: 80 + isolated inner card) */
.bsel-card-stamp {
  position: absolute;
  inset: 0;
  z-index: 80 !important;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 0, 2px) scale(1.16) rotate(-8deg);
  transition: opacity 0.18s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.bsel-card-stamp span {
  padding: 5px 16px;
  border-radius: 10px;
  background: var(--bsel-stamp-bg);
  border: 2px solid rgba(255, 255, 255, 0.94);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  box-shadow: 0 10px 22px var(--bsel-stamp-shadow);
}

.scry-slot.is-selected .bsel-card-stamp {
  opacity: 1;
  transform: translate3d(0, 0, 2px) scale(1) rotate(-8deg);
}

/* Bottom Slot Action Pill */
.scry-slot-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.36);
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 10px -4px rgba(15, 23, 42, 0.16);
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    opacity 0.18s ease;
}

.scry-slot-action:hover,
.scry-slot-action:focus-visible {
  background: #ffffff;
  border-color: var(--bsel-accent-light);
  color: var(--bsel-accent);
  transform: translateY(-1px);
  outline: none;
}

.battle-scry-overlay:is([data-sel-theme="scry"], [data-sel-theme="undercurrent"], [data-sel-theme="discard"], [data-sel-theme="exhaust"])
  .scry-slot.is-selected .scry-slot-action {
  background: rgba(254, 242, 242, 0.96);
  border-color: rgba(248, 113, 113, 0.65);
  color: #b91c1c;
}

.battle-scry-overlay:is([data-sel-theme="scry"], [data-sel-theme="undercurrent"], [data-sel-theme="discard"], [data-sel-theme="exhaust"])
  .scry-slot.is-selected .scry-slot-action:hover,
.battle-scry-overlay:is([data-sel-theme="scry"], [data-sel-theme="undercurrent"], [data-sel-theme="discard"], [data-sel-theme="exhaust"])
  .scry-slot.is-selected .scry-slot-action:focus-visible {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

.battle-scry-overlay:is([data-sel-theme="retain"], [data-sel-theme="copy"], [data-sel-theme="retrieve"])
  .scry-slot.is-selected .scry-slot-action {
  background: var(--bsel-stamp-bg);
  border-color: rgba(255, 255, 255, 0.72);
  color: #ffffff;
  box-shadow: 0 6px 14px -6px var(--bsel-stamp-shadow);
}

/* Choose-One Option Cards */
.bsel-options-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: clamp(14px, 2.2vw, 26px);
  width: min(860px, 100%);
  padding: 12px;
}

.bsel-option-card {
  flex: 1 1 clamp(220px, 32%, 340px);
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 20px 22px;
  border-radius: 20px;
  border: 1.5px solid rgba(148, 163, 184, 0.36);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px) saturate(1.38);
  -webkit-backdrop-filter: blur(18px) saturate(1.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 18px 34px -14px rgba(15, 42, 78, 0.22);
  color: #0f172a;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.bsel-option-card:hover,
.bsel-option-card:focus-visible {
  transform: translateY(-6px);
  border-color: #38bdf8;
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.2),
    0 22px 40px -14px rgba(2, 132, 199, 0.34);
  outline: none;
}

.bsel-option-card.is-selected {
  transform: translateY(-6px) scale(1.02);
  background: linear-gradient(180deg, #f0f9ff 0%, rgba(255, 255, 255, 0.98) 100%);
  border-color: #0284c7;
  box-shadow:
    0 0 0 5px rgba(56, 189, 248, 0.26),
    0 24px 44px -14px rgba(2, 132, 199, 0.42);
}

.bsel-option-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.bsel-option-idx {
  padding: 2px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11.5px;
  font-weight: 800;
}

.bsel-option-state {
  padding: 2px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 11.5px;
  font-weight: 800;
}

.bsel-option-card.is-selected .bsel-option-state {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  color: #ffffff;
}

.bsel-option-title {
  font-size: clamp(16px, 1.8vw, 19px);
  font-weight: 900;
  color: #0f172a;
  line-height: 1.25;
}

.bsel-option-desc {
  font-size: 13.5px;
  font-weight: 600;
  color: #475569;
  line-height: 1.5;
}

/* Keep layout intact while hiding the live slot during entry flight */
.scry-slot.is-scry-entering .bsel-card-inner,
.scry-slot.is-scry-entering .poke-card {
  visibility: hidden !important;
  pointer-events: none !important;
}

.scry-slot.is-scry-entering .scry-order-badge,
.scry-slot.is-scry-entering .scry-slot-action {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

/* Footer Confirm Dock */
.scry-footer {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.battle-selection-confirm.is-scry-confirm {
  position: static;
  min-width: 196px;
  min-height: 48px;
  padding: 10px 28px;
  font-size: 15.5px;
}

/* ============================================================================
   LEFT-EDGE PEEK (EYE) DOCK & SELECTED MINI-CARD STACK
   ============================================================================ */

.bsel-peek-dock {
  position: absolute;
  left: clamp(14px, 2.2vw, 30px);
  top: 52%;
  transform: translateY(-50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.bsel-peek-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 62px;
  padding: 10px 13px 8px;
  border-radius: 18px;
  border: 1.5px solid rgba(148, 163, 184, 0.36);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px) saturate(1.38);
  -webkit-backdrop-filter: blur(18px) saturate(1.38);
  color: #334155;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    0 12px 26px -10px rgba(15, 42, 78, 0.24);
  cursor: pointer;
  font: inherit;
  transition:
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.bsel-peek-btn:hover,
.bsel-peek-btn:focus-visible {
  transform: translateY(-2px);
  border-color: #38bdf8;
  color: #0284c7;
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.18),
    0 14px 28px -10px rgba(2, 132, 199, 0.32);
  outline: none;
}

.bsel-peek-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  border-color: rgba(255, 255, 255, 0.85);
  color: #ffffff;
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.28),
    0 14px 28px -8px rgba(37, 99, 235, 0.52);
}

.bsel-peek-btn[aria-pressed="true"]:hover,
.bsel-peek-btn[aria-pressed="true"]:focus-visible {
  background: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%);
  color: #ffffff;
}

.bsel-peek-eye {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.bsel-peek-eye svg {
  width: 24px;
  height: 24px;
  display: block;
}

.bsel-peek-label {
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.04em;
}

.bsel-peek-cards[hidden] {
  display: none;
}

.bsel-peek-cards {
  --peek-card-w: clamp(78px, 8.4vw, 106px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.bsel-peek-stack {
  position: relative;
  width: var(--peek-card-w);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.bsel-peek-cards:hover .bsel-peek-stack {
  transform: translateY(-3px) scale(1.04);
}

.bsel-peek-card-item {
  width: var(--peek-card-w);
  position: relative;
  border-radius: 10px;
}

.bsel-peek-stack[data-peek-count="2"] .bsel-peek-card-item:nth-child(1) {
  transform: translate3d(-5px, -3px, 0) rotate(-4deg);
  z-index: 1;
}

.bsel-peek-stack[data-peek-count="2"] .bsel-peek-card-item:nth-child(2) {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate3d(6px, 4px, 0) rotate(3deg);
  z-index: 2;
}

.bsel-peek-stack[data-peek-count="3"] .bsel-peek-card-item:nth-child(1) {
  transform: translate3d(-8px, -4px, 0) rotate(-5deg);
  z-index: 1;
}

.bsel-peek-stack[data-peek-count="3"] .bsel-peek-card-item:nth-child(2) {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate3d(0px, 0px, 0) rotate(0deg);
  z-index: 2;
}

.bsel-peek-stack[data-peek-count="3"] .bsel-peek-card-item:nth-child(3) {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate3d(8px, 5px, 0) rotate(5deg);
  z-index: 3;
}

#app .bsel-peek-stack .poke-card.ptcg-v2.is-card3d {
  width: var(--peek-card-w) !important;
  height: auto !important;
  aspect-ratio: 0.718 !important;
  margin: 0 !important;
  transform: none !important;
  pointer-events: none !important;
  outline: 2.5px solid var(--bsel-accent-light);
  outline-offset: 1px;
  box-shadow:
    0 0 0 4px var(--bsel-accent-ring),
    0 12px 24px -8px rgba(15, 23, 42, 0.45);
}

.bsel-peek-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bsel-stamp-bg);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 6px 14px -4px var(--bsel-stamp-shadow);
}

.bsel-peek-opt-pill {
  max-width: 150px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid #38bdf8;
  color: #0369a1;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 8px 18px -6px rgba(2, 132, 199, 0.35);
}

/* Responsive & Touch Adjustments */
@media (any-pointer: coarse) {
  .scry-cards-row .poke-card.is-card3d {
    touch-action: pan-x;
  }
  .scry-cards-row[data-sel-layout="grid"] .poke-card.is-card3d {
    touch-action: pan-y;
  }
}

@media (max-width: 620px) {
  .battle-scry-overlay {
    padding: calc(var(--run-hud-size, 72px) + 10px) 10px 14px;
    gap: 8px;
  }
  .scry-header {
    padding: 9px 14px;
    border-radius: 16px;
  }
  .scry-order-bar {
    width: 100%;
    padding: 5px 11px;
    gap: 8px;
  }
  .scry-order-anchor {
    font-size: 11.5px;
  }
  .scry-cards-row {
    --scry-card-width: clamp(118px, 34vw, 154px);
    gap: 12px;
    padding: 10px 8px 12px;
  }
  .scry-cards-row[data-scry-count="5"],
  .scry-cards-row[data-scry-count="6"],
  .scry-cards-row[data-scry-count="7"],
  .scry-cards-row[data-sel-layout="grid"] {
    --scry-card-width: clamp(106px, 30vw, 142px);
    gap: 10px;
  }
  .bsel-option-card {
    padding: 15px 16px;
  }
  .bsel-peek-dock {
    left: 8px;
    top: 46%;
    gap: 6px;
  }
  .bsel-peek-btn {
    min-width: 50px;
    padding: 8px 9px 6px;
    border-radius: 14px;
  }
  .bsel-peek-cards {
    --peek-card-w: 62px;
  }
}

@media (max-height: 600px) {
  .battle-screen.is-selecting-cards {
    --selection-top: calc(var(--run-hud-size, 62px) + 8px);
  }
  .battle-selection-confirm {
    min-height: 40px;
  }
  .battle-scry-overlay {
    padding: calc(var(--run-hud-size, 64px) + 8px) 14px 12px;
    gap: 6px;
  }
  .scry-header {
    padding: 7px 16px;
    gap: 3px;
  }
  .scry-header-sub {
    display: none;
  }
  .scry-cards-row {
    --scry-card-width: clamp(104px, 26vh, 148px);
    padding: 8px 10px 10px;
  }
  .scry-slot {
    gap: 6px;
  }
  .battle-selection-confirm.is-scry-confirm {
    min-height: 40px;
    padding: 8px 22px;
  }
  .bsel-cancel-btn {
    min-height: 38px;
    padding: 6px 16px;
  }
  .bsel-peek-dock {
    left: 10px;
    gap: 6px;
  }
  .bsel-peek-cards {
    --peek-card-w: 64px;
  }
}

.run-stage:has(.is-selecting-cards),
#app[data-screen="battle"] .battle-screen.is-selecting-cards {
  overflow: clip;
}

body:has(#app .is-selecting-cards) > .meta-toast {
  top: calc(var(--run-hud-size, 0px) + 12px);
  bottom: auto;
  right: 12px;
  left: auto;
  transform: none;
}

@media (max-width: 620px) {
  body:has(#app .is-selecting-cards) > .meta-toast {
    top: calc(var(--run-hud-size, 0px) + 116px);
    scale: .85;
    transform-origin: right top;
  }
}

@media (prefers-reduced-motion: reduce) {
  .battle-scry-overlay.is-entering,
  .battle-scry-overlay.is-entering .scry-header,
  .battle-scry-overlay.is-entering .scry-footer,
  .scry-slot.is-rank-promoted .scry-order-badge.is-top {
    animation: none !important;
  }
  .bsel-card-holder,
  .scry-order-badge,
  .scry-slot-action,
  .bsel-card-stamp,
  .bsel-option-card,
  .bsel-cancel-btn,
  .bsel-peek-btn,
  .bsel-peek-stack,
  .battle-scry-overlay,
  .battle-scry-overlay::before,
  .battle-scry-overlay .scry-header,
  .battle-scry-overlay .battle-scry-stage,
  .battle-scry-overlay .scry-footer,
  .battle-selection-confirm {
    transition: none !important;
  }
}
