/* Mancala on bozcode.com. A light page (the house style) with a walnut board
   as the one 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 { max-width: 1240px; margin: 0 auto; padding: 4px 20px 24px; display: grid; gap: 20px; }
.stage { width: 100%; max-width: min(1180px, calc((100dvh - 250px) * 2.22)); justify-self: center; display: flex; flex-direction: column; gap: 10px; }

/* ── seats ───────────────────────────────────────────────────────────── */
.seat {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 16px; 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-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--line-strong); }
.seat.active .seat-dot { background: var(--accent); box-shadow: 0 0 0 4px rgb(36 89 196 / 18%); }
.seat-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 { 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%); }
.seat-tally { display: flex; align-items: baseline; gap: 6px; }
.seat-score { font: 800 1.6rem/1 var(--sans); color: var(--navy); font-variant-numeric: tabular-nums; min-width: 1.6ch; text-align: right; }
.seat-unit { color: var(--ink-2); font-size: .82rem; }

/* ── the board ───────────────────────────────────────────────────────── */
.board-wrap { position: relative; width: 100%; aspect-ratio: 1420 / 640; }
.board-wrap.tall { aspect-ratio: 640 / 1420; max-width: 460px; margin: 0 auto; }
.board { display: block; width: 100%; height: 100%; filter: drop-shadow(0 18px 26px rgb(40 20 5 / 30%)); user-select: none; -webkit-user-select: none; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
.confetti.on { display: block; }
.board .base, .board .marks, .board .seeds, .board .badges, .board .fx { pointer-events: none; }
.board-shadow { filter: blur(6px); }
.grain-dark { fill: none; stroke: rgb(30 14 5 / 22%); stroke-width: 2.2; }
.grain-light { fill: none; stroke: rgb(255 214 170 / 9%); stroke-width: 3; }
.board-edge { stroke: rgb(255 220 180 / 22%); stroke-width: 3; }
.board-bevel { stroke: rgb(20 8 2 / 35%); stroke-width: 2; }
.seam { stroke: rgb(20 8 2 / 45%); stroke-width: 3; stroke-dasharray: 2 0; }
.hinge { stroke: rgb(80 50 10 / 55%); stroke-width: 1.5; }
.rim { stroke: rgb(255 214 170 / 28%); stroke-width: 3; }
.pit-lit { fill: none; stroke: rgb(255 210 160 / 20%); stroke-width: 6; stroke-linecap: round; }
.pit-shade { fill: none; stroke: rgb(0 0 0 / 30%); stroke-width: 7; stroke-linecap: round; }
.hit { fill: transparent; stroke: none; outline: none; }
.hit.playable { cursor: pointer; }
.board.can-play .hit.playable { stroke: rgb(170 210 255 / 0%); stroke-width: 5; transition: stroke .15s; }
.board.can-play .hit.playable:hover, .board.can-play .hit.playable:focus-visible { stroke: rgb(170 214 255 / 85%); }
.hit:focus-visible { stroke: #ffd36b; stroke-width: 6; }
.count rect { fill: rgb(22 10 3 / 62%); stroke: rgb(255 220 180 / 20%); stroke-width: 1.5; }
.count text { font: 700 24px var(--mono); fill: #f8ead4; }
.store-count text { font-size: 28px; }
.pv-from { fill: none; stroke: #9fd0ff; stroke-width: 6; }
.pv-from.hint { stroke: #7fe7ff; stroke-dasharray: 18 10; animation: march .9s linear infinite; }
.pv-to { fill: rgb(255 214 120 / 12%); stroke: #ffd27a; stroke-width: 5; stroke-dasharray: 14 9; animation: march 1s linear infinite; }
.pv-label rect { fill: #ffd27a; }
.pv-label text { font: 800 22px var(--sans); fill: #3a2405; }
.seed { will-change: transform; }

@keyframes march { to { stroke-dashoffset: -46; } }
@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; }


.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: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); }


/* the panel: three cards side by side, stacked on narrow screens */
.panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
#meter { margin-bottom: 16px; }
#meter[hidden] + .moves-title { margin-top: 0; }
.moves { list-style: none; padding: 0; margin-top: 8px; max-height: 120px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 4px; font: 600 .85rem/1 var(--mono); }
.moves li { padding: .35rem .45rem; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); }
.moves li.north { background: #f6efe4; border-color: #e3d4bd; }
.moves li.again::after { content: " ↻"; color: var(--accent-ink); }
.moves li.current { outline: 2px solid var(--accent); }
.moves:empty::before { content: "No moves yet."; font-family: var(--sans); font-weight: 400; color: var(--ink-2); }
body[data-game="mancala"] .rules-oware, body[data-game="oware"] .rules-mancala { display: none; }

@media (max-width: 560px) {
  .topbar { padding: 12px 16px 10px; }
  .brand img { width: 36px; height: 36px; }
  .table { padding: 4px 16px 20px; gap: 14px; }
  .seat { padding: 8px 12px; gap: 10px; }
  .seat-score { font-size: 1.4rem; }
  .card { padding: 14px; }
}

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