#game {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) minmax(220px, 320px);
  align-items: stretch;
  justify-content: center;
  gap: var(--space-6);
  height: calc(100vh - 88px);
  padding: var(--space-8) var(--space-6) var(--space-6);
  box-sizing: border-box;
  overflow: hidden;
}

#game.game-entering .board-stage {
  animation: board-stage-enter 620ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

#game.game-entering .game-sidebar--left .sidebar-card {
  animation: panel-enter-left 520ms cubic-bezier(0.2, 0.8, 0.2, 1) 120ms both;
}

#game.game-entering .game-sidebar--right .sidebar-card {
  animation: panel-enter-right 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

#game.game-entering .game-sidebar--right .sidebar-card:nth-child(1) {
  animation-delay: 180ms;
}

#game.game-entering .game-sidebar--right .sidebar-card:nth-child(2) {
  animation-delay: 230ms;
}

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-height: 0;
  height: 100%;
}

.board-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
}

@keyframes board-stage-enter {
  0% {
    opacity: 0;
    transform: scale(0.94);
    filter: blur(5px);
  }

  70% {
    opacity: 1;
    transform: scale(1.01);
    filter: blur(0);
  }

  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

@keyframes panel-enter-left {
  from {
    opacity: 0;
    transform: translateX(-18px) scale(0.98);
    filter: blur(3px);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
}

@keyframes panel-enter-right {
  from {
    opacity: 0;
    transform: translateX(18px) scale(0.98);
    filter: blur(3px);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
    filter: blur(0);
  }
}

.board-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  padding: 8px;
}

#board-coords {
  display: grid;
  grid-template-columns: 1.8em 1fr;
  grid-template-rows: 1.8em 1fr;
  height: 100%;
  width: auto;
  aspect-ratio: 1 / 1;
  max-height: 100%;
  max-width: 100%;
}

#coords-corner {
  grid-area: 1 / 1;
}

#coords-cols {
  grid-area: 1 / 2;
  display: flex;
}

#coords-rows {
  grid-area: 2 / 1;
  display: flex;
  flex-direction: column;
}

#coords-cols span,
#coords-rows span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.42rem, 0.88vmin, 0.68rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--board-line);
  user-select: none;
  opacity: 0.9;
}

.neo-board {
  display: grid;
  grid-template-columns: repeat(19, 1fr);
  grid-template-rows: repeat(19, 1fr);
  gap: 0;
  grid-area: 2 / 2;

  height: 100%;
  width: 100%;

  position: relative;
  background-color: transparent;
  user-select: none;

  background-image:
    linear-gradient(to right,
      transparent calc(50% - 0.75px),
      var(--board-line) calc(50% - 0.75px),
      var(--board-line) calc(50% + 0.75px),
      transparent calc(50% + 0.75px)),
    linear-gradient(to bottom,
      transparent calc(50% - 0.75px),
      var(--board-line) calc(50% - 0.75px),
      var(--board-line) calc(50% + 0.75px),
      transparent calc(50% + 0.75px));
  background-size: calc(100% / 19) 100%, 100% calc(100% / 19);
  background-repeat: repeat-x, repeat-y;
}

.neo-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Hoshi star-point dot (hidden by default, shown via nth-child below) */
.neo-cell::before {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background-color: var(--board-line);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

/* 9 traditional hoshi points on a 19×19 board.
   Index = y*19 + x + 1 (nth-child is 1-based). */
.neo-board>.neo-cell:nth-child(61)::before,
.neo-board>.neo-cell:nth-child(67)::before,
.neo-board>.neo-cell:nth-child(73)::before,
.neo-board>.neo-cell:nth-child(175)::before,
.neo-board>.neo-cell:nth-child(181)::before,
.neo-board>.neo-cell:nth-child(187)::before,
.neo-board>.neo-cell:nth-child(289)::before,
.neo-board>.neo-cell:nth-child(295)::before,
.neo-board>.neo-cell:nth-child(301)::before {
  opacity: 0.65;
}

/* Ghost-stone preview on hover */
.neo-cell::after {
  content: "";
  position: absolute;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background-color: var(--neo-text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 1;
}

.neo-cell:hover::after {
  opacity: 0.13;
}

.stone-num {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  font-size: clamp(0.5rem, 1.5vmin, 0.85rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.neo-cell:hover .stone-num {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.neo-stone.black .stone-num {
  color: rgba(255, 255, 255, 0.95);
}

.neo-stone.white .stone-num {
  color: rgba(20, 20, 40, 0.95);
}

.neo-stone {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  position: absolute;
  pointer-events: none;
  z-index: 10;
  box-sizing: border-box;
  animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.3) forwards;
  box-shadow:
    rgba(0, 0, 0, 0.4) 0.3vmin 0.4vmin 0.6vmin,
    inset rgba(255, 255, 255, 0.3) 0px 0.2vmin 0.4vmin -0.1vmin,
    inset rgba(0, 0, 0, 0.2) 0px -0.2vmin 0.4vmin -0.1vmin;
  border: 1px solid rgba(255, 255, 255, 0.08);
  will-change: transform;
  backface-visibility: hidden;
}

.neo-stone::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: transparent;
  transition: background 160ms ease;
  pointer-events: none;
  z-index: 11;
}

.neo-cell:hover .neo-stone::after {
  background: rgba(0, 0, 0, 0.28);
}

.neo-stone.black {
  background: var(--stone-p1-bg);
}

.neo-stone.white {
  background: var(--stone-p2-bg);
}

.neo-cell--winning .neo-stone {
  animation: winning-stone-glow 1.25s ease-in-out infinite;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--winning-glow) 50%, transparent),
    0 0 28px color-mix(in srgb, var(--winning-glow) 70%, transparent),
    rgba(0, 0, 0, 0.4) 0.3vmin 0.4vmin 0.6vmin,
    inset rgba(255, 255, 255, 0.36) 0px 0.2vmin 0.4vmin -0.1vmin,
    inset rgba(0, 0, 0, 0.2) 0px -0.2vmin 0.4vmin -0.1vmin;
}

.neo-cell--winning .neo-stone.black {
  --winning-glow: var(--stone-p1-color);
}

.neo-cell--winning .neo-stone.white {
  --winning-glow: var(--stone-p2-color);
}

.neo-cell--capturing .neo-stone {
  pointer-events: none;
  animation: stone-capture-out 560ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.neo-cell--capturing .neo-stone::before {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  border: 2px solid var(--ui-accent);
  opacity: 0;
  animation: capture-ring 560ms ease-out forwards;
}

.neo-suggestion {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 68%;
  height: 68%;
  border-radius: 50%;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background-color: color-mix(in srgb, var(--ui-accent) 12%, transparent);
  box-shadow:
    inset 0 0 0.34em color-mix(in srgb, var(--ui-accent) 28%, transparent),
    0 0 0 2px color-mix(in srgb, var(--ui-accent) 72%, transparent),
    0 0 18px var(--ui-accent-muted);
  animation: hint-breathe 1.8s ease-in-out infinite;
}

.neo-suggestion::before,
.neo-suggestion::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.neo-suggestion::before {
  inset: -16%;
  border: 1px solid color-mix(in srgb, var(--ui-accent) 42%, transparent);
  animation: hint-orbit 1.8s ease-in-out infinite;
}

.neo-suggestion::after {
  inset: 18%;
  background-color: color-mix(in srgb, var(--ui-accent) 28%, transparent);
  box-shadow: inset 0 0 0.28em color-mix(in srgb, var(--ui-accent) 24%, transparent);
}

.neo-suggestion__core {
  position: relative;
  z-index: 1;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background-color: var(--ui-accent);
  box-shadow: 0 0 10px var(--ui-accent-muted);
}

@keyframes popIn {
  0% {
    transform: scale(0.3) translateY(-10px);
    opacity: 0;
  }

  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes winning-stone-glow {

  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }

  50% {
    transform: scale(1.13);
    filter: brightness(1.22);
  }
}

@keyframes stone-capture-out {
  0% {
    opacity: 1;
    transform: scale(1);
    filter: brightness(1);
  }

  38% {
    opacity: 1;
    transform: scale(1.12);
    filter: brightness(1.22) saturate(1.12);
  }

  100% {
    opacity: 0;
    transform: scale(0.18);
    filter: brightness(0.7) blur(2px);
  }
}

@keyframes capture-ring {
  0% {
    opacity: 0;
    transform: scale(0.62);
  }

  30% {
    opacity: 0.7;
  }

  100% {
    opacity: 0;
    transform: scale(1.48);
  }
}

@keyframes hint-breathe {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.96);
    opacity: 0.78;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
}

@keyframes hint-orbit {

  0%,
  100% {
    transform: scale(0.94);
    opacity: 0.35;
  }

  50% {
    transform: scale(1.08);
    opacity: 0.72;
  }
}

.sidebar-card {
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-sizing: border-box;
  background-color: var(--neo-sunken-fill);
  box-shadow:
    inset 0 0 0.8em var(--neo-sunken-hole),
    inset 0 0.5em 0.4em var(--neo-sunken-hole),
    inset 0 2em 1em var(--neo-sunken-depth),
    0 -0.25em 0.25em var(--neo-sunken-edge-top),
    0 0.25em 0.25em var(--neo-sunken-edge-bottom);
}

.sidebar-card p {
  margin: 0 0 var(--space-3);
  line-height: 1.45;
  color: var(--neo-text-muted);
}

.sidebar-card p:last-child {
  margin-bottom: 0;
}

.sidebar-card--placeholder {
  flex: 1;
}

.game-sidebar--left .sidebar-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.sidebar-card--history {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.panel-header h3 {
  margin: var(--space-2) 0 0;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--neo-text);
}

.panel-kicker {
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-accent);
}

/* ── AI debug telemetry ───────────────────────────────────── */

.ai-debug-card {
  flex: 0 0 auto;
  padding: var(--space-5);
}

.debug-header {
  margin-bottom: var(--space-3);
}

.debug-total {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--ui-accent);
  background-color: var(--neo-raised-fill);
  box-shadow:
    inset 0 0.1em 0.1em var(--neo-raised-highlight),
    inset 0 -0.1em 0.1em var(--neo-raised-shadow),
    0 0.24em 0.18em var(--neo-raised-drop-soft);
}

.debug-total small {
  font-size: var(--text-xs);
  color: var(--neo-text-muted);
}

.debug-bars {
  display: grid;
  gap: var(--space-2);
}

.debug-bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.debug-bar-row>span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--neo-text-muted);
}

.debug-bar-row code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--neo-text);
}

.debug-bar {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
  background-color: var(--ui-scroll-track);
  box-shadow:
    inset 0 0 0.35em var(--neo-sunken-hole),
    inset 0 1px 2px var(--neo-sunken-depth);
}

.debug-bar>span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background-color: var(--ui-accent);
  box-shadow: 0 0 10px var(--ui-accent-muted);
  transition: width 420ms cubic-bezier(0.4, 0, 0.2, 1);
}

.debug-foot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  padding-top: 4px;
}

.debug-foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--neo-text-muted);
}

.debug-foot code {
  font-family: var(--font-mono);
  color: var(--neo-text);
}

/* ── Player turn indicator ────────────────────────────────── */

.players-row {
  flex: 0 0 auto;
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.player-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3) var(--space-3);
  border-radius: var(--radius-lg);
  transition: opacity 280ms ease, transform 240ms ease, box-shadow 280ms ease;
  opacity: 0.35;
  background-color: var(--neo-sunken-fill);
  box-shadow:
    inset 0 0 0.6em var(--neo-sunken-hole),
    inset 0 0.4em 0.35em var(--neo-sunken-depth);
}

.player-card--active {
  opacity: 1;
  transform: translateY(-4px);
  background-color: var(--neo-raised-fill);
  box-shadow:
    inset 0 0.12em 0.12em var(--neo-raised-highlight),
    inset 0 -0.12em 0.12em var(--neo-raised-shadow),
    0 0.5em 0.4em var(--neo-raised-drop-soft),
    0 1em 0.9em var(--neo-raised-drop-deep);
}

.player-stone {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transition: box-shadow 280ms ease;
  box-shadow:
    rgba(0, 0, 0, 0.4) 0.3vmin 0.4vmin 0.6vmin,
    inset rgba(255, 255, 255, 0.3) 0px 0.2vmin 0.4vmin -0.1vmin,
    inset rgba(0, 0, 0, 0.2) 0px -0.2vmin 0.4vmin -0.1vmin;
}

.player-stone--blue {
  background: var(--stone-p1-bg);
}

.player-stone--pink {
  background: var(--stone-p2-bg);
}

.player-card--active .player-stone--blue {
  box-shadow:
    0 0 0 3px rgba(140, 170, 238, 0.6),
    0 0 0 7px rgba(140, 170, 238, 0.12),
    rgba(0, 0, 0, 0.4) 0.3vmin 0.4vmin 0.6vmin,
    inset rgba(255, 255, 255, 0.3) 0px 0.2vmin 0.4vmin -0.1vmin,
    inset rgba(0, 0, 0, 0.2) 0px -0.2vmin 0.4vmin -0.1vmin;
  animation: stone-pulse 2.6s ease-in-out infinite;
}

.player-card--active .player-stone--pink {
  box-shadow:
    0 0 0 3px rgba(244, 184, 228, 0.6),
    0 0 0 7px rgba(244, 184, 228, 0.12),
    rgba(0, 0, 0, 0.4) 0.3vmin 0.4vmin 0.6vmin,
    inset rgba(255, 255, 255, 0.3) 0px 0.2vmin 0.4vmin -0.1vmin,
    inset rgba(0, 0, 0, 0.2) 0px -0.2vmin 0.4vmin -0.1vmin;
  animation: stone-pulse 2.6s ease-in-out infinite;
}

@keyframes stone-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

.player-name {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--neo-text);
}

.player-captures {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--neo-text-muted);
}

.status-msg {
  flex: 0 0 auto;
  margin: 0;
  text-align: center;
  font-weight: 600;
  min-height: 1.35em;
  color: var(--neo-text-muted);
}

#suggestion {
  flex: 0 0 auto;
  min-height: 1.2em;
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  text-align: center;
}

/* ── Game actions ─────────────────────────────────────────── */

.game-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-3);
}

.game-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--neo-text);
}

.game-action-btn svg {
  flex: 0 0 auto;
  width: var(--icon-md);
  height: var(--icon-md);
  color: var(--ui-accent);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.16));
}

.game-action-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-action-btn--accent svg {
  color: var(--ui-accent-strong);
}

.game-action-btn:disabled svg,
.game-action-btn:disabled span {
  opacity: 0.6;
}

.history-section {
  display: flex;
  flex: 1 1 150px;
  min-height: 0;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--neo-sunken-hole);
  overflow: hidden;
}

.sidebar-card--history .history-section {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.history-header {
  gap: var(--space-3);
}

.history-header h3 {
  font-size: var(--text-lg);
}

.history-latest-btn {
  min-height: 26px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--ui-accent);
  box-shadow:
    inset 0 0.1em 0.1em var(--neo-raised-highlight),
    inset 0 -0.1em 0.1em var(--neo-raised-shadow),
    0 0.24em 0.18em var(--neo-raised-drop-soft);
}

.history-latest-btn:disabled {
  opacity: 0.45;
}

.move-history-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 8px 2px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--ui-scroll-thumb) var(--ui-scroll-track);
}

.move-history-list::-webkit-scrollbar {
  width: 9px;
}

.move-history-list::-webkit-scrollbar-track {
  border-radius: 99px;
  background-color: var(--ui-scroll-track);
  box-shadow: inset 0 0 0.35em var(--neo-sunken-hole);
}

.move-history-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background-color: var(--ui-scroll-thumb);
  background-clip: content-box;
}

.move-history-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--ui-scroll-thumb-hover);
}

.history-move {
  display: grid;
  grid-template-columns: 32px 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  border: 0;
  border-radius: 12px;
  text-align: left;
  color: var(--neo-text-muted);
  background-color: transparent;
  box-shadow: none;
}

.history-move:hover,
.history-move--preview {
  color: var(--neo-text);
  background-color: var(--neo-sunken-fill);
  box-shadow:
    inset 0 0 0.55em var(--neo-sunken-hole),
    inset 0 0.28em 0.24em var(--neo-sunken-depth),
    0 -0.08em 0.08em var(--neo-sunken-edge-top),
    0 0.08em 0.08em var(--neo-sunken-edge-bottom);
  filter: none;
}

.history-move--active {
  color: var(--neo-text);
  background-color: var(--neo-raised-fill);
  box-shadow:
    inset 0 0.12em 0.12em var(--neo-raised-highlight),
    inset 0 -0.12em 0.12em var(--neo-raised-shadow),
    0 0.35em 0.28em var(--neo-raised-drop-soft);
}

.history-move--active .history-move__num {
  color: var(--ui-accent);
}

.history-move__num {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.72rem;
  font-weight: 800;
}

.history-move__stone {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow:
    rgba(0, 0, 0, 0.36) 0 2px 4px,
    inset rgba(255, 255, 255, 0.32) 0 1px 2px;
}

.history-move__stone--blue {
  background: var(--stone-p1-bg);
}

.history-move__stone--pink {
  background: var(--stone-p2-bg);
}

.history-move__coord {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 700;
}

.history-move__badges {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 26px;
}

.history-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  box-sizing: border-box;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  color: var(--neo-text);
  background-color: var(--neo-sunken-fill);
  box-shadow:
    inset 0 0 0.35em var(--neo-sunken-hole),
    inset 0 0.18em 0.16em var(--neo-sunken-depth);
}

.history-badge--capture {
  color: var(--ui-accent);
}

.history-badge--threat {
  color: var(--ui-accent-strong);
  box-shadow:
    0 0 0 1px var(--ui-accent-muted),
    inset 0 0 0.35em var(--neo-sunken-hole),
    inset 0 0.18em 0.16em var(--neo-sunken-depth);
}

.history-empty {
  margin: 0;
  padding: 10px 2px;
  font-size: 0.8rem;
  color: var(--neo-text-muted);
}

.history-undo-btn {
  flex: 0 0 auto;
  margin-top: 12px;
}

/* ── AI stats ─────────────────────────────────────────────── */

.ai-section {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--neo-sunken-hole);
  border-bottom: 1px solid var(--neo-sunken-hole);
}

.ai-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.ai-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--neo-text-muted);
}

.ai-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--neo-text);
}

.depth-track {
  height: 6px;
  border-radius: 99px;
  background-color: var(--ui-scroll-track);
  box-shadow:
    inset 0 0 0.4em var(--neo-sunken-hole),
    inset 0 1px 2px var(--neo-sunken-depth);
  overflow: hidden;
}

.depth-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--ui-accent);
  box-shadow: 0 0 10px var(--ui-accent-muted);
  transition: width 450ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Lives SVG ────────────────────────────────────────────── */

.lives-svg {
  display: block;
  width: min(90px, 100%);
  overflow: visible;
}

.life {
  transition: opacity 400ms ease, r 400ms ease;
}

.life--blue {
  fill: var(--stone-p1-color);
}

.life--pink {
  fill: var(--stone-p2-color);
}

.life--lost {
  opacity: 0.14;
  r: 4.5;
}

/* ── Win modal ────────────────────────────────────────────── */

.win-modal[hidden] {
  display: none;
}

.win-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  box-sizing: border-box;
}

.win-modal__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.08), transparent 36%),
    rgba(18, 19, 30, 0.24);
  -webkit-backdrop-filter: blur(7px) saturate(1.08);
  backdrop-filter: blur(7px) saturate(1.08);
  animation: modal-fade-in 220ms ease-out both;
}

.win-dialog {
  position: relative;
  width: min(100%, 360px);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  text-align: center;
  overflow: hidden;
  background-color: var(--neo-raised-fill);
  color: var(--neo-text);
  box-shadow:
    inset 0 0.18em 0.16em var(--neo-raised-highlight),
    inset 0 -0.16em 0.16em var(--neo-raised-shadow),
    0 1.4em 2.4em rgba(0, 0, 0, 0.34);
  animation: dialog-pop-in 420ms cubic-bezier(0.2, 0.9, 0.25, 1.15) both;
}

.win-dialog::before {
  content: "";
  position: absolute;
  inset: -35% -20% auto;
  height: 180px;
  background: linear-gradient(90deg, transparent, var(--winner-color), transparent);
  opacity: 0.14;
  transform: rotate(-8deg);
}

.win-dialog__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
}

.win-dialog__close svg {
  width: 17px;
  height: 17px;
  color: var(--neo-text-muted);
}

.win-burst {
  position: absolute;
  inset: 18px 42px auto;
  height: 88px;
  pointer-events: none;
}

.win-burst span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 26px;
  border-radius: 99px;
  background-color: var(--winner-color);
  transform-origin: 50% 74px;
  opacity: 0;
  animation: burst-pop 760ms ease-out 120ms both;
}

.win-burst span:nth-child(1) {
  --burst-rotation: 0deg;
}

.win-burst span:nth-child(2) {
  --burst-rotation: 60deg;
}

.win-burst span:nth-child(3) {
  --burst-rotation: 120deg;
}

.win-burst span:nth-child(4) {
  --burst-rotation: 180deg;
}

.win-burst span:nth-child(5) {
  --burst-rotation: 240deg;
}

.win-burst span:nth-child(6) {
  --burst-rotation: 300deg;
}

.win-stone {
  position: relative;
  z-index: 1;
  width: 74px;
  height: 74px;
  margin: 10px auto 18px;
  border-radius: 50%;
  background: var(--winner-bg);
  box-shadow:
    0 0 0 8px color-mix(in srgb, var(--winner-color) 16%, transparent),
    0 0 38px color-mix(in srgb, var(--winner-color) 42%, transparent),
    rgba(0, 0, 0, 0.42) 0.5vmin 0.7vmin 1vmin,
    inset rgba(255, 255, 255, 0.34) 0 0.35vmin 0.55vmin -0.1vmin,
    inset rgba(0, 0, 0, 0.22) 0 -0.35vmin 0.55vmin -0.1vmin;
  animation: winner-stone-pop 620ms cubic-bezier(0.2, 0.9, 0.24, 1.2) both;
}

.win-kicker {
  position: relative;
  z-index: 1;
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--winner-color);
}

.win-dialog h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: var(--text-2xl);
  color: var(--neo-text);
}

.win-message {
  position: relative;
  z-index: 1;
  margin: var(--space-2) 0 var(--space-5);
  color: var(--neo-text-muted);
}

.win-new-game-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 48px;
}

.win-new-game-btn svg {
  width: var(--icon-md);
  height: var(--icon-md);
  color: var(--winner-color);
}

.win-modal--blue {
  --winner-bg: var(--stone-p1-bg);
  --winner-color: var(--stone-p1-color);
}

.win-modal--pink {
  --winner-bg: var(--stone-p2-bg);
  --winner-color: var(--stone-p2-color);
}

.win-modal--draw {
  --winner-bg: linear-gradient(135deg, var(--stone-p1-color), var(--stone-p2-color));
  --winner-color: var(--neo-text);
}

/* ── Rules modal ──────────────────────────────────────────── */

.rules-modal[hidden] {
  display: none;
}

.rules-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  box-sizing: border-box;
}

.rules-modal__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.08), transparent 38%),
    rgba(18, 19, 30, 0.24);
  -webkit-backdrop-filter: blur(7px) saturate(1.08);
  backdrop-filter: blur(7px) saturate(1.08);
  animation: modal-fade-in 220ms ease-out both;
}

.rules-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(760px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 48px));
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  box-sizing: border-box;
  overflow: hidden;
  background-color: var(--neo-raised-fill);
  color: var(--neo-text);
  box-shadow:
    inset 0 0.18em 0.16em var(--neo-raised-highlight),
    inset 0 -0.16em 0.16em var(--neo-raised-shadow),
    0 1.4em 2.4em rgba(0, 0, 0, 0.34);
  animation: dialog-pop-in 360ms cubic-bezier(0.2, 0.9, 0.25, 1.12) both;
}

.rules-dialog__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 3;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
}

.rules-dialog__close svg {
  width: 18px;
  height: 18px;
  color: var(--neo-text-muted);
}

.rules-slide {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.rules-slide--active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  animation: rules-slide-in 240ms ease-out both;
}

.rules-slide__header {
  flex: 0 0 auto;
  min-height: 78px;
  padding: 2px 48px var(--space-3) 0;
  box-sizing: border-box;
}

.rules-slide__header h2 {
  margin: var(--space-2) 0 0;
  font-size: var(--text-2xl);
  line-height: 1.1;
  color: var(--neo-text);
}

.rules-slide__body {
  position: relative;
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 4px 22px 8px 0;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--ui-scroll-thumb) var(--ui-scroll-track);
}

.rules-slide__body::-webkit-scrollbar {
  width: 10px;
}

.rules-slide__body::-webkit-scrollbar-track {
  border-radius: 99px;
  background-color: var(--ui-scroll-track);
  box-shadow: inset 0 0 0.35em var(--neo-sunken-hole);
}

.rules-slide__body::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background-color: var(--ui-scroll-thumb);
  background-clip: content-box;
}

.rules-slide__body::-webkit-scrollbar-thumb:hover {
  background-color: var(--ui-scroll-thumb-hover);
}

.rules-slide__body p {
  max-width: 640px;
  margin: 0 0 var(--space-4);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--neo-text);
}

.rules-list {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
  padding-left: var(--space-5);
  color: var(--neo-text-muted);
}

.rules-list li::marker {
  color: var(--ui-accent);
}

.rules-visual {
  display: grid;
  place-items: center;
  margin: 8px 0 22px;
}

.rules-visual--stack {
  gap: 16px;
}

.rules-demo-board {
  --rule-cols: 5;
  --rule-rows: 5;
  --rule-cell: clamp(34px, 5.4vh, 48px);
  display: grid;
  grid-template-columns: repeat(var(--rule-cols), var(--rule-cell));
  grid-template-rows: repeat(var(--rule-rows), var(--rule-cell));
  width: fit-content;
  height: fit-content;
  padding: calc(var(--rule-cell) * 0.35);
  border-radius: 24px;
  box-sizing: border-box;
  background-color: transparent;
  background-image:
    linear-gradient(to right,
      transparent calc(50% - 0.75px),
      var(--board-line) calc(50% - 0.75px),
      var(--board-line) calc(50% + 0.75px),
      transparent calc(50% + 0.75px)),
    linear-gradient(to bottom,
      transparent calc(50% - 0.75px),
      var(--board-line) calc(50% - 0.75px),
      var(--board-line) calc(50% + 0.75px),
      transparent calc(50% + 0.75px));
  background-position:
    calc(var(--rule-cell) * 0.35) 0,
    0 calc(var(--rule-cell) * 0.35);
  background-size:
    var(--rule-cell) 100%,
    100% var(--rule-cell);
  background-repeat: repeat-x, repeat-y;
}

.rules-demo-cell {
  cursor: default;
}

.rules-demo-cell::before,
.rules-demo-cell::after,
.rules-demo-cell:hover::after,
.rules-demo-cell:hover .neo-stone::after {
  display: none;
}

.rules-demo-cell .neo-stone {
  animation-duration: 320ms;
}

.rules-demo-stone--soft {
  opacity: 0.38;
}

.rules-demo-stone--target {
  outline: 3px solid var(--ui-accent);
  outline-offset: 3px;
}

.rules-capture-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-width: 142px;
  margin: 0 auto;
  padding: 16px 18px 14px;
  border-radius: 18px;
  background-color: var(--neo-sunken-fill);
  box-shadow:
    inset 0 0 0.6em var(--neo-sunken-hole),
    inset 0 0.4em 0.35em var(--neo-sunken-depth);
}

.rules-capture-card .player-stone {
  width: 42px;
  height: 42px;
}

.rules-capture-card .player-name {
  line-height: 1;
}

.rules-capture-card .lives-svg {
  width: 90px;
}

.rules-capture-card .player-captures {
  margin-top: -2px;
}

.rules-progress {
  --rules-progress-fill: 0%;
  --rules-progress-start: 10%;
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  margin: 24px 78px 18px;
  padding: 0;
}

.rules-progress::before {
  content: "";
  position: absolute;
  left: var(--rules-progress-start);
  right: var(--rules-progress-start);
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background-color: var(--ui-scroll-track);
  box-shadow: inset 0 1px 2px var(--neo-sunken-depth);
}

.rules-progress::after {
  content: "";
  position: absolute;
  left: var(--rules-progress-start);
  top: 50%;
  width: var(--rules-progress-fill);
  height: 2px;
  border-radius: 99px;
  transform: translateY(-50%);
  background-color: var(--ui-accent);
  box-shadow: 0 0 10px var(--ui-accent-muted);
  transition: width 260ms ease;
}

.rules-step {
  position: relative;
  z-index: 1;
  justify-self: center;
  display: grid;
  place-items: center;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 50%;
  color: var(--ui-scroll-track);
  background-color: var(--neo-raised-fill);
  box-shadow:
    inset 0 0.08em 0.08em var(--neo-raised-highlight),
    inset 0 -0.08em 0.08em var(--neo-raised-shadow),
    0 0.18em 0.16em var(--neo-raised-drop-soft);
}

.rules-step::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
  opacity: 0.9;
  transition: background-color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.rules-step--done,
.rules-step--active {
  color: var(--ui-accent);
}

.rules-step--active {
  color: var(--ui-accent);
  box-shadow:
    0 0 0 5px var(--ui-accent-muted),
    inset 0 0.08em 0.08em var(--neo-raised-highlight),
    inset 0 -0.08em 0.08em var(--neo-raised-shadow),
    0 0.22em 0.18em var(--neo-raised-drop-soft);
}

.rules-step--active::after {
  transform: scale(1.12);
}

.rules-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
}

.rules-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 130px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 16px;
  color: var(--neo-text);
}

.rules-nav-btn svg {
  width: 19px;
  height: 19px;
  color: var(--ui-accent);
}

.rules-nav-btn--primary {
  color: var(--neo-bg);
  background-color: var(--ui-accent);
}

.rules-nav-btn--primary svg {
  color: currentColor;
}

@keyframes rules-slide-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes dialog-pop-in {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.92);
  }

  65% {
    opacity: 1;
    transform: translateY(-3px) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes winner-stone-pop {
  0% {
    opacity: 0;
    transform: scale(0.35) rotate(-18deg);
  }

  70% {
    opacity: 1;
    transform: scale(1.08) rotate(3deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes burst-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--burst-rotation, 0deg)) scaleY(0.2);
  }

  40% {
    opacity: 0.8;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -120%) rotate(var(--burst-rotation, 0deg)) scaleY(1);
  }
}

@media (max-width: 1320px) {
  #game {
    grid-template-columns: 1fr;
    gap: 20px;

    /* Sur trois colonnes, `height: calc(100vh - 88px)` et `overflow: hidden`
       tiennent tout dans un écran. En colonne unique, les panneaux et le
       plateau se partageaient cette même hauteur figée : le plateau tombait à
       195 px et se retrouvait coupé. Ici la page défile. */
    height: auto;
    min-height: calc(100vh - 88px);
    overflow: visible;
  }

  .game-sidebar,
  .board-stage {
    height: auto;
  }

  /* Le plateau est ce qu'on vient voir : il passe avant les panneaux.
     Repasser à `order: 1` pour retrouver l'ordre d'origine. */
  .board-stage {
    order: -1;
  }

  /* Le carré est piloté par la hauteur disponible en mode trois colonnes.
     En colonne unique c'est l'inverse : la largeur est abondante, la hauteur
     manque. On borne à 78vh pour que le plateau tienne dans l'écran. */
  #board-coords {
    width: min(100%, 78vh);
    height: auto;
    max-height: none;
  }

  .game-sidebar--right {
    display: none;
  }
}

@media (max-width: 720px) {
  .rules-modal {
    padding: 14px;
  }

  .rules-dialog {
    width: calc(100vw - 28px);
    height: calc(100vh - 28px);
    padding: 24px 18px 18px;
    border-radius: 24px;
  }

  .rules-slide__header {
    min-height: 68px;
    padding-right: 42px;
  }

  .rules-slide__header h2 {
    font-size: 1.5rem;
  }

  .rules-slide__body p {
    font-size: 0.94rem;
  }

  .rules-demo-board {
    --rule-cell: min(10vw, 40px);
    border-radius: 20px;
  }

  .rules-progress {
    margin: 20px 28px 14px;
  }

  .rules-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .rules-nav-btn {
    min-width: 0;
  }
}