/* ============================================================
   Board — Mancala
   ============================================================ */

/* ============================================================
   Board wrapper & layout
   ============================================================ */

#board-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 40;
}

/* Direction labels */
.direction-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
}

.dir-label {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

/* ============================================================
   Main board: [store] [pits-grid] [store]
   ============================================================ */

#board {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 14px;
  background: var(--board-bg);
  border: 2px solid var(--board-border);
  border-radius: 20px;
  box-shadow:
    0 4px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
}

/* ============================================================
   Stores (tall ovals on left and right)
   ============================================================ */

.store {
  width: var(--store-width, 80px);
  min-height: var(--store-height, 200px);
  border-radius: 40px;
  background: var(--store-bg);
  border: 2px solid var(--store-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  transition: box-shadow 0.3s, border-color 0.3s;
  flex-shrink: 0;
}

.store-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  opacity: 0.6;
}

.store-count {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 0 12px var(--accent-glow);
}

/* P1 store gets a subtle P1 accent */
.p1-store {
  border-color: var(--p1-store-border, var(--store-border));
}

/* P2 store gets a subtle P2 accent */
.p2-store {
  border-color: var(--p2-store-border, var(--store-border));
}

/* Active store glow when that player has a big lead */
.store.highlight {
  box-shadow: 0 0 20px var(--accent-glow);
  border-color: var(--accent);
}

/* ============================================================
   Pits grid: 6 columns × 2 rows
   ============================================================ */

.pits-grid {
  display: grid;
  grid-template-columns: repeat(6, var(--pit-size, 72px));
  grid-template-rows: repeat(2, var(--pit-size, 72px));
  gap: var(--pit-gap, 8px);
}

/* ============================================================
   Individual pits
   ============================================================ */

.pit {
  width: var(--pit-size, 72px);
  height: var(--pit-size, 72px);
  border-radius: 50%;
  background: var(--pit-bg);
  border: 2px solid var(--pit-border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s, opacity 0.2s;
  overflow: hidden;
  user-select: none;
}

/* Stone count label */
.pit-count {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--stone-color);
  position: relative;
  z-index: 2;
  pointer-events: none;
  line-height: 1;
}

/* Decorative stones container (small dots behind the count) */
.stones {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* Individual decorative stone dot */
.stone-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stone-color);
  opacity: 0.22;
}

/* ============================================================
   P1 vs P2 pit colouring
   ============================================================ */

.p1-pit {
  background: var(--p1-pit-bg, var(--pit-bg));
  border-color: var(--p1-pit-border, var(--pit-border));
}

.p2-pit {
  background: var(--p2-pit-bg, var(--pit-bg));
  border-color: var(--p2-pit-border, var(--pit-border));
}

/* ============================================================
   Legal-move highlight — current player's clickable pits
   ============================================================ */

.pit.legal {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 16px var(--accent-glow);
  cursor: pointer;
  animation: pit-legal-pulse 1.1s ease-in-out infinite;
  z-index: 5;
}

.pit.legal:hover {
  box-shadow:
    0 0 0 3px var(--accent),
    0 0 24px var(--accent-glow);
  filter: brightness(1.15);
}

/* Non-legal pits are dimmed */
.pit:not(.legal) {
  opacity: 0.65;
}

/* Empty pits are even more dimmed */
.pit.empty-pit {
  opacity: 0.35;
  cursor: default;
}

/* ============================================================
   Last-moved pit flash
   ============================================================ */

.pit.last-moved {
  animation: pit-last-move 0.9s ease-out forwards;
}

@keyframes pit-last-move {
  0%   { box-shadow: 0 0 0 3px var(--accent), 0 0 24px var(--accent-glow); }
  100% { box-shadow: none; }
}

/* ============================================================
   Capture flash — pit that was captured flashes red
   ============================================================ */

.pit.captured {
  animation: pit-capture-flash 0.7s ease-out forwards;
}

@keyframes pit-capture-flash {
  0%   { background: var(--capture-flash, rgba(248, 113, 113, 0.6)); border-color: #f87171; }
  100% { background: var(--pit-bg); border-color: var(--pit-border); }
}

/* ============================================================
   Stone count highlights based on number of stones
   ============================================================ */

.pit[data-empty="true"] .pit-count {
  opacity: 0.25;
}

/* ============================================================
   Board player lane indicator strips
   ============================================================ */

#board::before,
#board::after {
  content: '';
  position: absolute;
  left: calc(var(--store-width, 80px) + 14px + 8px);
  right: calc(var(--store-width, 80px) + 14px + 8px);
  height: 2px;
  border-radius: 2px;
  pointer-events: none;
}

#board::before {
  top: -1px;
  background: var(--p2-color, #f87171);
  opacity: 0.4;
}

#board::after {
  bottom: -1px;
  background: var(--p1-color, #60a5fa);
  opacity: 0.4;
}

/* ============================================================
   Keyframe animations (board-specific)
   ============================================================ */

@keyframes pit-legal-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 10px var(--accent-glow);
  }
  50% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 22px var(--accent-glow);
    filter: brightness(1.1);
  }
}

/* ============================================================
   Responsive — smaller pits on narrow viewports
   ============================================================ */

@media (max-width: 900px) {
  :root {
    --pit-size: 60px;
    --pit-gap: 6px;
    --store-width: 66px;
    --store-height: 170px;
  }

  .store-count { font-size: 1.3rem; }
  .pit-count   { font-size: 0.95rem; }
  #board       { padding: 10px; border-radius: 16px; gap: 6px; }
}

@media (max-width: 680px) {
  :root {
    --pit-size: 48px;
    --pit-gap: 5px;
    --store-width: 54px;
    --store-height: 140px;
  }

  .store { border-radius: 27px; }
  .store-count { font-size: 1.1rem; }
  .pit-count   { font-size: 0.82rem; }
  #board       { padding: 8px; gap: 5px; border-radius: 14px; }
  .store-label { font-size: 0.55rem; }
}

@media (max-width: 480px) {
  :root {
    --pit-size: 40px;
    --pit-gap: 4px;
    --store-width: 46px;
    --store-height: 116px;
  }

  .store { border-radius: 23px; gap: 4px; }
  .store-count { font-size: 0.95rem; }
  .pit-count   { font-size: 0.72rem; }
  #board       { padding: 6px; gap: 4px; border-radius: 12px; }
  .store-label { display: none; }
  .stone-dot   { width: 5px; height: 5px; }
  .dir-label   { font-size: 0.5rem; }
}

@media (max-width: 360px) {
  :root {
    --pit-size: 34px;
    --pit-gap: 3px;
    --store-width: 38px;
    --store-height: 100px;
  }
  .pit-count { font-size: 0.62rem; }
}
