/* ===== Gomoku — game UI =====
   Chrome colours come from the center's shared --gc-* tokens (base.css), so the
   page follows light/dark automatically. The board itself is a fixed warm wood
   field with glossy black and white stones, drawn on canvas. */

.wrap {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: clamp(24px, 6vw, 48px) 20px 40px;
  text-align: center;
}
.head .title { margin: 0; font-size: clamp(26px, 6vw, 34px); letter-spacing: -.02em; }
.head .sub { margin: 4px 0 0; color: var(--gc-text-muted); font-weight: 600; min-height: 1.4em; }

/* Mode / difficulty segmented controls */
.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--gc-surface-2); border: 1px solid var(--gc-border); border-radius: 999px; }
/* The class display beats the UA [hidden] rule, so restore it explicitly. */
.segmented[hidden] { display: none; }
.segmented--sub { margin-top: -8px; }
.seg {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px;
  background: transparent; color: var(--gc-text-muted);
  transition: background .15s ease, color .15s ease;
}
.seg--sm { padding: 5px 12px; font-size: 12.5px; }
.seg:hover { color: var(--gc-text); }
.seg[aria-selected="true"] { background: var(--gc-accent); color: var(--gc-on-accent); box-shadow: var(--gc-shadow); }
.seg:focus-visible { outline: none; box-shadow: var(--gc-ring); }

/* Stone counts */
.scores { display: flex; gap: 10px; width: 100%; }
.score {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  padding: 9px 8px;
  background: var(--gc-surface); border: 1px solid var(--gc-border); border-radius: 12px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.score.is-turn { border-color: var(--gc-accent); box-shadow: var(--gc-ring); }
.score__k { font-size: 12px; color: var(--gc-text-muted); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.score__v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stone { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.stone--b { background: radial-gradient(circle at 35% 30%, #55616d, #14181d 62%, #05070a); }
.stone--w { background: radial-gradient(circle at 35% 30%, #ffffff, #e8ecf2 60%, #aeb8c6); border: 1px solid var(--gc-border); }
.record { margin: -8px 0 0; font-size: 12px; color: var(--gc-text-muted); font-variant-numeric: tabular-nums; }

/* Board: square canvas, wood frame drawn by JS on the canvas itself */
.board-frame { position: relative; width: min(92vw, 480px); }
#board {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  box-shadow: var(--gc-shadow-hi);
  cursor: pointer;
  touch-action: manipulation;
}
#board:focus-visible { outline: none; box-shadow: var(--gc-shadow-hi), var(--gc-ring); }

/* Controls */
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--gc-border); background: var(--gc-surface); color: var(--gc-text);
  transition: transform .06s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover { border-color: var(--gc-accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--gc-ring); }
.btn:disabled { opacity: .45; cursor: default; }
.btn--primary { background: var(--gc-accent); border-color: var(--gc-accent); color: var(--gc-on-accent); }
.btn--primary:hover { filter: brightness(1.05); }

/* ---------- Rules modal ----------
   The full-screen overlay scrolls, never the card, so no scrollbar gutter
   ever sits inside the panel. */
.modal {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 12, 20, .5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal__panel {
  position: relative; z-index: 1;
  margin: auto;                    /* centres, and a too-tall card scrolls in from the top */
  width: min(94vw, 520px);
  border-radius: 16px;
  background: var(--gc-surface);
  border: 1px solid var(--gc-border);
  box-shadow: var(--gc-shadow-hi);
  color: var(--gc-text);
}
.modal__head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--gc-border); }
.modal__head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal__x {
  margin-left: auto; border: 0; background: transparent; cursor: pointer;
  font-size: 26px; line-height: 1; padding: 0 4px; color: var(--gc-text-muted);
}
.modal__x:hover { color: var(--gc-text); }
.modal__body { padding: 6px 20px 4px; font-size: 14px; line-height: 1.6; }
.modal__lead { margin: 10px 0 12px; }
.modal__body h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--gc-accent); }
.modal__body ul { margin: 0 0 6px; padding-left: 20px; }
.modal__body li { margin: 3px 0; }
.modal__foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; }
kbd {
  font: 600 12px/1.4 ui-monospace, "Segoe UI", monospace;
  padding: 1px 6px; border-radius: 5px;
  color: var(--gc-text); background: var(--gc-surface-2);
  border: 1px solid var(--gc-border);
}

@media (prefers-reduced-motion: reduce) {
  .btn, .seg, .score { transition: none; }
}
