:root {
  --navy: #17324d;
  --navy-2: #244a6c;
  --blue: #2563eb;
  --paper: #f4f1e9;
  --surface: #fffdf8;
  --ink: #17202a;
  --muted: #64717f;
  --line: #d9d7cf;
  --good: #14734a;
  --good-soft: #e5f6ed;
  --bad: #b53a32;
  --bad-soft: #fff0ee;
  --warn: #9a5a0a;
  --focus: #f3b61f;
  --shadow: 0 18px 45px rgba(23, 50, 77, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% 0, #dce8ee 0, transparent 32rem), var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; background: white; color: var(--navy); padding: .8rem; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }
.topbar { min-height: 72px; padding: .7rem clamp(1rem, 4vw, 3rem); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(23, 50, 77, .12); background: rgba(255, 253, 248, .9); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.brand { border: 0; background: transparent; display: flex; align-items: center; gap: .75rem; color: var(--navy); text-align: left; padding: 0; }
.brand-mark { display: grid; place-items: center; width: 42px; aspect-ratio: 1; border-radius: 50%; background: var(--navy); color: white; font-weight: 900; letter-spacing: .05em; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: .12rem; }
.shell { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(2rem, 5vw, 4.5rem) 0; }
.hero { max-width: 780px; }
.hero h1 { font-family: Georgia, serif; color: var(--navy); font-size: clamp(2.2rem, 6vw, 4.7rem); line-height: .98; margin: .35rem 0 1.15rem; letter-spacing: -.04em; }
.hero > p:last-child { font-size: clamp(1.05rem, 2vw, 1.3rem); color: var(--muted); line-height: 1.6; max-width: 680px; }
.eyebrow { margin: 0; font-size: .76rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; color: var(--blue); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin: 2.5rem 0 1.25rem; }
.stat-card { border-top: 3px solid var(--navy); background: rgba(255,255,255,.56); padding: 1.1rem; }
.stat-card span, .stat-card strong { display: block; }
.stat-card span { color: var(--muted); font-size: .86rem; }
.stat-card strong { color: var(--navy); font-size: 1.65rem; margin-top: .35rem; }
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.mode-card { position: relative; min-height: 285px; padding: clamp(1.4rem, 3vw, 2.2rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: 0 4px 18px rgba(23,50,77,.05); overflow: hidden; }
.mode-card.featured { color: white; background: linear-gradient(145deg, var(--navy), var(--navy-2)); border-color: transparent; box-shadow: var(--shadow); }
.mode-card.featured .eyebrow { color: #9dd3ff; }
.mode-card h2 { margin: .5rem 0 .65rem; font-size: 1.55rem; }
.mode-card p:not(.eyebrow) { line-height: 1.55; color: var(--muted); max-width: 75%; }
.mode-card.featured p:not(.eyebrow) { color: #dbe6ef; }
.mode-icon { position: absolute; right: 1.2rem; top: 1.1rem; color: rgba(37,99,235,.12); font-weight: 900; font-size: 3.2rem; }
.featured .mode-icon { color: rgba(255,255,255,.14); }
.mode-card .button { position: absolute; left: clamp(1.4rem, 3vw, 2.2rem); bottom: 1.5rem; }
.hard-card { border-style: dashed; }

.button { min-height: 44px; border-radius: .65rem; padding: .72rem 1rem; border: 1px solid transparent; font-weight: 750; transition: transform .16s, box-shadow .16s, background .16s; }
.button:not(:disabled):hover { transform: translateY(-1px); }
.button-primary { background: var(--blue); color: white; box-shadow: 0 7px 18px rgba(37,99,235,.2); }
.button-secondary { color: var(--navy); background: white; border-color: #b9c4ce; }
.button-ghost { color: var(--navy); background: transparent; border-color: #bdc7d0; }
.button-help { color: #744600; background: #fff6dd; border-color: #e5bd67; }
.text-button { color: var(--blue); border: 0; background: transparent; padding: .3rem 0; text-decoration: underline; font-weight: 700; }
.danger-text { color: var(--bad); margin-top: 1.25rem; }
.privacy-note { margin-top: 1.5rem; color: var(--muted); line-height: 1.5; }
.privacy-note summary { color: var(--navy); cursor: pointer; font-weight: 750; }
.resume-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding: 1rem 1.25rem; background: #fff7dc; border: 1px solid #e1c46f; border-radius: .85rem; }
.resume-panel strong { display: block; color: var(--navy); margin-top: .25rem; }

.quiz-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.quiz-metrics { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: .9rem; }
.timer { color: var(--navy); background: white; border: 1px solid var(--line); border-radius: .5rem; padding: .45rem .65rem; font-variant-numeric: tabular-nums; }
.timer.urgent { color: var(--bad); border-color: var(--bad); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { background: var(--bad-soft); } }
.progress-row { display: flex; justify-content: space-between; margin: 2rem 0 .55rem; color: var(--muted); font-size: .88rem; }
.progress-track { height: 7px; border-radius: 99px; background: #d9dfe2; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--blue); transition: width .25s; }
.question-card { width: min(820px, 100%); margin: 2rem auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 1.15rem; padding: clamp(1.3rem, 4vw, 3rem); box-shadow: var(--shadow); }
.question-meta { display: flex; justify-content: space-between; gap: .75rem; align-items: center; }
.question-number { font-weight: 800; color: var(--navy); }
.topic-chip { border-radius: 99px; color: var(--navy); background: #e7eff5; padding: .3rem .65rem; font-size: .76rem; font-weight: 750; }
.question-card h1 { font-family: Georgia, serif; color: var(--navy); font-size: clamp(1.45rem, 4vw, 2.15rem); line-height: 1.28; margin: 1.25rem 0 1.5rem; }
#choices-list { border: 0; padding: 0; margin: 0; display: grid; gap: .7rem; }
.choice { display: grid; grid-template-columns: 2.25rem 1fr; gap: .85rem; align-items: center; width: 100%; min-height: 58px; padding: .85rem; border: 1px solid #cbd2d6; border-radius: .75rem; background: white; cursor: pointer; line-height: 1.4; transition: border .15s, background .15s; }
.choice:hover { border-color: var(--blue); }
.choice:has(input:checked) { border: 2px solid var(--blue); background: #eff5ff; padding: calc(.85rem - 1px); }
.choice.correct { border: 2px solid var(--good); background: var(--good-soft); padding: calc(.85rem - 1px); }
.choice.wrong { border: 2px solid var(--bad); background: var(--bad-soft); padding: calc(.85rem - 1px); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-letter { display: grid; place-items: center; width: 2.15rem; aspect-ratio: 1; border-radius: 50%; color: var(--navy); background: #edf0f2; font-weight: 850; }
.choice:has(input:checked) .choice-letter { color: white; background: var(--blue); }
.choice.correct .choice-letter { background: var(--good); color: white; }
.choice.wrong .choice-letter { background: var(--bad); color: white; }
.check-button { width: 100%; margin-top: 1.2rem; }
.feedback { margin-top: 1.2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.feedback-heading { display: grid; grid-template-columns: 2.4rem 1fr; gap: .75rem; }
#feedback-icon { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; color: white; font-weight: 900; }
.feedback.is-correct #feedback-icon { background: var(--good); }
.feedback.is-wrong #feedback-icon { background: var(--bad); }
.feedback-heading p { margin: .25rem 0 1rem; color: var(--muted); }
.hint-panel, .explanation-panel { border-left: 4px solid #d69d29; background: #fff7e3; padding: 1rem; margin-top: 1rem; border-radius: 0 .65rem .65rem 0; line-height: 1.5; }
.explanation-panel { border-color: var(--good); background: var(--good-soft); }
.hint-panel p, .explanation-panel p { margin: .35rem 0 0; }
.next-button { width: 100%; margin-top: 1.1rem; }

.results-card { max-width: 680px; margin: 1rem auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 1.2rem; padding: clamp(1.5rem, 5vw, 3.5rem); box-shadow: var(--shadow); }
.result-ring { --score-angle: 0deg; width: 142px; aspect-ratio: 1; display: grid; place-items: center; margin: 0 auto 1.5rem; border-radius: 50%; background: conic-gradient(var(--good) var(--score-angle), #e0e4e5 0); position: relative; }
.result-ring::before { content: ""; position: absolute; inset: 10px; border-radius: inherit; background: var(--surface); }
.result-ring strong { position: relative; color: var(--navy); font-size: 1.7rem; }
.results-card h1 { color: var(--navy); margin: .4rem 0; }
.results-card > p { color: var(--muted); line-height: 1.5; }
.result-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 1.5rem 0; }
.result-details div { background: #eff2f3; padding: .85rem; border-radius: .65rem; }
.result-details span, .result-details strong { display: block; }
.result-details span { color: var(--muted); font-size: .8rem; }
.result-details strong { margin-top: .25rem; color: var(--navy); font-size: 1.25rem; }
.result-message { padding: .9rem; background: #eef4ff; border-radius: .6rem; }
.result-actions { display: flex; justify-content: center; gap: .7rem; flex-wrap: wrap; }
footer { color: var(--muted); font-size: .8rem; text-align: center; padding: 1.5rem; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 30; max-width: calc(100% - 2rem); color: white; background: var(--navy); border-radius: .65rem; padding: .8rem 1rem; box-shadow: var(--shadow); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 270px; }
  .quiz-toolbar { align-items: flex-start; }
  .quiz-metrics { display: grid; gap: .25rem; text-align: right; }
  .resume-panel { align-items: flex-start; flex-direction: column; }
  .resume-panel .button { width: 100%; }
}
@media (max-width: 440px) {
  .brand small { display: none; }
  .brand strong { font-size: .88rem; }
  .install-button { font-size: .8rem; }
  .shell { width: min(100% - 1rem, 1120px); }
  .question-card { padding: 1rem; }
  .question-card h1 { font-size: 1.35rem; }
  .choice { grid-template-columns: 2rem 1fr; padding: .75rem; }
  .result-details { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
