:root {
  --bg: #08090a;
  --panel: #0f1011;
  --surface: #191a1b;
  --surface2: #28282c;
  --text: #f7f8f8;
  --muted: #8a8f98;
  --silver: #d0d6e0;
  --border: rgba(255,255,255,.08);
  --border-subtle: rgba(255,255,255,.05);
  --blue: #2563eb;
  --blue2: #3b82f6;
  --gold: #f59e0b;
  --gold2: #fbbf24;
  --green: #10b981;
  --red: #ef4444;
  --violet: #7170ff;
  --radius: 14px;
  --font: Inter, "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.bg-orbs {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 15% 10%, rgba(37,99,235,.18), transparent 55%),
    radial-gradient(ellipse 50% 35% at 85% 15%, rgba(245,158,11,.12), transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 90%, rgba(113,112,255,.1), transparent 50%);
}
.app {
  position: relative; z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
}
.screen { display: none; flex: 1; flex-direction: column; animation: fadeIn .35s ease; }
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* HUD */
.hud {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
}
.hud-lives { display: flex; gap: 4px; }
.heart {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
}
.heart.on { background: linear-gradient(135deg, #f43f5e, #fb7185); border-color: transparent; box-shadow: 0 0 8px rgba(244,63,94,.4); }
.hud-mid { flex: 1; min-width: 0; }
.hud-stage {
  font-size: 11px; color: var(--gold); font-weight: 600;
  letter-spacing: .04em; text-transform: none;
}
.hud-progress-track {
  height: 6px; background: rgba(255,255,255,.06);
  border-radius: 999px; margin-top: 4px; overflow: hidden;
}
.hud-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--gold));
  border-radius: 999px; transition: width .35s ease;
}
.hud-score {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--gold2); white-space: nowrap;
}
.combo-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(16,185,129,.15); color: var(--green);
  border: 1px solid rgba(16,185,129,.3); display: none;
}
.combo-chip.show { display: inline-block; }

/* Landing */
.hero {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  text-align: center; padding: 12px 4px 24px;
}
.logo-mark {
  width: 72px; height: 72px; margin: 0 auto 18px;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(37,99,235,.35), rgba(245,158,11,.2));
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 32px; box-shadow: 0 12px 40px rgba(37,99,235,.2);
}
.badge-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.badge {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  color: var(--silver);
}
.badge.gold { color: var(--gold); border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.1); }
.hero h1 {
  font-size: clamp(26px, 7vw, 34px); font-weight: 600;
  letter-spacing: -.03em; line-height: 1.15; margin-bottom: 12px;
}
.gold-text {
  background: linear-gradient(90deg, var(--gold2), #fde68a, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { color: var(--muted); font-size: 14px; line-height: 1.65; margin-bottom: 8px; }
.lead strong { color: var(--silver); font-weight: 560; }
.stages-preview {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 20px 0 24px; text-align: left;
}
.stage-card {
  padding: 12px; border-radius: 12px;
  background: rgba(255,255,255,.03); border: 1px solid var(--border-subtle);
}
.stage-card .n { font-family: var(--mono); font-size: 11px; color: var(--blue2); margin-bottom: 4px; }
.stage-card .t { font-size: 13px; font-weight: 600; color: var(--text); }
.stage-card .d { font-size: 11px; color: var(--muted); margin-top: 2px; }

.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 15px;
  border-radius: 12px; padding: 14px 20px;
  transition: transform .12s ease, background .15s, box-shadow .15s, border-color .15s;
  min-height: 48px;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: #fff; box-shadow: 0 8px 28px rgba(37,99,235,.35);
  width: 100%;
}
.btn-primary:hover { box-shadow: 0 10px 32px rgba(37,99,235,.45); }
.btn-ghost {
  background: rgba(255,255,255,.03);
  color: var(--silver);
  border: 1px solid var(--border);
  width: 100%;
}
.btn-ghost:hover { background: rgba(255,255,255,.06); }
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.btn-row.row2 { flex-direction: row; }
.btn-row.row2 .btn { flex: 1; }

/* Quiz card */
.q-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 8px; flex-wrap: wrap;
}
.q-num {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.q-cat {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: rgba(37,99,235,.15); color: var(--blue2);
  border: 1px solid rgba(37,99,235,.3);
}
.q-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  flex: 0 0 auto;
}
.q-text {
  font-size: 17px; font-weight: 560; line-height: 1.45;
  letter-spacing: -.01em;
}
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  text-align: left;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 14px 12px;
  color: var(--silver);
  font-size: 14px; line-height: 1.45;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 12px;
  transition: border-color .15s, background .15s, transform .1s;
  min-height: 52px;
  width: 100%;
  font-family: inherit;
}
.opt:hover:not(:disabled) {
  border-color: rgba(37,99,235,.45);
  background: rgba(37,99,235,.08);
}
.opt:disabled { cursor: default; }
.opt .key {
  flex: 0 0 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.06); color: var(--muted);
  margin-top: 1px;
}
.opt.correct {
  border-color: rgba(16,185,129,.55);
  background: rgba(16,185,129,.12);
  color: #d1fae5;
}
.opt.correct .key { background: var(--green); color: #042f1a; }
.opt.wrong {
  border-color: rgba(239,68,68,.5);
  background: rgba(239,68,68,.1);
  color: #fecaca;
}
.opt.wrong .key { background: var(--red); color: #fff; }
.opt.dim { opacity: .45; }

.feedback {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.5; display: none;
}
.feedback.show { display: block; }
.feedback.ok {
  background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #a7f3d0;
}
.feedback.bad {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fecaca;
}
.feedback .pts { font-family: var(--mono); font-weight: 600; }

.next-wrap { margin-top: 16px; display: none; }
.next-wrap.show { display: block; }

/* Stage clear */
.stage-banner {
  text-align: center; padding: 28px 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: auto 0;
}
.stage-banner .emoji { font-size: 40px; margin-bottom: 10px; }
.stage-banner h2 { font-size: 22px; margin-bottom: 6px; letter-spacing: -.02em; }
.stage-banner p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* Result */
.result-card {
  text-align: center;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 18px 22px;
  margin: 8px 0 16px;
}
.rank-pill {
  display: inline-block;
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: rgba(245,158,11,.15); color: var(--gold);
  border: 1px solid rgba(245,158,11,.35);
  margin-bottom: 12px;
}
.result-card h2 {
  font-size: clamp(24px, 6vw, 30px);
  letter-spacing: -.03em; margin-bottom: 6px;
}
.result-score {
  font-family: var(--mono); font-size: 42px; font-weight: 600;
  background: linear-gradient(90deg, var(--blue2), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.1; margin: 8px 0;
}
.result-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 16px 0;
}
.stat {
  background: rgba(255,255,255,.03); border: 1px solid var(--border-subtle);
  border-radius: 12px; padding: 12px 6px;
}
.stat .v { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--text); }
.stat .l { font-size: 11px; color: var(--muted); margin-top: 2px; }
.share-box {
  width: 100%; min-height: 96px; resize: vertical;
  background: rgba(0,0,0,.35); border: 1px solid var(--border);
  border-radius: 12px; color: var(--silver);
  padding: 12px; font-family: inherit; font-size: 13px; line-height: 1.5;
  margin-bottom: 10px;
}
.footer-note {
  text-align: center; color: var(--muted); font-size: 11px;
  margin-top: 18px; opacity: .8;
}
.shake { animation: shake .4s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.confetti-dot {
  position: fixed; width: 8px; height: 8px; border-radius: 2px;
  pointer-events: none; z-index: 99;
  animation: confetti-fall 1.2s ease-out forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}
@media (max-width: 380px) {
  .q-text { font-size: 16px; }
  .opt { font-size: 13px; }
}
