@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600&family=Press+Start+2P&family=Share+Tech+Mono&family=Oxanium:wght@400;600&family=Audiowide&family=Quantico:wght@400;700&family=Chakra+Petch:wght@400;600&family=VT323&display=swap');

/* === FIXED-SIZE GAME STAGE (no reflow on zoom) === */
/* Entire game rendered as a fixed 1600x765 canvas, scaled to fit viewport */
:root {
  --gameVerticalOffset: 50%;
}

html, body {
  overflow: auto;
  height: 100%;
  margin: 0;
  background: #000;
  /* Hide scrollbars while keeping scroll functionality (invisible scroll) */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* Hide scrollbar for Chrome, Safari and Edge */
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

.gameViewport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* override with dynamic viewport height — adapts to iOS Safari toolbar */
  overflow: visible;
  background: transparent;
  z-index: 10;
  /* Account for device safe-area insets (notches, rounded corners) */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  box-sizing: border-box;
}

.gameStage {
  /* Fixed design canvas size (landscape phone-like) */
  width: 1600px;
  height: 765px;
  /* Centered horizontally, positioned higher to ensure bottom is visible */
  position: absolute;
  left: 50%;
  top: var(--gameVerticalOffset);
  transform: translate(-50%, -50%) scale(var(--uiScale, 1));
  transform-origin: center center;
  will-change: transform;
  pointer-events: auto;
  /* Logo anchor position (set by game.js, relative to viewport) */
  --logoCX: 50vw;
  --logoCY: 50vh;
}

:root{
  --bg:#1a1d24;
  --felt:#1a1f2e;
  --feltDark:#0f1319;
  --panel:#1e2530;
  --panel2:#181d28;
  --card:#1b2436;
  --card2:#1a2233;
  --text:#e7eefc;
  --muted:#a7b3cc;
  --accent:#5eead4;
  --danger:#fb7185;
  --warn:#fbbf24;
  --ok:#34d399;
  animation: orbitBob var(--orbitFloatDur, 6s) ease-in-out infinite;
  animation-delay: var(--orbitFloatDelay, 0s);
  /* All cards: unified size (DRAW × 0.90) */
  --cardW: 119px;
  --cardH: 158px;
  /* Recent cards: smaller than hand cards (reduced 15% twice from original) */
  --recentW: 61px;
  --recentH: 82px;
}

/* Utility class for hiding seats in different layouts */
.isHidden {
  display: none !important;
}
/* Round-robin deal animation - cards start hidden */
.dealHidden {
  opacity: 0 !important;
  transform: scale(0.8) !important;
  pointer-events: none !important;
  transition: opacity 0.22s ease-out, transform 0.22s ease-out;
}


/* Opening cinematic: keep all elements mounted, only toggle visibility */
body.openingCinematic .cardArea {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease-out, visibility 0.15s ease-out;
}

body.openingCinematic #floorCard {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.openingCinematic #floorStatus {
  opacity: 0;
  visibility: hidden;
}

body.openingCinematic #drawBtn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.openingCinematic .recentArea {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.openingCinematic #grabBtn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.openingCinematic #opResult {
  opacity: 0;
  visibility: hidden;
}

/* Recent area stays hidden until first card played */
body:not(.openingCinematic) .recentArea {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease-out, visibility 0.18s ease-out;
}

/* Show recent area after first play (JS removes .openingCinematic and checks lastPlayedCard) */
body.hasPlayedCard .recentArea {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ===== SEAT LAYER & TABLE LAYER ARCHITECTURE ===== */
/* Independent layers: seats stay fixed, table can animate/transform */

#seatLayer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none; /* Seats don't block table interactions */
  z-index: 10;
}

#tableLayer {
  position: relative;
  width: 100%;
  z-index: 5;
  /* All center table transforms/animations apply only to this layer */
}

/* Side seats for future players (landscape only) */

.seatLeft,
.seatRight {
  display: none; /* Hidden by default, shown via JS for 3P/4P */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 160px;
  padding: 14px;
  background: transparent; /* Hide translucent box background */
  border: none; /* Hide border */
  border-radius: 12px;
  box-shadow: none; /* Hide shadow */
  flex-shrink: 0;
  position: absolute;
  pointer-events: auto; /* Seats are interactive */
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Active turn indicator for side seats - base styling, colors applied via JS */
.seatLeft.activeTurn,
.seatRight.activeTurn {
  /* Colors are dynamically set via JavaScript for unique CPU colors */
}

/* Side seat turn indicators - positioned above hand, rotated to match hand direction */
.seatTurnIndicator {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.25;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 10;
}

/* Left seat turn indicator - rotated 90deg clockwise, positioned to right of hand */
.seatLeft .seatTurnIndicator {
  top: 50%;
  right: -72px;
  transform: translateY(-50%) rotate(90deg);
  transform-origin: center center;
}

/* Right seat turn indicator - rotated 90deg counter-clockwise, positioned to left of hand */
.seatRight .seatTurnIndicator {
  top: 50%;
  left: -72px;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center center;
}

.seatTurnIndicator .turnLight {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(94, 234, 212, 0.3);
  box-shadow: 0 0 4px rgba(94, 234, 212, 0.3);
  flex-shrink: 0;
}

.seatTurnIndicator .turnText {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Show indicator when seat is active turn */
.seatLeft.activeTurn .seatTurnIndicator,
.seatRight.activeTurn .seatTurnIndicator {
  opacity: 1;
}

/* Scale up dot and text by 25% when active */
.seatLeft.activeTurn .seatTurnIndicator {
  transform: translateY(-50%) rotate(90deg) scale(1.25);
}
.seatRight.activeTurn .seatTurnIndicator {
  transform: translateY(-50%) rotate(-90deg) scale(1.25);
}

.seatLeft.activeTurn .seatTurnIndicator .turnLight,
.seatRight.activeTurn .seatTurnIndicator .turnLight {
  background: rgba(94, 234, 212, 1);
  box-shadow: 0 0 8px rgba(94, 234, 212, 0.8), 0 0 16px rgba(94, 234, 212, 0.5);
  animation: seatTurnPulse 1.5s ease-in-out infinite;
}

.seatLeft.activeTurn .seatTurnIndicator .turnText,
.seatRight.activeTurn .seatTurnIndicator .turnText {
  color: rgba(94, 234, 212, 1);
}

@keyframes seatTurnPulse {
  0%, 100% {
    box-shadow: 0 0 4px rgba(94, 234, 212, 0.6), 0 0 8px rgba(94, 234, 212, 0.3);
  }
  50% {
    box-shadow: 0 0 8px rgba(94, 234, 212, 1), 0 0 16px rgba(94, 234, 212, 0.7);
  }
}

/* P3: Left side, vertically centered */
.seatLeft {
  left: 16px;
  top: 50%;
  transform: translateY(calc(-50% + 22%));
}

/* P4: Right side, vertically centered (mirrored) */
.seatRight {
  right: 16px;
  top: 50%;
  transform: translateY(calc(-50% - 22%));
}

.seatLabel {
  display: none; /* Hide CPU labels on side seats */
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  text-align: center;
  /* Label stays upright (no rotation) */
}

/* Show seat labels when seat is visible (controlled by JS) */
.seatLeft[style*="flex"] .seatLabel,
.seatRight[style*="flex"] .seatLabel {
  display: none; /* Keep hidden */
}

.seatHandOuter {
  width: 280px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.seatHand {
  position: relative;
  width: 280px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center; /* Rotate around center to prevent drift */
  background: transparent;
}

/* Rotate P3 hand -90deg (left side, cards vertical pointing down) */
.seatLeft .seatHand {
  transform: rotate(-90deg);
}

/* Rotate P4 hand +90deg (right side, cards vertical pointing up) - mirrored */
.seatRight .seatHand {
  transform: rotate(90deg);
}

.seatCount {
  display: none; /* Hide card count on side seats */
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(0,0,0,.5);
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid rgba(94,234,212,.35);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  /* Count badge stays upright (no rotation) */
}

/* Show seat counts when seat is visible (controlled by JS) */
.seatLeft[style*="flex"] .seatCount,
.seatRight[style*="flex"] .seatCount {
  display: none; /* Keep hidden */
}

/* Seat back cards (P3/P4) - match CPU opponent card size and styling exactly */
.seatBackCard {
  position: absolute;
  width: var(--cardW);
  height: var(--cardH);
  background-color: transparent;
  background-image: url('Assets/Cards/Backside/BackCard COMPOUND(background to all cards on deck).png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Add transition for pile-to-fan animation */
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Ensure no white background bleeding */
  opacity: 1;
}

/* Pre-deal-closed pile state: all cards start in center pile, invisible */
.seatHandPreDealClosed .seatBackCard {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translate(0, 0) rotateZ(0deg) scale(1) !important;
}

/* Apply dealHidden animation to seat back cards */
.seatBackCard.dealHidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.22s ease-out, transform 0.22s ease-out;
}

/* Combine dealHidden scale with nth-child positioning */
.seatLeft .seatBackCard.dealHidden:nth-child(1) { transform: scale(0.8) translate(-120px, 0) rotateZ(15deg); }
.seatLeft .seatBackCard.dealHidden:nth-child(2) { transform: scale(0.8) translate(-60px, 8px) rotateZ(8deg); }
.seatLeft .seatBackCard.dealHidden:nth-child(3) { transform: scale(0.8) translate(0, 12px) rotateZ(0deg); }
.seatLeft .seatBackCard.dealHidden:nth-child(4) { transform: scale(0.8) translate(60px, 8px) rotateZ(-8deg); }
.seatLeft .seatBackCard.dealHidden:nth-child(5) { transform: scale(0.8) translate(120px, 0) rotateZ(-15deg); }
.seatLeft .seatBackCard.dealHidden:nth-child(6) { transform: scale(0.8) translate(180px, -12px) rotateZ(-22deg); }
.seatLeft .seatBackCard.dealHidden:nth-child(7) { transform: scale(0.8) translate(240px, -28px) rotateZ(-28deg); }

.seatRight .seatBackCard.dealHidden:nth-child(1) { transform: scale(0.8) translate(-120px, 0) rotateZ(15deg); }
.seatRight .seatBackCard.dealHidden:nth-child(2) { transform: scale(0.8) translate(-60px, 8px) rotateZ(8deg); }
.seatRight .seatBackCard.dealHidden:nth-child(3) { transform: scale(0.8) translate(0, 12px) rotateZ(0deg); }
.seatRight .seatBackCard.dealHidden:nth-child(4) { transform: scale(0.8) translate(60px, 8px) rotateZ(-8deg); }
.seatRight .seatBackCard.dealHidden:nth-child(5) { transform: scale(0.8) translate(120px, 0) rotateZ(-15deg); }
.seatRight .seatBackCard.dealHidden:nth-child(6) { transform: scale(0.8) translate(180px, -12px) rotateZ(-22deg); }
.seatRight .seatBackCard.dealHidden:nth-child(7) { transform: scale(0.8) translate(240px, -28px) rotateZ(-28deg); }

/* Fan layout for side seats - match CPU opponent fan (7-card spread) */
/* Note: These transforms apply within the ROTATED .seatHand container */
/* Z-index layering: left-to-right stacking for clean depth separation */
.seatLeft .seatBackCard:nth-child(1) { transform: translate(-120px, 0) rotateZ(15deg); z-index: 1; }
.seatLeft .seatBackCard:nth-child(2) { transform: translate(-60px, 8px) rotateZ(8deg); z-index: 2; }
.seatLeft .seatBackCard:nth-child(3) { transform: translate(0, 12px) rotateZ(0deg); z-index: 3; }
.seatLeft .seatBackCard:nth-child(4) { transform: translate(60px, 8px) rotateZ(-8deg); z-index: 4; }
.seatLeft .seatBackCard:nth-child(5) { transform: translate(120px, 0) rotateZ(-15deg); z-index: 5; }
.seatLeft .seatBackCard:nth-child(6) { transform: translate(180px, -12px) rotateZ(-22deg); z-index: 6; }
.seatLeft .seatBackCard:nth-child(7) { transform: translate(240px, -28px) rotateZ(-28deg); z-index: 7; }

.seatRight .seatBackCard:nth-child(1) { transform: translate(-120px, 0) rotateZ(15deg); z-index: 1; }
.seatRight .seatBackCard:nth-child(2) { transform: translate(-60px, 8px) rotateZ(8deg); z-index: 2; }
.seatRight .seatBackCard:nth-child(3) { transform: translate(0, 12px) rotateZ(0deg); z-index: 3; }
.seatRight .seatBackCard:nth-child(4) { transform: translate(60px, 8px) rotateZ(-8deg); z-index: 4; }
.seatRight .seatBackCard:nth-child(5) { transform: translate(120px, 0) rotateZ(-15deg); z-index: 5; }
.seatRight .seatBackCard:nth-child(6) { transform: translate(180px, -12px) rotateZ(-22deg); z-index: 6; }
.seatRight .seatBackCard:nth-child(7) { transform: translate(240px, -28px) rotateZ(-28deg); z-index: 7; }

.seatCards {
  width: 100%;
  height: 100px;
  border: 1px dashed rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(0,0,0,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.2);
  font-size: 10px;
}

/* Show seats in landscape mode (wider than tall) */
@media (min-aspect-ratio: 1.2/1) {
  .seatLeft,
  .seatRight {
    display: flex;
  }
}

/* Deck ceremony: hide real draw pile while ghost animates */
.deckHiddenDuringCeremony {
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Hand deal: hide container and individual cards during one-by-one reveal */
.handDealHidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.handCard.cardHidden {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Pre-deal closed state: prevent fan flash before deal animation */
#hand.handPreDealClosed .handCard {
  transform: translate(0, 0) rotateZ(0deg) !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Pre-deal closed state for opponent hand: hide cards until animation reveals them */
.opponentHand.opponentPreDealClosed .opponentBackCard {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Pre-deal closed state for seat hands (P3/P4): hide cards until animation reveals them */
.seatHandPreDealClosed .seatBackCard {
  opacity: 0 !important;
  visibility: hidden !important;
}

*{box-sizing:border-box}

body{
  margin:0;
  /* Deep black background behind the table */
  background: #000000;
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Global starfield - positioned in bottom background area only */
body::before,
body::after{
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  /* Position only in bottom area of viewport */
  top: 60%;
  left: 0;
  right: 0;
  height: 40%;
  bottom: 0;
}

body::before{
  background-image:
    radial-gradient(circle, rgba(255, 244, 194, 1) 3.5px, rgba(255, 244, 194, 0.5) 6px, transparent 9px),
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 2.8px, rgba(255, 255, 255, 0.35) 4.5px, transparent 7px),
    radial-gradient(circle, rgba(255, 244, 194, 0.85) 1.8px, rgba(255, 244, 194, 0.3) 3px, transparent 4px),
    radial-gradient(circle, rgba(255, 220, 180, 0.7) 0.6px, transparent 0.6px),
    radial-gradient(circle, rgba(200, 220, 255, 0.6) 0.5px, transparent 0.5px),
    radial-gradient(circle, rgba(255, 240, 200, 0.65) 0.7px, transparent 0.7px),
    radial-gradient(circle, rgba(220, 230, 255, 0.55) 0.4px, transparent 0.4px),
    radial-gradient(circle, rgba(255, 235, 190, 0.6) 0.5px, transparent 0.5px);
  background-size: 
    800px 650px,
    1100px 920px,
    550px 480px,
    180px 150px,
    220px 190px,
    160px 140px,
    200px 170px,
    190px 160px;
  background-position: 
    17% 28%,
    72% 61%,
    38% 83%,
    25% 45%,
    68% 32%,
    42% 78%,
    85% 55%,
    12% 18%;
  animation: starDrift 22s linear infinite, starAppearFade 5s ease-in-out infinite;
}

body::after{
  background-image:
    radial-gradient(circle, rgba(255, 244, 194, 1) 4px, rgba(255, 244, 194, 0.6) 7px, transparent 11px),
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 2.2px, rgba(255, 255, 255, 0.4) 4px, transparent 6px),
    radial-gradient(circle, rgba(255, 244, 194, 0.7) 1px, transparent 1px),
    radial-gradient(circle, rgba(180, 210, 255, 0.65) 0.6px, transparent 0.6px),
    radial-gradient(circle, rgba(255, 225, 185, 0.6) 0.5px, transparent 0.5px),
    radial-gradient(circle, rgba(210, 225, 255, 0.55) 0.7px, transparent 0.7px),
    radial-gradient(circle, rgba(255, 230, 190, 0.65) 0.4px, transparent 0.4px);
  background-size: 
    950px 820px,
    680px 590px,
    420px 350px,
    195px 170px,
    210px 185px,
    175px 155px,
    205px 180px;
  background-position: 
    55% 42%,
    89% 18%,
    23% 67%,
    48% 25%,
    77% 68%,
    33% 52%,
    62% 88%;
  animation: starDrift 30s linear infinite, starAppearFade 7s ease-in-out infinite;
  animation-delay: 0s, 2.5s;
  filter: blur(0.3px);
}

/* Portrait rotation hint - only visible on narrow portrait screens */
.rotateHint {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.rotateHintContent {
  text-align: center;
  padding: 20px;
}

.rotateIcon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: rotatePhone 2s ease-in-out infinite;
}

@keyframes rotatePhone {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

.rotateText {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
}

/* Show hint only on portrait mode with narrow width */
@media (max-width: 640px) and (orientation: portrait) {
  .rotateHint {
    display: flex;
  }
}

.app{
  width: 100%;
  height: 100%;
  position: relative;
}

/* === TABLETOP SCENE - centered felt table === */
.tableScene{
  width: 100%;
  max-width: 1600px;
  height: 100%;
  margin: 0 auto;
  border-radius: 24px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  
  /* Slightly lifted black table surface (+10% lightness) */
  background: #111111;
  
  /* Deep shadow to make table float */
  box-shadow: 
    0 50px 100px -20px rgba(0, 0, 0, 0.7),
    0 30px 60px -30px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  
  /* Subtle texture */
  position: relative;
  z-index: 1;
}

/* Subtle starfield loop on the table surface - HIDDEN (stars moved to bottom area) */
.tableScene::before{
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background-image: none;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

@keyframes tableStarLoop{
  0% {
    background-position:
      12% 18%,
      67% 42%,
      33% 71%,
      84% 26%,
      48% 58%;
  }
  100% {
    background-position:
      calc(12% - 240px) calc(18% + 210px),
      calc(67% - 310px) calc(42% + 260px),
      calc(33% - 190px) calc(71% + 170px),
      calc(84% - 280px) calc(26% + 230px),
      calc(48% - 220px) calc(58% + 190px);
  }
}

/* Light texture pass above stars */
.tableScene::after{
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.06) 2px, rgba(0,0,0,.06) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0,0,0,.05) 2px, rgba(0,0,0,.05) 4px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 1;
}

/* Keep table content above the global starfield */
.tableScene > *{
  position: relative;
  z-index: 2;
}

@keyframes dealIn {
  from { 
    transform: translateY(40px) scale(.90) rotateZ(-8deg);
    opacity: 0;
  }
  to   { 
    transform: translateY(0) scale(1) rotateZ(0deg);
    opacity: 1;
  }
}

/* Fan spread animation - cards move from pile anchor to final fan positions */
@keyframes fanSpread {
  from {
    transform: translate(0, 0) !important;
  }
  to {
    transform: translate(0, 0) !important; /* Override by nth-child in next rule */
  }
}

.handCard.fanSpread {
  /* Transition will handle the movement to final positions */
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Anchor position used before fan spread */
.hand .handCard.fanAnchor {
  transform: translate(0px, 0px) rotateZ(0deg) !important;
}

/* Hand spread spacing variable - responsive and scales with viewport */
.hand {
  --handSpreadStep: clamp(66px, 6.5vw, 103px);
}

/* Apply final fan positions with staggered delays - position ONLY, no scale */
.hand .handCard.fanSpread:nth-child(1) { transform: translate(calc(-3 * var(--handSpreadStep)), 24px) rotateZ(-28deg); }
.hand .handCard.fanSpread:nth-child(2) { transform: translate(calc(-2 * var(--handSpreadStep)), 12px) rotateZ(-20deg); }
.hand .handCard.fanSpread:nth-child(3) { transform: translate(calc(-1 * var(--handSpreadStep)), 4px) rotateZ(-12deg); }
.hand .handCard.fanSpread:nth-child(4) { transform: translate(0px, 0px) rotateZ(0deg); }
.hand .handCard.fanSpread:nth-child(5) { transform: translate(calc(1 * var(--handSpreadStep)), 4px) rotateZ(12deg); }
.hand .handCard.fanSpread:nth-child(6) { transform: translate(calc(2 * var(--handSpreadStep)), 12px) rotateZ(20deg); }
.hand .handCard.fanSpread:nth-child(7) { transform: translate(calc(3 * var(--handSpreadStep)), 24px) rotateZ(28deg); }
.handCard.dealAnimate{
  animation: dealIn .4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

/* Stagger animation for multiple cards */
.handCard.dealAnimate:nth-child(1) { animation-delay: 0ms; }
.handCard.dealAnimate:nth-child(2) { animation-delay: 40ms; }
.handCard.dealAnimate:nth-child(3) { animation-delay: 80ms; }
.handCard.dealAnimate:nth-child(4) { animation-delay: 120ms; }
.handCard.dealAnimate:nth-child(5) { animation-delay: 160ms; }
.handCard.dealAnimate:nth-child(6) { animation-delay: 200ms; }
.handCard.dealAnimate:nth-child(7) { animation-delay: 240ms; }
.handCard.dealAnimate:nth-child(8) { animation-delay: 280ms; }
.handCard.dealAnimate:nth-child(9) { animation-delay: 320ms; }
.handCard.dealAnimate:nth-child(10) { animation-delay: 360ms; }

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding: 0 0 6px 0 !important;
  margin-bottom: 6px !important;
  border-bottom: 1px solid rgba(255,255,255,.08) !important;
  flex-wrap: nowrap;
  position: relative;
  z-index: 20;
}

.topbarSpacer {
  flex: 1 1 auto;
}

.topRightHUD {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-left: auto;
}

.watermarkTitle {
  font-weight: 800;
  letter-spacing: .12em;
  font-size: 18px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  text-shadow: 0 2px 6px rgba(0,0,0,.25);
  line-height: 1;
  user-select: none;
}

.watermarkVersion {
  font-size: 9px;
  vertical-align: super;
  margin-left: 4px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.05em;
}

.topRightControls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.menuButton {
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  width: 26px;
  height: 22px;
  color: #e7eefc;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}

.topRightMenu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: rgba(12,16,26,0.95);
  border: 1px solid rgba(94,234,212,.25);
  border-radius: 10px;
  padding: 8px;
  min-width: 190px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 40;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}

.topRightMenu.open {
  display: flex;
}

.menuItem {
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
}

.menuToggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text);
  padding: 4px 6px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
}

.menuRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  padding: 2px 4px;
}

.menuLabel {
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.menuHiddenSelect {
  display: none;
}

.title {
  flex: 0 0 auto;
}

.brandText{
  font-weight:800; 
  letter-spacing:.08em; 
  font-size:20px;
  color: var(--text);
  text-shadow: 0 2px 4px rgba(0,0,0,.3);
}

.sub{
  color:var(--muted); 
  font-size:11px; 
  margin-top:2px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

#topbarPlayerCount {
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

#topbarPlayerCount:hover {
  border-color: rgba(94,234,212,.5);
  background: rgba(0,0,0,.5);
}

#topbarPlayerCount:focus {
  border-color: rgba(94,234,212,.7);
}

/* Topbar controls - compact layout on right */
.topbarControls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
  margin-left: auto;
}

.playerInfo {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: rgba(0,0,0,.15);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  white-space: nowrap;
}

.playerInfo .panelTitle {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
}

.playerInfo .panelSub {
  font-size: 9px;
  color: var(--muted);
}

.gameControls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.gameControls label {
  padding: 2px 5px;
  background: rgba(0,0,0,.15);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  font-size: 9px;
  white-space: nowrap;
}

.hud{
  display:flex; 
  gap:6px; 
  flex-wrap:nowrap; 
  justify-content:flex-end;
  flex: 0 0 auto;
  min-height: 0 !important;
}

.pill{
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.12);
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text);
  font-size: 10px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  white-space: nowrap;
}

/* Main layout: center table + log on right */
.mainLayout {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 12px;
  margin-bottom: 0;
}

.centerTable {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* Card area: Floor and Draw side by side, closer - felt cloth background */
.cardArea {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  
  /* Felt/cloth texture background */
  background: 
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0,0,0,.08) 2px, rgba(0,0,0,.08) 4px),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.06) 2px, rgba(0,0,0,.06) 4px),
    linear-gradient(135deg, rgba(0,0,0,.25), rgba(0,0,0,.15));
  
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.3), inset 0 -1px 2px rgba(0,0,0,.2);
  position: relative;
}

/* Shared status row under both cards */
.sharedStatus {
  padding: 10px 12px;
  background: rgba(0,0,0,.15);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.2);
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.logPanel {
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 
    0 4px 16px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  max-height: 500px;
}

.logPanel .log {
  flex: 1;
  overflow-y: auto;
}

/* Hand area at bottom */
.handArea {
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 
    0 4px 16px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.05);
  backdrop-filter: blur(8px);
}

.handHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.handInfo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.handInfoBottom {
  justify-content: center;
  margin: 0 auto 2px;
  padding: 2px 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  width: fit-content;
  transform: translateY(174px);
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.handInfoBottom.counterVisible {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.handControls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.handRow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.hand {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
  scroll-behavior: smooth;
  min-width: 0;
}

.hand::-webkit-scrollbar {
  height: 8px;
}

.hand::-webkit-scrollbar-track {
  background: rgba(0,0,0,.2);
  border-radius: 4px;
}

.hand::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.2);
  border-radius: 4px;
}

.hand::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.3);
}

.recentArea {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.recentWrap {
  flex: 1;
  min-width: 0;
}

.recent {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.logoContainer {
  position: relative; /* Needed for reverse indicator overlay positioning */
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.15);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 4px;
}

.recentLogo {
  max-width: 100%;
  max-height: 100%;
  opacity: 0.85; /* More visible at larger size */
  object-fit: contain;
  transition: opacity 0.3s ease;
}

/* Superscript badge: exponent-style overlay (upper-right of logo) */
.superscriptBadge {
  position: absolute;
  top: 0;
  right: 0;
  width: 40%;
  height: 40%;
  aspect-ratio: 1;
  transform: translate(35%, -35%);
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.95) 0%, rgba(94, 234, 212, 0.85) 100%);
  border: 2px solid rgba(94, 234, 212, 1);
  border-radius: 6px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(94, 234, 212, 0.4), inset 0 0 8px rgba(255, 255, 255, 0.1);
  pointer-events: none;
  z-index: 10;
}

.badgeContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  width: 100%;
  height: 100%;
}

.badgeNumber {
  font-size: 18px;
  font-weight: 900;
  color: #000;
  font-family: 'Orbitron', monospace;
  line-height: 1;
  letter-spacing: -0.5px;
}

.badgeLabel {
  font-size: 8px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.8);
  font-family: 'VT323', monospace;
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: 0.5px;
}

.stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stackLabel{
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

.card{
  background: linear-gradient(145deg, rgba(255,255,255,.95), rgba(240,240,245,.92));
  border: 2px solid rgba(0,0,0,.1);
  border-radius: 12px;
  padding: 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  user-select:none;
  box-shadow: 
    0 4px 8px rgba(0,0,0,.15),
    0 1px 2px rgba(0,0,0,.1);
  position: relative;
}

/* Add slight card shine */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,.2), transparent);
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}

.card.big{
  width: calc(var(--cardW) * 1.32);
  height: calc(var(--cardH) * 1.32);
  padding: 0;
  box-sizing: border-box;
  border-radius: 12px;
  background: transparent;
  border: 2px solid rgba(0,0,0,.12);
  box-shadow: 
    0 10px 24px rgba(0,0,0,.35),
    0 4px 8px rgba(0,0,0,.2);
  position: relative;
  transition: transform .3s cubic-bezier(0.23, 1, 0.320, 1);
}

/* Slight tilt variation for floor and draw cards */
.stack:nth-child(1) .card.big {
  transform: perspective(1200px) rotateZ(-1.5deg) rotateX(0.5deg);
}

.stack:nth-child(2) .card.big {
  transform: perspective(1200px) rotateZ(1.5deg) rotateX(-0.5deg);
}

.floorTypeIcon{ max-width:90px; max-height:120px; object-fit:contain; opacity:0.96 }

.card.back{
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  background: linear-gradient(145deg, #2a3f5f, #1e2d47);
  border-color: rgba(0,0,0,.3);
  will-change: transform;
}

.card.back:hover{
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 12px 24px rgba(0,0,0,.4),
    0 6px 12px rgba(0,0,0,.25);
}

.card.back:active{
  transform: translateY(0) scale(.98);
  box-shadow: 
    0 4px 12px rgba(0,0,0,.3),
    0 2px 4px rgba(0,0,0,.15);
}
.backText{font-weight:800; letter-spacing:.08em; color: rgba(255,255,255,.9)}

/* Draw button background */
#drawBtn{
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  padding: 0;
  border: 2px solid rgba(0,0,0,.3);
  width: var(--cardW);
  height: var(--cardH);
  display: inline-block;
  border-radius: 12px;
  background-color: linear-gradient(145deg, #2a3f5f, #1e2d47);
  box-shadow: 
    0 6px 16px rgba(0,0,0,.25),
    0 2px 4px rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

#drawBtn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 12px 24px rgba(0,0,0,.4),
    0 6px 12px rgba(0,0,0,.25);
}

#drawBtn:active {
  transform: translateY(0) scale(.98);
}

/* Subtle yellow blink animation with bloom */
@keyframes drawNeedsBlink {
  0%, 100% { 
    border-color: rgba(250, 204, 21, 0.3);
    box-shadow: 
      0 0 0 2px rgba(250, 204, 21, 0.2),
      0 0 12px rgba(250, 204, 21, 0.3),
      0 6px 16px rgba(0,0,0,.25),
      0 2px 4px rgba(0,0,0,.15);
  }
  50% { 
    border-color: rgba(250, 204, 21, 0.8);
    box-shadow: 
      0 0 0 3px rgba(250, 204, 21, 0.4),
      0 0 20px rgba(250, 204, 21, 0.6),
      0 0 40px rgba(250, 204, 21, 0.3),
      0 6px 16px rgba(0,0,0,.25),
      0 2px 4px rgba(0,0,0,.15);
  }
}

/* Green highlight when player needs to draw */
#drawBtn.needsDraw {
  border-color: rgba(250, 204, 21, 0.5);
  animation: drawNeedsBlink 2s ease-in-out infinite;
}

#drawBtn.needsDraw:hover {
  animation: none;
  border-color: rgba(250, 204, 21, 1);
  box-shadow: 
    0 0 0 3px rgba(250, 204, 21, 0.6),
    0 0 24px rgba(250, 204, 21, 0.7),
    0 0 48px rgba(250, 204, 21, 0.4),
    0 12px 24px rgba(0,0,0,.4),
    0 6px 12px rgba(0,0,0,.25);
}

/* Yellow blink for floor card when it's power/swap */
#floorCard.specialCard {
  border-color: rgba(250, 204, 21, 0.5);
  animation: drawNeedsBlink 2s ease-in-out infinite;
}

#floorCard.specialCard:hover {
  animation: none;
  border-color: rgba(250, 204, 21, 1);
  box-shadow: 
    0 0 0 3px rgba(250, 204, 21, 0.6),
    0 0 24px rgba(250, 204, 21, 0.7),
    0 0 48px rgba(250, 204, 21, 0.4),
    0 10px 24px rgba(0,0,0,.35),
    0 4px 8px rgba(0,0,0,.2);
}

.meta {
  margin-top: 8px;
  min-height: 18px;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  line-height: 1.3;
  background: rgba(0,0,0,.15);
  border: 1px solid rgba(255,255,255,.1);
  padding: 8px 10px;
  border-radius: 8px;
}

#opResult{
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.08));
  border: 2px solid rgba(34, 197, 94, 0.3);
  color: var(--ok);
  max-width: 100%;
  width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: 11px;
  font-weight:700;
  min-height: 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  line-height: 1.3;
}

.recent{
  display:flex;
  gap:6px;
  padding:0;
  flex-wrap:nowrap;
  overflow-x:auto;
  overflow-y:visible;
}
.recentSlot{
  background: transparent;
  width:var(--recentW);
  height:var(--recentH);
  padding:0;
  border-radius:8px;
  border: 2px solid rgba(0,0,0,.1);
  font-size:11px;
  color: var(--muted);
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  flex: 0 0 auto;
  position: relative;
  box-shadow: 
    0 3px 8px rgba(0,0,0,.2),
    0 1px 2px rgba(0,0,0,.1);
}
.recentSlot.empty{
  border-color: rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.recentLastLabel{
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .03em;
  color: rgba(148, 163, 184, 0.9);
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,.45);
  display: none;
}
.recentSlot.isLastPlayed:not(.empty) .recentLastLabel{
  display: block;
}
.recentOpHint{
  border: 3px solid rgba(96, 165, 250, 0.9);
  box-shadow:
    0 0 0 3px rgba(96, 165, 250, 0.5),
    0 0 20px rgba(59, 130, 246, 0.8),
    0 8px 24px rgba(30, 64, 175, 0.5);
  background: rgba(59, 130, 246, 0.35);
  position: relative;
}
.recentOpHint::before{
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.3), rgba(59, 130, 246, 0.25));
  border-radius: 6px;
  pointer-events: none;
  z-index: 1;
}
.recentOpHint img{
  position: relative;
  z-index: 2;
}

/* Last Card Tracker (bottom-right under slot) */
.recentLastTag {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  right: 6px;
  bottom: -14px;
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: opacity 0.2s ease;
}
.recentSlot.isLastPlayed .recentLastTag {
  opacity: 1;
}
.lastDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.lastText {
  color: rgba(34, 197, 94, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.handCard.pile{ position: relative; display:flex; align-items:center; justify-content:center }
.handCard.pile .pileCount{
  position:absolute; right:8px; bottom:8px;
  background: rgba(0,0,0,0.6); color: white; font-weight:700; padding:4px 6px; border-radius:10px; font-size:12px;
}
.handCard.pile img{ width:100%; height:100%; object-fit:cover; border-radius:12px }

.cardImg{width:100%; height:100%; display:block; margin:0; object-fit:contain; border-radius:12px; opacity:1; background:transparent;}
.floorImg{width:100%; height:100%; display:block; margin:0; object-fit:contain; border-radius:12px; opacity:1; background:transparent;}
.recentSlot img { width:100%; height:100%; object-fit:contain; display:block; margin:0; border-radius:4px; opacity:1; background:transparent; }

/* Modal / Welcome screen */
.modalOverlay{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.92);
  backdrop-filter: blur(4px);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
}

.modalBox{
  background: linear-gradient(145deg, var(--panel), var(--panel2));
  border: 2px solid rgba(255,255,255,.15);
  padding: 24px;
  border-radius: 16px;
  max-width:720px;
  color:var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}

.modalBox h2{
  margin:0 0 12px;
  color: var(--text);
  font-size: 22px;
}

.modalBox p{
  color:var(--muted); 
  font-size:14px;
  line-height: 1.6;
}

.modalActions{
  display:flex; 
  gap:10px; 
  margin-top:16px;
}

/* ===== POST-TYPEWRITER MENU (Orbiting Shape Menu) ===== */
.welcomeOverlay{
  position: fixed;
  inset: 0;
  background: #000000;
  display: block;
  z-index: 9999;
  overflow: hidden;
}

.welcomeOverlay::before,
.welcomeOverlay::after{
  content: "";
  position: absolute;
  inset: -20%;
  background-image:
    /* Few large glowing stars scattered randomly */
    radial-gradient(circle, rgba(255, 244, 194, 1) 3.5px, rgba(255, 244, 194, 0.5) 6px, transparent 9px),
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 2.8px, rgba(255, 255, 255, 0.35) 4.5px, transparent 7px),
    /* Occasional medium stars */
    radial-gradient(circle, rgba(255, 244, 194, 0.85) 1.8px, rgba(255, 244, 194, 0.3) 3px, transparent 4px),
    /* Many tiny stars with color variance */
    radial-gradient(circle, rgba(255, 220, 180, 0.7) 0.6px, transparent 0.6px),
    radial-gradient(circle, rgba(200, 220, 255, 0.6) 0.5px, transparent 0.5px),
    radial-gradient(circle, rgba(255, 240, 200, 0.65) 0.7px, transparent 0.7px),
    radial-gradient(circle, rgba(220, 230, 255, 0.55) 0.4px, transparent 0.4px),
    radial-gradient(circle, rgba(255, 235, 190, 0.6) 0.5px, transparent 0.5px);
  background-size: 
    800px 650px,
    1100px 920px,
    550px 480px,
    180px 150px,
    220px 190px,
    160px 140px,
    200px 170px,
    190px 160px;
  background-position: 
    17% 28%,
    72% 61%,
    38% 83%,
    25% 45%,
    68% 32%,
    42% 78%,
    85% 55%,
    12% 18%;
  opacity: 0;
  animation: starDrift 22s linear infinite, starAppearFade 5s ease-in-out infinite;
  pointer-events: none;
}

.welcomeOverlay::after{
  background-image:
    /* More scattered large stars */
    radial-gradient(circle, rgba(255, 244, 194, 1) 4px, rgba(255, 244, 194, 0.6) 7px, transparent 11px),
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 2.2px, rgba(255, 255, 255, 0.4) 4px, transparent 6px),
    /* A few tiny distant stars */
    radial-gradient(circle, rgba(255, 244, 194, 0.7) 1px, transparent 1px),
    /* More tiny stars with color tints */
    radial-gradient(circle, rgba(180, 210, 255, 0.65) 0.6px, transparent 0.6px),
    radial-gradient(circle, rgba(255, 225, 185, 0.6) 0.5px, transparent 0.5px),
    radial-gradient(circle, rgba(210, 225, 255, 0.55) 0.7px, transparent 0.7px),
    radial-gradient(circle, rgba(255, 230, 190, 0.65) 0.4px, transparent 0.4px);
  background-size: 
    950px 820px,
    680px 590px,
    420px 350px,
    195px 170px,
    210px 185px,
    175px 155px,
    205px 180px;
  background-position: 
    55% 42%,
    89% 18%,
    23% 67%,
    48% 25%,
    77% 68%,
    33% 52%,
    62% 88%;
  opacity: 0;
  animation: starDrift 30s linear infinite, starAppearFade 7s ease-in-out infinite;
  animation-delay: 0s, 2.5s;
  filter: blur(0.3px);
}

.shootingStar{
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 244, 194, 1);
  border-radius: 50%;
  box-shadow: 
    0 0 8px rgba(255, 244, 194, 1), 
    0 0 16px rgba(255, 244, 194, 0.8),
    0 0 24px rgba(255, 244, 194, 0.5),
    0 0 32px rgba(255, 244, 194, 0.3);
  animation: shootingStarFly 5s linear infinite;
  opacity: 0;
}

.shootingStar:nth-child(1){ top: 35%; left: -5%; animation-delay: 0s; }
.shootingStar:nth-child(2){ top: 55%; left: -5%; animation-delay: 3s; }
.shootingStar:nth-child(3){ top: 85%; left: -5%; animation-delay: 6s; }
.shootingStar:nth-child(4){ top: 90%; left: -5%; animation-delay: 9s; }
.shootingStar:nth-child(4){ top: 85%; left: -5%; animation-delay: 9s; }

.welcomeOverlay{
  --logo-size: 200px;
  --orbit-size: clamp(300px, 60vmin, 360px);
  --orbit-radius: calc(var(--orbit-size) / 2);
}

.welcomeMenu{
  position: relative;
  width: 100%;
  height: 100%;
}

.menuLogoAnchor{
  position: absolute;
  left: 50%;
  top: 45%;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transform: translate(-50%, -50%) scale(1.15);
  opacity: 0;
  transition: transform 560ms ease-out, opacity 560ms ease-out;
  z-index: 10002;
}

.welcomeOverlay.logoIntroReady .menuLogoAnchor{
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.9);
}

.menuLogo{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.orbitWrap{
  position: absolute;
  left: 50%;
  top: 45%;
  width: var(--orbit-size);
  height: var(--orbit-size);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%) scale(1);
  z-index: 10001;
  pointer-events: auto;
  transition: transform 320ms ease, opacity 320ms ease;
}

.welcomeOverlay.orbitImplode .orbitWrap{
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
}

.orbitRing{
  position: relative;
  width: 100%;
  height: 100%;
  animation: orbitRotate 24s linear infinite;
  transform: rotate(-45deg);
  transform-origin: center center;
}

.orbitRing:hover{
  animation-play-state: paused;
}

.orbitPaused .orbitRing{
  animation-play-state: paused;
}

.orbitRing:hover .orbitInner,
.orbitPaused .orbitInner{
  animation-play-state: paused;
}

.orbitItem{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: rotate(var(--angle)) translate(var(--orbit-radius));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  color: #ffffff;
  cursor: pointer;
}

.orbitInner{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: orbitCounter 24s linear infinite;
  transform-origin: center center;
}

.orbitIcon{
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
  transition: filter 0.3s ease;
}

.orbitItem:hover .orbitIcon{
  filter: drop-shadow(0 4px 12px rgba(255,255,255,0.6));
}

.orbitLabel{
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.4px;
  transition: color 0.3s ease, text-shadow 0.3s ease, font-size 0.3s ease;
}

.orbitItem:hover .orbitLabel,
.orbitItem:focus-visible .orbitLabel{
  color: #ffffff;
  text-shadow: 0 0 12px rgba(255,255,255,0.5);
}

.menuNameBlock{
  position: absolute;
  right: 40px;
  bottom: 160px;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10011;
  color: #ffffff;
  text-align: center;
  width: auto;
  max-width: none;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  backdrop-filter: none;
  box-shadow: none;
}

.introTopRightHUD{
  top: 10px;
  right: 12px;
  bottom: auto;
  align-items: flex-end;
  text-align: right;
  gap: 6px;
}

.introTopRightHUD .menuNameInput,
.introTopRightHUD .menuModeSelect{
  text-align: right;
}

.introTopRightHUD > div{
  justify-content: flex-end;
}

.menuNameLabel,
.menuModeLabel{
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  display: none;
}

@keyframes namePulsate {
  0%, 100% { 
    color: #22c55e;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
  }
  50% { 
    color: #ef4444;
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
  }
}

@keyframes nameGlow {
  0%, 100% { 
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.3);
    background: rgba(0, 0, 0, 0.6);
  }
  50% { 
    box-shadow: inset 0 0 8px rgba(34, 197, 94, 0.5);
    background: rgba(0, 0, 0, 0.65);
  }
}

.menuNameInput{
  width: 160px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.6);
  color: #22c55e;
  font-size: 12px;
  outline: none;
  flex: 0 0 auto;
  animation: namePulsate 2.5s ease-in-out infinite;
  transition: all 0.3s ease;
}

.menuNameInput-active {
  animation: none !important;
  color: #ffffff;
  text-shadow: none;
  box-shadow: inset 0 0 8px rgba(34, 197, 94, 0.5);
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(34, 197, 94, 0.5);
}

.menuNameInput-active:focus {
  box-shadow: inset 0 0 12px rgba(34, 197, 94, 0.7);
  border-color: rgba(34, 197, 94, 0.8);
}

.menuModeSelect{
  width: 70px;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.6);
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
  flex: 0 0 auto;
  text-align: center;
}

.menuModeNote{
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  margin-top: 0;
  display: none;
}

.menuStartLink{
  margin-top: 0;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 13px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  border-radius: 0;
  flex: 0 0 auto;
  transition: text-shadow 0.3s ease, color 0.3s ease;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
  margin-top: 8px;
}

.menuStartLink:hover{
  background: none;
  text-shadow: 0 0 20px rgba(255, 255, 255, 1);
  color: #34d399;
}

.menuModalOverlay{
  position: fixed;
  inset: 0;
  background: transparent;
  display: none;
  z-index: 10010;
  pointer-events: none;
}

.menuModalOverlay.active{
  display: block;
  pointer-events: auto;
}

.menuModal{
  position: absolute;
  width: min(900px, 92vw);
  max-width: 900px;
  max-height: none;
  height: auto;
  overflow: visible;
  background: #0a0a0a;
  border: 2px solid rgba(94,234,212,0.4);
  border-radius: 12px;
  padding: 16px 18px 18px;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.8), 0 0 40px rgba(94,234,212,0.15);
  pointer-events: auto;
  transform-origin: center center;
}

.menuModal.centered{
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: modalGrowInCentered 0.25s ease-out;
}

@keyframes modalGrowInCentered{
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.menuModalHeader{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.menuModalTitle{
  font-size: 16px;
  font-weight: 600;
}

.menuModalClose{
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
}

.menuModalBody{
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255,255,255,0.85);
  max-height: none;
  overflow: visible;
}

@keyframes orbitRotate{
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes orbitCounter{
  from { transform: rotate(calc(-1 * var(--angle))) rotate(0deg); }
  to { transform: rotate(calc(-1 * var(--angle))) rotate(-360deg); }
}

@keyframes starDrift{
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-40px, 30px, 0); }
}

@keyframes starTwinkle{
  0%, 100% { opacity: 0.18; }
  50% { opacity: 0.32; }
}

@keyframes starAppearFade{
  0% { opacity: 0; }
  20% { opacity: 0.35; }
  80% { opacity: 0.35; }
  100% { opacity: 0; }
}

@keyframes shootingStarFly{
  0% {
    transform: translateX(0) translateY(0) scale(1);
    opacity: 0;
  }
  3% {
    opacity: 1;
  }
  10% {
    box-shadow: 
      0 0 12px rgba(255, 244, 194, 1), 
      0 0 24px rgba(255, 244, 194, 0.8),
      0 0 40px rgba(255, 244, 194, 0.5),
      -60px -30px 30px rgba(255, 244, 194, 0.3),
      -90px -45px 20px rgba(255, 244, 194, 0.2);
  }
  95% {
    opacity: 0.6;
  }
  100% {
    transform: translateX(130vw) translateY(65vh) scale(0.3);
    opacity: 0;
    box-shadow: 
      -120px -60px 40px rgba(255, 244, 194, 0.4), 
      -180px -90px 50px rgba(255, 244, 194, 0.2),
      -240px -120px 30px rgba(255, 244, 194, 0.1);
  }
}

@keyframes orbitBob{
  0%, 100% {
    transform: rotate(var(--angle)) translate(var(--orbit-radius));
  }
  50% {
    transform: rotate(var(--angle)) translate(calc(var(--orbit-radius) + var(--orbitFloat, 6px)));
  }
}

.actions{
  display:flex;
  gap:10px;
  margin-top: 12px;
}

.btn{
  flex:1;
  border:none;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.25), rgba(34, 197, 94, 0.18));
  color: var(--text);
  border: 1px solid rgba(34, 197, 94, 0.4);
  font-weight: 700;
  cursor:pointer;
  transition: all .12s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.3), rgba(34, 197, 94, 0.22));
}

.btn:active{
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.btn.secondary{
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--muted);
}

.btn.secondary:hover {
  background: rgba(0,0,0,.3);
  color: var(--text);
}

.btn.tiny{
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 11px;
  border-radius: 16px;
  background: rgba(94, 234, 212, 0.12);
  border: 1.5px solid rgba(94, 234, 212, 0.35);
  color: rgba(94, 234, 212, 0.95);
  box-shadow: none;
  font-weight: 600;
  transition: all .12s ease;
}

.btn.tiny:hover {
  transform: none;
  background: rgba(94, 234, 212, 0.18);
  border-color: rgba(94, 234, 212, 0.5);
  box-shadow: 0 2px 6px rgba(94, 234, 212, 0.1);
}

.btn.tiny:active {
  transform: none;
  box-shadow: none;
  background: rgba(94, 234, 212, 0.15);
}

.notice{
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,.15);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: 12px;
  min-height: 40px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.2);
}

.panelHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 10px;
}

.panelTitle{
  font-weight:800;
  font-size: 14px;
  color: var(--text);
}

.panelSub{
  color:var(--muted); 
  font-size: 11px;
}

.carouselBtn{
  flex:0 0 auto;
  padding:10px 12px;
  border-radius:10px;
  border:2px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.25);
  color:var(--text);
  cursor:pointer;
  font-size:18px;
  font-weight:bold;
  transition: all .2s cubic-bezier(0.23, 1, 0.320, 1);
  z-index:10;
  pointer-events:auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  will-change: transform;
}

.carouselBtn:hover{
  background: rgba(0,0,0,.35);
  border-color:rgba(255,255,255,.3);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}

.carouselBtn:active{
  transform:translateY(0) scale(.95);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.handCard{
  width: var(--cardW);
  height: var(--cardH);
  padding: 6px;
  border-radius: 12px;
  background: transparent;
  border: 2px solid rgba(0,0,0,.1);
  cursor:pointer;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  flex: 0 0 auto;
  transition: transform .15s cubic-bezier(0.34, 1.56, 0.64, 1), border-color .12s ease, box-shadow .12s ease;
  box-shadow: 
    0 4px 12px rgba(0,0,0,.2),
    0 2px 4px rgba(0,0,0,.1);
  position: relative;
  will-change: transform;
}

/* Inner wrapper for scale control - all hand cards get base scale 1.20 */
.handCardInner {
  transform: translateY(var(--pullOut, 0px)) scale(1.20);
  transform-origin: center;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 140ms ease-out, filter 140ms ease-out;
}

/* Selected cards grow larger (1.34) to stand out above deck */
.handCard.selected .handCardInner,
.handCard.cardSelected .handCardInner {
  transform: translateY(var(--pullOut, 0px)) scale(1.34);
}

/* Card shine effect */
.handCard::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: transparent;
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}

/* Hover: keep card behind neighbors (no z-index change) */
.handCard:hover{
  z-index: 1;
}

/* Pull-out effect on inner element (follows parent rotation) */
.handCard:hover .handCardInner {
  --pullOut: clamp(-34px, -5.2vh, -92px);
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.35));
}

/* Stronger pull for playable/doublePlay cards */
.handCard.playable:hover .handCardInner,
.handCard.doublePlay:hover .handCardInner {
  --pullOut: clamp(-40px, -6.0vh, -108px);
}

.handCard:active .handCardInner{
  transform: translateY(var(--pullOut, 0px)) scale(1.176);
}

/* Active state for playable cards - slightly reduce from 1.34 */
.handCard.playable:active .handCardInner,
.handCard.doublePlay:active .handCardInner {
  transform: translateY(var(--pullOut, 0px)) scale(1.313);
}

.handCard:not(.playable){
  filter: grayscale(100%);
}

/* Frozen hand state when not player's turn - grayscale, no hover */
.handFrozen .handCard {
  filter: grayscale(100%) !important;
  pointer-events: none !important;
}
.handFrozen .handCard.playable,
.handFrozen .handCard.doublePlay,
.handFrozen .handCard.resultCard {
  border-color: transparent !important;
  box-shadow: none !important;
  background: transparent !important;
}
.handFrozen .handCard .handCardInner {
  transform: translateY(0) scale(1) !important;
}

.handCard.playable{
  border-color: rgba(34, 197, 94, 1);
  box-shadow: 
    0 0 0 3px rgba(34, 197, 94, 0.4),
    0 0 20px rgba(34, 197, 94, 0.6),
    0 0 40px rgba(34, 197, 94, 0.3),
    0 6px 16px rgba(0,0,0,.25),
    0 2px 4px rgba(0,0,0,.15);
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.25), rgba(34, 197, 94, 0.15));
}

/* Playable cards scale up to stand out */
.handCard.playable .handCardInner {
  transform: translateY(var(--pullOut, 0px)) scale(1.34);
}

.handCard.doublePlay{
  border-color: rgba(250,204,21,1);
  box-shadow: 
    0 0 0 3px rgba(250,204,21,0.4),
    0 0 20px rgba(250,204,21,0.6),
    0 0 40px rgba(250,204,21,0.3),
    0 6px 16px rgba(0,0,0,.25),
    0 2px 4px rgba(0,0,0,.15);
  background: linear-gradient(145deg, rgba(250,204,21,0.25), rgba(250,204,21,0.15));
}

/* Double-play cards also scale up */
.handCard.doublePlay .handCardInner {
  transform: translateY(var(--pullOut, 0px)) scale(1.34);
}

.handCard.resultCard{
  border-color: rgba(96,165,250,.6);
  box-shadow: 
    0 0 0 2px rgba(96,165,250,.2),
    0 6px 16px rgba(0,0,0,.25),
    0 2px 4px rgba(0,0,0,.15);
  background: linear-gradient(145deg, rgba(96,165,250,.08), rgba(255,255,255,.95));
}
.handCard .top{
  display:flex;
  justify-content:space-between;
  color: var(--muted);
  font-size: 12px;
}
.handCard .mid{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .02em;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
}
.handCard .bot{
  color: rgba(255,255,255,.82);
  font-size: 12px;
}

.resultLabel{
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  margin-top: 2px;
  opacity: 0.85;
  text-shadow: 0 0 8px rgba(94,234,212,.3);
}

/* When a card image is present, hide text top/bot to show the image cleanly */
/* Reduce inner padding when showing full-card art so image fills more area */
.handCard.hasImage { padding: 6px; }

.recentSlot img { width: 48px; height: 74px; object-fit:contain; display:block; margin:0 auto }

.log .logIcon{ width:18px; height:18px; object-fit:contain; display:inline-block; vertical-align:middle }

/* small shape icon used in hand/top and floor overlay */
.handShapeIcon{ width:18px; height:18px; object-fit:contain; vertical-align:middle }
.floorOverlayIcon{ width:20px; height:20px; object-fit:contain; vertical-align:middle }

/* Draw hint label under draw button - hidden to avoid duplicate */
.drawHint{
  display: none;
}

.log{
  height: 100%;
  min-height: 200px;
  overflow:auto;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.5;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.3);
}
.log .line{margin-bottom: 6px}
.log .line.old{
  font-weight: normal;
  color: var(--muted);
  text-shadow: none;
}

/* === CARD SIZING UNIFICATION === */
/* ALL cards: uniform size (DRAW × 0.90 = 119×158px) */
#floorCard, .board .card.big, #drawBtn, .handCard, .hand .card, #hand .card, .handRow .card, .handGrid .card, .recentSlot{
  width: var(--cardW) !important;
  height: var(--cardH) !important;
  flex: 0 0 auto !important;
}

/* Image scaling: preserve aspect ratio, never stretch */
.card img, .cardImg, .floorImg{
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  opacity: 1 !important;
  background: transparent !important;
}

/* Hand card images: fill the green hitbox by cropping transparent padding */
.handCard img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block !important;
  opacity: 1 !important;
  background: transparent !important;
  transform: scale(1.12);
  transform-origin: center;
  clip-path: inset(3% round 12px);
  border-radius: 12px;
}

.handRow, .hand, #hand, .handGrid{
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 12px;
  scroll-behavior: smooth;
}

/* === MUSIC PLAYER AT BOTTOM === */
.musicPlayer{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(11,14,20,.95), rgba(11,14,20,.88));
  border-top: 1px solid rgba(94,234,212,.20);
}

/* Music control volume slider - white */
#musicVolume {
  accent-color: white;
}

#musicVolume[value="0"],
#musicVolume::-webkit-slider-thumb[value="0"] {
  accent-color: #ef4444;
}

/* Red styling when volume is zero */
#musicVolume[value="0"] {
  accent-color: #ef4444;
}

/* WebKit browsers (Chrome, Safari) */
#musicVolume::-webkit-slider-thumb {
  accent-color: white;
}

/* Firefox */
#musicVolume::-moz-range-thumb {
  accent-color: white;
}

/* When volume is at 0, buttons turn red */
#musicToggle[data-zero-volume],
#musicNext[data-zero-volume],
#musicSettings[data-zero-volume] {
  color: #ef4444 !important;
}

/* === MUSIC MODAL === */
#musicBtn{
  position:relative;
  z-index:100;
  pointer-events:auto !important;
}

.musicModalOverlay{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.70);
  display: flex !important;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  pointer-events:auto !important;
}

#musicModal .modalBox{
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 320px;
  box-shadow: var(--shadow);
}

/* === MINI MUSIC CONTROL === */
.musicMini{
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 500;
}

.musicMiniBtn{
  background: rgba(94,234,212,.20);
  border: 1px solid rgba(94,234,212,.40);
  color: #ffffff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.musicMiniBtn:hover{
  background: rgba(94,234,212,.30);
  border-color: rgba(94,234,212,.60);
}

.musicMiniBtn:active{
  transform: scale(.90);
}

/* Mobile performance optimization: reduce animations on slower devices */
@media (max-width: 640px) {
  /* Reduce deal-in animation on mobile for better performance */
  @keyframes dealInMobile {
    from { 
      transform: translateY(20px) scale(.95);
      opacity: 0;
    }
    to   { 
      transform: translateY(0) scale(1);
      opacity: 1;
    }
  }
  
  .handCard.dealAnimate {
    animation: dealInMobile .3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards !important;
  }
  
  /* Reduce hover effects on touch devices */
  .handCard:hover,
  .card.back:hover,
  #drawBtn:hover {
    transform: translateY(-2px) !important;
  }
}

/* Respect prefers-reduced-motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .handCard,
  .card.big,
  .card.back,
  #drawBtn,
  .carouselBtn {
    animation: none !important;
    transition: none !important;
  }
  
  .handCard:hover,
  .card.back:hover,
  #drawBtn:hover,
  .carouselBtn:hover {
    transform: none !important;
  }
}

@media (max-width: 1024px) {
  .mainLayout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .logPanel {
    max-height: 200px;
  }
  
  .cardArea {
    padding: 16px;
    gap: 12px;
  }
}

@media (max-width: 859px) {
  .tableScene {
    padding: 16px;
  }
  
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .topbarControls {
    order: 3;
    width: 100%;
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 8px;
  }
  
  .hud {
    justify-content: flex-end;
    order: 2;
    flex: 0 1 auto;
  }
  
  .pill {
    font-size: 9px;
    padding: 5px 8px;
  }

  .cardArea {
    flex-direction: row-reverse;
    gap: 10px;
    padding: 12px;
  }
  
  .handHeader {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .handInfo {
    width: 100%;
  }
  
  .handControls {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .cardArea {
    flex-direction: column;
    align-items: center;
  }
}

@media (min-width: 860px){
  .card.big{width: calc(var(--cardW) * 1.32); height: calc(var(--cardH) * 1.32);}
  .handCard{width: var(--cardW); height: var(--cardH);}
  .hand{max-width: 100%}
}

/* ============================================================================
   TABLETOP LAYOUT RESTRUCTURING
   ============================================================================ */

/* Remove old mainLayout grid */
.mainLayout {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
}

.centerTable {
  display: none !important;
}

.handArea {
  display: none !important;
}

/* NEW LAYOUT STRUCTURE */

/* Opponent hand zone (top fan) - positioned within seatLayer */
.opponentZone {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: auto;
}

.opponentHand {
  width: 160px;
  height: 110px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 14px;
}

/* Active turn indicator for top opponent (COMPOUND) - colors applied via JS */\n.opponentZone.activeTurn .opponentHand {\n  /* Colors are dynamically set via JavaScript for unique CPU colors */\n}

/* Opponent back cards - fanned across top */
.opponentBackCard {
  position: absolute;
  width: var(--cardW);
  height: var(--cardH);
  background-color: transparent;
  background-image: url('Assets/Cards/Backside/BackCard COMPOUND(background to all cards on deck).png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Add transition for pile-to-fan animation */
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Ensure no white background bleeding */
  opacity: 1;
}

/* Pre-deal-closed pile state: all cards start in center pile, invisible */
.opponentHand.opponentPreDealClosed .opponentBackCard {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translate(0, 0) rotateZ(0deg) scale(1) !important;
}

/* Fan positioning for opponent cards (0-6 cards spread across top) */
/* Mirrored arc: rotate inverted, translate Y negative (curves toward top) */
/* Z-index layering: left-to-right stacking for clean depth separation */
.opponentBackCard:nth-child(1) { transform: translate(-180px, -12px) rotateZ(22deg); z-index: 1; }
.opponentBackCard:nth-child(2) { transform: translate(-120px, 0) rotateZ(15deg); z-index: 2; }
.opponentBackCard:nth-child(3) { transform: translate(-60px, 8px) rotateZ(8deg); z-index: 3; }
.opponentBackCard:nth-child(4) { transform: translate(0, 12px) rotateZ(0deg); z-index: 4; }
.opponentBackCard:nth-child(5) { transform: translate(60px, 8px) rotateZ(-8deg); z-index: 5; }
.opponentBackCard:nth-child(6) { transform: translate(120px, 0) rotateZ(-15deg); z-index: 6; }
.opponentBackCard:nth-child(7) { transform: translate(180px, -12px) rotateZ(-22deg); z-index: 7; }

/* Center zone - floor, draw, recent, logo in a horizontal row */
.centerZone {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  margin-top: 150px; /* Space for opponent zone above */
  margin-bottom: 8px;
  background: none;
  border: none;
  box-shadow: none;
}

/* Card area keeps floor and draw side-by-side */
.cardArea {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  align-items: flex-start;
  gap: 8px;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  flex: 0 0 auto;
}

/* Recent cards on right of floor/draw */
.recentArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.recentWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 18px;
}

.recent {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 0 18px 0;
  flex-wrap: nowrap;
}

/* Logo container - scaled to 3× size as prominent table centerpiece */
.logoContainer {
  flex-shrink: 0;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Prelock: hide logo until CSS vars are set and centered state is ready */
body.logoPrelock .logoContainer {
  visibility: hidden;
}

/* Logo centered at deck ceremony hold point (fixed position) */
body.logoCentered .logoContainer {
  position: absolute;
  left: 50%;
  top: 64.5%;
  transform: translate(-50%, -50%) scale(1);
  z-index: 2000;
  flex-shrink: 0;
  transition: none;
  /* Positioned inside gameStage at exact center (deck origin) */
  pointer-events: all;
}

/* Logo home position: return to normal layout (relative) */
body.logoHome .logoContainer {
  position: relative;
  transform: scale(1);
  z-index: auto;
  transition: transform 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Pop animation on first play: scale up briefly as it transitions */
body.logoHome.logoFirstPlay .logoContainer {
  animation: logoFirstPlayPop 240ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes logoFirstPlayPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.10);
  }
  100% {
    transform: scale(1);
  }
}

/* Logo animation container */
.logoContainer {
  background: rgba(0,0,0,.08);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 8px;
  pointer-events: none; /* Don't block clicks to cards beneath */
  z-index: 1; /* Above table, below interactive cards */
}

/* Status display - below center zone */
.statusDisplay {
  padding: 12px 16px;
  background: none;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  box-shadow: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 8px;
}

/* Operation result display - make it larger and more prominent */
#opResult {
  margin: 6px 0 !important;
  padding: 12px 14px !important;
  border-radius: 12px !important;
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1)) !important;
  border: 2px solid rgba(34, 197, 94, 0.35) !important;
  color: var(--ok) !important;
  max-width: 100% !important;
  width: auto !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  min-height: 28px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.25) !important;
  line-height: 1.4 !important;
  text-align: center !important;
}

/* Log panel - collapsible */
.logPanel {
  background: rgba(0,0,0,.1);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 10px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  max-height: 140px;
  margin-bottom: 8px;
  transition: max-height 0.3s ease;
}

.logPanel.collapsed {
  max-height: 32px;
}

.logPanel.collapsed .log {
  display: none;
}

.logPanel .log {
  flex: 1;
  overflow-y: auto;
  max-height: 100px;
}

/* Player hand zone (bottom fan) */
.playerZone {
  background: none;
  border: none;
  border-radius: 0;
  padding: 12px 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: visible;
  position: relative;
}

/* Turn indicator light above hand */
.turnIndicator {
  position: absolute;
  top: 172px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.25;
  transition: opacity 0.3s ease;
  z-index: 1;
  pointer-events: none;
}

/* Hide all turn indicators completely until floor card icon appears */
body.turnIndicatorsHidden .turnIndicator,
body.turnIndicatorsHidden .oppTurnIndicator,
body.turnIndicatorsHidden .seatTurnIndicator {
  opacity: 0 !important;
  visibility: hidden !important;
  transition: none !important;
}

.turnIndicator.active {
  opacity: 1;
}

.turnLight {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 
    0 0 6px rgba(34, 197, 94, 0.8),
    0 0 12px rgba(34, 197, 94, 0.5),
    0 0 18px rgba(34, 197, 94, 0.3);
  animation: turnPulse 1.5s ease-in-out infinite;
}

.turnText {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: #22c55e;
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

@keyframes turnPulse {
  0%, 100% {
    box-shadow: 
      0 0 6px rgba(34, 197, 94, 0.8),
      0 0 12px rgba(34, 197, 94, 0.5),
      0 0 18px rgba(34, 197, 94, 0.3);
  }
  50% {
    box-shadow: 
      0 0 8px rgba(34, 197, 94, 1),
      0 0 16px rgba(34, 197, 94, 0.7),
      0 0 24px rgba(34, 197, 94, 0.4);
  }
}

/* Opponent turn indicator light below opponent hand */
.oppTurnIndicator {
  position: absolute;
  top: 173px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.25;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.oppTurnIndicator.active {
  opacity: 1;
  transform: translateX(-50%) scale(1.25);
}

.handHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  flex-wrap: wrap;
}

.handInfo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.handControls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Hand container with fanning layout */
.handContainer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  padding: 0 12px;
  height: 380px;
  position: relative;
  margin-top: -160px;
  overflow-x: visible;
  overflow-y: visible;
  padding-top: clamp(70px, 8vh, 140px);
}

/* Player hand - fanned at bottom */
.hand {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

/* Fan cards along bottom with consistent spacing like opponent hand */
.handCard {
  position: absolute;
  transform-origin: center bottom;
  transition: transform .2s cubic-bezier(0.34, 1.56, 0.64, 1), 
              filter .15s ease,
              box-shadow .15s ease;
  z-index: 1;
}

/* Clean, evenly-spaced fan: -28deg to +28deg arc with consistent translate spacing */
/* Cards spread with 12% more horizontal space for better card visibility */
.hand .handCard:nth-child(1) { transform: translate(-222px, 24px) rotateZ(-28deg); }
.hand .handCard:nth-child(2) { transform: translate(-147px, 12px) rotateZ(-20deg); }
.hand .handCard:nth-child(3) { transform: translate(-74px, 4px) rotateZ(-12deg); }
.hand .handCard:nth-child(4) { transform: translate(0px, 0px) rotateZ(0deg); }
.hand .handCard:nth-child(5) { transform: translate(74px, 4px) rotateZ(12deg); }
.hand .handCard:nth-child(6) { transform: translate(147px, 12px) rotateZ(20deg); }
.hand .handCard:nth-child(7) { transform: translate(222px, 24px) rotateZ(28deg); }

/* Hover: no outer transform override - pull happens on inner only (keeps fan angle) */

/* Carousel buttons in hand container */
.carouselBtn {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.25);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  transition: all .2s cubic-bezier(0.23, 1, 0.320, 1);
  z-index: 10;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  will-change: transform;
  align-self: center;
}

.carouselBtn:hover {
  background: rgba(0,0,0,.35);
  border-color: rgba(255,255,255,.3);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}

.carouselBtn:active {
  transform: translateY(0) scale(.95);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* Hide old sharedStatus */
.sharedStatus {
  display: none !important;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 1200px) {
  .centerZone {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .opponentBackCard:nth-child(1) { transform: translate(-80px, 0) rotateZ(12deg); }
  .opponentBackCard:nth-child(2) { transform: translate(-40px, 4px) rotateZ(6deg); }
  .opponentBackCard:nth-child(3) { transform: translate(0, 6px) rotateZ(0deg); }
  .opponentBackCard:nth-child(4) { transform: translate(40px, 4px) rotateZ(-6deg); }
  .opponentBackCard:nth-child(5) { transform: translate(80px, 0) rotateZ(-12deg); }
  .opponentBackCard:nth-child(6) { display: none; }
}

@media (max-width: 900px) {
  .cardArea {
    gap: 6px;
  }
  
  .handCard {
    width: calc(var(--cardW) * 0.85) !important;
    height: calc(var(--cardH) * 0.85) !important;
  }
  
  /* Tighter fan for tablet: -24deg to +24deg, 12% wider spacing */
  .hand .handCard:nth-child(1) { transform: translate(-185px, 18px) rotateZ(-24deg) !important; }
  .hand .handCard:nth-child(2) { transform: translate(-123px, 10px) rotateZ(-16deg) !important; }
  .hand .handCard:nth-child(3) { transform: translate(-62px, 3px) rotateZ(-8deg) !important; }
  .hand .handCard:nth-child(4) { transform: translate(0px, 0px) rotateZ(0deg) !important; }
  .hand .handCard:nth-child(5) { transform: translate(62px, 3px) rotateZ(8deg) !important; }
  .hand .handCard:nth-child(6) { transform: translate(123px, 10px) rotateZ(16deg) !important; }
  .hand .handCard:nth-child(7) { transform: translate(185px, 18px) rotateZ(24deg) !important; }
  
  /* Hover: no outer transform override on tablet - pull happens on inner only */
}

@media (max-width: 640px) {
  .centerZone {
    flex-direction: column;
    align-items: center;
    padding: 12px;
  }
  
  .opponentZone {
    height: 100px;
    padding: 8px 0;
  }
  
  .opponentBackCard:nth-child(1) { transform: translate(-50px, 0) rotateZ(8deg); }
  .opponentBackCard:nth-child(2) { transform: translate(-25px, 2px) rotateZ(4deg); }
  .opponentBackCard:nth-child(3) { transform: translate(0, 3px) rotateZ(0deg); }
  .opponentBackCard:nth-child(4) { transform: translate(25px, 2px) rotateZ(-4deg); }
  .opponentBackCard:nth-child(5) { transform: translate(50px, 0) rotateZ(-8deg); }
  .opponentBackCard:nth-child(6) { display: none; }
  
  .handContainer {
    height: 160px;
    padding: 0 8px;
  }
  
  /* Compact mobile fan: -20deg to +20deg, 12% wider spacing */
  .hand .handCard:nth-child(1) { transform: translate(-147px, 14px) rotateZ(-20deg) !important; }
  .hand .handCard:nth-child(2) { transform: translate(-99px, 8px) rotateZ(-13deg) !important; }
  .hand .handCard:nth-child(3) { transform: translate(-50px, 3px) rotateZ(-7deg) !important; }
  .hand .handCard:nth-child(4) { transform: translate(0px, 0px) rotateZ(0deg) !important; }
  .hand .handCard:nth-child(5) { transform: translate(50px, 3px) rotateZ(7deg) !important; }
  .hand .handCard:nth-child(6) { transform: translate(99px, 8px) rotateZ(13deg) !important; }
  .hand .handCard:nth-child(7) { transform: translate(147px, 14px) rotateZ(20deg) !important; }
  
  /* Hover: no outer transform override on mobile - pull happens on inner only */
  
  .logoContainer {
    width: 120px;
    height: 120px;
  }
  
  .recentLogo {
    opacity: 0.75 !important;
  }
}
/* ============================================================================
   UI CLEANUP - MINIMAL TABLETOP VIEW
   ============================================================================ */

/* Hide UI elements visually while keeping in DOM for game.js */
#uiHidden,
.notice,
#notice,
.logPanel,
.logWrap,
#gameInfoAccordion {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

/* Clean tabletop - remove borders and panel styling */
.statusDisplay {
  padding: 8px 16px !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* Minimal operation result display */
#opResult {
  display: none !important; /* TEMPORARY HIDE - Remove this line to re-enable */
  margin: 6px auto !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  background: rgba(34, 197, 94, 0.12) !important;
  border: 1px solid rgba(34, 197, 94, 0.25) !important;
  color: var(--ok) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  text-align: center !important;
  max-width: 400px !important;
  box-shadow: none !important;
}

/* When opResult is empty, hide it completely */
#opResult:empty {
  display: none !important;
}

/* Clean center zone - no borders */
.centerZone {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

/* Clean card area - remove texture box */
.cardArea {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 8px !important;
  flex-direction: row-reverse !important;
}

/* Clean player zone - no panel styling */
.playerZone {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 8px 0 !important;
}

/* Minimal hand header */
.handHeader {
  padding: 0 8px 8px 8px !important;
  margin-bottom: 4px !important;
}

/* Clean topbar - minimal styling */
.topbar {
  padding: 0 0 6px 0 !important;
  margin-bottom: 6px !important;
  border-bottom: 1px solid rgba(255,255,255,.08) !important;
  flex-wrap: nowrap;
}

/* Hide HUD pills while keeping accessible to JS */
.hud {
  min-height: 0 !important;
}

/* Make table scene feel like one surface */
.tableScene {
  gap: 6px !important;
  padding: 12px 16px !important;
}

/* Subtle opponent zone */
.opponentZone {
  padding: 12px 0 !important;
  margin-bottom: 4px !important;
}

/* Reduce visual clutter in recent area */
.recentArea {
  gap: 4px !important;
}

.stackLabel {
  font-size: 9px !important;
  opacity: 0.7 !important;
  letter-spacing: 0.5px !important;
}

/* Clean logo container */
.logoContainer {
  background: none !important;
  border: none !important;
}

/* Minimal hand controls */
.handControls label {
  font-size: 10px !important;
  opacity: 0.8 !important;
}

#handSort {
  font-size: 10px !important;
  padding: 3px 6px !important;
  background: rgba(0,0,0,.2) !important;
  border: 1px solid rgba(255,255,255,.15) !important;
}

/* Clean hand header - now just contains hidden elements */
.handHeader {
  display: none !important;
}

/* Clean hand container */
.handContainer {
  padding: 0 8px !important;
}

/* Subtle carousel buttons */
.carouselBtn {
  opacity: 0.7 !important;
  transition: opacity .2s ease, transform .2s ease !important;
}

.carouselBtn:hover {
  opacity: 1 !important;
}

/* Remove extra spacing */
.statusDisplay,
#gameInfoAccordion,
.logPanel {
  margin-bottom: 0 !important;
}

/* Responsive cleanup */
@media (max-width: 900px) {
  .tableScene {
    padding: 8px 12px !important;
  }
  
  #topbarPlayerCount {
    font-size: 8px;
    padding: 2px 3px;
  }
  
  .stackLabel {
    font-size: 8px !important;
  }
  
  .topbarControls {
    gap: 6px;
    flex: 0 1 auto;
    justify-content: flex-end;
    order: 3;
    width: auto;
  }
  
  .playerInfo {
    padding: 2px 4px;
  }
  
  .playerInfo .panelTitle {
    font-size: 9px;
  }
  
  .playerInfo .panelSub {
    font-size: 8px;
  }
  
  .gameControls {
    gap: 4px;
  }
  
  .gameControls label {
    font-size: 8px !important;
    padding: 2px 4px;
  }
  
  #handSort {
    font-size: 8px !important;
    padding: 1px 3px !important;
  }
}

@media (max-width: 640px) {
  .tableScene {
    padding: 6px 8px !important;
  }
  
  .topbar {
    padding: 0 0 5px 0 !important;
    gap: 6px;
    margin-bottom: 4px !important;
  }
  
  #topbarPlayerCount {
    font-size: 7px;
    padding: 1px 2px;
  }
  
  .brandText {
    font-size: 14px !important;
  }
  
  .topbarControls {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    width: auto;
    flex: 0 1 auto;
    margin-left: auto;
    order: 2;
  }
  
  .playerInfo {
    padding: 1px 3px;
    gap: 2px;
  }
  
  .playerInfo .panelTitle {
    font-size: 8px;
  }
  
  .playerInfo .panelSub {
    font-size: 7px;
  }
  
  .gameControls {
    gap: 3px;
  }
  
  .gameControls label {
    font-size: 7px !important;
    padding: 1px 3px;
  }
  
  #handSort {
    font-size: 7px !important;
    padding: 1px 2px !important;
  }
  
  .hud {
    order: 1;
    flex: 0 0 auto;
  }
}

@media (max-width: 420px) {
  .gameControls {
    flex-wrap: wrap;
  }
  
  .gameControls label {
    font-size: 8px !important;
    padding: 2px 4px;
  }
  
  #handSort {
    font-size: 8px !important;
    padding: 2px 3px !important;
  }
}
/* Round-robin deal ghost card animation */
.dealGhostCard {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background-image: url('Assets/Cards/Backside/BackCard COMPOUND(background to all cards on deck).png');
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  will-change: transform;
}
/* ===== MOBILE FULLSCREEN FIT ===== */
/* On phones: game fills viewport without wrapper scaling; on desktop: keep existing behavior */
@media (max-width: 768px) {
  html, body {
    overflow: hidden;
    height: 100%;
  }

  .gameViewport {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
    background: #000;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    padding: 0;
  }

  /* gameStage: JS scaling (fitGameStage) handles all sizes — no CSS override needed */
}
/* ===== BACKGROUND CHANGER BUTTON ===== */
#backgroundToggle {
  transition: all 0.2s ease;
}

#backgroundToggle:hover {
  background: rgba(94, 234, 212, 0.2) !important;
  border-color: rgba(94, 234, 212, 0.6) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(94, 234, 212, 0.3);
}

#backgroundToggle:active {
  transform: translateY(0) scale(0.95);
}

/* ===== BACKGROUND COLOR OVERLAY ===== */
#bgColorOverlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease, background 0.3s ease;
  width: 100vw;
  height: 100vh;
}

/* Range slider styling */
#bgColorSlider {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  height: 6px;
  outline: none;
}

#bgColorSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5eead4, #34d399);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(94, 234, 212, 0.4);
  transition: all 0.2s ease;
}

#bgColorSlider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 3px 10px rgba(94, 234, 212, 0.6);
}

#bgColorSlider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5eead4, #34d399);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(94, 234, 212, 0.4);
  transition: all 0.2s ease;
}

#bgColorSlider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 3px 10px rgba(94, 234, 212, 0.6);
}

/* Player dropdown styling */
#topbarPlayerCount {
  background: #000000 !important;
  color: #ffffff !important;
}

#topbarPlayerCount option {
  background: #000000 !important;
  color: #ffffff !important;
  padding: 2px 4px;
}

#topbarPlayerCount option:hover {
  background: #ffffff !important;
  color: #000000 !important;
}

#topbarPlayerCount option:checked {
  background: linear-gradient(#34d399, #34d399) !important;
  background-color: #34d399 !important;
  color: #ffffff !important;
}
/* === TUTORIAL OVERLAY === */
#tutorialOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1999;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#tutorialOverlay.isHidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tutorialCard {
  background: linear-gradient(135deg, rgba(10, 10, 15, 0.98), rgba(15, 10, 20, 0.98));
  border: 2px solid rgba(94, 234, 212, 0.5);
  border-radius: 16px;
  padding: 28px;
  width: 820px;
  height: 680px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.9), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 2000;
}

/* Tutorial card scaling handled by scaleTutorialCard() in JS */

@media (max-width: 768px) {
  .tutorialCard {
    padding: 20px;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.tutorialHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(94, 234, 212, 0.2);
  padding-bottom: 12px;
  flex-shrink: 0;
}

.tutorialHeader h2 {
  margin: 0;
  color: #5eeadc;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  line-height: 1.15;
}

@media (max-width: 768px) {
  .tutorialHeader h2 {
    font-size: 16px;
  }
}

#tutorialCloseBtn {
  background: none;
  border: none;
  color: #5eeadc;
  font-size: 32px;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

#tutorialCloseBtn:hover {
  color: #34d399;
}

/* === SPLIT LAYOUT === */
.tutorialBody {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  align-items: stretch;
  flex: 1;
  overflow: hidden;
}

/* 
  Original rule switched to 1-column layout on small screens, 
  but zoom now scales the whole card uniformly — keeping 2-column 
  so the visual panel never collapses. 
  Instead, ensure visual panel has min-height as safety net.
*/
@media (max-width: 868px) {
  .tutorialBody {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 12px;
  }
  .tutorialVisualPanel {
    min-height: 200px;
  }
}

.tutorialNavRow {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  margin-top: auto;
  margin: 0;
  padding-top: 10px;
  padding-bottom: 0;
  flex-shrink: 0;
}

.tutorialTextDivider {
  display: none !important;
}

.tutorialNavBtn {
  width: 44px;
  height: 36px;
  border-radius: 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(94, 234, 212, 0.5);
  background: transparent;
  color: #5eeadc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tutorialNavBtn:hover:not(:disabled) {
  background: rgba(94, 234, 212, 0.1);
  border-color: #5eeadc;
  color: #34d399;
}

.tutorialNavBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tutorialJumpBtn {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
  border: none;
}

.tutorialJumpBtn.tutorialSecondary {
  background: transparent;
  color: #5eeadc;
  border: 1px solid rgba(94, 234, 212, 0.5);
}

.tutorialJumpBtn.tutorialSecondary:hover {
  background: rgba(94, 234, 212, 0.1);
  border-color: #5eeadc;
  color: #34d399;
}

.tutorialJumpBtn.tutorialPrimary {
  background: linear-gradient(135deg, #5eeadc, #34d399);
  color: #000;
}

.tutorialJumpBtn.tutorialPrimary:hover {
  background: linear-gradient(135deg, #34d399, #00ff88);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(94, 234, 212, 0.3);
}

.tutorialVisualPanel {
  border: 2px solid rgba(94, 234, 212, 0.35);
  border-radius: 14px;
  background: rgba(30, 30, 40, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
  animation: fadeIn 0.3s ease;
  position: relative;
}

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

.tutorialVisualLogo {
  display: none !important;
}

.tutorialPanelLogo {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 120px;
  height: 120px;
  object-fit: contain;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.55));
}

.tutorialVisualRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: nowrap;
  position: relative;
  z-index: 3;
}

.tutorialVisualCard {
  max-height: 140px;
  object-fit: contain;
  border-radius: 8px;
}

/* ====== Tutorial Slide 1: 7-Card Fan Animation ====== */
.tutorialHandAnim7 {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.tutorialHandFan7 {
  position: absolute;
  left: 45%;
  top: 30%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tutorialHandCard7 {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(58px, 8vw, 88px);
  height: auto;
  transform-origin: 50% 88%;
  will-change: transform, opacity;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Fan positions (7 cards spread) */
.tutorialHandCard7.c1 {
  transform: translate(-170px, 30px) rotate(-30deg);
  animation: tutorialFade1 5.6s infinite;
}

.tutorialHandCard7.c2 {
  transform: translate(-120px, 14px) rotate(-20deg);
  animation: tutorialFade2 5.6s infinite;
}

.tutorialHandCard7.c3 {
  transform: translate(-70px, 2px) rotate(-10deg);
  animation: tutorialFade3 5.6s infinite;
}

.tutorialHandCard7.c4 {
  transform: translate(-20px, -4px) rotate(-4deg);
  animation: tutorialFade4 5.6s infinite;
}

.tutorialHandCard7.c5.last {
  transform: translate(30px, -4px) rotate(4deg);
  animation: tutorialLaunch5 5.6s infinite;
}

.tutorialHandCard7.c6 {
  transform: translate(80px, 2px) rotate(10deg);
  animation: tutorialFade6 5.6s infinite;
}

.tutorialHandCard7.c7 {
  transform: translate(130px, 14px) rotate(20deg);
  animation: tutorialFade7 5.6s infinite;
}

/* Disappear order: c3(1.0s), c1(1.3s), c6(1.6s), c2(1.9s), c7(2.2s), c4(2.5s) - faster timing */
/* Total 5.6s loop: 1s hold + 1.8s fades + 0.5s launch + 1.8s WIN + 0.5s reset */
@keyframes tutorialFade3 {
  0%, 17.9% { opacity: 1; transform: translate(-70px, 2px) rotate(-10deg) scale(1); }
  21.4% { opacity: 0; transform: translate(-70px, 2px) rotate(-10deg) scale(0.7); }
  100% { opacity: 0; transform: translate(-70px, 2px) rotate(-10deg) scale(0.7); }
}

@keyframes tutorialFade1 {
  0%, 23.2% { opacity: 1; transform: translate(-170px, 30px) rotate(-30deg) scale(1); }
  26.8% { opacity: 0; transform: translate(-170px, 30px) rotate(-30deg) scale(0.7); }
  100% { opacity: 0; transform: translate(-170px, 30px) rotate(-30deg) scale(0.7); }
}

@keyframes tutorialFade6 {
  0%, 28.6% { opacity: 1; transform: translate(80px, 2px) rotate(10deg) scale(1); }
  32.1% { opacity: 0; transform: translate(80px, 2px) rotate(10deg) scale(0.7); }
  100% { opacity: 0; transform: translate(80px, 2px) rotate(10deg) scale(0.7); }
}

@keyframes tutorialFade2 {
  0%, 33.9% { opacity: 1; transform: translate(-120px, 14px) rotate(-20deg) scale(1); }
  37.5% { opacity: 0; transform: translate(-120px, 14px) rotate(-20deg) scale(0.7); }
  100% { opacity: 0; transform: translate(-120px, 14px) rotate(-20deg) scale(0.7); }
}

@keyframes tutorialFade7 {
  0%, 39.3% { opacity: 1; transform: translate(130px, 14px) rotate(20deg) scale(1); }
  42.9% { opacity: 0; transform: translate(130px, 14px) rotate(20deg) scale(0.7); }
  100% { opacity: 0; transform: translate(130px, 14px) rotate(20deg) scale(0.7); }
}

@keyframes tutorialFade4 {
  0%, 44.6% { opacity: 1; transform: translate(-20px, -4px) rotate(-4deg) scale(1); }
  48.2% { opacity: 0; transform: translate(-20px, -4px) rotate(-4deg) scale(0.7); }
  100% { opacity: 0; transform: translate(-20px, -4px) rotate(-4deg) scale(0.7); }
}

/* Last card (c5) launches to discard at 2.8s (50%) */
@keyframes tutorialLaunch5 {
  0%, 50% { opacity: 1; transform: translate(30px, -4px) rotate(4deg) scale(1); }
  58.9% { 
    opacity: 0; 
    transform: translate(calc(30px + clamp(28px, 4vw, 56px)), calc(-4px + clamp(-70px, -10vh, -110px))) rotate(22deg) scale(0.85); 
  }
  100% { 
    opacity: 0; 
    transform: translate(calc(30px + clamp(28px, 4vw, 56px)), calc(-4px + clamp(-70px, -10vh, -110px))) rotate(22deg) scale(0.85); 
  }
}

/* WIN popup container - positioning context only, no flex */
.tutorialWinPop7 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

.tutorialWinLogo7 {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(117.6px, 18.48vw, 176.96px);
  height: auto;
  animation: tutorialWinLogoShow 5.6s infinite;
  margin-top: 0;
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
}

.tutorialWinText7 {
  position: absolute;
  left: 50%;
  top: 47%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: clamp(40.32px, 5.76vw, 60.48px);
  font-weight: 800;
  color: #FFD700;
  text-shadow: 0 0 16px rgba(255, 215, 0, 0.8), 0 0 8px rgba(255, 215, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 4px;
  animation: tutorialWinTextShow 5.6s infinite;
  margin: 0;
}

/* WIN text appears at 58.8% (3.28s), stays 1s (until 76.6%), then fades */
@keyframes tutorialWinTextShow {
  0%, 58.8% { opacity: 0; }
  62.5% { opacity: 1; }
  76.6% { opacity: 1; }
  80.3% { opacity: 0; }
  100% { opacity: 0; }
}

/* Logo appears at 76.6% (4.28s), stays 1s (until 94.5%), then fades */
@keyframes tutorialWinLogoShow {
  0%, 76.6% { opacity: 0; }
  80.3% { opacity: 1; }
  94.5% { opacity: 1; }
  98.2% { opacity: 0; }
  100% { opacity: 0; }
}


/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
  .tutorialHandCard7.c1 { transform: translate(-140px, 24px) rotate(-28deg); }
  .tutorialHandCard7.c2 { transform: translate(-98px, 12px) rotate(-18deg); }
  .tutorialHandCard7.c3 { transform: translate(-56px, 2px) rotate(-9deg); }
  .tutorialHandCard7.c4 { transform: translate(-16px, -2px) rotate(-3deg); }
  .tutorialHandCard7.c5.last { transform: translate(24px, -2px) rotate(3deg); }
  .tutorialHandCard7.c6 { transform: translate(64px, 2px) rotate(9deg); }
  .tutorialHandCard7.c7 { transform: translate(106px, 12px) rotate(18deg); }
  
  @keyframes tutorialFade3 {
    0%, 17.9% { opacity: 1; transform: translate(-56px, 2px) rotate(-9deg) scale(1); }
    21.4% { opacity: 0; transform: translate(-56px, 2px) rotate(-9deg) scale(0.7); }
    100% { opacity: 0; transform: translate(-56px, 2px) rotate(-9deg) scale(0.7); }
  }
  
  @keyframes tutorialFade1 {
    0%, 23.2% { opacity: 1; transform: translate(-140px, 24px) rotate(-28deg) scale(1); }
    26.8% { opacity: 0; transform: translate(-140px, 24px) rotate(-28deg) scale(0.7); }
    100% { opacity: 0; transform: translate(-140px, 24px) rotate(-28deg) scale(0.7); }
  }
  
  @keyframes tutorialFade6 {
    0%, 28.6% { opacity: 1; transform: translate(64px, 2px) rotate(9deg) scale(1); }
    32.1% { opacity: 0; transform: translate(64px, 2px) rotate(9deg) scale(0.7); }
    100% { opacity: 0; transform: translate(64px, 2px) rotate(9deg) scale(0.7); }
  }
  
  @keyframes tutorialFade2 {
    0%, 33.9% { opacity: 1; transform: translate(-98px, 12px) rotate(-18deg) scale(1); }
    37.5% { opacity: 0; transform: translate(-98px, 12px) rotate(-18deg) scale(0.7); }
    100% { opacity: 0; transform: translate(-98px, 12px) rotate(-18deg) scale(0.7); }
  }
  
  @keyframes tutorialFade7 {
    0%, 39.3% { opacity: 1; transform: translate(106px, 12px) rotate(18deg) scale(1); }
    42.9% { opacity: 0; transform: translate(106px, 12px) rotate(18deg) scale(0.7); }
    100% { opacity: 0; transform: translate(106px, 12px) rotate(18deg) scale(0.7); }
  }
  
  @keyframes tutorialFade4 {
    0%, 44.6% { opacity: 1; transform: translate(-16px, -2px) rotate(-3deg) scale(1); }
    48.2% { opacity: 0; transform: translate(-16px, -2px) rotate(-3deg) scale(0.7); }
    100% { opacity: 0; transform: translate(-16px, -2px) rotate(-3deg) scale(0.7); }
  }
  
  @keyframes tutorialLaunch5 {
    0%, 50% { opacity: 1; transform: translate(24px, -2px) rotate(3deg) scale(1); }
    58.9% { 
      opacity: 0; 
      transform: translate(calc(24px + clamp(28px, 4vw, 56px)), calc(-2px + clamp(-70px, -10vh, -110px))) rotate(21deg) scale(0.85); 
    }
    100% { 
      opacity: 0; 
      transform: translate(calc(24px + clamp(28px, 4vw, 56px)), calc(-2px + clamp(-70px, -10vh, -110px))) rotate(21deg) scale(0.85); 
    }
  }
}

@media (max-width: 768px) {
  .tutorialVisualCard {
    max-height: 120px;
  }
}

.tutorialVisualIcon {
  max-height: 86px;
  object-fit: contain;
}

@media (max-width: 768px) {
  .tutorialVisualIcon {
    max-height: 72px;
  }
}

.tutorialVisualArrow {
  font-size: 28px;
  color: #5eeadc;
  font-weight: 700;
  line-height: 1;
}

.tutorialVisualNumChip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #5eeadc, #34d399);
  color: #000;
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  font-weight: 700;
  border-radius: 10px;
}

@media (max-width: 768px) {
  .tutorialVisualNumChip {
    min-width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

.tutorialVisualTextChip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: rgba(94, 234, 212, 0.15);
  color: #5eeadc;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(94, 234, 212, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@media (max-width: 768px) {
  .tutorialVisualTextChip {
    padding: 6px 10px;
    font-size: 12px;
  }
}

.tutorialTextPanel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.tutorialTextPanel > :not(.tutorialPanelLogo) {
  position: relative;
  z-index: 1;
}

.tutorialProgress,
#tutorialDots,
.tutorialDots,
.tutorialDot,
#tutorialProgressText,
.tutorialProgressText {
  display: none !important;
}

.tutorialIcon {
  display: none !important;
  max-width: 80px;
  max-height: 80px;
  margin: 0 auto 10px;
  object-fit: contain;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .tutorialIcon {
    max-width: 70px;
    max-height: 70px;
    margin-bottom: 8px;
  }
}

.tutorialExampleRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid rgba(94, 234, 212, 0.15);
  flex-shrink: 0;
}

.exampleChipNum,
.exampleChipText,
.exampleChipArrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
}

.exampleChipNum {
  background: linear-gradient(135deg, #5eeadc, #34d399);
  color: #000;
  min-width: 32px;
}

.exampleChipText {
  background: rgba(94, 234, 212, 0.15);
  color: #5eeadc;
  font-size: 14px;
}

.exampleChipArrow {
  background: transparent;
  color: #5eeadc;
  font-size: 16px;
  padding: 4px 8px;
}

.exampleChipIcon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.tutorialContent {
  color: #d0d0d0;
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(14px, 1.8vw, 18px);
  line-height: 1.25;
  letter-spacing: 0.2px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.tutorialContent p {
  margin: 0 0 10px 0;
  padding: 0;
}

@media (max-width: 768px) {
  .tutorialContent {
    font-size: 11px;
    line-height: 1.25;
  }
  
  .tutorialContent p {
    margin-bottom: 4px;
  }
}

/* === SLIDE 1 HERO TEXT STYLING === */
#tutorialOverlay.tutSlideObjective #tutorialContent {
  font-size: clamp(15px, 2.0vw, 19px);
  line-height: 1.22;
}

#tutorialOverlay.tutSlideObjective #tutorialContent p {
  margin: 0 0 10px 0;
}

#tutorialOverlay.tutSlideObjective #tutorialContent p:last-child {
  margin-bottom: 0;
  font-weight: 700;
  font-size: clamp(16px, 2.2vw, 20px);
  color: #FFD700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 0 0 4px rgba(255, 215, 0, 0.3);
}

/* ====== Tutorial Slide 2: Setup Deal Animation ====== */
.tutSetup2 {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  --cH: clamp(92px, 18vh, 150px);
}

.tutDealer2 {
  position: absolute;
  left: 50%;
  top: 50%;
  height: var(--cH);
  width: auto;
  transform: translate(-50%, -50%);
  z-index: 4;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55));
  animation: tutDealer2 4.6s linear infinite;
}

.tutOppHand2,
.tutPlayerHand2 {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tutOppCard2,
.tutPlayCard2 {
  position: absolute;
  left: 50%;
  top: 50%;
  height: var(--cH);
  width: auto;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.96);
  transform-origin: 50% 88%;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.5));
}

/* Opponent hand (top fan) - 25% closer to center */
.tutOppCard2.o1 {
  --tx: -142.5px;
  --ty: -112.5px;
  --rot: -26deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.05s;
}
.tutOppCard2.o2 {
  --tx: -97.5px;
  --ty: -123.75px;
  --rot: -16deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.13s;
}
.tutOppCard2.o3 {
  --tx: -52.5px;
  --ty: -132px;
  --rot: -8deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.21s;
}
.tutOppCard2.o4 {
  --tx: 0px;
  --ty: -135px;
  --rot: 0deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.29s;
}
.tutOppCard2.o5 {
  --tx: 52.5px;
  --ty: -132px;
  --rot: 8deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.37s;
}
.tutOppCard2.o6 {
  --tx: 97.5px;
  --ty: -123.75px;
  --rot: 16deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.45s;
}
.tutOppCard2.o7 {
  --tx: 142.5px;
  --ty: -112.5px;
  --rot: 26deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.53s;
}

/* Player hand (bottom fan) - 25% closer to center */
.tutPlayCard2.p1 {
  --tx: -142.5px;
  --ty: 112.5px;
  --rot: -26deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.10s;
}
.tutPlayCard2.p2 {
  --tx: -97.5px;
  --ty: 123.75px;
  --rot: -16deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.18s;
}
.tutPlayCard2.p3 {
  --tx: -52.5px;
  --ty: 132px;
  --rot: -8deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.26s;
}
.tutPlayCard2.p4 {
  --tx: 0px;
  --ty: 135px;
  --rot: 0deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.34s;
}
.tutPlayCard2.p5 {
  --tx: 52.5px;
  --ty: 132px;
  --rot: 8deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.42s;
}
.tutPlayCard2.p6 {
  --tx: 97.5px;
  --ty: 123.75px;
  --rot: 16deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.50s;
}
.tutPlayCard2.p7 {
  --tx: 142.5px;
  --ty: 112.5px;
  --rot: 26deg;
  animation: tutDealToHand2 4.6s cubic-bezier(0.2, 0.9, 0.2, 1) infinite;
  animation-delay: 0.58s;
}

@keyframes tutDealToHand2 {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  27% {
    opacity: 1;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(var(--rot));
  }
  71% {
    opacity: 1;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(var(--rot));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1) rotate(var(--rot));
  }
}

.tutFloor2 {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
}

.tutFloorFace2 {
  height: var(--cH);
  width: auto;
  opacity: 0;
  transform: scale(0.98);
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55));
  animation: tutFloorShow2 4.6s ease-in-out infinite;
}

@keyframes tutFloorShow2 {
  0% {
    opacity: 0;
    transform: scale(0.98);
  }
  49% {
    opacity: 0;
  }
  49.5% {
    opacity: 1;
    transform: scale(1);
  }
  67% {
    opacity: 1;
    transform: scale(1);
  }
  85% {
    opacity: 0;
    transform: scale(0.98);
  }
  100% {
    opacity: 0;
    transform: scale(0.98);
  }
}

@keyframes tutDealer2 {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) translateX(0);
  }
  48.5% {
    opacity: 1;
    transform: translate(-50%, -50%) translateX(0);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) translateX(calc(-1 * (var(--cH) * 0.66) - 2%));
  }
  67% {
    opacity: 1;
    transform: translate(-50%, -50%) translateX(calc(-1 * (var(--cH) * 0.66) - 2%));
  }
  85% {
    opacity: 0;
    transform: translate(-50%, -50%) translateX(calc(-1 * (var(--cH) * 0.66) - 2%));
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translateX(calc(-1 * (var(--cH) * 0.66) - 2%));
  }
}

/* ====== Tutorial Slide 3: Your Turn (Play or Draw) ====== */
.tutTurnFlow3 {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  --cH: clamp(95px, 18.7vh, 156px);
}

/* Deck pile (higher, left of floor) */
.tutDeck3 {
  position: absolute;
  left: 31.9%;
  top: 47%;
  transform: translate(-50%, -50%);
  height: var(--cH);
  width: auto;
  z-index: 2;
  opacity: 0.95;
  filter: drop-shadow(0 14px 18px rgba(0,0,0,0.55));
}

/* Floor (higher, center-right) */
.tutFloorWrap3 {
  position: absolute;
  left: 52%;
  top: 47%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.tutFloorFace3 {
  height: var(--cH);
  width: auto;
  filter: drop-shadow(0 16px 20px rgba(0,0,0,0.6));
  transition: opacity 0.3s ease;
}

/* Deck glow during draw */
.tutDeck3.tutDeckGlow3 {
  outline: 4px solid rgba(255, 215, 0, 0.95);
  box-shadow: 0 0 36px rgba(255, 215, 0, 0.95), 0 0 12px rgba(255, 215, 0, 0.85);
  animation: tutDeckGlowDraw3 3.3s ease-out forwards;
  z-index: 5;
}

@keyframes tutDeckGlowDraw3 {
  0% {
    outline-color: rgba(255, 215, 0, 0.95);
    box-shadow: 0 0 40px rgba(255, 215, 0, 1), 0 0 16px rgba(255, 215, 0, 0.9);
  }
  70% {
    outline-color: rgba(57, 255, 20, 0.9);
    box-shadow: 0 0 32px rgba(57, 255, 20, 0.95), 0 0 12px rgba(57, 255, 20, 0.7);
  }
  100% {
    outline-color: rgba(57, 255, 20, 0);
    box-shadow: 0 0 0 rgba(57, 255, 20, 0), 0 0 0 rgba(57, 255, 20, 0);
  }
}

/* Celebration shape icon (real image, larger and further right) */
.tutShapeIcon3 {
  position: absolute;
  left: 69.5%;
  top: 47%;
  transform: translate(-50%, -50%) scale(0);
  height: clamp(40px, 7.7vw, 59px);
  width: auto;
  opacity: 0;
  z-index: 4;
  filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.7));
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.tutShapeIcon3.tutShowCeleb3 {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Phase text overlays */
.tutPhaseText3 {
  position: absolute;
  left: 50%;
  top: 11%;
  transform: translate(-50%, -50%);
  font-size: clamp(16px, 2.2vw, 22px);
  font-weight: 800;
  font-family: 'Arial Black', sans-serif;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 20px rgba(57, 255, 20, 0.8), 0 2px 8px rgba(0, 0, 0, 0.9);
  opacity: 0;
  z-index: 5;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.tutPhaseText3.tutShowText3 {
  opacity: 1;
}

/* Play matching shape (Phase A) */
.tutPhaseText3.playMatch {
  top: 11%;
}

/* Next turn (Phase B) */
.tutPhaseText3.nextTurn {
  top: 11%;
}

/* Draw a card (Phase B) */
.tutPhaseText3.drawCard {
  top: 11%;
}

/* Dim filter for unplayable cards */
.tutHand3.tutDim3 {
  filter: grayscale(100%) brightness(0.55) contrast(1.05) drop-shadow(0 12px 16px rgba(0,0,0,0.5));
  opacity: 0.75;
}

/* Player hand fan (3 cards, centered) */
.tutHandFan3 {
  position: absolute;
  left: 50%;
  top: 87%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.tutHand3 {
  position: absolute;
  left: 50%;
  top: 50%;
  height: var(--cH);
  width: auto;
  opacity: 1;
  transform: translate(-50%, -50%);
  transform-origin: 50% 88%;
  filter: drop-shadow(0 12px 16px rgba(0,0,0,0.5));
  transition: opacity 0.3s ease, filter 0.2s ease;
}

/* 3-card fan spread positions (tighter hand) */
.tutHand3.c1 {
  --tx: -60px;
  --ty: 5px;
  --rot: -10deg;
  --px: -12px;
  --py: -18px;
}

.tutHand3.c2 {
  --tx: 0px;
  --ty: 0px;
  --rot: 0deg;
  --px: 0px;
  --py: -20px;
}

.tutHand3.c3 {
  --tx: 60px;
  --ty: 5px;
  --rot: 10deg;
  --px: 12px;
  --py: -18px;
}

.tutHand3.c1,
.tutHand3.c2,
.tutHand3.c3 {
  transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot));
}

/* Hidden state for Phase B (only show 3 cards) */
.tutHand3.tutHidden3 {
  opacity: 0;
  pointer-events: none;
}

/* Playable highlight glow */
.tutPlayableGlow3 {
  outline: none;
  box-shadow: none;
  filter: drop-shadow(0 12px 16px rgba(0,0,0,0.5));
}

/* Ghost card that launches to floor */
.tutPlayGhost3 {
  position: absolute;
  left: 50%;
  top: 87%;
  height: var(--cH);
  width: auto;
  opacity: 0;
  transform: translate(-50%, -50%);
  transform-origin: 50% 88%;
  z-index: 5;
  filter: drop-shadow(0 16px 22px rgba(0,0,0,0.65));
  animation: playLaunch3 9s cubic-bezier(0.2,0.9,0.2,1) infinite;
}

@keyframes playLaunch3 {
  /* Phase A play (11-22% = 1.0-2.0s) */
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--ghost-tx, 0px)), calc(-50% + var(--ghost-ty, 0px))) rotate(var(--ghost-rot, 0deg)) scale(1);
  }
  11% {
    opacity: 0;
    transform: translate(calc(-50% + var(--ghost-tx, 0px)), calc(-50% + var(--ghost-ty, 0px))) rotate(var(--ghost-rot, 0deg)) scale(1);
  }
  13% {
    opacity: 1;
    transform: translate(calc(-50% + var(--ghost-tx, 0px)), calc(-50% + var(--ghost-ty, 0px))) rotate(var(--ghost-rot, 0deg)) scale(1);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(-120px) scale(1.02) rotate(0deg);
  }
  22% {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(-120px) scale(1.02) rotate(0deg);
  }
  100% {
    opacity: 0;
  }
}

/* Draw card fly-in during Phase B */
.tutDrawFly3 {
  position: absolute;
  left: 31.9%;
  top: 47%;
  height: var(--cH);
  width: auto;
  opacity: 0;
  z-index: 4;
  filter: drop-shadow(0 14px 18px rgba(0,0,0,0.55));
  animation: drawFly3 9s ease-in-out infinite;
}

@keyframes drawFly3 {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateX(0) translateY(0);
  }
  65% {
    opacity: 0;
    transform: translate(-50%, -50%) translateX(0) translateY(0);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) translateX(80px) translateY(240px);
  }
  76% {
    opacity: 0;
    transform: translate(-50%, -50%) translateX(90px) translateY(255px);
  }
  100% {
    opacity: 0;
  }
}

/* === TUTORIAL SLIDE 4: VALUE MATCH LOOP === */
.tutValueMatch4 {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  --cH: clamp(95px, 18.7vh, 156px);
}

/* Deck pile (left, matches Slide 3) */
.tutDeck4 {
  position: absolute;
  left: 31.9%;
  top: 47%;
  transform: translate(-50%, -50%);
  height: var(--cH);
  width: auto;
  z-index: 2;
  opacity: 0.95;
  filter: drop-shadow(0 14px 18px rgba(0,0,0,0.55));
}

/* Floor (center, matches Slide 3) */
.tutFloorWrap4 {
  position: absolute;
  left: 52%;
  top: 47%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.tutFloorFace4 {
  height: var(--cH);
  width: auto;
  filter: drop-shadow(0 16px 20px rgba(0,0,0,0.6));
  transition: all 0.4s ease;
}

/* Shape icon token (next to floor) */
.tutShapeIcon4 {
  position: absolute;
  left: 69.5%;
  top: 47%;
  transform: translate(-50%, -50%);
  height: clamp(40px, 7.7vw, 59px);
  width: auto;
  opacity: 1;
  z-index: 4;
  filter: drop-shadow(0 0 12px rgba(255, 215, 0, 0.7));
  transition: all 0.4s ease;
}

/* Counter display (top center) */
.tutCounter4 {
  position: absolute;
  left: 50%;
  top: 11%;
  transform: translate(-50%, -50%);
  font-size: clamp(18px, 2.5vw, 26px);
  font-weight: 800;
  font-family: 'Arial Black', sans-serif;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 20px rgba(94, 234, 212, 0.8), 0 2px 8px rgba(0, 0, 0, 0.9);
  z-index: 5;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tutCounterNum {
  font-size: clamp(28px, 3.5vw, 38px);
  color: rgba(94, 234, 212, 1);
  text-shadow: 0 0 24px rgba(94, 234, 212, 1), 0 2px 12px rgba(0, 0, 0, 0.95);
}

.tutCounterLabel {
  font-size: clamp(12px, 1.8vw, 16px);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Player hand fan (7 cards, bottom, matches Slide 3) */
.tutHandFan4 {
  position: absolute;
  left: 50%;
  top: 87%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.tutHand4 {
  position: absolute;
  left: 50%;
  top: 50%;
  height: var(--cH);
  width: auto;
  opacity: 1;
  transform: translate(-50%, -50%);
  transform-origin: 50% 88%;
  filter: drop-shadow(0 12px 16px rgba(0,0,0,0.5));
  transition: opacity 0.3s ease, filter 0.2s ease;
}

/* 7-card fan spread (wider spread than 3-card) */
.tutHand4.c1 {
  --tx: -135px;
  --ty: 12px;
  --rot: -18deg;
}

.tutHand4.c2 {
  --tx: -90px;
  --ty: 6px;
  --rot: -12deg;
}

.tutHand4.c3 {
  --tx: -45px;
  --ty: 2px;
  --rot: -6deg;
}

.tutHand4.c4 {
  --tx: 0px;
  --ty: 0px;
  --rot: 0deg;
}

.tutHand4.c5 {
  --tx: 45px;
  --ty: 2px;
  --rot: 6deg;
}

.tutHand4.c6 {
  --tx: 90px;
  --ty: 6px;
  --rot: 12deg;
}

.tutHand4.c7 {
  --tx: 135px;
  --ty: 12px;
  --rot: 18deg;
}

.tutHand4.c1,
.tutHand4.c2,
.tutHand4.c3,
.tutHand4.c4,
.tutHand4.c5,
.tutHand4.c6,
.tutHand4.c7 {
  transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot));
}

/* Hidden state */
.tutHand4.tutHidden4 {
  opacity: 0;
  pointer-events: none;
}

/* Desaturated (non-playable cards) */
.tutHand4.tutDim4 {
  filter: grayscale(100%) brightness(0.55) contrast(1.05) drop-shadow(0 12px 16px rgba(0,0,0,0.5));
  opacity: 1;
}

/* Ghost cards for play animation */
.tutPlayGhost4 {
  position: absolute;
  left: 50%;
  top: 87%;
  height: var(--cH);
  width: auto;
  opacity: 0;
  transform: translate(-50%, -50%);
  transform-origin: 50% 88%;
  z-index: 10;
  filter: drop-shadow(0 16px 22px rgba(0,0,0,0.65));
  display: none;
}

.tutPlayGhost4.tutAnimate4 {
  animation: valueMatchPlay4 0.8s cubic-bezier(0.2,0.9,0.2,1) forwards;
}

@keyframes valueMatchPlay4 {
  0% {
    opacity: 1;
    transform: translate(calc(-50% + var(--ghost-tx, 0px)), calc(-50% + var(--ghost-ty, 0px))) rotate(var(--ghost-rot, 0deg)) scale(1);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(-120px) scale(1.02) rotate(0deg);
  }
}

/* 7-card fan spread for Operations slide (reusing Slide 3 structure) */
.tutHandFan7Ops {
  position: absolute;
  left: 50%;
  top: 87%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.tutHand7Ops {
  position: absolute;
  left: 50%;
  top: 50%;
  height: var(--cH);
  width: auto;
  opacity: 1;
  transform: translate(-50%, -50%);
  transform-origin: 50% 88%;
  filter: drop-shadow(0 12px 16px rgba(0,0,0,0.5));
  transition: opacity 0.3s ease, filter 0.2s ease;
}

/* 7-card positions (wider fan spread) */
.tutHand7Ops.c1 {
  --tx: -120px;
  --ty: 8px;
  --rot: -18deg;
}

.tutHand7Ops.c2 {
  --tx: -75px;
  --ty: 3px;
  --rot: -12deg;
}

.tutHand7Ops.c3 {
  --tx: -30px;
  --ty: 0px;
  --rot: -6deg;
}

.tutHand7Ops.c4 {
  --tx: 0px;
  --ty: 0px;
  --rot: 0deg;
}

.tutHand7Ops.c5 {
  --tx: 30px;
  --ty: 0px;
  --rot: 6deg;
}

.tutHand7Ops.c6 {
  --tx: 75px;
  --ty: 3px;
  --rot: 12deg;
}

.tutHand7Ops.c7 {
  --tx: 120px;
  --ty: 8px;
  --rot: 18deg;
}

.tutHand7Ops.c1,
.tutHand7Ops.c2,
.tutHand7Ops.c3,
.tutHand7Ops.c4,
.tutHand7Ops.c5,
.tutHand7Ops.c6,
.tutHand7Ops.c7 {
  transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot));
}

/* Hidden state for Operations animation */
.tutHand7Ops.tutHidden3 {
  opacity: 0;
  pointer-events: none;
}

/* Playable highlight glow for Operations */
.tutHand7Ops.tutPlayableGlow3 {
  outline: none;
  box-shadow: none;
  filter: drop-shadow(0 12px 16px rgba(0,0,0,0.5));
}

/* Dim filter for unplayable cards in Operations */
.tutHand7Ops.tutDim3 {
  filter: grayscale(100%) brightness(0.55) contrast(1.05) drop-shadow(0 12px 16px rgba(0,0,0,0.5));
  opacity: 0.75;
}

@keyframes tutPlayAnimate3 {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--ghost-tx, 0px)), calc(-50% + var(--ghost-ty, 0px))) rotate(var(--ghost-rot, 0deg)) scale(1);
  }
  10% {
    opacity: 1;
    transform: translate(calc(-50% + var(--ghost-tx, 0px)), calc(-50% + var(--ghost-ty, 0px))) rotate(var(--ghost-rot, 0deg)) scale(1);
  }
  95% {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(-120px) scale(1.02) rotate(0deg);
  }
  100% {
    opacity: 0;
  }
}

.tutPlayGhost3.tutPlayAnimate3 {
  animation: tutPlayAnimate3 0.8s cubic-bezier(0.2,0.9,0.2,1) forwards;
}

/* Operations equation styling (positioned inside board, matches Slide 3 safe bounds) */
.tutorialOpEq {
  position: absolute;
  top: clamp(8px, 4%, 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  max-width: 92%;
  text-align: center;
  line-height: 1.1;
  font-size: clamp(18px, 3.6vw, 34px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  font-family: 'Arial', sans-serif;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.5px;
}

.tutorialOpEq .tutOpsOperator,
.tutorialOpEq .tutOpsEquals {
  color: rgba(255, 215, 0, 0.9);
  margin: 0 2px;
}

.tutorialOpEq .tutOpsA,
.tutorialOpEq .tutOpsB {
  color: rgba(255, 255, 255, 0.95);
  font-weight: 700;
}

.tutorialOpEq .tutOpsResult {
  color: rgba(57, 255, 20, 0.95);
  font-weight: 800;
}

.tutorialOpEq .tutOpsResult.tutOpsStrikeTens {
  color: rgba(200, 100, 100, 0.7);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 100, 100, 0.9);
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: none;
}

.tutorialOpEq .tutOpsResult.tutOpsHighlightOnes {
  background: rgba(57, 255, 20, 0.3);
  border-radius: 6px;
  padding: 0 4px;
  box-shadow: 0 0 16px rgba(57, 255, 20, 0.7), inset 0 0 8px rgba(57, 255, 20, 0.3);
  font-weight: 900;
  color: rgba(57, 255, 20, 1);
}

/* ====== Operation Equation Overlay (Gameplay) ====== */
/* TOP overlay - Play options (above icon) */
.opEqOverlayTop {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  font-family: 'Orbitron', sans-serif;
  background: transparent;
  border: none;
  padding: 8px 16px;
  z-index: 50;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  animation: opEqFadeIn 0.3s ease-out forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -8px;
}

/* BOTTOM overlay - Equation (below icon) */
.opEqOverlayBottom {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  font-family: 'Orbitron', sans-serif;
  background: transparent;
  border: none;
  padding: 8px 16px;
  z-index: 50;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  animation: opEqFadeInBottom 0.3s ease-out 0.1s forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: -8px;
}

@keyframes opEqFadeIn {
  from { opacity: 0; transform: translate(-50%, -100%) translateY(8px); }
  to { opacity: 1; transform: translate(-50%, -100%) translateY(0); }
}

@keyframes opEqFadeInBottom {
  from { opacity: 0; transform: translate(-50%, 100%) translateY(-8px); }
  to { opacity: 1; transform: translate(-50%, 100%) translateY(0); }
}

/* Cycling container for equation/playable */
.opEqCycleContainer {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50px;
}

.opEqCycleItem {
  position: absolute;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Equation shows for 2.3s, then fades out */
.opEqCycleEquation {
  font-size: 22px;
  font-weight: 700;
}

/* Playable hint shows for 2.3s after equation fades */
.opEqCyclePlayable {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

/* Reverse Direction Indicator Overlay */
.reverseIndicatorOverlay {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  font-family: 'Orbitron', sans-serif;
  background: transparent;
  border: none;
  padding: 8px 16px;
  z-index: 50;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  animation: reverseIndicatorFadeIn 0.4s ease-out forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: -8px;
}

@keyframes reverseIndicatorFadeIn {
  from { opacity: 0; transform: translate(-50%, 100%) translateY(-8px); }
  to { opacity: 1; transform: translate(-50%, 100%) translateY(0); }
}

.reverseIndicatorContent {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: #5eead4;
  text-shadow: 0 0 10px rgba(94, 234, 212, 0.6);
}

.reverseIndicatorArrow {
  font-size: 24px;
  animation: reverseArrowPulse 1.5s ease-in-out infinite;
}

@keyframes reverseArrowPulse {
  0%, 100% { 
    transform: scale(1); 
    text-shadow: 0 0 8px rgba(94, 234, 212, 0.6);
  }
  50% { 
    transform: scale(1.15); 
    text-shadow: 0 0 16px rgba(94, 234, 212, 0.9);
  }
}

/* Checkmark that appears next to result */
.opCheckmark {
  color: rgba(57, 255, 20, 1);
  font-size: 24px;
  font-weight: 900;
  margin-left: 8px;
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.8);
  opacity: 0;
}

/* Shape icon in playable line */
.opPlayableIcon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
}

.opEqLabel {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
  text-shadow: 0 0 10px rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 8px;
}

.opEqLabel .opLabelIcon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  vertical-align: middle;
  position: relative;
  top: 3%;
  margin: 0 4px;
}

.opEqLabel .opLabelHighlight {
  color: rgba(57, 255, 20, 1);
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.6);
  font-size: 28px;
  font-weight: 900;
  vertical-align: middle;
  margin-left: 4px;
}

.opEqEquation {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  gap: 10px;
}

.opEqEquation .opNum,
.opEqCycleEquation .opNum {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}

.opEqEquation .opSymbol,
.opEqCycleEquation .opSymbol {
  color: #fbbf24;
  font-size: 22px;
  font-weight: 700;
}

.opEqEquation .opEquals,
.opEqCycleEquation .opEquals {
  color: #64748b;
  font-size: 22px;
  font-weight: 700;
}

.opEqEquation .opPending,
.opEqCycleEquation .opPending {
  color: #64748b;
  font-size: 22px;
  animation: opPendingPulse 1s ease-in-out infinite;
}

@keyframes opPendingPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.opEqEquation .opResultTens,
.opEqCycleEquation .opResultTens,
.opEqCyclePlayable .opResultTens {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(239, 68, 68, 0.85);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 22px;
  font-weight: 700;
  margin-right: 4px;
}

.opEqEquation .opResultOnes,
.opEqCycleEquation .opResultOnes,
.opEqCyclePlayable .opResultOnes {
  color: rgba(57, 255, 20, 1);
  text-shadow: 0 0 16px rgba(57, 255, 20, 0.8), 0 0 32px rgba(57, 255, 20, 0.4);
  font-weight: 900;
  font-size: 28px;
}

/* Operation result box near logo - no longer used, keeping for cleanup */
.opResultOverlay {
  display: none;
}

.tutorialOpEq .tutOpsLabel {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.7em;
  font-weight: 500;
  margin-left: 6px;
  opacity: 0.85;
}

/* ====== Turn Action Message ====== */
.turnActionMessage {
  position: absolute;
  top: 97%;
  left: 49%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #a5f3fc;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(94, 234, 212, 0.4);
  border-radius: 8px;
  padding: 10px 20px;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  text-shadow: 0 0 8px rgba(94, 234, 212, 0.5);
}

.turnActionMessage.visible {
  opacity: 1;
}

/* Inline shape icons in turn messages */
.turnMsgIcon {
  width: 22px;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 3px;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.4));
}

/* ====== Tutorial Slide 6: Take Stack Animation ====== */
.tutTakeCounter {
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 1px;
}

@keyframes tutTakeWobble {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  50% { transform: translateX(0) rotate(1.5deg); }
}

.tutTakeStackStrip {
  max-width: 30%;
  flex-wrap: wrap;
}

.tutTakeDrawBurst {
  align-items: center;
}

/* Old in-gameStage rotate hint — replaced by body-level #bodyRotateHint */
.rotateHint { display: none !important; }

/* Landscape phone — reflow welcome/menu to use horizontal layout */
@media (max-height: 500px) and (orientation: landscape) {
  .welcomeOverlay {
    overflow-y: auto;
  }
  .welcomeMenu {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    align-items: center !important;
    justify-content: center !important;
    max-height: 100vh;
    overflow-y: auto;
  }
  .welcomeMenu h1, .welcomeMenu .gameTitle {
    width: 100%;
    font-size: clamp(14px, 4vw, 28px) !important;
    margin: 4px 0 !important;
  }
  .welcomeMenu button, .welcomeMenu .menuBtn {
    padding: 6px 14px !important;
    font-size: 11px !important;
  }
}

/* Landscape phone — typewriter intro fits without scrolling */
@media (max-height: 500px) and (orientation: landscape) {
  #typewriterOverlay, .typewriter-overlay {
    overflow-y: auto;
    padding: 8px 16px !important;
  }
  #typewriterText {
    font-size: clamp(10px, 2.5vw, 18px) !important;
    line-height: 1.4 !important;
  }
}

/* Game option modals — landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
  .choiceModal, .promptModal, .optionModal, [class*="Modal"], [class*="modal"] {
    max-height: 90vh !important;
    overflow-y: auto !important;
    padding: 8px 16px !important;
  }
  .choiceModal h2, .choiceModal .modalTitle {
    font-size: 14px !important;
    margin: 4px 0 !important;
  }
  .choiceModal button, .optionModal button {
    padding: 6px 12px !important;
    font-size: 11px !important;
  }
}

/* Mobile landscape — tighter HUD and topbar to give more game space */
[data-mobile-landscape="true"] .topbar {
  padding: 2px 8px !important;
  min-height: 28px !important;
}
[data-mobile-landscape="true"] .watermarkTitle {
  font-size: 9px !important;
}
[data-mobile-landscape="true"] .topRightControls button {
  font-size: 9px !important;
  padding: 2px 4px !important;
}

/* Safety: CSS always hides rotate hint in landscape even if JS lags */
@media (orientation: landscape) {
  #bodyRotateHint { display: none !important; }
}
/* Safety: always show in portrait on narrow phones */
@media (orientation: portrait) and (max-width: 639px) {
  #bodyRotateHint { display: flex !important; }
}

/* (topbar mobile readability handled via [data-mobile="true"] transform rules below) */

/* =====================================================================
   TUTORIAL — landscape phone: fill screen, text scrollable on right
   ===================================================================== */
@media (max-height: 520px) and (orientation: landscape) {
  /* Overlay fills full screen */
  #tutorialOverlay {
    display: flex !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
  }

  /* Card fills entire viewport — no zoom shrinking needed */
  .tutorialCard {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    padding: 10px 14px !important;
    zoom: 1 !important;
  }

  /* Side-by-side: animation left (fixed), text right (scrollable) */
  .tutorialBody {
    grid-template-columns: 1fr 1.2fr !important;
    gap: 12px !important;
    overflow: hidden !important;
    height: 100% !important;
  }

  /* Visual/animation panel — fixed, no scroll */
  .tutorialVisualPanel,
  .tutorialBody > *:first-child {
    overflow: hidden !important;
    min-height: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Text panel — scrollable */
  .tutorialTextPanel,
  .tutorialBody > *:last-child {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
    max-height: calc(100vh - 60px) !important;
    padding-right: 6px !important;
  }

  /* Larger text inside tutorial in landscape — easier to read */
  .tutorialTextPanel p,
  .tutorialTextPanel li,
  .tutorialTextPanel span {
    font-size: 13px !important;
    line-height: 1.6 !important;
  }

  .tutorialTextPanel h2,
  .tutorialTextPanel h3 {
    font-size: 15px !important;
  }

  /* Logo panel at top — compact */
  .tutorialPanelLogo {
    width: 40px !important;
    height: 40px !important;
  }
}

/* =====================================================================
   MOBILE TOPBAR — consistent sizing for COMPOUND V2 + New Game + ☰
   Only applies on [data-mobile="true"] (set by fitGameStage in index.html).
   transform: scale() is visual-only — no layout reflow, no overflow.
   ===================================================================== */

/* Scale the whole right block (COMPOUND V2 + New Game + ☰) together
   so all three stay proportional to each other */
[data-mobile="true"] .topRightHUD {
  transform: scale(1.5);
  transform-origin: top right;
}

/* COMPOUND V2: make it visible and same visual weight as New Game button
   (default is rgba(255,255,255,0.2) — nearly invisible watermark) */
[data-mobile="true"] .watermarkTitle {
  color: rgba(255,255,255,0.85) !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  letter-spacing: 0.1em !important;
}

/* ← BACK: match the right side scale */
[data-mobile="true"] .topbarSpacer button {
  transform: scale(1.5);
  transform-origin: top left;
  display: inline-block;
}

/* Menu dropdown: slightly larger than the bar, anchored top-right */
[data-mobile="true"] #topRightMenu {
  transform: scale(1.8);
  transform-origin: top right;
}
