/* Checkers on bozcode.com. A light page (the house style) with the board as
   the one dark, rich object on it. Fonts come from /static/css/fonts.css. */

:root {
  color-scheme: light;
  --page: #e6ecf5;
  --page-hi: #f8fbff;
  --panel: #ffffff;
  --panel-2: #f3f6fb;
  --line: #d6deea;
  --line-strong: #7b8aa0;
  --ink: #12203a;
  --ink-2: #44546c;
  --accent: #2459c4;
  --accent-ink: #1a3f8f;
  --accent-soft: #e1eafb;
  --gold: #b88a2c;
  --sapphire: #2f6fd0;
  --navy: #0f1d38;
  --warn-bg: #fff3d9;
  --warn-ink: #6e4700;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(16 32 64 / 6%), 0 10px 28px rgb(16 32 64 / 7%);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --display: Syne, Inter, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  background:
    radial-gradient(900px 600px at 28% 18%, var(--page-hi) 0%, transparent 62%),
    radial-gradient(700px 500px at 85% 90%, #dbe5f6 0%, transparent 60%),
    linear-gradient(180deg, #e9eff7 0%, #dfe7f2 100%);
}

.visually-hidden {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

h1, h2, h3, p, ul, ol { margin: 0; }

/* ── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 1260px; margin: 0 auto; padding: 18px 20px 14px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { filter: drop-shadow(0 4px 10px rgb(15 29 56 / 25%)); }
.brand h1 {
  font: 800 clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem)/1.05 var(--display);
  letter-spacing: -0.01em; color: var(--navy);
}
.sub { color: var(--ink-2); font-size: .95rem; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-block-size: 44px; padding: 0 1.05rem; border-radius: 12px;
  border: 1px solid transparent; font: 600 .95rem/1 var(--sans); cursor: pointer;
  color: var(--ink); background: transparent; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:focus-visible, .seg input:focus-visible + span, .toggle input:focus-visible + span::before, summary:focus-visible {
  outline: 3px solid #f2b631; outline-offset: 2px;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #3b7ae0 0%, #2459c4 55%, #1d4cab 100%);
  border-color: #1a4499;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 30%), 0 2px 6px rgb(36 89 196 / 35%);
  text-shadow: 0 1px 0 rgb(0 0 0 / 20%);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #3470d6 0%, #1f4fb3 60%, #1a4499 100%); }
.btn-secondary { background: var(--panel); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.btn-quiet { color: var(--ink); }
.btn-quiet:hover { background: rgb(255 255 255 / 60%); }
.btn-quiet[aria-pressed="false"] { color: var(--ink-2); }

/* ── layout ──────────────────────────────────────────────────────────── */
.table {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 370px);
  gap: 28px; align-items: start;
  max-width: 1260px; margin: 0 auto; padding: 4px 20px 28px;
}
.stage {
  width: 100%;
  /* the board plus both player strips fit the window height */
  max-width: min(800px, max(320px, calc(100dvh - 290px)));
  justify-self: center;
  display: flex; flex-direction: column; gap: 12px;
}

/* ── seats (player strips above and below the board) ─────────────────── */
.seat {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "chip text pill" "tray tray tray";
  align-items: center; column-gap: 12px; row-gap: 6px;
  padding: 10px 14px; border-radius: 14px;
  background: rgb(255 255 255 / 72%); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgb(16 32 64 / 5%);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease), background-color .25s var(--ease);
}
.seat .chip { grid-area: chip; }
.seat-text { grid-area: text; display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.seat-name { font-weight: 700; font-size: 1.02rem; }
.seat-detail { color: var(--ink-2); font-size: .85rem; overflow-wrap: anywhere; }
.turn-pill {
  grid-area: pill; justify-self: end;
  font: 700 .78rem/1 var(--sans); letter-spacing: .02em; text-transform: uppercase;
  padding: .45rem .7rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink);
}
.seat.thinking .turn-pill { background: var(--warn-bg); color: var(--warn-ink); }
.seat.thinking .turn-pill::after { content: ""; display: inline-block; width: 1.1em; text-align: left; animation: dots 1.2s steps(4) infinite; }
.seat.active { background: #fff; border-color: #9db8e8; box-shadow: 0 0 0 3px rgb(47 111 208 / 14%), 0 6px 18px rgb(16 32 64 / 8%); }
.tray { grid-area: tray; display: flex; flex-wrap: wrap; gap: 3px; min-height: 0; }
.tray:empty { display: none; }

/* CSS pieces for seats, trays and the settings */
.chip {
  display: inline-block; flex: none; width: 18px; height: 18px; border-radius: 50%;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 22%), 0 1px 2px rgb(0 0 0 / 25%);
}
.chip.dark { background: radial-gradient(circle at 36% 30%, #a7cbff 0%, #4583e6 32%, #1c4ca3 72%, #12377e 100%); }
.chip.light { background: radial-gradient(circle at 36% 30%, #fff 0%, #f6f1e6 42%, #dbd1bd 82%, #c4b8a1 100%); }
.chip.big { width: 36px; height: 36px; box-shadow: inset 0 -3px 0 rgb(0 0 0 / 22%), 0 2px 5px rgb(0 0 0 / 25%); }
.chip.mini { width: 13px; height: 13px; box-shadow: inset 0 -1.5px 0 rgb(0 0 0 / 22%); }

/* ── the board ───────────────────────────────────────────────────────── */
.board-wrap { position: relative; width: 100%; aspect-ratio: 1; }
.board {
  position: relative; display: block; width: 100%; height: 100%;
  filter: drop-shadow(0 22px 34px rgb(15 29 56 / 34%)) drop-shadow(0 4px 8px rgb(15 29 56 / 20%));
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.board-glow {
  position: absolute; inset: -7%; border-radius: 50%;
  background: radial-gradient(closest-side, rgb(47 111 208 / 34%), transparent 72%);
  opacity: 1; transition: background .6s var(--ease), opacity .6s var(--ease);
  pointer-events: none;
}
.board-wrap[data-turn="light"] .board-glow { background: radial-gradient(closest-side, rgb(255 226 170 / 70%), transparent 72%); }
.board-wrap[data-turn="over"] .board-glow { opacity: .35; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
.confetti.on { display: block; }

.board .marks, .board .pieces, .board .fx, .board .hint-layer, .board .numbers, .board .focus-ring { pointer-events: none; }
.board .sq { outline: none; }
.board-wrap:not(.busy) .sq { cursor: pointer; }
.focus-ring { fill: none; stroke: #ffd36b; stroke-width: 6; opacity: 0; transition: opacity .12s; }
.board.kbd:focus-within .focus-ring { opacity: 1; }
.num { font: 600 15px var(--mono); fill: #cbd8ee; opacity: 0; transition: opacity .2s; }
.board.show-numbers .num { opacity: .92; }
.frame-label { font: 700 17px var(--display); letter-spacing: 8px; fill: #dcb563; opacity: .78; }

.last { fill: rgb(140 190 255 / 26%); }
.last-path { fill: none; stroke: rgb(214 230 255 / 62%); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 15; }
.sel-sq { fill: rgb(120 180 255 / 22%); }
.movable, .selected, .target-dot, .target-ring, .hint-ring { transform-box: fill-box; transform-origin: center; }
.movable { fill: rgb(150 200 255 / 10%); stroke: #a9d4ff; stroke-width: 5; animation: pulse 1.9s ease-in-out infinite; }
.movable.must { fill: rgb(255 198 92 / 14%); stroke: #ffc65c; stroke-width: 6; }
.board-wrap.flash .movable { animation: flash .45s ease-in-out 3; }
.selected { fill: none; stroke: #93d3ff; stroke-width: 6; }
.target-dot { fill: rgb(176 218 255 / 92%); animation: breathe 1.3s ease-in-out infinite; }
.target.jump .target-dot { fill: #ffc65c; }
.target-ring { fill: rgb(255 198 92 / 14%); stroke: #ffc65c; stroke-width: 5; animation: breathe 1.3s ease-in-out infinite; }

.piece .lift { transition: transform .18s var(--ease); transform-box: fill-box; transform-origin: center; }
.piece.lifted .lift { transform: translateY(-7px) scale(1.07); }
.piece.dragging .lift { transform: scale(1.14); transition: none; }
.piece.lifted .shadow, .piece.dragging .shadow { opacity: .85; }
.piece .crown { display: none; transform-box: fill-box; transform-origin: center; }
.piece.king .crown { display: inline; }

.hint { fill: none; stroke: #6fd9ff; stroke-width: 11; stroke-linecap: round; stroke-linejoin: round; opacity: .92; stroke-dasharray: 22 12; animation: march 0.9s linear infinite; }
.hint-head { fill: #6fd9ff; }
.hint-ring { fill: none; stroke: #6fd9ff; stroke-width: 5; animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: .55; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.03); } }
@keyframes breathe { 0%, 100% { transform: scale(.88); } 50% { transform: scale(1.08); } }
@keyframes flash { 0%, 100% { opacity: .4; } 50% { opacity: 1; stroke-width: 9; } }
@keyframes march { to { stroke-dashoffset: -34; } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ── panel ───────────────────────────────────────────────────────────── */
.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card h2, .settings summary { font: 700 .82rem/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }

.status { font: 700 1.3rem/1.3 var(--sans); color: var(--navy); }
.status-sub { color: var(--ink-2); font-size: .92rem; margin-top: 4px; }
.status-sub:empty { display: none; }
.status-card .btn { margin-top: 10px; }

.meter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.go-tag { font: 700 .72rem/1 var(--mono); padding: .35rem .55rem; border-radius: 999px; background: #d8f2fa; color: #0b4152; }
.meter { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.meter-end { font: 600 .78rem/1 var(--sans); color: var(--ink-2); }
.meter-track {
  position: relative; height: 14px; border-radius: 999px; overflow: hidden;
  background: linear-gradient(180deg, #f8f4ea, #ddd3bf); box-shadow: inset 0 1px 2px rgb(0 0 0 / 18%);
}
.meter-track::after { content: ""; position: absolute; left: 50%; top: 2px; bottom: 2px; width: 2px; background: rgb(18 32 58 / 35%); }
.meter-fill {
  height: 100%; width: 50%;
  background: linear-gradient(180deg, #5a93ec, #1f4fae);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 35%);
  transition: width .7s var(--ease);
}
.meter-text { font-weight: 700; margin-top: 10px; }
.readout { font: 500 .8rem/1.45 var(--mono); color: var(--ink-2); margin-top: 4px; }
.meter-card[hidden] { display: none; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.settings summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; border-radius: 8px; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { content: "▾"; font-size: 1rem; transition: transform .2s var(--ease); }
.settings:not([open]) summary::after { transform: rotate(-90deg); }
.seg { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.seg legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; padding: 0; }
.seg label { position: relative; flex: 1 1 auto; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 .7rem; border-radius: 10px; font-size: .88rem; font-weight: 600;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
  white-space: nowrap;
}
.seg label:hover span { border-color: var(--accent); background: var(--accent-soft); }
.seg input:checked + span { background: var(--accent); border-color: var(--accent-ink); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / 25%); }
.seg:disabled { opacity: .5; }
.seg:disabled label:hover span { border-color: var(--line-strong); background: var(--panel); }
.seg:disabled input:checked + span { background: var(--ink-2); border-color: var(--ink-2); }
.seg-5 label { flex: 1 1 30%; }

.toggles { display: grid; gap: 4px; margin-top: 14px; }
.toggle { position: relative; display: flex; align-items: center; min-height: 40px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle span { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.toggle span::before {
  content: ""; flex: none; width: 40px; height: 24px; border-radius: 999px;
  background: #c3ccd9 radial-gradient(circle at 12px 12px, #fff 8px, transparent 8.5px);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 20%);
  transition: background-color .2s var(--ease), background-position .2s var(--ease);
}
.toggle input:checked + span::before { background: var(--accent) radial-gradient(circle at 28px 12px, #fff 8px, transparent 8.5px); }
.fine { font-size: .82rem; color: var(--ink-2); margin-top: 10px; }

.moves {
  list-style: none; padding: 0; margin-top: 10px; max-height: 210px; overflow-y: auto;
  font: 500 .9rem/1.9 var(--mono); counter-reset: none;
}
.moves li { display: grid; grid-template-columns: 2.6em 1fr 1fr; padding: 0 6px; border-radius: 6px; }
.moves li:nth-child(odd) { background: var(--panel-2); }
.mv-n { color: var(--ink-2); }
.mv.current { color: var(--accent-ink); font-weight: 800; }
.moves:empty::before { content: "No moves yet."; font-family: var(--sans); color: var(--ink-2); }
.record { font-size: .86rem; color: var(--ink-2); margin-top: 10px; }

.foot { max-width: 1260px; margin: 0 auto; padding: 4px 20px 28px; color: var(--ink-2); font-size: .85rem; }

/* ── dialogs and toast ───────────────────────────────────────────────── */
.dlg {
  margin: auto; padding: 0; border: 0; border-radius: 20px; background: transparent;
  max-width: min(560px, calc(100vw - 32px)); color: var(--ink);
}
.dlg::backdrop { background: rgb(10 20 40 / 45%); backdrop-filter: blur(3px); }
.dlg-card { background: var(--panel); border-radius: 20px; padding: 24px 26px; box-shadow: 0 30px 60px rgb(10 20 40 / 35%); }
.dlg h2 { font: 800 1.6rem/1.15 var(--display); color: var(--navy); margin-bottom: 12px; }
.dlg h3 { font-size: 1rem; margin: 18px 0 8px; }
.rules { padding-left: 1.1rem; display: grid; gap: 8px; }
.rules li { line-height: 1.5; }
kbd { font: 600 .82rem var(--mono); padding: .05rem .4rem; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--panel-2); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.end h2 { font-size: 2rem; }
.end-reason { font-size: 1.05rem; }
.end-record { color: var(--ink-2); margin-top: 8px; }
.end-record:empty { display: none; }
.confirm-text { font-size: 1.05rem; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 10; max-width: min(520px, calc(100vw - 32px));
  transform: translate(-50%, 16px); opacity: 0;
  padding: 12px 18px; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 600;
  box-shadow: 0 12px 30px rgb(10 20 40 / 35%);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── smaller screens ─────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .table { grid-template-columns: minmax(0, 1fr); }
  .stage { max-width: min(760px, max(300px, calc(100dvh - 260px))); }
  .panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
  .controls { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 16px 10px; }
  .brand img { width: 36px; height: 36px; }
  .sub { font-size: .85rem; }
  .table { padding: 4px 16px 20px; gap: 18px; }
  .stage { max-width: 100%; gap: 8px; }
  .seat { padding: 8px 10px; column-gap: 10px; }
  .chip.big { width: 28px; height: 28px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .panel { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
