* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #1b120a;
  color: #f1e6d8;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #2a1b0f;
  border-bottom: 2px solid #6b3f1d;
}
.topbar h1 { font-size: 1.1rem; margin: 0; flex: 0 0 auto; }
.score { display: flex; gap: 0.4rem; align-items: baseline; font-variant-numeric: tabular-nums; }
.score-value { font-weight: 700; font-size: 1.1rem; }
.seat-badge { margin-left: auto; padding: 0.2rem 0.6rem; border-radius: 999px; background: #3a2818; font-size: 0.85rem; }

.connection-banner {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: #5a3a12;
  color: #ffe9c2;
  font-size: 0.9rem;
}
.retry-btn {
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  border: none;
  background: #d98c2b;
  color: #1b120a;
  font-weight: 600;
  cursor: pointer;
}

/* Show the banner whenever the page isn't in a "connected & playing" status */
body[data-status="connecting"] .connection-banner,
body[data-status="waking"] .connection-banner,
body[data-status="give_up"] .connection-banner,
body[data-status="closed_no_retry"] .connection-banner,
body[data-status="offer_rejoin"] .connection-banner {
  display: flex;
}
body[data-status="give_up"] .retry-btn,
body[data-status="offer_rejoin"] .retry-btn { display: inline-block; }
.retry-btn { display: none; }
body[data-status="give_up"] .connection-banner,
body[data-status="offer_rejoin"] .connection-banner { background: #5a1414; }

.table-wrap {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr) 40px repeat(6, 1fr) 30px;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  background: #6b3f1d;
  border: 6px solid #3a2210;
  border-radius: 6px;
  padding: 8px;
  width: min(100%, 760px);
  aspect-ratio: 16 / 10;
}

.quadrant { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.quadrant.top-left { grid-column: 1 / 7; grid-row: 1; }
.quadrant.top-right { grid-column: 8 / 14; grid-row: 1; }
.quadrant.bottom-left { grid-column: 1 / 7; grid-row: 2; }
.quadrant.bottom-right { grid-column: 8 / 14; grid-row: 2; }

.bar-col { grid-column: 7; grid-row: 1 / 3; display: flex; flex-direction: column; justify-content: center; gap: 6px; background: #3a2210; border-radius: 4px; }
/* Layout-only filler to keep the implicit grid balanced -- must never intercept
   clicks meant for .bar-col (which spans the same column/row-2 cell and holds
   the real, clickable bar stacks). See defect #2 in
   tests/test_backgammon_two_client.py's module docstring. */
.bar-col-spacer { grid-column: 7; grid-row: 2; pointer-events: none; }
.off-col { grid-column: 14; grid-row: 1 / 3; display: flex; flex-direction: column; justify-content: space-between; background: #24160b; border-radius: 4px; padding: 4px 2px; }
/* Same overlap pattern as .bar-col-spacer above, over .off-col's row-2 cell
   (the black off-stack). Must not swallow clicks now that off-stacks are
   clickable (bear-off, defect #1). */
.off-col-spacer { grid-column: 14; grid-row: 2; pointer-events: none; }

.point {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 6px;
  cursor: pointer;
  background: linear-gradient(#caa26a, #caa26a);
}
.point:nth-child(odd) { background: linear-gradient(#8a5a2c, #8a5a2c); }
.point-top { justify-content: flex-start; border-radius: 0 0 40% 40%; }
.point-bottom { justify-content: flex-end; flex-direction: column-reverse; border-radius: 40% 40% 0 0; }
.point.legal-source { outline: 3px solid #6fd66f; outline-offset: -3px; }
.point.legal-dest { outline: 3px dashed #ffd35c; outline-offset: -3px; }

.checker {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin: 1px 0;
  border: 2px solid #111;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.checker[data-color="white"] { background: #f4ecd8; }
.checker[data-color="black"] { background: #2a2118; }
.checker .count { font-size: 0.7rem; color: inherit; }

/* Bear-off destination highlight. ⚠️ `.off-stack` is NOT a `.point`, so the
   `.point.legal-dest` rule above does not reach it — without this rule
   `onPointClick` adds the class and absolutely nothing appears on screen, which
   is indistinguishable from the bug it fixes. Kept visually identical to
   `.point.legal-dest` on purpose: it means the same thing to the player. */
.off-stack.legal-dest { outline: 3px dashed #ffd35c; outline-offset: -3px; }

.bar-stack, .off-stack {
  min-height: 30px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
}

.side-panel {
  flex: 1 1 240px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dice-area { display: flex; gap: 0.4rem; min-height: 40px; }
.die {
  width: 34px; height: 34px;
  background: #f4ecd8;
  color: #1b120a;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  border: 2px solid #111;
}
.die[data-used="true"] { opacity: 0.35; }

.opening-area { padding: 0.5rem 0.75rem; background: #3a2818; border-radius: 6px; }
.opening-copy { margin: 0; }

.turn-info { min-height: 1.5rem; }

.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.controls button {
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  border: none;
  background: #d98c2b;
  color: #1b120a;
  font-weight: 600;
  cursor: pointer;
}
.controls button:disabled { opacity: 0.4; cursor: not-allowed; }

.event-log { font-size: 0.85rem; opacity: 0.75; min-height: 1.2rem; }

@media (max-width: 640px) {
  .board { aspect-ratio: 4 / 5; grid-template-columns: repeat(6, 1fr) 30px repeat(6, 1fr) 24px; }
  .checker { width: 18px; height: 18px; }
}
