/* 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); }

/* ---- Mancala-specific layout: 2 rows of 6 pits + 2 side stores ---- */
.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;
  width: min(100%, 740px);
  gap: 8px;
}
.board-grid[data-layout="mancala"] .board-cell {
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  font-size: clamp(16px, 2.4vw, 32px);
  width: 100%;
  justify-self: center;
  align-self: center;
  max-width: 90%;
}
.board-grid[data-layout="mancala"] .board-cell__glyph {
  font-weight: 800;
}
/* Stores are tall pill shapes with their own colour. */
.board-grid[data-layout="mancala"] .board-cell.kind-store-p1,
.board-grid[data-layout="mancala"] .board-cell.kind-store-p2 {
  border-radius: var(--radius-lg, 18px);
  aspect-ratio: auto;
  height: 92%;
  width: 80%;
  background: rgba(245,197,66,0.15);
  box-shadow: inset 0 0 0 3px rgba(245,197,66,0.45);
  color: #ffe9a8;
  font-size: clamp(18px, 3vw, 40px);
}
/* Place stores: p1 store left-top, p2 store right-top (approximation across 2 rows). */
.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; }
/* P1 pits top row (cols 2..7), P2 pits bottom row. */
.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; }
.board-grid[data-layout="mancala"] .board-cell.kind-p1-pit .board-cell__glyph,
.board-grid[data-layout="mancala"] .board-cell.kind-p2-pit .board-cell__glyph {
  color: #fff;
}

.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);
}
.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;
}
