/* Compass Game Night Trivia. Visual language from reference/demo-v2.html.
   Every text/background pair here is checked for WCAG AA by test/contrast.test.js. */

@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/open-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/open-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/open-sans-700.woff2') format('woff2'); }
@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 800; font-display: swap; src: url('/assets/fonts/open-sans-800.woff2') format('woff2'); }

:root {
  --navy: #294B77; --navy-deep: #1C3556; --steel: #50748A;
  --green: #78AB46;          /* progress bar and non-text accents only (2.7:1 with white) */
  --btn: #496B28;            /* green-800: 6.2:1 with white text */
  --btn-hover: #3B5A20;
  --on-dark: #FFFFFF; --on-dark-muted: #C3D0DF;
  --bg: #F3F6F9; --card: #FFFFFF; --ink: #16263B; --muted: #5B6B7C; --rule: #D8E0E8; --rule-strong: #7B8A9B;
  --pick: #E8EFF7; --pick-ink: #294B77;
  --right: #E7F2DC; --right-ink: #3B5A20; --right-edge: #496B28;
  --wrong: #F9E5E2; --wrong-ink: #A33A2B;
  --warn: #FFF6D6; --warn-ink: #5A4600;
  --accent-ink: #294B77;     /* big numbers on cards */
  --focus: #294B77;
  --font: 'Open Sans', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1B2B; --card: #172738; --ink: #E9EFF5; --muted: #9FB0C2; --rule: #2A3D52; --rule-strong: #6B8AA8;
    --pick: #22384F; --pick-ink: #C6D6E8;
    --right: #24391A; --right-ink: #B5DB8E; --right-edge: #8CC152;
    --wrong: #3E211D; --wrong-ink: #F0A597;
    --warn: #3A3310; --warn-ink: #F2E3A6;
    --accent-ink: #9DC3EC;
    --focus: #9DC3EC;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1B2B; --card: #172738; --ink: #E9EFF5; --muted: #9FB0C2; --rule: #2A3D52; --rule-strong: #6B8AA8;
  --pick: #22384F; --pick-ink: #C6D6E8;
  --right: #24391A; --right-ink: #B5DB8E; --right-edge: #8CC152;
  --wrong: #3E211D; --wrong-ink: #F0A597;
  --warn: #3A3310; --warn-ink: #F2E3A6;
  --accent-ink: #9DC3EC;
  --focus: #9DC3EC;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.top { background: var(--navy); color: var(--on-dark); padding: 14px 20px; padding-top: max(14px, env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top img { height: 22px; width: auto; display: block; }
.top .tag { font-size: 13px; font-weight: 600; color: var(--on-dark-muted); white-space: nowrap; }

.net { background: var(--warn); color: var(--warn-ink); font-size: 14px; font-weight: 600; padding: 8px 20px; text-align: center; }

/* Scoreboard: the one bold element */
.board { background: var(--navy-deep); color: var(--on-dark); padding: 18px 20px 22px; }
.board-inner { max-width: 560px; margin: 0 auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.board .big { font-weight: 800; font-size: 56px; line-height: .9; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.board .big small { font-size: 22px; font-weight: 700; color: var(--on-dark-muted); letter-spacing: 0; }
.board .big.word { font-size: 40px; line-height: 1; }
.board .cap { font-size: 13px; color: var(--on-dark-muted); margin-top: 6px; }
.board .side { text-align: right; min-width: 0; max-width: 50%; }
.board .timer { font-weight: 800; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.board .who { font-size: 14px; font-weight: 600; color: var(--on-dark-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 6px; }
.bar { max-width: 560px; margin: 14px auto 0; height: 6px; background: rgba(255, 255, 255, .14); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--green); border-radius: 3px; transition: width .25s linear; }

main { flex: 1 0 auto; width: 100%; max-width: 560px; margin: 0 auto; padding: 22px 20px 40px; }
main:focus { outline: none; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 0 0 10px; }
h2 { font-size: 22px; line-height: 1.3; font-weight: 700; margin: 0 0 18px; letter-spacing: -.01em; }
h3 { font-size: 17px; line-height: 1.3; font-weight: 700; margin: 0 0 10px; }
[tabindex="-1"]:focus { outline: none; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.lede { font-size: 17px; }

.field label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field .hint { display: block; font-weight: 400; font-size: 14px; color: var(--muted); margin: -2px 0 6px; }
.field input, .field textarea { width: 100%; padding: 14px 16px; border: 1.5px solid var(--rule-strong); border-radius: 10px; background: var(--card); color: var(--ink); font-size: 18px; }
.field textarea { font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 160px; }
.field input:focus, .field textarea:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.field + .field { margin-top: 14px; }
.err { color: var(--wrong-ink); font-size: 15px; font-weight: 600; margin-top: 8px; min-height: 1.5em; }
.err:empty { min-height: 0; margin: 0; }

.btn { display: block; width: 100%; min-height: 48px; padding: 14px 16px; border: 0; border-radius: 10px; background: var(--btn); color: #FFFFFF; font-weight: 700; font-size: 17px; cursor: pointer; margin-top: 20px; text-align: center; text-decoration: none; }
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--rule); color: var(--muted); cursor: not-allowed; transform: none; }
.btn.ghost { background: transparent; color: var(--pick-ink); border: 1.5px solid var(--rule-strong); }
.btn.ghost:hover { background: var(--pick); }
.btn.navy { background: var(--navy); color: #FFFFFF; }
.btn.navy:hover { background: var(--navy-deep); }
.btn.danger { background: transparent; color: var(--wrong-ink); border: 1.5px solid var(--wrong-ink); }
.btn.danger:hover { background: var(--wrong); }
.btn.small { min-height: 44px; padding: 10px 14px; font-size: 15px; margin-top: 12px; }
.btn:focus-visible, .opt:focus-visible, .link:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px 16px; border: 1.5px solid var(--rule-strong); border-radius: 12px; background: var(--card); color: var(--ink); font-size: 17px; cursor: pointer; min-height: 58px; }
.opt:disabled { cursor: default; }
.opt .k { flex: 0 0 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--rule-strong); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--muted); }
.opt .t { flex: 1; }
.opt .tag { flex: 0 0 auto; font-size: 13px; font-weight: 700; }
.opt[aria-pressed="true"] { border-color: var(--navy); background: var(--pick); }
.opt[aria-pressed="true"] .k { background: var(--navy); border-color: var(--navy); color: #FFFFFF; }
.opt[aria-pressed="true"] .tag { color: var(--pick-ink); }
.opt.is-right { border-color: var(--right-edge); background: var(--right); }
.opt.is-right .k { background: var(--btn); border-color: var(--btn); color: #FFFFFF; }
.opt.is-right .tag { color: var(--right-ink); }
.opt.is-wrong { border-color: var(--wrong-ink); background: var(--wrong); }
.opt.is-wrong .tag { color: var(--wrong-ink); }
.opt.dim { opacity: 1; color: var(--muted); }

.status { margin-top: 16px; font-size: 16px; }
.banner { border-radius: 12px; padding: 14px 16px; margin: 0 0 18px; font-weight: 700; font-size: 18px; }
.banner.right { background: var(--right); color: var(--right-ink); }
.banner.wrong { background: var(--wrong); color: var(--wrong-ink); }
.banner.none { background: var(--pick); color: var(--pick-ink); }

.note { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 16px 18px; }
.note p:last-child { margin-bottom: 0; }
.done-score { font-size: 64px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.done-score span { font-size: 24px; color: var(--muted); }
.review { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; }
.review li { padding: 10px 12px; border-radius: 10px; font-size: 15px; }
.review li.r { background: var(--right); }
.review li.w { background: var(--wrong); }
.review li.n { background: var(--card); border: 1px solid var(--rule); }
.review b { display: block; font-weight: 700; }

footer { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 20px 36px; padding-bottom: max(36px, env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); }
footer p { margin: 0 0 6px; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: inherit; }
.link.ink { color: var(--pick-ink); }

/* Host view */
.stand { width: 100%; border-collapse: collapse; font-size: 15px; }
.stand th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.stand td { padding: 10px 6px; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.stand td:nth-child(2) { white-space: nowrap; max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; }
.stand th:first-child, .stand td:first-child { padding-left: 0; }
.stand th:last-child, .stand td:last-child { padding-right: 0; }
.stand td.n, .stand th.n { text-align: right; white-space: nowrap; }
.stand tr.top1 td { font-weight: 700; }
.stand tr.out td { color: var(--muted); text-decoration: line-through; }
.table-wrap { overflow-x: auto; }
.section { border: 1.5px solid var(--rule); border-radius: 14px; padding: 18px 20px; margin-top: 22px; background: var(--card); }
.section > h2 { font-size: 19px; margin-bottom: 8px; }
details.section > summary { cursor: pointer; font-weight: 700; font-size: 19px; list-style-position: inside; }
details.section[open] > summary { margin-bottom: 12px; }
.pill { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--pick); color: var(--pick-ink); vertical-align: middle; }
.pill.open { background: var(--right); color: var(--right-ink); }
.pill.closed { background: var(--warn); color: var(--warn-ink); }
.pill.revealed { background: var(--pick); color: var(--pick-ink); }
.row2 { display: flex; gap: 10px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; }
.inline-form .field { flex: 2; }
.inline-form .btn { flex: 1; margin: 0; min-height: 56px; }
.row2 > * { flex: 1; }
.dist { display: grid; gap: 6px; margin-top: 12px; }
.dist .d { display: grid; grid-template-columns: 28px 1fr 44px; gap: 8px; align-items: center; font-size: 14px; }
.dist .track { height: 12px; border-radius: 6px; background: var(--pick); overflow: hidden; }
.dist .track i { display: block; height: 100%; background: var(--steel); }
.dist .d.right .track i { background: var(--green); }
.dist .d.right b { color: var(--right-ink); }
.kv { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; margin: 8px 0 0; }
.kv b { font-variant-numeric: tabular-nums; }
.reveal { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; min-height: 38px; margin: 14px 0 4px; color: var(--accent-ink); }
.drawn { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; }
.drawn li { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; padding: 8px 12px; border-radius: 10px; background: var(--right); color: var(--ink); }
.drawn li span { color: var(--ink); font-size: 14px; white-space: nowrap; }
.plist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; max-height: 360px; overflow: auto; }
.plist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.plist li .btn { width: auto; margin: 0; min-height: 36px; padding: 4px 12px; font-size: 14px; }
.qlist { padding-left: 22px; margin: 8px 0 0; font-size: 15px; }
.qlist li { margin-bottom: 4px; }
.errs { color: var(--wrong-ink); font-size: 14px; padding-left: 18px; margin: 8px 0 0; }
.ok-msg { color: var(--right-ink); font-weight: 600; font-size: 15px; margin-top: 8px; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (max-width: 380px) {
  .board .big { font-size: 48px; }
  .board .timer { font-size: 30px; }
  h2 { font-size: 20px; }
}
