:root {
  --bg: #0e1424;
  --bg2: #151d33;
  --card: #1b2540;
  --line: #2b3759;
  --text: #eef1f8;
  --muted: #9aa6c4;
  --gold: #f3c14b;
  --gold2: #ffdd84;
  --green: #3ccf8e;
  --red: #ff6b6b;
  --blue: #6ea8ff;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -200px, #24315a 0%, var(--bg) 60%) fixed;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 96px; }
main.wide { max-width: 1100px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 10px; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; color: var(--muted); font-weight: 600; }
p { margin: 0 0 10px; }
a { color: var(--gold2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

.brand { display: flex; align-items: center; gap: 10px; margin: 6px 0 18px; }
.brand .logo { font-size: 26px; }
.brand b { font-size: 18px; letter-spacing: .3px; }
.brand span { color: var(--gold); }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 12px; }

label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 18px; color: var(--text);
  background: #0c1220; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; outline: none;
}
input:focus, textarea:focus { border-color: var(--gold); }
input.code { font-size: 32px; letter-spacing: 10px; text-align: center; font-weight: 700; }

button, .btn {
  font: inherit; font-weight: 650; font-size: 17px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px;
  background: #24304f; color: var(--text); text-decoration: none; display: inline-block;
  touch-action: manipulation;
}
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--gold); color: #1a1405; border-color: var(--gold); }
button.green { background: var(--green); color: #052014; border-color: var(--green); }
button.red { background: transparent; color: var(--red); border-color: #6b2b2b; }
button.ghost { background: transparent; }
button.block { width: 100%; }
button.sm { font-size: 14px; padding: 8px 11px; border-radius: 10px; }
button.big { font-size: 20px; padding: 18px; }

.pill { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #26324f; color: var(--muted); }
.pill.gold { background: #3d3214; color: var(--gold2); }
.pill.green { background: #123826; color: var(--green); }
.pill.red { background: #3a1818; color: var(--red); }

.qmeta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.qtext { font-size: 22px; font-weight: 650; line-height: 1.35; }
.answer-key { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #123826; color: #c9f6df; font-weight: 600; }

.opts { display: grid; gap: 10px; margin-top: 14px; }
.opt { text-align: left; font-weight: 600; padding: 16px; font-size: 18px; }
.opt.sel { background: var(--gold); color: #1a1405; border-color: var(--gold); }

.timer { height: 8px; border-radius: 99px; background: #26324f; overflow: hidden; margin: 12px 0 6px; }
.timer > i { display: block; height: 100%; background: var(--gold); width: 100%; transition: width .25s linear; }
.timer.low > i { background: var(--red); }
.tleft { font-variant-numeric: tabular-nums; font-weight: 700; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

table.board { width: 100%; border-collapse: collapse; }
table.board th, table.board td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.board th { color: var(--muted); font-size: 13px; font-weight: 600; }
table.board td.num, table.board th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.board tr.out td { color: var(--muted); text-decoration: line-through; }
table.board tr.low td { background: rgba(255,107,107,.08); }
table.board tr.top td:first-child::before { content: "★ "; color: var(--gold); }

.mark { font-weight: 800; }
.mark.ok { color: var(--green); }
.mark.no { color: var(--red); }
.mark.wait { color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #2c1b1b; color: #ffd2d2; border: 1px solid #6b2b2b;
  padding: 10px 16px; border-radius: 12px; max-width: 92vw; z-index: 10; display: none;
}
.toast.show { display: block; }
.toast.info { background: #13281f; color: #c9f6df; border-color: #1f5a3f; }

.tabs { display: flex; gap: 6px; position: sticky; top: 0; z-index: 5; padding: 10px 0; background: var(--bg); }
.tabs button { flex: 1; font-size: 15px; padding: 10px; }
.tabs button.on { background: var(--gold); color: #1a1405; border-color: var(--gold); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 14px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.on { border-color: var(--green); color: var(--green); }
.chip.out { text-decoration: line-through; opacity: .6; }

.ansrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ansrow:last-child { border-bottom: 0; }
.ansrow .who { font-size: 13px; color: var(--muted); }
.ansrow .txt { font-weight: 600; word-break: break-word; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 9px 13px; font-size: 16px; background: transparent; }
.seg button.on.ok { background: var(--green); color: #052014; }
.seg button.on.no { background: var(--red); color: #2a0808; }

.bigcode { font-size: 56px; font-weight: 800; letter-spacing: 12px; color: var(--gold); text-align: center; }
.hint { font-size: 14px; color: var(--muted); }
.sticky-actions { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(14,20,36,0), var(--bg) 35%); }
.sticky-actions .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }

/* Том дэлгэц */
body.screen main { max-width: 1400px; padding: 32px; }
body.screen .qtext { font-size: clamp(28px, 4vw, 56px); }
body.screen .opt { font-size: clamp(20px, 2.4vw, 34px); }
body.screen table.board td, body.screen table.board th { font-size: clamp(18px, 2vw, 30px); padding: 14px 10px; }
body.screen .bigcode { font-size: clamp(60px, 12vw, 180px); }
body.screen .timer { height: 16px; }
body.screen .tleft { font-size: 40px; }
