:root {
  color-scheme: light;
  --navy: #102b50;
  --blue: #174f91;
  --red: #c52832;
  --ink: #182d45;
  --muted: #5c6b7a;
  --line: #d7e1eb;
  --paper: #ffffff;
  --canvas: #f3f6f9;
  --good: #166534;
  --good-bg: #eaf6ed;
  --green-button: #16703d;
  --green-button-hover: #115c31;
  --bad: #a61e2b;
  --bad-bg: #fff0f0;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--canvas);
}

button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  min-height: 68px;
  padding: 0 clamp(18px, 5vw, 64px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: #fff;
  background: var(--navy);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: .01em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 17px;
}

.brand-light, .topbar-note { color: #d6e4f2; font-weight: 400; }
.topbar-note { font-size: 14px; }

.page-shell {
  width: min(900px, calc(100% - 32px));
  margin: clamp(28px, 6vh, 64px) auto 44px;
  flex: 1;
}

.panel {
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgb(16 43 80 / 6%);
}

.start-panel, .result-panel, .error-panel { max-width: 800px; margin: 0 auto; }
.eyebrow { margin: 0 0 10px; color: var(--blue); font-size: 13px; font-weight: 700; letter-spacing: .09em; }
h1 { margin: 0; color: var(--navy); font-size: clamp(30px, 5vw, 42px); line-height: 1.15; }
.intro { max-width: 690px; margin: 16px 0 0; color: var(--muted); font-size: 18px; line-height: 1.55; }

.setup-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .85fr); gap: 28px; margin: 34px 0 20px; align-items: center; }
.topic-field { grid-column: 1 / -1; }
.setup-field > label { display: block; margin-bottom: 10px; color: var(--navy); font-size: 17px; font-weight: 700; }
.topic-select { width: 100%; min-height: 50px; padding: 11px 42px 11px 14px; border: 1px solid #aebdcd; border-radius: 8px; color: var(--navy); background-color: #fff; font-size: 16px; }
.topic-select:focus-visible { outline: 3px solid rgb(23 79 145 / 22%); border-color: var(--blue); }
.topic-select:disabled { color: var(--muted); background: #f2f5f8; }
.field-note { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.count-control { display: flex; align-items: baseline; gap: 11px; }
.count-control input { width: 150px; padding: 10px 12px; border: 1px solid #aebdcd; border-radius: 8px; color: var(--navy); font-size: 24px; font-weight: 700; }
.count-control span { color: var(--muted); font-size: 15px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.preset { min-width: 48px; padding: 7px 12px; border: 1px solid #c8d5e2; border-radius: 20px; color: var(--blue); background: #f6f9fc; font-size: 14px; font-weight: 700; }
.preset:hover, .preset:focus-visible { border-color: var(--blue); background: #eaf2fb; }
.toggle-row { display: flex; align-items: flex-start; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; cursor: pointer; }
.toggle-row input { width: 19px; height: 19px; margin: 2px 0 0; accent-color: var(--blue); }
.toggle-copy { display: grid; gap: 5px; }
.toggle-copy strong { color: var(--navy); font-size: 15px; }
.toggle-copy span { color: var(--muted); font-size: 14px; line-height: 1.4; }

.status { min-height: 21px; margin: 10px 0 14px; color: var(--muted); font-size: 14px; }
.status.error { color: var(--bad); }
.button { min-height: 48px; padding: 12px 20px; border: 0; border-radius: 8px; font-size: 16px; font-weight: 700; transition: background-color .15s ease, transform .15s ease; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { color: #fff; background: var(--red); }
.button-primary:hover:not(:disabled) { background: #a91e28; }
.button-secondary { border: 1px solid #b8c8d9; color: var(--navy); background: #fff; }
.button-secondary:hover { background: #f2f6fa; }
.button-quiet { min-height: 40px; padding: 9px 12px; color: var(--blue); background: transparent; }
.button-quiet:hover { background: #f1f5f9; }
.source-note { margin: 25px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.5; }

.quiz-panel { max-width: 900px; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.progress-label { margin: 0; color: var(--muted); font-size: 15px; }
.progress-track { height: 8px; overflow: hidden; margin: 18px 0 28px; border-radius: 8px; background: #e8edf2; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--red); transition: width .2s ease; }
.question-number { margin: 0 0 10px; color: var(--blue); font-size: 15px; font-weight: 700; }
.question-text { max-width: 760px; font-size: clamp(24px, 4vw, 32px); line-height: 1.28; }
.answer-list { display: grid; gap: 12px; margin: 28px 0 20px; padding: 0; border: 0; }
.answer-option { position: relative; display: flex; align-items: flex-start; gap: 14px; min-height: 58px; padding: 16px 18px; border: 1px solid #cbd7e2; border-radius: 10px; background: #fff; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.answer-option:hover { border-color: #7394b7; background: #f8fbfe; }
.answer-option:has(input:checked) { border-color: var(--blue); box-shadow: 0 0 0 2px rgb(23 79 145 / 12%); background: #f2f7fd; }
.answer-option input { width: 19px; height: 19px; flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--blue); }
.answer-marker { min-width: 24px; color: var(--blue); font-weight: 700; }
.answer-copy { color: var(--ink); font-size: 17px; line-height: 1.45; }
.answer-letter { min-width: 24px; color: var(--blue); font-weight: 700; }
.answer-text { color: var(--ink); font-size: 17px; line-height: 1.45; }
.answer-option.correct, .answer-option.answer-correct { border-color: #67a77b; background: var(--good-bg); }
.answer-option.incorrect, .answer-option.answer-incorrect { border-color: #d3797f; background: var(--bad-bg); }
.answer-list.locked .answer-option { cursor: default; }
.answer-list.locked .answer-option:hover { border-color: #cbd7e2; background: #fff; }
.answer-list.locked .answer-option.correct:hover { border-color: #67a77b; background: var(--good-bg); }
.response-row { display: flex; align-items: center; gap: 18px; margin-top: 18px; }
.feedback { flex: 1 1 auto; min-width: 0; margin: 0; padding: 15px 17px; border-radius: 9px; font-size: 16px; font-weight: 700; line-height: 1.5; }
.feedback.correct, .feedback.feedback-correct { color: var(--good); background: var(--good-bg); }
.feedback.incorrect, .feedback.feedback-incorrect { color: var(--bad); background: var(--bad-bg); }
.quiz-actions { display: flex; flex: 0 0 auto; justify-content: flex-end; margin: 0; }
.button-next { color: #fff; background: var(--green-button); }
.button-next:hover:not(:disabled) { background: var(--green-button-hover); }
.button-next:focus-visible { outline: 3px solid #8bc99c; outline-offset: 3px; }

.score-line { margin: 18px 0 0; color: var(--red); font-size: clamp(28px, 5vw, 40px); font-weight: 700; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 30px; }
.answer-review { display: grid; gap: 12px; }
.review-item { padding: 17px 18px; border: 1px solid var(--line); border-left: 5px solid #8ba1b7; border-radius: 8px; background: #fff; }
.review-item.was-correct { border-left-color: #32804a; }
.review-item.was-wrong { border-left-color: var(--red); }
.review-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.review-question { margin: 0 0 9px; color: var(--navy); font-size: 16px; font-weight: 700; line-height: 1.45; }
.review-answer { margin: 4px 0 0; color: var(--ink); font-size: 14px; line-height: 1.45; }
.review-answer strong { color: var(--navy); }
.error-panel { border-top: 5px solid var(--red); }
.site-footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px clamp(18px, 5vw, 64px); color: #647386; background: #e9eef3; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 650px) {
  .topbar { min-height: 60px; }
  .brand { font-size: 16px; }
  .topbar-note { font-size: 12px; }
  .setup-grid { grid-template-columns: 1fr; gap: 18px; }
  .quiz-head { align-items: flex-start; }
  .quiz-head .button { font-size: 14px; }
  .panel { border-radius: 10px; }
  .site-footer { flex-direction: column; }
  .answer-option { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
