:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #15803d;
  --soft-blue: #eff6ff;
  --soft-green: #ecfdf5;
  --soft-red: #fef2f2;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #dbeafe 0, transparent 32rem), var(--bg);
}
button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .75; transform: none; }

.app { max-width: 1180px; margin: 0 auto; padding: 28px 18px 56px; }
.page { display: none; }
.page.active { display: block; }
.card { background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.hero { padding: 56px; text-align: center; margin-top: 42px; }
.eyebrow { color: var(--primary); font-weight: 800; letter-spacing: .08em; margin: 0 0 10px; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.1; margin: 0 0 18px; }
.lead { color: var(--muted); font-size: 1.1rem; line-height: 1.7; margin: 0 auto 30px; max-width: 720px; }
.summary { margin-top: 24px; color: var(--muted); }
.hero-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; }
.big { padding: 16px 24px; font-size: 1rem; }
.primary { background: var(--primary); color: white; box-shadow: 0 10px 20px rgba(37,99,235,.22); }
.primary:hover { background: var(--primary-dark); }
.secondary { background: var(--soft-blue); color: var(--primary-dark); }
.ghost { background: white; border: 1px solid var(--line); color: var(--text); padding: 10px 14px; }
.full { width: 100%; padding: 13px 16px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 22px; }
.topbar h2 { margin: 0; font-size: 1.65rem; }
.round-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.round-btn { text-align: left; background: white; border: 1px solid var(--line); padding: 18px; min-height: 94px; box-shadow: 0 8px 18px rgba(15,23,42,.05); }
.round-btn strong { display: block; margin-bottom: 8px; font-size: 1.05rem; }
.round-btn span { color: var(--muted); font-size: .9rem; }

.quiz-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.status { padding: 22px; position: sticky; top: 18px; }
.mode { font-weight: 900; font-size: 1.15rem; margin-bottom: 18px; }
.progress-text { color: var(--muted); margin-bottom: 10px; }
.progress { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--primary); transition: width .2s ease; }
.score-box { display: flex; align-items: baseline; justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 22px 0; padding: 18px 0; }
.score-box span { color: var(--muted); }
.score-box strong { font-size: 1.35rem; }
.question-card { padding: 30px; }
.question-meta { color: var(--muted); font-weight: 700; margin-bottom: 10px; }
#question-number { margin: 0 0 18px; font-size: 1.8rem; }
.question-text, .choice-text, .explanation { white-space: pre-wrap; line-height: 1.72; word-break: keep-all; }
.question-text { background: #f8fafc; border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin-bottom: 18px; }
.choices { display: grid; gap: 12px; }
.choice { display: grid; grid-template-columns: 48px 1fr; align-items: start; gap: 12px; text-align: left; width: 100%; padding: 16px; background: white; border: 1px solid var(--line); color: var(--text); }
.choice-label { font-size: 1.1rem; font-weight: 900; color: var(--primary); }
.choice.correct { background: var(--soft-green); border-color: #86efac; }
.choice.wrong { background: var(--soft-red); border-color: #fca5a5; }
.feedback { margin-top: 18px; border-radius: 18px; padding: 18px; border: 1px solid var(--line); }
.feedback.correct { background: var(--soft-green); border-color: #86efac; }
.feedback.wrong { background: var(--soft-red); border-color: #fca5a5; }
.feedback h3 { margin: 0 0 10px; }
.feedback .answer-line { font-weight: 800; margin-bottom: 8px; }
.hidden { display: none; }
.quiz-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.quiz-actions button { padding: 14px 22px; }
.result-card { max-width: 720px; margin: 72px auto 0; padding: 46px; text-align: center; }
.result-card h2 { font-size: 2.2rem; margin: 0 0 14px; }
.result-score { font-size: 1.25rem; color: var(--muted); margin-bottom: 28px; }

@media (max-width: 820px) {
  .hero { padding: 34px 22px; }
  .quiz-layout { grid-template-columns: 1fr; }
  .status { position: static; }
  .quiz-topbar { align-items: stretch; }
  .choice { grid-template-columns: 38px 1fr; }
}
