:root {
  --bg: #000;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.075);
  --glass-solid: #0d0d0f;
  --hair: rgba(255, 255, 255, 0.09);
  --hair-2: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --muted: #8e8e93;
  --dim: #5a5a5f;
  --accent: #d6b46a;   /* champagne */
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --blue: #0a84ff;
  --r-card: 14px;
  --r-btn: 6px;
  --blur: blur(28px) saturate(170%);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 20px 50px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 50% -120px, rgba(214, 180, 106, 0.10), transparent 70%),
    radial-gradient(700px 500px at 110% 110%, rgba(255, 255, 255, 0.04), transparent 70%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--text); }
.hidden { display: none !important; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand-mark { display: none; }
.brand-text { line-height: 1; display: flex; flex-direction: column; gap: 3px; }
.brand-text small { font-size: 10px; letter-spacing: 0.28em; color: var(--muted); font-weight: 600; }
.brand-text b { font-size: 19px; font-weight: 700; letter-spacing: 0.06em; color: var(--text); }
.brand-text b::first-letter { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--hair);
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: var(--r-btn);
  background: var(--glass); border: 1px solid var(--hair);
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.dot.off { background: var(--red); }

/* ---------- generic ---------- */
.card {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--hair);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2, .card h3 { margin: 0 0 14px; font-weight: 600; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.btn {
  border: 1px solid transparent; border-radius: var(--r-btn); padding: 12px 20px;
  font-weight: 600; font-size: 15px;
  background: var(--text); color: #000;
  transition: transform .08s ease, opacity .15s, background .15s;
}
.btn:hover { background: #fff; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.ghost { background: var(--glass-2); color: var(--text); border-color: var(--hair-2); }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.btn.blue { background: var(--glass-2); color: var(--text); border-color: var(--hair-2); }
.btn.green { background: var(--green); color: #00150a; }
.btn.red { background: rgba(255, 69, 58, .14); color: var(--red); border-color: rgba(255, 69, 58, .4); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; }

label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--r-btn);
  background: rgba(255, 255, 255, .05); border: 1px solid var(--hair); outline: none;
  transition: border-color .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus { border-color: var(--hair-2); background: rgba(255, 255, 255, .08); }
select option { background: var(--glass-solid); }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 2px 0 10px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(30, 30, 32, .85); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--hair-2); color: var(--text);
  padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100;
  max-width: calc(100% - 32px); text-align: center; font-size: 14px;
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- question + options ---------- */
.round-tag { display: block; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); line-height: 1.5; }
.round-tag .num { color: var(--accent); }
.round-tag .num::after { content: '·'; color: var(--dim); margin: 0 8px; }

.lozenge {
  position: relative;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset;
}
.question-box {
  padding: 26px 24px; text-align: center; font-size: clamp(19px, 2.3vw, 26px); font-weight: 600; line-height: 1.35; letter-spacing: -0.02em;
  background: rgba(255, 255, 255, .06); border-color: var(--hair-2);
}
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
@media (max-width: 640px) { .options { grid-template-columns: 1fr; gap: 8px; } }
.option {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; font-size: 16px; font-weight: 500; min-height: 56px; width: 100%;
  transition: background .15s, border-color .15s, transform .08s;
}
.option .key {
  display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 5px; border: 1px solid var(--hair-2); color: var(--muted); font-weight: 600; font-size: 13px;
}
.option:not(:disabled):hover { background: rgba(255, 255, 255, .08); border-color: var(--hair-2); }
.option:not(:disabled):active { transform: scale(.99); }
.option:disabled { cursor: default; }
.option.selected { background: var(--text); color: #000; border-color: var(--text); }
.option.selected .key { border-color: rgba(0, 0, 0, .2); color: #000; }
.option.locked { background: var(--orange); color: #1a0e00; border-color: var(--orange); }
.option.locked .key { border-color: rgba(0, 0, 0, .25); color: #1a0e00; }
.option.correct { background: var(--green); color: #00150a; border-color: var(--green); animation: flash .45s ease 3; }
.option.correct .key { border-color: rgba(0, 0, 0, .25); color: #00150a; }
.option.wrong { background: var(--red); color: #fff; border-color: var(--red); }
.option.wrong .key { border-color: rgba(255, 255, 255, .35); color: #fff; }
.option.removed { opacity: .15; }
.option.removed .label { visibility: hidden; }
.option .bar-pct { margin-left: auto; font-size: 13px; font-weight: 600; opacity: .75; font-variant-numeric: tabular-nums; }
@keyframes flash { 50% { filter: brightness(1.25); } }

.timer {
  --p: 1;
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--text) calc(var(--p) * 360deg), rgba(255, 255, 255, .08) 0);
  position: relative; flex-shrink: 0;
}
.timer::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #0b0b0d; }
.timer span { position: relative; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.timer.low { background: conic-gradient(var(--red) calc(var(--p) * 360deg), rgba(255, 255, 255, .08) 0); }
.timer.low span { color: var(--red); }

/* ---------- ladder ---------- */
.ladder { display: flex; flex-direction: column-reverse; border: 1px solid var(--hair); border-radius: 10px; overflow: hidden; }
.ladder .rung {
  display: flex; justify-content: space-between; padding: 10px 14px;
  font-weight: 500; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.ladder .rung + .rung { border-bottom: 1px solid var(--hair); }
.ladder .rung.safe { color: var(--text); }
.ladder .rung.safe small { color: var(--accent); }
.ladder .rung.done { color: var(--green); }
.ladder .rung.now { background: var(--orange); color: #1a0e00; }
.ladder .rung.now small { color: #1a0e00; }
.ladder .rung small { font-weight: 600; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; margin-left: 8px; }

/* ---------- leaderboard ---------- */
.lb { list-style: none; margin: 0; padding: 0; }
.lb li {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 4px; font-size: 14px; border-bottom: 1px solid var(--hair);
}
.lb li:last-child { border-bottom: 0; }
.lb li.me { background: rgba(214, 180, 106, .08); margin: 0 -8px; padding: 11px 12px; border-radius: 6px; }
.lb .rank { font-weight: 600; color: var(--dim); font-variant-numeric: tabular-nums; }
.lb li:nth-child(-n+3) .rank { color: var(--accent); }
.lb .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lb .score { font-weight: 600; font-variant-numeric: tabular-nums; }
.lb li.cut { border-bottom: 1px solid var(--accent); }
.lb .score small { color: var(--muted); font-weight: 500; }
.qtag { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--green); border: 1px solid rgba(48, 209, 88, .4); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }
.lb-empty { color: var(--muted); font-size: 14px; padding: 12px 0; grid-template-columns: 1fr !important; }
