:root {
  --bg: #14110f;
  --panel: #1f1a17;
  --panel-2: #2a231f;
  --line: #3a312b;
  --text: #f3ece4;
  --muted: #a89a8d;
  --accent: #c8553d;
  --accent-soft: #e8b4a3;
  --good: #6fae7c;
  --bad: #d1655a;
  --gold: #d9a441;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; display: flex; flex-direction: column; }

.top {
  display: grid; grid-template-columns: 44px 1fr 72px; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  position: sticky; top: 0; background: rgba(20,17,15,.92); backdrop-filter: blur(10px); z-index: 2;
  border-bottom: 1px solid var(--line);
}
.brand { margin: 0; font-size: 20px; letter-spacing: .5px; text-align: center; font-weight: 700; cursor: pointer; white-space: nowrap; justify-self: center; }
.brand span { color: var(--accent); }
.back { background: none; border: 0; color: var(--text); font-size: 22px; width: 44px; height: 44px; cursor: pointer; }
.timer { font-variant-numeric: tabular-nums; color: var(--gold); text-align: right; font-weight: 600; }

.view { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 16px 16px 32px; }

.foot { color: var(--muted); font-size: 11px; line-height: 1.4; text-align: center; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); max-width: 640px; margin: 0 auto; }

h2 { font-size: 22px; margin: 8px 0 6px; }
h3 { font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: .4px; text-transform: uppercase; margin: 22px 0 10px; }
p { line-height: 1.5; }
.lead { color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card.tap { cursor: pointer; transition: transform .08s, background .15s; }
.card.tap:active { transform: scale(.985); background: var(--panel-2); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row .meta { color: var(--muted); font-size: 13px; }
.badge { white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.badge.accent { background: rgba(200,85,61,.18); color: var(--accent-soft); }
.badge.gold { background: rgba(217,164,65,.16); color: var(--gold); }

.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.bar.good > i { background: var(--good); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 14px 18px; font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn:disabled { opacity: .45; cursor: default; }
.btn + .btn { margin-top: 10px; }

.q-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.stem { font-size: 18px; line-height: 1.45; margin: 0 0 16px; font-weight: 500; }
.options { display: grid; gap: 10px; }
.opt {
  text-align: left; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 14px 14px 14px 46px; font-size: 16px; line-height: 1.35; position: relative; cursor: pointer;
}
.opt::before {
  content: attr(data-letter); position: absolute; left: 12px; top: 12px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--good); background: rgba(111,174,124,.12); }
.opt.correct::before { background: var(--good); color: #0f1a12; }
.opt.wrong { border-color: var(--bad); background: rgba(209,101,90,.12); }
.opt.wrong::before { background: var(--bad); color: #fff; }

.explain { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--panel-2); border-left: 3px solid var(--gold); line-height: 1.5; font-size: 15px; }
.explain b { color: var(--gold); }

.score { text-align: center; padding: 28px 0 10px; }
.score .big { font-size: 56px; font-weight: 800; line-height: 1; }
.score .big.pass { color: var(--good); }
.score .big.fail { color: var(--bad); }
.score .sub { color: var(--muted); margin-top: 6px; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }

textarea {
  width: 100%; min-height: 140px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font: inherit; font-size: 15px; line-height: 1.45; resize: vertical;
}
.points { display: grid; gap: 8px; margin-top: 12px; }
.pt { display: flex; gap: 10px; align-items: flex-start; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.pt input { margin-top: 3px; accent-color: var(--good); }
.marks { color: var(--gold); font-weight: 700; }
.note { color: var(--muted); font-size: 13px; }
.rule { font-size: 13px; color: var(--muted); font-style: italic; margin: 6px 0 0; }
.part { margin-bottom: 18px; }
.part h4 { margin: 0 0 8px; font-size: 16px; }
.hidden { display: none; }
.tag { color: var(--accent-soft); font-weight: 600; }
.kicker { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); }
