/* ===== Reversi — game UI =====
   Chrome colours come from the center's shared --gc-* tokens (base.css), so the
   page follows light/dark automatically. The board itself keeps the classic
   green felt field with black and white discs. */

.wrap {
  max-width: 520px;
  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); }

/* Disc 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; }
.chip { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.chip--b { background: radial-gradient(circle at 35% 30%, #55616d, #14181d 62%, #05070a); }
.chip--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 */
.board-frame { position: relative; width: min(92vw, 440px); }
.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1 / 1;
  padding: 9px;
  border-radius: 16px;
  background: linear-gradient(160deg, #249063, #14603f);
  box-shadow: var(--gc-shadow-hi), inset 0 0 0 1px rgba(0, 0, 0, .25);
}
.cell {
  position: relative;
  appearance: none; border: 0; padding: 0; margin: 0;
  background: transparent; cursor: default;
  /* hairline field lines */
  box-shadow: inset 0 0 0 .5px rgba(4, 32, 20, .55);
  border-radius: 3px;
  /* gives the disc flip its depth */
  perspective: 420px;
}
.cell--legal { cursor: pointer; }
.cell--legal:hover { background: rgba(255, 255, 255, .07); }
.cell:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gc-accent); }

/* Legal-move hint dot */
.cell--hint::after {
  content: "";
  position: absolute; inset: 37%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .42);
  animation: rv-hint 1.5s ease-in-out infinite;
}
.board[data-cur="2"] .cell--hint::after { background: rgba(6, 26, 16, .45); }
@keyframes rv-hint { 50% { transform: scale(1.5); opacity: .55; } }

/* Last played square */
.cell--last { box-shadow: inset 0 0 0 2px var(--gc-accent); }

/* One permanent disc per cell: the colour is a 3D rotation, so a flip is a
   real coin turn instead of a swapped element. */
.disc {
  position: absolute; inset: 11%;
  transform-style: preserve-3d;
  transition: transform .42s cubic-bezier(.45, .05, .35, 1);
  opacity: 0;
  pointer-events: none;
}
.disc.is-on { opacity: 1; }
.disc[data-c="w"] { transform: rotateY(180deg); }
.disc.no-trans { transition: none; }
.disc__face {
  position: absolute; inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.disc__face--b { background: radial-gradient(circle at 35% 28%, #57636f, #171c22 58%, #05070a); box-shadow: 0 2px 4px rgba(0, 0, 0, .45); }
.disc__face--w {
  background: radial-gradient(circle at 35% 28%, #ffffff, #eaeef4 55%, #b3bdca);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .35);
  transform: rotateY(180deg);
}
/* Freshly played disc springs in (faces animate, so the flip is untouched). */
.disc.is-new .disc__face { animation: rv-pop .22s ease; }
@keyframes rv-pop { from { transform: scale(.55); } }

/* 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) {
  .disc { transition: none; }
  .cell--hint::after, .disc.is-new .disc__face { animation: none; }
}
