:root {
  --bg: #0f141a;
  --card: #151c24;
  --ink: #e8eef4;
  --muted: #a9b6c5;
  --primary: #4aa3ff;
  --secondary: #6c8cff;
  --accent: #ffd36e;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --barbg: #233140;
  --barfg: #4aa3ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
}

.hidden { display: none !important; }

#app { max-width: 900px; margin: 0 auto; padding: 16px; }

.view { padding: 8px 0 48px; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  justify-content: space-between; margin-bottom: 16px;
}
.topbar h2 { margin: 0; }
.topbar .right { display: flex; gap: 8px; align-items: center; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid #1e2a35; border-radius: 12px;
  padding: 16px; margin-bottom: 16px; box-shadow: 0 2px 10px rgb(0 0 0 / 20%);
}
.card.wide { padding: 20px; }
.row { display: flex; gap: 16px; }
.row.between { justify-content: space-between; align-items: center; }

h1,h2,h3 { margin: 0 0 12px; }

.label { color: var(--muted); font-size: 14px; }
.pct { font-size: 28px; font-weight: 700; }

.progress { display: flex; align-items: center; gap: 12px; width: 60%; }
.progress.small { width: 40%; }
.progress .bar { background: var(--barbg); height: 8px; border-radius: 999px; width: 100%; position: relative; overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--barfg); width: 0%; transition: width .25s ease; }
.progress .count { font-size: 13px; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions.center { justify-content: center; }

button {
  background: #223040; color: var(--ink); border: 1px solid #2a3a4b;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
}
button.primary { background: var(--primary); border-color: var(--primary); color: #001325; font-weight: 700; }
button.secondary { background: #223040; }
button.accent { background: var(--accent); color: #2b1b00; border-color: #f7c95a; font-weight: 700; }
button.ghost { background: transparent; border-color: #2a3a4b; color: var(--muted); }
button:disabled { opacity: .6; cursor: not-allowed; }

input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #2a3a4b;
  background: #0e141b; color: var(--ink);
}
label { display: grid; gap: 6px; margin: 8px 0; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 10px; }
.tabs button.active { border-color: var(--primary); color: var(--primary); background: #122133; }

.tab { display: none; }
.tab.active { display: block; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tile {
  background: var(--card); border: 1px solid #1e2a35; border-radius: 12px; padding: 14px;
}
.tile h3 { margin: 0 0 6px; }
.tile .muted { color: var(--muted); font-size: 14px; }

.list { display: grid; gap: 8px; }
.list .rowline {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid #223040; border-radius: 10px; background: #0f1821;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { padding: 8px 12px; }

.qmeta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.prompt { font-size: 18px; line-height: 1.5; margin-bottom: 10px; }

.options { display: grid; gap: 8px; }
.options button {
  text-align: left; padding: 12px; border-radius: 12px; border: 1px solid #243243; background: #111922;
}
.options button.correct { border-color: #2e744a; background: #12221a; }
.options button.wrong { border-color: #7a2f2f; background: #221212; }

.feedback { margin-top: 10px; padding: 12px; border-radius: 10px; background: #101925; border: 1px solid #243243; }
.feedback .ok { color: var(--ok); font-weight: 700; }
.feedback .bad { color: var(--danger); font-weight: 700; }

.qmeta .origin { opacity: .7; }

.big-score { font-size: 42px; text-align: center; font-weight: 800; margin: 8px 0 16px; }

@media (max-width: 640px) {
  .progress { width: 100%; }
  .progress.small { width: 60%; }
  .topbar { gap: 8px; }
}

/* Ensure Next button actually shows and has space */
#nextBtn {
  display: block;
  width: 100%;
  margin-top: 12px;
}
