:root {
  --bg: #12131a;
  --panel: #1b1d27;
  --panel2: #232634;
  --line: #2f3344;
  --ink: #ece6d6;
  --muted: #9a9686;
  --gold: #d6aa4f;
  --gold-soft: rgba(214, 170, 79, .14);
  --red: #c4554d;
  --green: #6fae7b;
  --blue: #7d9fd6;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); background:
  radial-gradient(1200px 500px at 50% -200px, rgba(214,170,79,.10), transparent 70%), var(--bg); }
button { font: inherit; cursor: pointer; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(18,19,26,.92); backdrop-filter: blur(8px); z-index: 5; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 24px; letter-spacing: .5px; }
.mark { color: var(--gold); }
.top .me { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot.on { background: var(--green); }
.link { background: none; border: 0; color: var(--muted); padding: 4px 6px; border-radius: 8px; text-decoration: none; }
.link:hover { color: var(--ink); background: var(--panel); }
main, #answerBox { max-width: 860px; margin: 0 auto; padding: 18px; }
#answerBox { padding-top: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0 0 8px; }
h1 { font-size: 34px; } h2 { font-size: 26px; } h3 { font-size: 20px; }
.muted { color: var(--muted); }
.center { text-align: center; } .pad { padding: 40px 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; color: var(--gold); font-weight: 600; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--ink); padding: 10px 16px; border-radius: 10px; font-weight: 600; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
#banner .note { max-width: 824px; margin: 12px auto 0; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
@media (max-width: 860px) { #banner .note { margin: 12px 18px 0; } }
.note.spec { background: rgba(125,159,214,.12); border: 1px solid rgba(125,159,214,.35); }
.note.demo { background: rgba(196,85,77,.10); border: 1px solid rgba(196,85,77,.35); }

/* lobby */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.std { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; color: var(--ink); position: relative; min-height: 132px; }
.std:hover:not(:disabled) { border-color: var(--gold); }
.std.mine { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; background: linear-gradient(180deg, var(--gold-soft), var(--panel)); }
.std:disabled { opacity: .5; cursor: not-allowed; }
.std .trad { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.std .name { font-family: var(--serif); font-size: 21px; font-weight: 700; margin: 2px 0 4px; }
.std .docs { font-size: 13px; color: var(--muted); }
.std .voters { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.voters { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); }
.chip.me { border-color: var(--gold); color: var(--gold); }
.chip.ok { border-color: rgba(111,174,123,.6); color: var(--green); }
.chip.off { opacity: .5; }
.soon { position: absolute; top: 12px; right: 12px; font-size: 11px; color: var(--muted); }
.countdown { position: fixed; inset: 0; background: rgba(10,10,14,.82); display: grid; place-items: center; z-index: 20; text-align: center; }
.countdown .n { font-family: var(--serif); font-size: 120px; color: var(--gold); line-height: 1; }

/* question */
.topic { text-align: center; padding: 18px 8px 6px; }
.topic h1 { font-size: 40px; margin-top: 6px; }
.timer { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin: 14px 0 6px; }
.timer > div { height: 100%; background: linear-gradient(90deg, var(--gold), #e8c77d); transition: width .25s linear; }
.timer.low > div { background: var(--red); }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; }
textarea { width: 100%; min-height: 240px; resize: vertical; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; font: 16px/1.55 var(--sans); }
textarea:focus { outline: none; border-color: var(--gold); }
textarea:disabled { opacity: .7; }
.answerbar { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* entries */
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.entry.me { border-color: rgba(214,170,79,.55); }
.entry .head { display: flex; align-items: baseline; gap: 10px; }
.entry .who { font-weight: 600; font-size: 16px; }
.entry .rank { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--gold); min-width: 34px; }
.entry .total { margin-left: auto; font-family: var(--serif); font-size: 28px; font-weight: 700; }
.entry .ans { white-space: pre-wrap; margin: 10px 0; color: #d9d3c2; font-size: 14.5px; max-height: 220px; overflow: auto; padding: 10px 12px; background: var(--bg); border-radius: 10px; border: 1px solid var(--line); }
.entry .ans.empty { color: var(--muted); font-style: italic; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { background: var(--panel2); border-radius: 10px; padding: 8px 10px; }
.metric .lab { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.metric .val { font-weight: 600; font-size: 18px; font-variant-numeric: tabular-nums; }
.metric .bar { height: 4px; background: var(--bg); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.metric .bar > div { height: 100%; background: var(--gold); transition: width .5s ease; }
.metric.acc .bar > div { background: var(--blue); }
.metric.tim .bar > div { background: var(--green); }
.pending { color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.feedback { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.formula { font-size: 12px; color: var(--muted); margin-top: 6px; }
.status-line { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 8px 0 14px; }

/* leaderboard */
.lb { width: 100%; border-collapse: collapse; }
.lb td { padding: 12px 10px; border-bottom: 1px solid var(--line); }
.lb tr.me td { background: var(--gold-soft); }
.lb .r { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--gold); width: 48px; }
.lb .s { text-align: right; font-family: var(--serif); font-size: 24px; font-weight: 700; }
.lb .d { text-align: right; color: var(--green); font-size: 13px; width: 70px; }
.move { font-size: 12px; margin-left: 6px; }
.move.up { color: var(--green); } .move.down { color: var(--red); }
details.excerpt { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; }
details.excerpt summary { cursor: pointer; font-weight: 600; color: var(--gold); }
.excerpt p { font-size: 14px; color: #d9d3c2; }
.excerpt b { color: var(--ink); }
.sticky-actions { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(rgba(18,19,26,0), var(--bg) 22%); display: flex; justify-content: center; gap: 12px; align-items: center; flex-wrap: wrap; }

dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; margin: 10px 0 14px; }
dialog .btn { width: 100%; }
@media (max-width: 560px) {
  .topic h1 { font-size: 30px; }
  .metrics { gap: 6px; } .metric .val { font-size: 16px; }
  .entry .total { font-size: 24px; }
}
.lb td:nth-child(2) { width: 100%; }
.entry .rank, .entry .total, .lb .r, .lb .s, .countdown .n { font-variant-numeric: lining-nums tabular-nums; }

/* practice, toasts, forfeit */
.btn.sm { padding: 6px 12px; font-size: 13px; }
.link.danger { color: var(--red); font-size: 13px; }
.link.danger:hover { background: rgba(196,85,77,.1); color: var(--red); }
.note.spec { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pstats > div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; text-align: center; }
.pstats .lab { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pstats b { font-family: var(--serif); font-size: 24px; font-variant-numeric: lining-nums tabular-nums; }
.lb tr.gone td { opacity: .55; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--gold); border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 30px rgba(0,0,0,.45); animation: rise .25s ease-out; }
.toast span { flex: 1; font-size: 14px; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
dialog.wide { width: min(94vw, 760px); }
dialog.wide .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
dialog.wide .std { min-height: 96px; }
@media (max-width: 560px) { .pstats b { font-size: 20px; } }
