:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7690;
  --line: #dfe5ef;
  --blue: #2b56b8;
  --orange: #f7a11a;
  --green: #2fa36b;
  --red: #e0524f;
  --shadow: 0 2px 10px rgba(31, 42, 68, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; font-size: 18px; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; border: 0; }
img { max-width: 100%; display: block; }
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* top bar */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 5; }
.bar .title { font-weight: 700; flex: 1; text-align: center; font-size: 17px; }
.bar .spacer { width: 44px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; background: #eef2f8; color: var(--ink); font-size: 20px; }
.icon-btn:hover { background: #e2e8f2; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 8px 12px; border-radius: 12px; background: #eef2f8; min-width: 78px; text-align: center; }
.timer.low { background: #fde8e7; color: var(--red); }

.page { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
h1 { font-size: 30px; margin: 8px 0 4px; }
h2 { font-size: 22px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* big buttons */
.big-btn { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); text-align: left; margin-bottom: 12px; border: 2px solid transparent; color: var(--ink); }
.big-btn:hover { border-color: var(--blue); }
.big-btn .emoji { font-size: 32px; }
.big-btn .label { font-weight: 700; font-size: 20px; }
.big-btn .sub { color: var(--muted); font-size: 15px; }
.primary { background: var(--blue); color: #fff; padding: 14px 28px; border-radius: 14px; font-weight: 700; font-size: 20px; box-shadow: var(--shadow); }
.primary:hover { background: #244a9f; }
.primary:disabled, .secondary:disabled { opacity: .35; cursor: default; }
.secondary { background: #eef2f8; color: var(--ink); padding: 12px 22px; border-radius: 14px; font-weight: 600; }
.secondary:hover { background: #e2e8f2; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

/* mode chooser */
.choice { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); cursor: pointer; }
.choice.on { border-color: var(--blue); background: #eef3fd; }
.choice b { font-size: 18px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (max-width: 520px) { .choice-grid { grid-template-columns: 1fr; } }
label.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; }
label.check input { width: 22px; height: 22px; }

/* progress */
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 16px; }
.progress > div { height: 100%; background: var(--orange); border-radius: 99px; transition: width .25s; }

/* question */
.qnum { font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.matrix { display: flex; justify-content: center; margin-bottom: 14px; }
.matrix img { max-height: 40vh; width: auto; border-radius: 6px; }
.options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 560px) { .options { grid-template-columns: repeat(3, 1fr); } }
.options.n4 { grid-template-columns: repeat(4, 1fr); }
.options.n3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .options.n4 { grid-template-columns: repeat(2, 1fr); } }
.options.n4 .opt img, .options.n3 .opt img { height: 84px; }
.opt { background: var(--card); border: 3px solid var(--line); border-radius: 16px; padding: 10px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: transform .08s, border-color .1s; box-shadow: var(--shadow); }
.opt:hover { border-color: #9db1e3; }
.opt:active { transform: scale(.96); }
.opt img { height: 56px; width: auto; }
.opt .txt { height: 56px; display: flex; align-items: center; font-size: 30px; font-weight: 800; letter-spacing: .5px; }
.prompt { background: #fff7e8; border: 1px solid #f7d9a3; border-radius: 12px; padding: 8px 14px; margin-bottom: 10px; font-size: 17px; }
.opt .letter { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.opt.selected { border-color: var(--blue); background: #eef3fd; }
.opt.selected .letter { background: var(--blue); border-color: var(--blue); color: #fff; }
.opt.correct { border-color: var(--green); background: #e9f8f0; }
.opt.correct .letter { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: #fdecec; }
.opt.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
.opt:disabled { cursor: default; opacity: 1; color: var(--ink); }

.feedback { margin: 0 0 10px; padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.feedback.ok { background: #e9f8f0; color: #1d7a4c; }
.feedback.bad { background: #fdecec; color: #b53c39; }
.feedback.hint { background: #eef2f8; color: var(--muted); font-weight: 500; }
.feedback .expl { font-weight: 400; margin-top: 6px; color: var(--ink); }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); box-shadow: 0 -2px 10px rgba(31,42,68,.08); }
.nav-row { max-width: 728px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.nav .feedback { max-width: 728px; margin-left: auto; margin-right: auto; }
.nav .primary, .nav .secondary { min-width: 120px; }
.page.quiz { padding-bottom: 96px; }

/* results */
.score { font-size: 64px; font-weight: 800; color: var(--blue); line-height: 1; }
.dots { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; margin-top: 12px; }
.dot { height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.skip { background: #b9c2d3; }
.dot:hover { filter: brightness(.92); }

.resume { padding: 12px 16px; border-radius: 14px; background: #fff7e8; border: 1px solid #f7d9a3; margin-bottom: 14px; }
