/* Board screen (Expansion Fire A): setup panel, board grid, cells. */

.board-setup {
  display: flex; flex-direction: column; gap: var(--space);
  padding: calc(var(--space) * 1.4);
  background: rgba(34, 48, 71, var(--panel-alpha, 0.92));
  border-radius: var(--radius-lg, 18px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  max-width: 640px;
  margin: 0 auto;
}
.setup-row {
  display: flex; flex-direction: column; gap: 8px;
}
.setup-label {
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 0.82em;
  font-weight: 600;
}
.setup-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.setup-choice {
  flex: 1;
  min-height: var(--tap);
  padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-weight: 600;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.setup-choice:hover { background: rgba(255,255,255,0.12); }
.setup-choice.is-chosen {
  border-color: var(--focus);
  background: rgba(245,197,66,0.15);
  box-shadow: 0 0 0 3px rgba(245,197,66,0.22);
}
.setup-actions { display: flex; gap: var(--space); flex-wrap: wrap; margin-top: 6px; }

/* ---- Board grid ---- */
.board-wrap {
  display: flex; justify-content: center;
  padding: calc(var(--space) * 1.2);
  border-radius: var(--radius-lg, 18px);
  background: radial-gradient(120% 90% at 50% 28%, #2e4d78 0%, #1d2f4a 55%, #152238 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 0 60px rgba(0,0,0,0.35);
  position: relative;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(var(--board-cols, 8), 1fr);
  grid-template-rows: repeat(var(--board-rows, 8), 1fr);
  gap: 6px;
  width: min(100%, 620px);
  aspect-ratio: var(--board-cols, 8) / var(--board-rows, 8);
  margin: 0 auto;
  position: relative;
}
.board-grid.is-thinking::after {
  content: "…";
  position: absolute;
  top: -22px; right: 6px;
  color: var(--fg-dim);
  font-weight: 700;
  letter-spacing: 2px;
  animation: boardThinking 1s ease-in-out infinite;
}
@keyframes boardThinking {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.board-cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.06);
  color: var(--fg);
  font-size: clamp(14px, 2.6vw, 26px);
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
  padding: 0;
  min-width: 0;
  min-height: 0;
}
.board-cell .board-cell__glyph {
  display: block;
  line-height: 1;
  font-weight: 700;
}
/* Reversi / Four in a Row pieces: glossy circles. */
.board-cell.kind-dark .board-cell__glyph {
  color: transparent;
  width: 78%; height: 78%; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #6b7a8e 0%, #26313f 55%, #0e1620 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.18),
    inset 0 -3px 8px rgba(0,0,0,0.55),
    0 4px 10px rgba(0,0,0,0.45);
}
.board-cell.kind-light .board-cell__glyph {
  color: transparent;
  width: 78%; height: 78%; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fffdf0 0%, #e0d7c2 60%, #b8ab8c 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.85),
    inset 0 -3px 8px rgba(80,60,20,0.35),
    0 4px 10px rgba(0,0,0,0.35);
}
/* Legal-move hint: subtle gold ring on empty cells, safe place to click. */
.board-cell.is-legal.kind-empty {
  background: rgba(245,197,66,0.08);
  box-shadow: inset 0 0 0 2px rgba(245,197,66,0.35);
}
.board-cell.is-win {
  box-shadow: inset 0 0 0 3px rgba(245,197,66,0.9), 0 0 16px rgba(245,197,66,0.4);
}
.board-cell.is-cursor {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus), 0 6px 14px rgba(0,0,0,0.4);
  z-index: 2;
}
.board-cell:hover { background: rgba(255,255,255,0.12); }
.board-cell:active { transform: scale(0.97); }
/* Changed-cell pulse after a move (most of all the computers move). */
.board-cell.is-changed { animation: boardPulse 0.65s ease; }
@keyframes boardPulse {
  0% { box-shadow: inset 0 0 0 3px rgba(245,197,66,0.95), 0 0 18px rgba(245,197,66,0.55); }
  100% { box-shadow: inset 0 0 0 0 rgba(245,197,66,0), 0 0 0 rgba(245,197,66,0); }
}
/* Four in a Row: the dropped disc falls the full height of its
   column — the screen measures the real distance (--fall-px) and
   pace (--fall-ms) per drop, so a disc dropped into an empty column
   falls far and fast, and one landing near the top barely drops. */
.board-grid[data-game="fourinarow"] .board-cell.is-dropping .board-cell__glyph {
  animation: firFall var(--fall-ms, 0.45s) cubic-bezier(0.5, 0, 0.8, 0.6) both;
}
@keyframes firFall {
  0% { transform: translateY(calc(var(--fall-px, 200px) * -1)); }
  78% { transform: translateY(0); }
  88% { transform: translateY(3px); }
  100% { transform: translateY(0); }
}

/* Four in a Row stage: the board flanked by the two disc piles,
   like the physical game — red on the left, yellow on the right. */
.board-wrap.fir-stage {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
}
.board-wrap.fir-stage .board-grid {
  width: min(940px, calc((var(--win-h, 100dvh) - 185px) * 1.1667), calc(100% - 150px));
}
.fir-pile {
  width: 58px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  touch-action: none;
}
.fir-pile.is-active {
  border-color: rgba(255, 207, 51, 0.75);
  box-shadow: 0 0 0 2px rgba(255, 207, 51, 0.35), 0 0 18px rgba(255, 207, 51, 0.18);
}
.fir-pile.is-empty { opacity: 0.45; }
.fir-pile-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.fir-disc {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4);
}
.fir-disc + .fir-disc { margin-top: -31px; }
.fir-disc.kind-dark { background: radial-gradient(circle at 32% 28%, #ff9a8a 0%, #e02318 55%, #8f1008 100%); }
.fir-disc.kind-light { background: radial-gradient(circle at 32% 28%, #fff3a6 0%, #ffd21f 55%, #c79a06 100%); }
.fir-pile-count {
  font-weight: 700;
  color: #eaf2ff;
  font-size: 0.95rem;
}

/* ---- Mancala: a real wooden board (Master, Nov 17) ----
   Wooden board surface, carved dimple pits, actual stones you can
   count. The board is the grid element itself: wood layers + rim. */
.board-grid[data-layout="mancala"] {
  /* 8 columns: store | 6 pits | store. */
  grid-template-columns: 0.9fr repeat(6, 1fr) 0.9fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 8 / 2.1;
  width: min(97%, 1020px);
  gap: 10px;
  padding: 22px 18px;
  border-radius: 30px;
  border: 6px solid #4e2f10;
  background:
    radial-gradient(120% 130% at 50% 0%, rgba(255, 214, 150, 0.20) 0%, rgba(255, 214, 150, 0) 55%),
    repeating-linear-gradient(93deg, rgba(62, 36, 10, 0.13) 0 2px, rgba(62, 36, 10, 0) 2px 9px),
    repeating-linear-gradient(88deg, rgba(255, 226, 170, 0.05) 0 3px, rgba(255, 226, 170, 0) 3px 14px),
    linear-gradient(165deg, #a06c33 0%, #8a5a28 48%, #754a1e 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 224, 168, 0.45),
    inset 0 -10px 22px rgba(43, 24, 4, 0.5),
    inset 0 0 60px rgba(43, 24, 4, 0.28),
    0 24px 48px rgba(0, 0, 0, 0.55);
}
/* Carved dimples: dark hollow centre, lit lower rim. */
.board-grid[data-layout="mancala"] .board-cell {
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  width: 100%;
  justify-self: center;
  align-self: center;
  max-width: 96%;
  background: radial-gradient(circle at 50% 40%, #2e1a08 0%, #40260d 52%, #5a3a16 74%, #7a5224 90%, rgba(255, 216, 150, 0.35) 100%);
  box-shadow:
    inset 0 12px 20px rgba(0, 0, 0, 0.62),
    inset 0 -5px 9px rgba(255, 214, 150, 0.20),
    0 1px 0 rgba(255, 224, 168, 0.25);
}
.board-grid[data-layout="mancala"] .board-cell:hover { background: radial-gradient(circle at 50% 40%, #38200a 0%, #4a2e10 52%, #654218 74%, #86602c 90%, rgba(255, 216, 150, 0.4) 100%); }
.board-grid[data-layout="mancala"] .board-cell.is-legal {
  box-shadow:
    inset 0 12px 20px rgba(0, 0, 0, 0.62),
    inset 0 -5px 9px rgba(255, 214, 150, 0.20),
    inset 0 0 0 3px rgba(245, 197, 66, 0.55),
    0 0 14px rgba(245, 197, 66, 0.30);
}
.board-grid[data-layout="mancala"] .board-cell.is-cursor {
  box-shadow:
    inset 0 12px 20px rgba(0, 0, 0, 0.62),
    0 0 0 3px var(--focus),
    0 0 18px rgba(245, 197, 66, 0.45);
  z-index: 2;
}
/* Stores: tall carved wells. */
.board-grid[data-layout="mancala"] .board-cell.kind-store-p1,
.board-grid[data-layout="mancala"] .board-cell.kind-store-p2 {
  border-radius: 52px;
  aspect-ratio: auto;
  height: 96%;
  width: 86%;
  max-width: 86%;
  background: radial-gradient(ellipse 90% 60% at 50% 38%, #2e1a08 0%, #40260d 55%, #5a3a16 78%, #7a5224 92%, rgba(255, 216, 150, 0.35) 100%);
}
.board-grid[data-layout="mancala"] .board-cell.kind-store-p1 { grid-column: 1; grid-row: 1 / span 2; }
.board-grid[data-layout="mancala"] .board-cell.kind-store-p2 { grid-column: 8; grid-row: 1 / span 2; }
.board-grid[data-layout="mancala"] .board-cell.kind-p1-pit { grid-row: 1; }
.board-grid[data-layout="mancala"] .board-cell.kind-p2-pit { grid-row: 2; }
/* Stones: glossy pebbles in mixed earth tones, clustered in the dimple. */
.pit-stones {
  display: flex; flex-wrap: wrap;
  align-content: center; justify-content: center; align-items: center;
  gap: 2px;
  width: 76%;
  pointer-events: none;
  position: relative;
}
.pit-stones.is-store { width: 70%; }
.m-stone {
  display: block;
  width: 29%; aspect-ratio: 1 / 0.92;
  border-radius: 48% 52% 55% 45% / 55% 48% 52% 45%;
  box-shadow:
    inset 0 -3px 5px rgba(0, 0, 0, 0.35),
    inset 0 2px 3px rgba(255, 255, 255, 0.35),
    0 2px 3px rgba(0, 0, 0, 0.5);
}
.pit-stones.is-store .m-stone { width: 24%; }
.m-stone--0 { background: radial-gradient(circle at 34% 28%, #f4cd7d 0%, #d9a441 55%, #9c6f1e 100%); }
.m-stone--1 { background: radial-gradient(circle at 34% 28%, #fdf6e0 0%, #e8dcc0 55%, #b3a37f 100%); }
.m-stone--2 { background: radial-gradient(circle at 34% 28%, #aebdd2 0%, #7d8aa0 55%, #4c586c 100%); }
.m-stone--3 { background: radial-gradient(circle at 34% 28%, #e59a76 0%, #b65c38 55%, #77381d 100%); }
.m-stone--4 { background: radial-gradient(circle at 34% 28%, #bcd3b4 0%, #8ba888 55%, #576f52 100%); }
.m-stone--5 { background: radial-gradient(circle at 34% 28%, #c3a6dd 0%, #7a5f8f 55%, #4c3a5e 100%); }
.m-stone.is-new { animation: mStoneDrop 0.18s ease; }
@keyframes mStoneDrop {
  0% { transform: scale(1.45); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}
.pit-count {
  position: absolute;
  right: -8px; bottom: -6px;
  background: rgba(20, 14, 6, 0.88);
  color: #ffe9a8;
  font-size: 13px; font-weight: 800; line-height: 1;
  padding: 4px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(245, 197, 66, 0.5);
}

.board-banner {
  display: block;
  font-weight: 700;
  color: var(--focus);
  font-size: 1.05em;
  margin-top: 2px;
}
[data-focusable].is-focused::after {
  /* Keep base styling — the board already shows strong focus via .is-cursor. */
}

@media (max-width: 700px) {
  .board-grid { gap: 4px; }
  .board-grid[data-layout="mancala"] { gap: 6px; }
}
@media (max-height: 500px) {
  .board-wrap { padding: 6px; margin: 0 -6px; }
  .board-grid { width: min(100%, 520px); }
}

/* ---- Checkers: checkerboard cells, red/black discs, crowns ---- */
.board-cell.kind-void {
  background: rgba(240,217,174,0.20);
}
.board-cell.kind-empty {
  background: rgba(20,26,38,0.35);
}
.board-cell.kind-p1 .board-cell__glyph,
.board-cell.kind-p2 .board-cell__glyph,
.board-cell.kind-p1king .board-cell__glyph,
.board-cell.kind-p2king .board-cell__glyph {
  color: transparent;
  width: 78%; height: 78%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.board-cell.kind-p1 .board-cell__glyph,
.board-cell.kind-p1king .board-cell__glyph {
  background: radial-gradient(circle at 32% 28%, #ff9a8a 0%, #d63a2a 55%, #8f1f14 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.35),
    inset 0 -3px 8px rgba(0,0,0,0.5),
    0 4px 10px rgba(0,0,0,0.45);
}
.board-cell.kind-p2 .board-cell__glyph,
.board-cell.kind-p2king .board-cell__glyph {
  background: radial-gradient(circle at 32% 28%, #6b7a8e 0%, #26313f 55%, #0e1620 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.18),
    inset 0 -3px 8px rgba(0,0,0,0.55),
    0 4px 10px rgba(0,0,0,0.45);
}
.board-cell.kind-p1king .board-cell__glyph,
.board-cell.kind-p2king .board-cell__glyph {
  color: #f5c542;
  font-size: 0.72em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
/* Checkers pieces are DISCS, not balls: flatter face shading, a turned
   ridge ring near the rim, and a hard offset edge underneath so the
   piece reads as a short cylinder with thickness. Scoped to checkers -
   Reversi keeps its glossy stones. (Visual sweep 2026-11-17: the
   shared ball gradient made checkers read as marbles.) */
.board-grid[data-game="checkers"] .board-cell.kind-p1 .board-cell__glyph,
.board-grid[data-game="checkers"] .board-cell.kind-p1king .board-cell__glyph {
  background: radial-gradient(circle at 50% 38%, #e2574a 0%, #cf3527 62%, #b02a1e 100%);
  box-shadow:
    inset 0 0 0 3px rgba(120, 20, 10, 0.35),
    inset 0 0 0 6px rgba(255, 210, 190, 0.16),
    inset 0 2px 3px rgba(255,255,255,0.25),
    0 4px 0 #7c1a10,
    0 7px 9px rgba(0,0,0,0.45);
}
.board-grid[data-game="checkers"] .board-cell.kind-p2 .board-cell__glyph,
.board-grid[data-game="checkers"] .board-cell.kind-p2king .board-cell__glyph {
  background: radial-gradient(circle at 50% 38%, #3d4756 0%, #232c38 62%, #171e28 100%);
  box-shadow:
    inset 0 0 0 3px rgba(0, 0, 0, 0.45),
    inset 0 0 0 6px rgba(200, 215, 235, 0.13),
    inset 0 2px 3px rgba(255,255,255,0.16),
    0 4px 0 #0a0f16,
    0 7px 9px rgba(0,0,0,0.5);
}
.board-cell.is-select {
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.45);
}
.board-cell.is-selected {
  box-shadow: inset 0 0 0 3px rgba(245,197,66,0.95), 0 0 14px rgba(245,197,66,0.35);
  transform: scale(1.04);
  z-index: 2;
}

/* SWEEP-2026-11-17: classic boards + TV sizing */
/* Board games get a bigger stage on big screens (was capped at 620px). */
.board-grid { width: min(940px, calc((var(--win-h, 100dvh) - 185px) * var(--fit-ratio, 1)), 100%); }
@media (max-height: 500px) {
  .board-grid { width: min(940px, calc((var(--win-h, 100dvh) - 120px) * var(--fit-ratio, 1)), 100%); }
}

/* Four in a Row: a wooden frame with carved dark holes and red and
   yellow discs - the physical game Master photographed, and what the
   home tile shows. (Was a blue plastic frame until the 2026-11-17
   visual sweep flagged the tile-vs-game mismatch.) */
.board-grid[data-game="fourinarow"] {
  --fit-ratio: 1.1667;
  background:
    repeating-linear-gradient(93deg, rgba(59, 36, 12, 0.10) 0 3px, rgba(255, 235, 200, 0.03) 3px 5px, transparent 5px 11px),
    linear-gradient(165deg, #b3814a 0%, #8a5a2b 55%, #6e4520 100%);
  border-color: #4a2e12;
  padding: 14px;
  gap: 8px;
}
.board-grid[data-game="fourinarow"] .board-cell {
  background: transparent;
  border-color: rgba(59, 36, 12, 0.25);
}
.board-grid[data-game="fourinarow"] .board-cell.kind-empty,
.board-grid[data-game="fourinarow"] .board-cell.is-legal.kind-empty {
  background: radial-gradient(circle at 50% 42%, #241304 0%, #33200c 72%, #4a2e12 100%);
  border-radius: 50%;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.7), inset 0 -2px 3px rgba(255, 225, 170, 0.22);
}
.board-grid[data-game="fourinarow"] .board-cell.is-cursor {
  box-shadow: 0 0 0 3px #ffcf33, inset 0 4px 8px rgba(0, 0, 0, 0.65);
}
.board-grid[data-game="fourinarow"] .board-cell.kind-dark .board-cell__glyph {
  background: radial-gradient(circle at 32% 28%, #ff9a8a 0%, #e02318 55%, #8f1008 100%);
}
.board-grid[data-game="fourinarow"] .board-cell.kind-light .board-cell__glyph {
  background: radial-gradient(circle at 32% 28%, #fff3a6 0%, #ffd21f 55%, #c79a06 100%);
}

/* Reversi: green baize, the way the real board looks. */
.board-grid[data-game="reversi"] {
  background: linear-gradient(160deg, #1a9150 0%, #0d6b38 55%, #09522b 100%);
  border-color: #063d1f;
}
.board-grid[data-game="reversi"] .board-cell {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(0, 0, 0, 0.28);
}

/* Checkers: real light-and-dark contrast (cream against warm brown). */
.board-grid[data-game="checkers"] { border-color: #6b4423; }
.board-grid[data-game="checkers"] .board-cell.kind-void { background: #f0d9b5; }
.board-grid[data-game="checkers"] .board-cell.kind-empty,
.board-grid[data-game="checkers"] .board-cell.kind-p1,
.board-grid[data-game="checkers"] .board-cell.kind-p2,
.board-grid[data-game="checkers"] .board-cell.kind-p1king,
.board-grid[data-game="checkers"] .board-cell.kind-p2king { background: #b58863; }

/* ==== Drag ghost + hints (Nov 17, 2026) ==== */
.board-drag-ghost {
  position: fixed;
  left: 0; top: 0;
  pointer-events: none;
  z-index: 9000;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  transform: translate3d(0,0,0) scale(1.1);
  will-change: transform;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,0.55));
  opacity: 0.96;
}
.board-drag-ghost .drag-ghost-glyph {
  width: 78%; height: 78%;
  border-radius: 50%;
}
.board-drag-ghost.drag-ghost-mancala {
  width: 72px; height: 72px;
}
.board-drag-ghost.drag-ghost-mancala .pit-stones {
  width: 100%;
}

/* Ghost disc paints (Master, Nov 17): the cell disc rules are scoped
   to .board-cell inside .board-grid, so a carried disc in a body-level
   ghost painted NOTHING and the drag looked empty. These mirror the
   cell paints, keyed off the kind class the drag code copies onto the
   ghost. Four in a Row paints through .fir-disc instead (unscoped). */
.board-drag-ghost.kind-p1 .drag-ghost-glyph,
.board-drag-ghost.kind-p1king .drag-ghost-glyph {
  background: radial-gradient(circle at 32% 28%, #ff9a8a 0%, #d63a2a 55%, #8f1f14 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.35),
    inset 0 -3px 8px rgba(0,0,0,0.5),
    0 4px 10px rgba(0,0,0,0.45);
}
.board-drag-ghost.kind-p2 .drag-ghost-glyph,
.board-drag-ghost.kind-p2king .drag-ghost-glyph {
  background: radial-gradient(circle at 32% 28%, #6b7a8e 0%, #26313f 55%, #0e1620 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.18),
    inset 0 -3px 8px rgba(0,0,0,0.55),
    0 4px 10px rgba(0,0,0,0.45);
}
.board-drag-ghost.kind-p1king .drag-ghost-glyph,
.board-drag-ghost.kind-p2king .drag-ghost-glyph {
  color: #f5c542;
  display: flex; align-items: center; justify-content: center;
}
.board-drag-ghost.kind-dark .drag-ghost-glyph {
  background: radial-gradient(circle at 32% 28%, #6b7a8e 0%, #26313f 55%, #0e1620 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.18),
    inset 0 -3px 8px rgba(0,0,0,0.55),
    0 4px 10px rgba(0,0,0,0.45);
}
.board-drag-ghost.kind-light .drag-ghost-glyph {
  background: radial-gradient(circle at 32% 28%, #fffdf0 0%, #e0d7c2 60%, #b8ab8c 100%);
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.85),
    inset 0 -3px 8px rgba(80,60,20,0.35),
    0 4px 10px rgba(0,0,0,0.35);
}
.board-drag-ghost.drag-ghost-fir {
  filter: drop-shadow(0 16px 22px rgba(0,0,0,0.6));
}

/* Source cell dims while lifted. */
.board-cell.is-lifted {
  opacity: 0.35;
  filter: grayscale(0.4);
  transition: opacity 0.12s ease, filter 0.12s ease;
}

/* Spring-back animation: aggressive easing back to the source. */
.board-drag-ghost.is-springing {
  animation: boardSpringBack 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes boardSpringBack {
  0%   { filter: drop-shadow(0 10px 16px rgba(0,0,0,0.55)); }
  100% { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25)); }
}

/* Hints OFF: hide every legal-move indicator on the grid. */
.board-grid.hints-off .board-cell.is-legal {
  background: inherit;
  box-shadow: none;
}
.board-grid.hints-off .board-cell.is-legal.kind-empty {
  background: inherit;
  box-shadow: none;
}
.board-grid[data-layout="mancala"].hints-off .board-cell.is-legal {
  box-shadow:
    inset 0 12px 20px rgba(0, 0, 0, 0.62),
    inset 0 -5px 9px rgba(255, 214, 150, 0.20),
    0 1px 0 rgba(255, 224, 168, 0.25);
}

/* Banner warning style for the illegal-move line. */
.board-banner.is-warning {
  color: #ff9a8a;
  animation: boardBannerWarn 1.2s ease;
}
@keyframes boardBannerWarn {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* Hints toggle button state. */
.board-hints-toggle.is-on {
  border-color: var(--focus);
  background: rgba(245,197,66,0.15);
}/* ===== Chess (Packet 3): squares, pieces, promotion picker ===== */
.board-grid[data-game="chess"] {
  gap: 0;
  border-radius: 6px;
  border: 2px solid #3d2a17;
  background: #2a1d10;
  box-shadow: 0 10px 24px rgba(0,0,0,0.45), inset 0 0 0 3px #6d4c2e;
  padding: 4px;
}
.board-grid[data-game="chess"] {
  gap: 0;
  padding: 10px;
  box-sizing: border-box;
  background: linear-gradient(155deg, #7a4e28 0%, #5a3a1e 55%, #3f2812 100%);
  border: 3px solid #2a1a0a;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,220,160,0.35);
}
.board-grid[data-game="chess"] .board-cell {
  border-radius: 0;
  background: transparent;
  padding: 0;
  font-size: 0;
}
.board-grid[data-game="chess"] .board-cell.kind-sq-light {
  background: linear-gradient(145deg, #f7e7c3 0%, #eed3a1 100%);
}
.board-grid[data-game="chess"] .board-cell.kind-sq-dark {
  background: linear-gradient(145deg, #83a862 0%, #648348 100%);
}
.board-grid[data-game="chess"] .board-cell:hover.kind-sq-light { background: #f7e6c8; }
.board-grid[data-game="chess"] .board-cell:hover.kind-sq-dark { background: #85a963; }
.board-grid[data-game="chess"] .board-cell .board-cell__glyph {
  font-size: clamp(22px, 5vw, 52px);
  line-height: 1;
  font-weight: 400;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  color: transparent;
  background: none;
  box-shadow: none;
  border-radius: 0;
  filter: none;
}
.board-grid[data-game="chess"] .board-cell .board-cell__glyph.piece-w {
  color: #fffbe9;
  text-shadow:
    0 0 1px #1a1408,
    1px 0 0 #1a1408,
   -1px 0 0 #1a1408,
    0 1px 0 #1a1408,
    0 -1px 0 #1a1408,
    1px 1px 0 #1a1408,
   -1px 1px 0 #1a1408,
    1px -1px 0 #1a1408,
   -1px -1px 0 #1a1408;
}
.board-grid[data-game="chess"] .board-cell .board-cell__glyph.piece-b {
  color: #14110c;
  text-shadow:
    0 0 1px rgba(255,255,255,0.25),
    0 1px 0 rgba(255,255,255,0.12);
}
/* Carved SVG pieces (w3.6.15): gradient-filled glyphs with a ground shadow. */
.chess-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.board-grid[data-game="chess"] .board-cell .board-cell__glyph.chess-piece {
  filter: drop-shadow(0 3px 2px rgba(24,14,4,0.5));
}
.chess-piece-svg { width: 94%; height: 94%; display: block; margin: auto; }
.promo-choice .board-cell__glyph.chess-piece { display: flex; width: 52px; height: 52px; filter: drop-shadow(0 2px 2px rgba(24,14,4,0.45)); }
.board-drag-ghost .board-cell__glyph.chess-piece { display: flex; width: 100%; height: 100%; filter: drop-shadow(0 4px 3px rgba(24,14,4,0.5)); }
/* A captured piece tips over and falls before the new position renders. */
.chess-topple-piece {
  position: absolute; z-index: 7; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  transform-origin: 50% 92%;
  animation: chessTopple 440ms ease-in forwards;
}
.chess-topple-piece .board-cell__glyph { width: 100%; height: 100%; filter: drop-shadow(0 3px 2px rgba(24,14,4,0.5)); }
@keyframes chessTopple {
  0% { transform: rotate(0deg) translateY(0); opacity: 1; }
  60% { opacity: 1; }
  100% { transform: rotate(var(--topple-rot, 82deg)) translateY(6%); opacity: 0; }
}
/* Highlight legal targets: a ring drawn over the square. */
.board-grid[data-game="chess"] .board-cell.is-legal::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle, rgba(20,20,20,0.42) 0%, rgba(20,20,20,0.42) 34%, rgba(20,20,20,0) 60%);
  pointer-events: none;
}
.board-grid[data-game="chess"] .board-cell.is-legal:has(.board-cell__glyph)::after,
.board-grid[data-game="chess"] .board-cell.is-legal .board-cell__glyph + .chess-legal-ring {
  background: none;
}
/* When a legal square contains a capture piece, draw a ring instead. */
.board-grid[data-game="chess"] .board-cell.is-legal[data-piece="1"]::after {
  inset: 6%;
  background: none;
  border: 4px solid rgba(200,40,40,0.75);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(200,40,40,0.45);
}
/* Selected source square. */
.board-grid[data-game="chess"] .board-cell.is-selected {
  box-shadow: inset 0 0 0 4px rgba(245,197,66,0.95);
  transform: none;
}
/* Movable pieces: a subtle bottom glow so the player knows what can lift. */
.board-grid[data-game="chess"] .board-cell.is-select {
  box-shadow: inset 0 -3px 0 rgba(245,197,66,0.55);
}
/* Last move tint. */
.board-grid[data-game="chess"] .board-cell.is-last {
  box-shadow: inset 0 0 0 4px rgba(245,197,66,0.35);
}
/* Keep hint-off behavior: hide the legal-target marker. */
.board-grid[data-game="chess"].hints-off .board-cell.is-legal::after {
  display: none;
}
/* Promotion picker. */
.promo-backdrop {
  z-index: 9600;
}
.promo-panel {
  background: rgba(20, 26, 40, 0.98);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.08);
  display: flex; flex-direction: column; gap: 12px;
  min-width: 240px;
}
.promo-title {
  color: var(--fg);
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 0.92em;
}
.promo-choices {
  display: flex; gap: 8px; justify-content: center;
}
.promo-choice {
  min-width: var(--tap);
  min-height: var(--tap);
  width: var(--tap);
  height: var(--tap);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  border: 2px solid transparent;
  font-size: 2.2em;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.promo-choice:hover { background: rgba(255,255,255,0.16); }
.promo-choice:focus-visible,
.promo-choice.is-focused {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(245,197,66,0.25);
}
.promo-choice .board-cell__glyph {
  font-size: inherit;
  color: inherit;
}
.promo-choice .board-cell__glyph.piece-w {
  color: #fffbe9;
  text-shadow:
    0 0 1px #1a1408,
    1px 0 0 #1a1408,
   -1px 0 0 #1a1408,
    0 1px 0 #1a1408,
    0 -1px 0 #1a1408,
    1px 1px 0 #1a1408,
   -1px 1px 0 #1a1408,
    1px -1px 0 #1a1408,
   -1px -1px 0 #1a1408;
}
.promo-choice .board-cell__glyph.piece-b { color: #14110c; }


/* Real 3D chess stage (Nov 17): the grid element becomes the stage for
   the WebGL canvas — a 4:3 frame the camera composes against. The
   generic sweep width is overridden by aspect: height follows width,
   and the measured fit pass still corrects against the real box. */
.board-grid[data-game="chess"].is-3d {
  display: block;
  width: min(980px, calc((var(--win-h, 100dvh) - 185px) * 1.3333), 100%);
  aspect-ratio: 4 / 3;
  padding: 0;
  gap: 0;
  background: none;
  border: none;
  box-shadow: none;
}
.board-grid.is-3d canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  touch-action: none;
}

/* Board spin (Master, Nov 17): two-player pass-and-play turns the
   board after every move. The grid rotates 180 degrees while each
   cells content counter-rotates, so pieces travel around the table
   and stay upright; at the end the cells are re-dealt in flipped
   order and the transforms clear. */
.board-grid.is-spinning {
  transition: transform 0.68s ease-in-out;
  z-index: 3;
}
.board-grid.is-spinning .board-cell > span {
  transition: transform 0.68s ease-in-out;
  transform: rotate(-180deg);
}

/* Mancala flipped: side 2 at the bottom — pit rows swap and the
   stores change ends (cell order reversal mirrors the columns). */
.board-grid[data-layout="mancala"].is-flipped .board-cell.kind-store-p1 { grid-column: 8; }
.board-grid[data-layout="mancala"].is-flipped .board-cell.kind-store-p2 { grid-column: 1; }
.board-grid[data-layout="mancala"].is-flipped .board-cell.kind-p1-pit { grid-row: 2; }
.board-grid[data-layout="mancala"].is-flipped .board-cell.kind-p2-pit { grid-row: 1; }
