/* Layout: one-column caller on phones (board is its own view), caller + board side by side from 900px. */
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Martian Mono"; src: url("fonts/martian-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Martian Mono"; src: url("fonts/martian-mono-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("fonts/figtree-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("fonts/figtree-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("fonts/figtree-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  /* Festive housie board: peacock ink, marigold for called numbers, gulabi rose for the latest call */
  --ground: #edf3f1;
  --surface: #ffffff;
  --surface-2: #e2ebe8;
  --ink: #0f2a30;
  --ink-2: #48616a;
  --line: #c9d8d4;
  --primary: #0e5560;
  --on-primary: #ffffff;
  --primary-hover: #0a454e;
  --called: #eba43c;
  --on-called: #2e1c00;
  --latest: #c2365a;
  --on-latest: #ffffff;
  --ok: #17663d;
  --ok-soft: #dcf0e4;
  --bad: #b3263f;
  --bad-soft: #f9e0e5;
  --focus: #c2365a;
  --shadow: 0 1px 2px rgb(15 42 48 / .08), 0 6px 20px rgb(15 42 48 / .08);
  --coin-shadow: 0 2px 0 rgb(120 70 0 / .25), 0 14px 34px rgb(150 90 0 / .28);

  --font-head: "Bricolage Grotesque", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-num: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0a2127;
    --surface: #10313a;
    --surface-2: #163c46;
    --ink: #e9f2ef;
    --ink-2: #93c6be;
    --line: #234a53;
    --primary: #f1ae48;
    --on-primary: #241500;
    --primary-hover: #f6c06c;
    --called: #f1ae48;
    --on-called: #241500;
    --latest: #f2668a;
    --on-latest: #2a0711;
    --ok: #6fd69c;
    --ok-soft: #123f2c;
    --bad: #ff8fa5;
    --bad-soft: #451a25;
    --focus: #f2668a;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    --coin-shadow: 0 2px 0 rgb(0 0 0 / .35), 0 16px 40px rgb(241 174 72 / .22);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0a2127;
  --surface: #10313a;
  --surface-2: #163c46;
  --ink: #e9f2ef;
  --ink-2: #93c6be;
  --line: #234a53;
  --primary: #f1ae48;
  --on-primary: #241500;
  --primary-hover: #f6c06c;
  --called: #f1ae48;
  --on-called: #241500;
  --latest: #f2668a;
  --on-latest: #2a0711;
  --ok: #6fd69c;
  --ok-soft: #123f2c;
  --bad: #ff8fa5;
  --bad-soft: #451a25;
  --focus: #f2668a;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  --coin-shadow: 0 2px 0 rgb(0 0 0 / .35), 0 16px 40px rgb(241 174 72 / .22);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
::selection { background: var(--called); color: var(--on-called); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* App bar */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1180px; margin: 0 auto; padding-block: 12px;
  background: var(--ground);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--ground); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand h1 { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; letter-spacing: -0.02em; white-space: nowrap; }
.bar-actions { display: flex; gap: 2px; }
@media (max-width: 419.98px) { .brand-long { display: none; } .icon-btn { width: 42px; } }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  transition: background-color .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[aria-pressed="false"] .on, .icon-btn[aria-pressed="true"] .off { display: none; }
/* Theme button shows the theme you'll switch to: a moon in light, a sun in dark */
.theme-sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-sun { display: block; } :root:not([data-theme="light"]) .theme-moon { display: none; } }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }
body { transition: background-color .25s; }
.install-btn {
  height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: .9rem;
}

/* Page frame */
.app {
  max-width: 1180px; margin: 0 auto; padding-block: 4px 32px;
  display: grid; gap: 28px;
}
@media (min-width: 900px) {
  .app { grid-template-columns: minmax(340px, 420px) 1fr; align-items: start; gap: 40px; }
  .caller { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 72px); }
  .back-btn { display: none !important; }
}
@media (max-width: 899.98px) {
  body[data-view="caller"] .board-view { display: none; }
  body[data-view="board"] .caller { display: none; }
}

/* Caller */
.caller { display: grid; gap: 20px; min-width: 0; }
.stage {
  display: grid; justify-items: center; gap: 14px; text-align: center;
  padding: 26px 16px 22px; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow);
}
.coin {
  position: relative; display: grid; place-items: center;
  width: min(62vw, 240px); aspect-ratio: 1; max-width: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 58%, rgb(0 0 0 / .07) 59%, transparent 61%),
    var(--called);
  color: var(--on-called);
  box-shadow: var(--coin-shadow);
  font-family: var(--font-num); font-weight: 700;
  font-size: clamp(4.2rem, 24vw, 6rem); letter-spacing: -0.04em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.coin.empty { background: var(--surface-2); color: var(--ink-2); box-shadow: none; font-size: clamp(3rem, 16vw, 4rem); }
.coin.done { background: var(--primary); color: var(--on-primary); font-size: clamp(2.6rem, 13vw, 3.4rem); }
.coin.pop { animation: pop .55s var(--ease-out); }
@keyframes pop {
  0% { transform: scale(.72) rotate(-8deg); filter: blur(6px); opacity: .4; }
  60% { filter: blur(0); opacity: 1; }
  100% { transform: none; }
}
.caption { margin: 0; min-height: 1.6em; font-family: var(--font-head); font-weight: 600; font-size: 1.35rem; letter-spacing: -0.01em; text-wrap: balance; }
.caption .digits { font-family: var(--font-num); font-weight: 500; font-size: .92em; letter-spacing: 0; }
.progress-line { margin: 0; color: var(--ink-2); font-size: .95rem; font-variant-numeric: tabular-nums; }
.progress-line strong { color: var(--ink); font-weight: 600; }
.meter { width: 100%; max-width: 280px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--called); border-radius: inherit; transition: width .4s var(--ease-out); }

.recent { display: grid; gap: 8px; }
.label { margin: 0; font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.recent-list { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; min-height: 44px; flex-wrap: wrap; }
.recent-list li {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--surface);
  font-family: var(--font-num); font-weight: 500; font-size: .95rem; font-variant-numeric: tabular-nums;
}
.recent-list li:first-child { border-color: var(--called); }
.recent-empty { color: var(--ink-2); font-size: .95rem; align-self: center; }

.controls { display: grid; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 1rem; transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary {
  min-height: 64px; border: 0; border-radius: var(--r-lg);
  background: var(--primary); color: var(--on-primary);
  font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; letter-spacing: -0.01em;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.btn-row .btn { padding: 0 8px; font-size: .95rem; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.auto-status { margin: 0; min-height: 1.5em; text-align: center; color: var(--ink-2); font-size: .92rem; font-variant-numeric: tabular-nums; }

/* Board / verify */
.board-view { display: grid; gap: 22px; min-width: 0; }
.view-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.view-head h2, .panel h2 { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.02em; }
.back-btn { min-height: 44px; }
.panel { display: grid; gap: 14px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
.panel h2 { font-size: 1.2rem; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: .9rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line); background: var(--surface); }
.swatch.called { background: var(--called); border-color: var(--called); }
.swatch.latest { background: var(--latest); border-color: var(--latest); }
.counts { display: flex; gap: 18px; flex-wrap: wrap; margin: 0; font-variant-numeric: tabular-nums; }
.counts div { display: grid; }
.counts dt { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.counts dd { margin: 0; font-family: var(--font-num); font-weight: 700; font-size: 1.4rem; }

.grid-wrap { overflow-x: auto; }
.board { display: grid; grid-template-columns: repeat(10, minmax(28px, 1fr)); gap: 5px; min-width: 300px; max-width: 600px; }
.cell {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--surface);
  font-family: var(--font-num); font-weight: 500; font-size: clamp(.72rem, 3.1vw, 1rem);
  font-variant-numeric: tabular-nums; color: var(--ink-2);
  transition: background-color .25s, color .25s, border-color .25s;
}
.cell.called { background: var(--called); border-color: var(--called); color: var(--on-called); font-weight: 700; }
.cell.latest { background: var(--latest); border-color: var(--latest); color: var(--on-latest); font-weight: 700; }

.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.order-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.order-list li {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 10px;
  background: var(--surface-2); font-family: var(--font-num); font-variant-numeric: tabular-nums;
}
.order-list .idx { font-size: .72rem; color: var(--ink-2); }
.order-list .num { font-weight: 700; }
.muted { margin: 0; color: var(--ink-2); }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; }
.hint { margin: 0; font-size: .9rem; color: var(--ink-2); }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--ground);
  font-family: var(--font-num); font-size: 1rem; caret-color: var(--latest);
}
.input:focus { border-color: var(--ink-2); }
.input::placeholder { color: var(--ink-2); opacity: 1; }
.claim-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; }
@media (max-width: 520px) {
  .claim-row { grid-template-columns: 1fr 1fr; }
  .claim-row .input { grid-column: 1 / -1; }
}
.result { display: grid; gap: 10px; padding: 14px; border-radius: var(--r-md); }
.result.ok { background: var(--ok-soft); }
.result.bad { background: var(--bad-soft); }
.result-title { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; }
.result.ok .result-title { color: var(--ok); }
.result.bad .result-title { color: var(--bad); }
.result p { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips li { min-width: 40px; padding: 6px 8px; text-align: center; border-radius: 8px; font-family: var(--font-num); font-weight: 700; font-variant-numeric: tabular-nums; }
.chips .hit { background: var(--called); color: var(--on-called); }
.chips .miss { background: var(--surface); color: var(--bad); border: 1.5px dashed var(--bad); }

/* Dialogs */
dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
dialog::backdrop { background: rgb(6 20 24 / .55); backdrop-filter: blur(3px); }
dialog[open] { animation: rise .3s var(--ease-out); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.dlg { display: grid; gap: 16px; padding: 22px; }
.dlg h2 { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 1.35rem; letter-spacing: -0.02em; }
.dlg p { margin: 0; color: var(--ink-2); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn-danger:hover { border-color: var(--bad); filter: brightness(1.08); }
.select {
  width: 100%; min-height: 48px; padding: 0 12px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--ground);
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: var(--ground); font-weight: 600; box-shadow: var(--shadow);
  transition: transform .3s var(--ease-out), opacity .3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

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