@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&family=Lilita+One&display=swap');

/* ═══════════════════ Design tokens ═══════════════════ */
:root {
  --felt-1: #2e7d5a;
  --felt-2: #123726;
  --wood-1: #7a5230;
  --wood-2: #432a15;
  --gold: #e8c15a;
  --gold-soft: rgba(232, 193, 90, 0.28);
  --face: #fdfaf2;
  --c-blue: #2f6fd0;
  --c-green: #2f9e63;
  --c-red: #d5453f;
  --wild-1: #232c52;
  --wild-2: #151a33;
  --panel: rgba(8, 18, 13, 0.62);
  --card-shadow: 0 2px 0 rgba(0,0,0,0.18), 0 6px 12px rgba(0,0,0,0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Montserrat', sans-serif; }

body {
  background-color: #141414;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════ Table rim + felt ═══════════════════ */
/* The rim is a wrapper so the 1100x750 canvas (and every coordinate
   inside it) stays exactly the same. main.js scales the rim to fit
   (or fill) the viewport. */
.table-rim {
  position: fixed;
  left: 50%;
  top: 50%;
  padding: 14px;
  border-radius: 24px;
  background: linear-gradient(160deg, var(--wood-1), var(--wood-2) 55%, #5c3d20);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 2px 3px rgba(255,255,255,0.15);
  flex-shrink: 0;
  transform-origin: center center;
}

.canvas {
  width: 1100px;
  height: 750px;
  overflow: hidden; /* CSS-positioned piles must never poke past the felt */
  background: radial-gradient(ellipse at 50% 42%, var(--felt-1) 0%, #1d543c 55%, var(--felt-2) 100%);
  position: relative;
  border-radius: 12px;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55);
}

/* subtle felt texture */
.canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

/* ═══════════════════ Mode select overlay ═══════════════════ */
.mode-select {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #5a9fd8 0%, #7db8e8 40%, #a8d4ef 75%, #c2e2f5 100%);
  display: flex;
  overflow-y: auto;
  /* Above every board element (cards in flight use 998-999, score popups
     1000) so nothing from a running game ever shows through the menu. */
  z-index: 3000;
  border-radius: 12px;
  scrollbar-width: none;             /* Firefox */
}
.mode-select::-webkit-scrollbar { display: none; }  /* Chrome/Safari */

/* margin:auto centers the menu when it fits and top-aligns the scroll
   when the canvas is shorter than the content (e.g. the 580px-high 4p
   phone canvas) - plain justify-content:center would clip the top. */
.mode-inner {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 25px 10px;
  position: relative;
  z-index: 2;
  /* keep the buttons clear of the animals at the bottom of the scene
     (the strip's upper part is transparent sky, overlap there is fine) */
  padding-bottom: 120px;
}

.mode-select h1 {
  font-family: 'Lilita One', cursive;
  color: var(--gold);
  font-size: 48px;
  letter-spacing: 2px;
  margin-bottom: 15px;
  text-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
.mode-select h2 {
  color: #1d3a2c;
  font-size: 20px;
  margin-bottom: 18px;
  font-weight: 600;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

/* News banners under the title - remove from index.html when old news */
.menu-news {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: -4px auto 16px;
  max-width: 500px;
}
.menu-news-item {
  background: linear-gradient(180deg, #fff8e0, #ffe6a8);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #143526;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.menu-news-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #143526;
  color: #ffe9b0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 13px;
  font-weight: 800;
  font-style: italic;
  line-height: 1;
  margin-right: 8px;
  vertical-align: -3px;
  flex: none;
}
.mode-buttons { display: flex; flex-direction: column; gap: 12px; }

/* Mode buttons: gold-bordered glass panels, matching the side panels */
.mode-btn {
  padding: 15px 40px;
  font-size: 16px;
  font-weight: 700;
  border: 1.5px solid rgba(232, 193, 90, 0.5);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 200ms, box-shadow 200ms, background 200ms, border-color 200ms;
  min-width: 320px;
  background: var(--panel);
  color: var(--gold);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.mode-btn:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  background: rgba(232, 193, 90, 0.16);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.45), 0 0 18px rgba(232, 193, 90, 0.25);
}
.mode-btn small { display: block; font-size: 11px; font-weight: 400; margin-top: 4px; color: rgba(255,255,255,0.75); }

.mode-btn.resume-btn {
  background: var(--gold);
  color: #231a05;
  border-color: var(--gold);
}
.mode-btn.resume-btn small { color: rgba(35, 26, 5, 0.75); }
.mode-btn.resume-btn:hover { background: #f2d27a; }

.length-buttons { display: flex; gap: 15px; justify-content: center; }
.length-btn {
  padding: 12px 25px;
  font-size: 14px;
  font-weight: 700;
  border: 1.5px solid rgba(232, 193, 90, 0.35);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 200ms, box-shadow 200ms, border-color 200ms;
  background: var(--panel);
  color: #fff;
}
.length-btn:hover { transform: translateY(-2px); border-color: var(--gold); }
.length-btn.selected { border-color: var(--gold); background: rgba(232,193,90,0.2); box-shadow: 0 0 15px rgba(232,193,90,0.3); }
.length-btn small { display: block; font-size: 10px; font-weight: 400; margin-top: 3px; opacity: 0.8; }

/* ═══════════════════ Cards ═══════════════════ */
/* New card faces: cream background with a colored frame and numeral.
   The value colors (blue 1-4, green 5-8, red 9-12) come from --cc,
   set by the color-* classes below. */
.card {
  width: 58px;
  height: 82px;
  border-radius: 9px;
  background: var(--face);
  box-shadow: var(--card-shadow);
  transition: transform 200ms, box-shadow 200ms;
  position: absolute;
  user-select: none;
  touch-action: none;
}

.card-content { position: relative; width: 100%; height: 100%; }

/* colored inner frame */
.card-content::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2.5px solid var(--cc, transparent);
  border-radius: 6px;
  pointer-events: none;
}

.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -52%);
  color: var(--cc, #333);
  font-family: 'Lilita One', cursive;
  font-weight: 400;
  font-size: 27px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.card-corner {
  position: absolute;
  color: var(--cc, #333);
  font-family: 'Lilita One', cursive;
  font-weight: 400;
  font-size: 11px;
}

.card-corner-tl { top: 5px; left: 7px; }
.card-corner-br { bottom: 5px; right: 7px; transform: rotate(180deg); }

/* value colors */
.color-blue   { --cc: var(--c-blue); }
.color-green  { --cc: var(--c-green); }
.color-red    { --cc: var(--c-red); }

/* Wild (Skip-Bo): dark navy + gold, soft glow */
.color-skipbo {
  --cc: var(--gold);
  background: linear-gradient(160deg, var(--wild-1), var(--wild-2));
}
.color-skipbo .card-content::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 42px; height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,193,90,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.color-skipbo .card-content::before { box-shadow: inset 0 0 10px rgba(232,193,90,0.25); }
.color-skipbo .card-center {
  font-size: 21px;
  text-shadow: 0 0 10px rgba(232,193,90,0.55);
}

/* Empty slots: faint labels tell new players what goes where */
.color-empty {
  background: rgba(0, 0, 0, 0.14);
  border: 2px dashed rgba(255, 255, 255, 0.28);
  box-shadow: none;
}
.card.color-empty::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.32);
  content: '';
}
.card.color-empty[data-pile-type="build"]::after {
  content: '1–12';
  color: rgba(232, 193, 90, 0.45);
}
.card.color-empty[data-pile-type="build"] { border-color: var(--gold-soft); }
.card.color-empty[data-pile-type$="pass"]::after { content: 'PASS'; }

/* Card back: red lattice with gold medallion */
.card-back {
  background: repeating-linear-gradient(45deg, #8f1d1d 0 6px, #7a1616 6px 12px);
}
.card-back::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(232, 193, 90, 0.75);
  border-radius: 6px;
}
.card-back::after {
  content: 'S·B';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lilita One', cursive;
  color: var(--gold);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: 0 0 8px rgba(232, 193, 90, 0.3);
}

/* Small cards (side players in 4p) */
.card-small { width: 42px; height: 60px; border-radius: 7px; }
.card-small .card-content::before { inset: 3px; border-width: 2px; border-radius: 5px; }
.card-small .card-center { font-size: 17px; }
.card-small.color-skipbo .card-center { font-size: 13px; }
.card-small.color-skipbo .card-content::after { width: 30px; height: 30px; }
.card-small .card-corner { font-size: 8px; }
.card-small .card-corner-tl { top: 3px; left: 5px; }
.card-small .card-corner-br { bottom: 3px; right: 5px; }
.card-small.card-back::before { inset: 3px; }
.card-small.card-back::after { width: 26px; height: 26px; font-size: 9px; }
.card-small.color-empty::after { font-size: 7px; letter-spacing: 1px; }

/* Large cards (interactive rows in the 4p phone landscape layout) */
.card-lg { width: 74px; height: 105px; border-radius: 11px; }
.card-lg .card-content::before { inset: 5px; border-width: 3px; border-radius: 8px; }
.card-lg .card-center { font-size: 34px; }
.card-lg.color-skipbo .card-center { font-size: 27px; }
.card-lg.color-skipbo .card-content::after { width: 54px; height: 54px; }
.card-lg .card-corner { font-size: 14px; }
.card-lg .card-corner-tl { top: 6px; left: 9px; }
.card-lg .card-corner-br { bottom: 6px; right: 9px; }
.card-lg.card-back::before { inset: 5px; }

/* 4P phone: build piles + draw pile match the large player cards */
.canvas.large-builds .build-pile-0, .canvas.large-builds .build-pile-1,
.canvas.large-builds .build-pile-2, .canvas.large-builds .build-pile-3,
.canvas.large-builds #draw-pile-visual {
  width: 74px; height: 105px; border-radius: 11px;
}
.canvas.large-builds [class*="build-pile-"] .card-content::before { inset: 5px; border-width: 3px; border-radius: 8px; }
.canvas.large-builds [class*="build-pile-"] .card-center { font-size: 34px; }
.canvas.large-builds [class*="build-pile-"].color-skipbo .card-center { font-size: 27px; }
.canvas.large-builds [class*="build-pile-"].color-skipbo .card-content::after { width: 54px; height: 54px; }
.canvas.large-builds [class*="build-pile-"] .card-corner { font-size: 14px; }
.canvas.large-builds [class*="build-pile-"] .card-corner-tl { top: 6px; left: 9px; }
.canvas.large-builds [class*="build-pile-"] .card-corner-br { bottom: 6px; right: 9px; }
.card-lg.card-back::after { width: 44px; height: 44px; font-size: 15px; }
.card-lg.color-empty::after { font-size: 11px; letter-spacing: 2px; }

/* Stacked-pile depth (pass piles with 2+ cards) */
.card.stacked {
  box-shadow: 2px 2px 0 #cfc8b8, 4px 4px 0 #b0a998, var(--card-shadow);
}
.card.stacked.color-skipbo {
  box-shadow: 2px 2px 0 #1a2140, 4px 4px 0 #10142a, var(--card-shadow);
}

/* Any card mid-animation: always above badges, plates and panels. */
.card.in-flight { z-index: 1500 !important; }

/* ═══════════════════ Drag & drop feedback ═══════════════════ */
.card.draggable:hover {
  cursor: grab;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45);
  transform: translateY(-4px);
}

.card.dragging {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5) !important;
  cursor: grabbing !important;
  z-index: 999;
  transition: none;
}

/* Tap-to-play: the selected card lifts and glows gold */
.card.tap-selected {
  transform: translateY(-8px);
  box-shadow: 0 0 0 3px var(--gold), 0 10px 20px rgba(0, 0, 0, 0.5) !important;
  z-index: 20;
}

/* Piles the picked-up card can legally be dropped on */
.droppable.valid-target {
  box-shadow: 0 0 0 3px rgba(232, 193, 90, 0.85), 0 0 14px rgba(232, 193, 90, 0.5);
}
.color-empty.valid-target {
  border-style: solid;
  border-color: var(--gold);
}

/* Pile currently hovered while dragging */
.card.drop-hover {
  box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(232, 193, 90, 0.8);
}

/* ═══════════════════ Center playing field ═══════════════════ */
.field {
  position: absolute;
  left: 282px;
  top: 328px;
  width: 442px;
  height: 150px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--gold-soft);
  box-shadow: inset 0 4px 18px rgba(0, 0, 0, 0.4), inset 0 0 0 4px rgba(0, 0, 0, 0.12);
}

.field-label {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #16311f;
  padding: 3px 16px;
  border-radius: 10px;
  border: 1px solid var(--gold-soft);
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.pile-caption {
  position: absolute;
  width: 58px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* Build pile positions (unchanged) */
.build-pile-0 { top: 365px; left: 420px; }
.build-pile-1 { top: 365px; left: 495px; }
.build-pile-2 { top: 365px; left: 570px; }
.build-pile-3 { top: 365px; left: 645px; }

/* Draw pile: styled like a stacked card back with a count badge */
.draw-pile {
  width: 58px;
  height: 82px;
  border-radius: 9px;
  position: absolute;
  top: 365px;
  left: 300px;
  background: repeating-linear-gradient(45deg, #8f1d1d 0 6px, #7a1616 6px 12px);
  box-shadow: 2px 2px 0 #5e1010, 4px 4px 0 #4a0c0c, var(--card-shadow);
}
.draw-pile::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(232, 193, 90, 0.75);
  border-radius: 6px;
}
.draw-medallion {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lilita One', cursive;
  color: var(--gold);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: 0 0 8px rgba(232, 193, 90, 0.3);
}

/* Count badge: used on the draw pile and (via .pass-pile-count) pass piles */
.count-badge, .pass-pile-count {
  position: absolute;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--gold);
  color: #231a05;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  z-index: 5;
}
.count-badge { top: -8px; right: -8px; }

/* ═══════════════════ Player zones ═══════════════════ */
.player-area {
  position: absolute;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 14px;
  transition: box-shadow 300ms, background 300ms;
}

.player-area.active-area {
  box-shadow: 0 0 22px rgba(232, 193, 90, 0.35), inset 0 0 26px rgba(232, 193, 90, 0.07);
  background: rgba(232, 193, 90, 0.045);
}

.player-tab {
  position: absolute;
  top: -12px;
  left: 95px; /* clear of the stock card + its corner badge */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #16311f;
  border: 1px solid currentColor;
  border-radius: 12px;
  padding: 2px 10px 2px 3px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  z-index: 5;
}

/* Horizontal players: name tab + score chip grouped and centered */
.player-plate {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
}
.player-plate.plate-flip { top: auto; bottom: -12px; }
.player-plate .player-tab,
.player-plate .player-score {
  position: static;
}

/* Narrow side players: tab centered on the top edge */
.player-tab.tab-center {
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  padding: 2px 8px 2px 3px;
}

.avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1.5px solid currentColor;
  flex-shrink: 0;
}

.player-score {
  position: absolute;
  top: -12px;
  right: 14px;
  display: inline-flex;
  align-items: baseline;
  padding: 2px 10px;
  background: var(--gold);
  color: #231a05;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  min-width: 35px;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  z-index: 5;
}

.player-score::after {
  content: ' pt';
  font-size: 9px;
  font-weight: 600;
  opacity: 0.8;
  margin-left: 2px;
}

/* Narrow side players: score chip centered on the bottom edge */
.player-score.chip-bottom {
  top: auto;
  bottom: -12px;
  right: 50%;
  transform: translateX(50%);
}

/* Stock count badge sits on the stock card's corner.
   IMPORTANT: .count-badge sets top/right for the draw pile; reset them
   here so only the inline (per-player) position applies - otherwise the
   badge gets both left AND right and stretches across the canvas. */
.stock-count-badge { position: absolute; top: auto; right: auto; }

/* Top players: nameplate + score on the BOTTOM edge of their area, so
   every nameplate faces the table center. */
.player-tab.tab-flip { top: auto; bottom: -12px; }
.player-score.chip-flip { top: auto; bottom: -12px; }

/* Stock pile: gold-trimmed so it reads as "the" pile to empty */
.card.stock-pile-card:not(.color-empty) {
  box-shadow: 0 0 0 2px rgba(232, 193, 90, 0.55), var(--card-shadow);
}
.card.stock-pile-card.color-empty {
  border-color: var(--gold-soft);
}
.card.stock-pile-card.color-empty::after {
  content: 'STOCK';
  color: rgba(232, 193, 90, 0.45);
}

.team-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
}

.team-a { background: rgba(232, 193, 90, 0.3); color: var(--gold); }
.team-b { background: rgba(100, 200, 255, 0.3); color: #64c8ff; }


/* ═══════════════════ Side panels ═══════════════════ */
.info-panel, .controls, .score-panel {
  position: absolute;
  top: 8px;
  color: #fff;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--gold-soft);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  z-index: 100;
}

/* Turn indicator pill: top-left, one line */
.info-panel {
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
}

/* Menu button pill: top-right */
.controls {
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
}

/* Team totals: centered on the top edge (team mode only) */
.score-panel {
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
}
.score-panel #score-display {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  white-space: nowrap;
}

/* Team score chips: color-coded, big numbers, leader glows. Compact
   enough that the panel never overlaps the top player's area. */
.team-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 1px 10px;
  border-radius: 20px;
  font-weight: 700;
  border: 1px solid transparent;
  opacity: 0.85;
}
.team-chip b {
  font-size: 16px;
  font-family: 'Lilita One', cursive;
  letter-spacing: 0.5px;
}
.mode-label {
  color: #cbb;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.team-chip-a { color: var(--gold); background: rgba(232, 193, 90, 0.14); }
.team-chip-b { color: #64c8ff; background: rgba(100, 200, 255, 0.14); }
.team-chip.leading { opacity: 1; }
.team-chip-a.leading { border-color: rgba(232, 193, 90, 0.6); box-shadow: 0 0 10px rgba(232, 193, 90, 0.35); }
.team-chip-b.leading { border-color: rgba(100, 200, 255, 0.6); box-shadow: 0 0 10px rgba(100, 200, 255, 0.35); }

.ptitle {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
}

.turnbig {
  font-family: 'Lilita One', cursive;
  font-size: 17px;
  color: #fff;
  line-height: 1.15;
}

.pdivider { border-top: 1px solid rgba(232, 193, 90, 0.18); margin: 8px 0; }

.prow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  margin: 3px 0;
}
.prow b { color: var(--gold); font-weight: 700; }

.status-text {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
  margin: 4px 0 0;
}

.info-item { margin: 3px 0; font-size: 11px; }
.info-label { font-weight: 600; color: var(--gold); }
.info-value { font-weight: 500; color: #fff; }

.controls button {
  width: auto;
  padding: 8px 14px;
  margin: 0;
  white-space: nowrap;
  background: rgba(232, 193, 90, 0.12);
  color: var(--gold);
  border: 1.5px solid rgba(232, 193, 90, 0.5);
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 200ms, background 200ms;
  font-size: 11px;
  display: block;
}

.controls button:hover { transform: translateY(-1px); background: rgba(232, 193, 90, 0.28); }
.controls button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* primary actions in solid gold */
#start-btn, #auto-play-btn {
  background: var(--gold);
  color: #231a05;
  border-color: var(--gold);
}
#start-btn:hover, #auto-play-btn:hover { background: #f2d27a; }

/* ═══════════════════ Score popups ═══════════════════ */
/* Flying "+N" that arcs from the build pile to the player's score badge */
.score-fly {
  position: absolute;
  font-weight: 900;
  text-shadow: -1.5px -1.5px 0 #1a1208, 1.5px -1.5px 0 #1a1208,
    -1.5px 1.5px 0 #1a1208, 1.5px 1.5px 0 #1a1208,
    0 0 8px currentColor, 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

@keyframes score-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}
/* Side-player chips are centered via translateX(50%); the pulse must
   keep that translate or the chip jumps left for the animation. */
@keyframes score-pulse-centered {
  0%   { transform: translateX(50%) scale(1); }
  40%  { transform: translateX(50%) scale(1.3); }
  100% { transform: translateX(50%) scale(1); }
}
.player-score.score-pulse { animation: score-pulse 300ms ease-out; }
.player-score.chip-bottom.score-pulse { animation: score-pulse-centered 300ms ease-out; }


.score-popup {
  position: absolute;
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
  text-shadow: -1.5px -1.5px 0 #1a1208, 1.5px -1.5px 0 #1a1208,
    -1.5px 1.5px 0 #1a1208, 1.5px 1.5px 0 #1a1208,
    0 2px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 1000;
  transition: opacity 300ms, transform 300ms;
  transform: translateX(-50%);
}

.score-popup.bonus {
  font-size: 22px;
  text-shadow: -1.5px -1.5px 0 #1a1208, 1.5px -1.5px 0 #1a1208,
    -1.5px 1.5px 0 #1a1208, 1.5px 1.5px 0 #1a1208,
    0 0 10px currentColor, 0 2px 4px rgba(0,0,0,0.8);
}

.score-popup.win-bonus {
  font-size: 32px;
  text-shadow: -2px -2px 0 #1a1208, 2px -2px 0 #1a1208,
    -2px 2px 0 #1a1208, 2px 2px 0 #1a1208,
    0 0 20px currentColor, 0 0 40px currentColor, 0 4px 8px rgba(0,0,0,0.8);
}

.score-popup.penalty {
  font-size: 20px;
  color: #ff4444 !important;
  text-shadow: 0 0 10px #ff0000, 0 2px 4px rgba(0,0,0,0.8);
}

/* ═══════════════════ Deck reshuffle toast ═══════════════════ */
.deck-toast {
  position: absolute;
  transform: translateX(-50%) translateY(6px);
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--gold);
  background: var(--panel);
  border: 1px solid var(--gold-soft);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 0;
  z-index: 1001;
  transition: opacity 300ms ease, transform 300ms ease;
}

.deck-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════ Winner overlay ═══════════════════ */
.winner-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 12px;
}

.winner-message {
  text-align: center;
  color: var(--gold);
  font-family: 'Lilita One', cursive;
  font-size: 34px;
  letter-spacing: 1px;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.winner-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
  margin-top: 20px;
}

.winner-message #new-game-btn {
  display: block;
  padding: 12px 35px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  background: var(--gold);
  color: #231a05;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 200ms;
}

.winner-message #new-game-btn:hover { transform: translateY(-2px); }

.winner-message #winner-menu-btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(232,193,90,0.1);
  color: var(--gold);
  cursor: pointer;
  transition: all 200ms;
}
.winner-message #winner-menu-btn:hover { background: rgba(232,193,90,0.3); }

.score-table {
  margin-top: 20px;
  background: rgba(255,255,255,0.1);
  padding: 15px 25px;
  border-radius: 10px;
  font-family: 'Montserrat', sans-serif;
}

.score-table h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  color: #fff;
}

.score-table h4 {
  margin: 15px 0 8px 0;
  font-size: 14px;
  color: #ccc;
  font-weight: 600;
}

.score-table table {
  width: 100%;
  border-collapse: collapse;
}

.score-table td {
  padding: 6px 15px;
  font-size: 14px;
  color: #fff;
  font-weight: 500;
}

.score-table td:last-child {
  text-align: right;
  font-weight: 700;
}

.score-table .winner-row td {
  color: var(--gold);
  background: rgba(232,193,90,0.15);
}

/* ═══════════════════ Menu buttons (Leaderboard + Rules) ═══════════════════ */
.menu-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

/* ═══════════════════ Leaderboard ═══════════════════ */
.leaderboard-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  overflow-y: auto;
  z-index: 2000;
}
.leaderboard-overlay .leaderboard-content { margin: auto; }

.leaderboard-content {
  background: linear-gradient(170deg, #17402d 0%, #0e2b1e 100%);
  border: 2px solid var(--gold);
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  width: min(92vw, 700px);
}

/* Narrow phones: tighter table + padding so 6 columns still fit */
@media (max-width: 520px) {
  .leaderboard-content { padding: 16px 10px; }
  /* Top-anchored on phones: the on-screen keyboard shrinking the viewport
     then never moves the popup (movement mid-tap broke the input focus). */
  .name-input-overlay .name-input-content { margin: 3vh auto auto; padding: 16px 14px; width: min(92vw, 420px); }
  .name-input-content h2 { font-size: 24px; }
  .leaderboard-table th,
  .leaderboard-table td { padding: 7px 3px; font-size: 12px; }
  .rules-content { padding: 18px 16px; }
}

.leaderboard-content h2 {
  text-align: center;
  color: var(--gold);
  font-family: 'Lilita One', cursive;
  letter-spacing: 1px;
  margin: 0 0 10px 0;
  font-size: 26px;
}

.leaderboard-info {
  text-align: center;
  color: #aaa;
  margin-bottom: 15px;
  font-size: 14px;
}

.leaderboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-bottom: 15px;
}

.lb-tab {
  padding: 5px 9px;
  font-size: 11px;
  border: 1px solid #444;
  border-radius: 5px;
  background: rgba(255,255,255,0.05);
  color: #aaa;
  cursor: pointer;
  transition: all 200ms;
}

.lb-tab:hover {
  border-color: var(--gold);
  color: #fff;
}

.lb-tab.active {
  background: rgba(232,193,90,0.2);
  border-color: var(--gold);
  color: var(--gold);
}

.leaderboard-table {
  margin-bottom: 20px;
}

/* Forced landscape: only the winner overlay renders rotated (see the
   forced-landscape block further down) - name-input and leaderboard
   stay portrait, so they use the regular phone styles above/below. */
body.forced-landscape .winner-message { font-size: 24px; }

/* Short viewports (landscape phones): dedicated landscape layout so the
   popups don't render as a clipped portrait column. */
@media (max-height: 600px) {
  .leaderboard-content {
    width: min(94vw, 700px);
    padding: 8px 14px;
  }
  .leaderboard-content h2 { font-size: 18px; margin-bottom: 4px; }
  .leaderboard-info { margin-bottom: 6px; font-size: 12px; }
  .leaderboard-tabs { margin-bottom: 8px; }
  .leaderboard-table th,
  .leaderboard-table td { padding: 4px 4px; font-size: 12px; }
  .winner-message { font-size: 24px; }

  /* Name popup: score table on the left, input + buttons on the right */
  .name-input-content {
    margin: 2vh auto auto;
    width: min(94vw, 640px);
    padding: 10px 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto auto;
    column-gap: 24px;
    align-items: center;
    text-align: center;
  }
  .name-input-content h2 { grid-column: 1 / -1; font-size: 20px; margin: 0 0 6px; }
  .name-input-content .score-table { grid-column: 1; grid-row: 2 / span 3; margin: 0; align-self: start; }
  .name-input-content .score-table table { font-size: 12px; }
  .name-input-form { grid-column: 2; margin-bottom: 6px; }
  .name-input-content #save-score-btn { grid-column: 2; margin-bottom: 6px; }
  .name-input-content #skip-save-btn { grid-column: 2; }
}

.leaderboard-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid rgba(232, 193, 90, 0.18);
  color: #fff;
}

.leaderboard-table th {
  color: var(--gold);
  font-weight: 600;
  font-size: 12px;
}

.leaderboard-table tr.lb-new td {
  background: rgba(232, 193, 90, 0.18);
  border-top: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
}
.leaderboard-table .lb-gold td { color: var(--gold); font-weight: 700; }
.leaderboard-table .lb-silver td { color: #c0c0c0; font-weight: 600; }
.leaderboard-table .lb-bronze td { color: #cd7f32; font-weight: 600; }

/* Compact single-row filters: Kaarten left, Modus right */
.lb-filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.lb-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lb-filter-label {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 600;
  margin-right: 3px;
}

.lb-count {
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
  margin-top: 8px;
}

/* Pagination (20 entries per page) */
.lb-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
}
.lb-page-btn {
  min-width: 40px;
  padding: 5px 12px;
  font-size: 14px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(232, 193, 90, 0.15);
  color: var(--gold);
  cursor: pointer;
}
.lb-page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.lb-page-info {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  min-width: 110px;
  text-align: center;
}

.lb-empty {
  text-align: center;
  color: #666;
  padding: 30px;
  font-style: italic;
}

.lb-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #888;
  gap: 15px;
}

.lb-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(232, 193, 90, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: lb-spin 1s linear infinite;
}

@keyframes lb-spin {
  to { transform: rotate(360deg); }
}

.lb-close-btn {
  display: block;
  margin: 0 auto;
  padding: 10px 30px;
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(232,193,90,0.2);
  color: var(--gold);
  cursor: pointer;
  transition: all 200ms;
}

.lb-close-btn:hover {
  background: rgba(232,193,90,0.4);
}

#winner-lb-btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(232,193,90,0.1);
  color: var(--gold);
  cursor: pointer;
  transition: all 200ms;
}

#winner-lb-btn:hover {
  background: rgba(232,193,90,0.3);
}

.lb-btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(232,193,90,0.1);
  color: var(--gold);
  cursor: pointer;
  transition: all 200ms;
}

.lb-btn:hover {
  background: rgba(232,193,90,0.3);
}

/* ═══════════════════ Name input overlay ═══════════════════ */
.name-input-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  /* margin:auto on the content centers it when it fits and lets the
     overlay scroll when it doesn't - flex centering would clip both ends.
     Top-anchored content also stops the keyboard-open reflow from moving
     the input mid-tap (which blurred it and forced a second tap). */
  overflow-y: auto;
  z-index: 2000;
}
.name-input-overlay .name-input-content { margin: auto; }

.name-input-content {
  background: linear-gradient(170deg, #17402d 0%, #0e2b1e 100%);
  border: 2px solid var(--gold);
  border-radius: 15px;
  padding: 25px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.name-input-content h2 { margin-bottom: 5px; }
.score-table .stat-header td { color: #aaa; font-size: 12px; padding-bottom: 2px; }
.stat-legend { color: #888; font-size: 11px; margin-top: 6px; text-align: center; }
.name-input-content .score-table { margin: 10px 0 15px; }

.name-input-content h2 {
  color: var(--gold);
  font-family: 'Lilita One', cursive;
  letter-spacing: 1px;
  margin: 0 0 15px 0;
  font-size: 30px;
}

.final-score {
  font-size: 20px;
  color: #fff;
  margin-bottom: 20px;
}

.final-score span {
  color: var(--gold);
  font-weight: 700;
  font-size: 24px;
}

.final-score.team-score {
  font-size: 16px;
  color: #aaa;
  margin-top: -10px;
  margin-bottom: 15px;
}

.final-score.team-score span {
  color: #64c8ff;
  font-size: 18px;
}

.name-input-form {
  margin-bottom: 20px;
}

.name-input-form label {
  display: block;
  color: #aaa;
  margin-bottom: 8px;
  font-size: 14px;
}

.name-input-form input {
  width: 200px;
  padding: 10px 15px;
  font-size: 16px;
  border: 1.5px solid rgba(232, 193, 90, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  text-align: center;
}

.name-input-form input:focus {
  outline: none;
  border-color: var(--gold);
}

#save-score-btn {
  display: block;
  width: 100%;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(232,193,90,0.2);
  color: var(--gold);
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 200ms;
}

#save-score-btn:hover {
  background: rgba(232,193,90,0.4);
}

#skip-save-btn {
  display: block;
  width: 100%;
  padding: 8px 15px;
  font-size: 12px;
  border: 1px solid #666;
  border-radius: 6px;
  background: transparent;
  color: #888;
  cursor: pointer;
  transition: all 200ms;
}

#skip-save-btn:hover {
  border-color: #aaa;
  color: #aaa;
}

.lb-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 15px;
}

.lb-clear-btn {
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid #ff4444;
  border-radius: 8px;
  background: rgba(255,68,68,0.1);
  color: #ff4444;
  cursor: pointer;
  transition: all 200ms;
}

.lb-clear-btn:hover {
  background: rgba(255,68,68,0.3);
}

/* ═══════════════════ Rules overlay ═══════════════════ */
.rules-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  overflow-y: auto;
  z-index: 2000;
}
.rules-overlay .rules-content { margin: auto; }

.rules-content {
  background: linear-gradient(170deg, #17402d 0%, #0e2b1e 100%);
  border: 2px solid var(--gold);
  border-radius: 15px;
  padding: 25px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  width: 90%;
  max-width: 550px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}

.rules-content h2 {
  text-align: center;
  color: var(--gold);
  font-family: 'Lilita One', cursive;
  letter-spacing: 1px;
  margin: 0 0 20px 0;
  font-size: 26px;
}

.rules-content h3 {
  color: var(--gold);
  margin-top: 18px;
  margin-bottom: 8px;
  font-size: 15px;
}

.rules-content h3:first-of-type {
  margin-top: 0;
}

.rules-content p {
  margin: 6px 0;
  line-height: 1.5;
  color: #ddd;
  font-size: 13px;
}

.rules-content ol,
.rules-content ul {
  padding-left: 20px;
  margin: 6px 0;
}

.rules-content li {
  margin: 5px 0;
  line-height: 1.4;
  color: #ddd;
  font-size: 13px;
}

.rules-content strong {
  color: #fff;
}

.rules-close-btn {
  display: block;
  margin: 20px auto 0;
  padding: 10px 30px;
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(232,193,90,0.2);
  color: var(--gold);
  cursor: pointer;
  transition: all 200ms;
}

.rules-close-btn:hover {
  background: rgba(232,193,90,0.4);
}

/* Custom scrollbar for overlay content */
.rules-content::-webkit-scrollbar,
.leaderboard-content::-webkit-scrollbar {
  width: 8px;
}

.rules-content::-webkit-scrollbar-track,
.leaderboard-content::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.rules-content::-webkit-scrollbar-thumb,
.leaderboard-content::-webkit-scrollbar-thumb {
  background: rgba(232,193,90,0.4);
  border-radius: 4px;
}

.rules-content::-webkit-scrollbar-thumb:hover,
.leaderboard-content::-webkit-scrollbar-thumb:hover {
  background: rgba(232,193,90,0.6);
}

/* ═══════════ Forced landscape (portrait viewport, rotation lock) ═══════════
   Landscape-only modes (4P) on a portrait viewport are rendered rotated
   90deg by main.js (fitCanvas), replacing the old "rotate your phone"
   overlay - which permanently blocked play for phones with rotation
   lock enabled. body.needs-landscape now only marks WHICH modes are
   landscape-only; fitCanvas turns that into body.forced-landscape.
   The winner overlay lives on document.body (outside the rotated rim)
   and must be rotated to match - it appears the moment the game ends,
   while the user is still holding the phone sideways. A rotated
   full-screen fixed element needs swapped dimensions plus a recentering
   offset to still cover the viewport.
   The name-input and leaderboard popups deliberately stay UN-rotated
   (portrait): the on-screen keyboard always follows the system
   orientation (portrait when rotation lock is on), so an upright popup
   is the only way the keyboard and the input line up - the user simply
   turns the phone back to type. */
body.forced-landscape .winner-overlay {
  transform: rotate(90deg);
  transform-origin: center center;
  width: 100vh;
  height: 100vw;
  left: calc(50vw - 50vh);
  top: calc(50vh - 50vw);
  right: auto;
  bottom: auto;
}

/* ── Mobile (portrait) board tweaks ── */
.canvas.mobile .pile-caption { display: none; }

/* Bigger nameplates + score chips on phones - easier on the eyes */
.canvas.mobile .player-tab { font-size: 14px; }
.canvas.mobile .player-score { font-size: 15px; padding: 3px 12px; }
.canvas.mobile .score-panel #score-display { font-size: 14px; }
.canvas.mobile .team-chip b { font-size: 17px; }

/* ═══════════════════ Checkbox ═══════════════════ */
.checkbox-row {
  margin-top: 25px;
  display: flex;
  justify-content: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #ccc;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid #666;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  position: relative;
  transition: all 200ms;
}

.checkbox-label:hover .checkbox-custom {
  border-color: var(--gold);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: rgba(232,193,90,0.3);
  border-color: var(--gold);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '\2713';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--gold);
  font-size: 14px;
  font-weight: bold;
}

/* ═══════════════════ Menu sky decor + pixel scene ═══════════════════ */
/* Sun and soft clouds behind the menu content (inside .mode-select) */
.menu-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 12px;
}
.menu-sun {
  position: absolute;
  top: 30px; right: 60px;
  width: 64px; height: 64px;
  background: #ffd968;
  border-radius: 50%;
  box-shadow: 0 0 36px 16px rgba(255, 220, 110, 0.55);
}
.menu-sun::after {
  content: '';
  position: absolute; inset: 7px;
  background: #ffe89a;
  border-radius: 50%;
}
.menu-cloud {
  position: absolute;
  width: 150px; height: 44px;
  opacity: 0.9;
  background:
    radial-gradient(circle at 30% 65%, #fff 26px, transparent 27px),
    radial-gradient(circle at 55% 45%, #fff 30px, transparent 31px),
    radial-gradient(circle at 78% 65%, #fff 24px, transparent 25px);
  animation: menu-cloud-drift linear infinite;
}
@keyframes menu-cloud-drift {
  from { transform: translateX(-180px); }
  to   { transform: translateX(1300px); }
}
.menu-cloud.c1 { top: 60px;  left: 0; animation-duration: 90s; }
.menu-cloud.c2 { top: 150px; left: 0; animation-duration: 130s; animation-delay: -40s; transform: scale(0.7); }
.menu-cloud.c3 { top: 30px;  left: 0; animation-duration: 110s; animation-delay: -70s; transform: scale(1.2); }

/* Ambient birds over the whole menu; clicks pass straight through */
#menu-birds {
  position: absolute;
  inset: 0;
  z-index: 1;              /* behind .mode-inner (z 2), above the sky decor */
  pointer-events: none;
  image-rendering: pixelated;
}

/* Pixel diorama strip pinned to the bottom of the menu */
.menu-scene {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
}
.menu-scene-inner { position: relative; width: 100%; }
.menu-scene canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  cursor: pointer;
  touch-action: none;   /* the browser never turns strip taps into scrolls */
}

.menu-bubble {
  position: absolute;
  font-family: 'Lilita One', cursive;
  font-size: 13px;
  background: #fdfaf2;
  color: #333;
  border: 2px solid #333;
  border-radius: 8px;
  padding: 3px 8px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 150ms, transform 150ms;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
.menu-bubble.show { opacity: 1; transform: scale(1); }
.menu-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px; left: 12px;
  width: 8px; height: 8px;
  background: #fdfaf2;
  border-right: 2px solid #333;
  border-bottom: 2px solid #333;
  transform: rotate(45deg);
}

/* Portrait phone menu (430x860 canvas): the strip is narrower, so it
   needs less reserved space; bubbles scale down a touch too. */
@media (max-width: 700px) {
  .mode-select .mode-inner { padding-bottom: 150px; }
  .menu-bubble { font-size: 11px; padding: 2px 6px; }
  .menu-sun { width: 46px; height: 46px; top: 20px; right: 30px; }
}


/* ═══ Sky-menu readability overrides ═══ */
/* Selected length button: dark panel + gold, instead of a washed-out light chip */
.mode-select .length-btn.selected {
  background: rgba(13, 42, 29, 0.85);
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(232, 193, 90, 0.35);
}

/* Scoring picker: same chips as the length buttons, just a little tighter
   so the extra row does not push the menu buttons off a phone screen. */
.scoring-row .length-buttons { gap: 10px; }
.scoring-row .length-btn { padding: 10px 18px; font-size: 13px; }
.scoring-row .length-btn small { font-size: 9px; }

/* Leaderboard stat-column legend (v2 board only) */
.lb-legend {
  margin-top: 6px;
  font-size: 11px;
  text-align: center;
  opacity: 0.75;
}

/* Explanatory note under the scoring table in the rules popup */
.rules-note { font-size: 12px; opacity: 0.85; font-style: italic; }

/* Checkbox label: dark text on the light sky */
.mode-select .checkbox-label { color: #1d3a2c; font-weight: 600; }
.mode-select .checkbox-custom {
  border-color: #3f5b4b;
  background: rgba(255, 255, 255, 0.55);
}
/* Checked: dark panel (same family as the buttons) with a gold check */
.mode-select .checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: rgba(13, 42, 29, 0.85);
  border-color: var(--gold);
}

/* Leaderboard / rules buttons: dark glass panels like the mode buttons */
.mode-select .lb-btn {
  background: rgba(13, 42, 29, 0.72);
  color: var(--gold);
  border: 1.5px solid rgba(232, 193, 90, 0.5);
  box-shadow: 0 4px 14px rgba(20, 50, 90, 0.2);
}
.mode-select .lb-btn:hover {
  border-color: var(--gold);
  background: rgba(13, 42, 29, 0.85);
}