:root {
  color-scheme: light;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #ccfbf1;
  --accent: #b45309;
  --background: #f0fdfa;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #102a2a;
  --muted: #526568;
  --border: #b6d9d4;
  --success: #137333;
  --success-soft: #e6f4ea;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --focus: #f59e0b;
  --shadow: 0 18px 50px rgba(15, 118, 110, .10);
  --radius: 20px;
  --font-heading: "Lexend", "Segoe UI", sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 85% 4%, rgba(45, 212, 191, .16), transparent 28rem),
    linear-gradient(180deg, #f8fffd 0, var(--background) 52%, #e6fffa 100%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
}

button, a { touch-action: manipulation; }
button { font: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; left: 16px; top: 12px; z-index: 1000;
  transform: translateY(-150%); padding: 10px 14px;
  border-radius: 10px; background: var(--text); color: white;
}
.skip-link:focus { transform: translateY(0); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.site-header, .site-footer {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between;
}
.site-header { min-height: 88px; padding-block: 16px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-family: var(--font-heading); font-weight: 650; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: white; box-shadow: 0 6px 18px rgba(15,118,110,.2); }
.brand-mark svg { width: 23px; }
.header-stat { text-align: right; font-size: 13px; color: var(--muted); line-height: 1.25; }
.header-stat strong { display: block; color: var(--text); font: 650 18px var(--font-heading); font-variant-numeric: tabular-nums; }

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
main { width: min(960px, calc(100% - 32px)); min-height: calc(100dvh - 180px); margin: 0 auto; }
.screen { padding: clamp(44px, 8vw, 92px) 0 72px; }
.screen:focus { outline: none; }
.welcome-screen { text-align: center; }
.eyebrow { color: var(--primary); font-family: var(--font-heading); font-size: 13px; font-weight: 650; letter-spacing: .13em; text-transform: uppercase; }
h1, h2 { margin-top: 0; font-family: var(--font-heading); line-height: 1.12; letter-spacing: -.035em; text-wrap: balance; }
h1 { margin-bottom: 22px; font-size: clamp(38px, 7vw, 70px); }
h1 span { color: var(--primary); }
.lead { max-width: 650px; margin: 0 auto 42px; color: var(--muted); font-size: clamp(18px, 2.5vw, 22px); }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 0 auto 36px; text-align: left; }
.feature-card { min-height: 164px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,.78); box-shadow: 0 8px 30px rgba(15,118,110,.05); }
.feature-card svg { width: 28px; color: var(--primary); margin-bottom: 20px; }
.feature-card strong, .feature-card span { display: block; }
.feature-card strong { margin-bottom: 4px; font-family: var(--font-heading); font-size: 16px; }
.feature-card span { color: var(--muted); font-size: 15px; }

.start-actions, .result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }
.button {
  min-height: 52px; padding: 13px 22px; border: 1px solid transparent; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer; font-family: var(--font-heading); font-weight: 600; transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.button:active { opacity: .82; }
.button svg { width: 20px; }
.button-primary { background: var(--primary); color: white; box-shadow: 0 9px 24px rgba(15,118,110,.22); }
.button-primary:hover { background: var(--primary-hover); box-shadow: 0 12px 28px rgba(15,118,110,.28); }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button-secondary:hover { border-color: var(--primary); background: #f7fffd; }
.button:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
.privacy-note { margin: 18px 0 0; color: var(--muted); font-size: 14px; }

.quiz-screen { max-width: 800px; margin-inline: auto; padding-top: 30px; }
.quiz-topbar { min-height: 48px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.text-button { min-width: 48px; min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-align: left; font-weight: 600; }
.text-button:hover { color: var(--danger); }
.question-count { font-weight: 600; color: var(--text); }
.score-live { text-align: right; font-variant-numeric: tabular-nums; }
.progress-track { height: 7px; overflow: hidden; margin: 10px 0 30px; border-radius: 999px; background: #d8ebe8; }
.progress-fill { width: 5%; height: 100%; border-radius: inherit; background: var(--primary); transition: transform .25s ease, width .25s ease; }

.question-card { padding: clamp(24px, 5vw, 48px); border: 1px solid var(--border); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.question-number { margin-bottom: 14px; color: var(--primary); font: 650 13px var(--font-heading); letter-spacing: .1em; text-transform: uppercase; }
.question-card h2 { margin-bottom: 30px; font-size: clamp(24px, 4vw, 34px); overflow-wrap: anywhere; }
.answers { display: grid; gap: 12px; }
.answer {
  width: 100%; min-height: 62px; padding: 14px 16px; border: 1.5px solid #b8c9ca; border-radius: 15px;
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left; transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}
.answer:hover:not(:disabled) { border-color: var(--primary); background: #f6fffd; }
.answer-letter { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: #edf6f5; font: 650 14px var(--font-heading); }
.answer-text { line-height: 1.4; overflow-wrap: anywhere; }
.answer-icon { width: 23px; height: 23px; }
.answer.correct { border-color: var(--success); background: var(--success-soft); box-shadow: 0 0 0 1px var(--success); }
.answer.incorrect { border-color: var(--danger); background: var(--danger-soft); box-shadow: 0 0 0 1px var(--danger); }
.answer.correct .answer-letter { background: var(--success); color: white; }
.answer.incorrect .answer-letter { background: var(--danger); color: white; }
.answer:disabled { cursor: default; color: var(--text); }
.feedback { margin: 20px 0 0; padding: 13px 16px; border-radius: 12px; font-weight: 650; }
.feedback.success { background: var(--success-soft); color: var(--success); }
.feedback.error { background: var(--danger-soft); color: var(--danger); }
.next-button { margin-top: 20px; margin-left: auto; }

.results-screen { max-width: 820px; margin-inline: auto; text-align: center; }
.results-screen h1 { margin-bottom: 10px; font-size: clamp(38px, 6vw, 58px); }
.result-badge { width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 22px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); }
.result-badge svg { width: 38px; }
.result-message { margin: 0 auto 30px; color: var(--muted); font-size: 19px; }
.score-card { margin-bottom: 28px; padding: 24px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.score-card div + div { border-left: 1px solid var(--border); }
.score-card strong, .score-card span { display: block; }
.score-card strong { font: 650 clamp(26px, 5vw, 38px) var(--font-heading); font-variant-numeric: tabular-nums; }
.score-card span { color: var(--muted); font-size: 14px; }
.mistakes-section { margin-top: 48px; text-align: left; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 5px 0 0; font-size: 25px; }
.count-badge { min-width: 38px; padding: 5px 11px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); text-align: center; font-weight: 700; }
.mistakes-list { display: grid; gap: 12px; }
.mistake-card { padding: 20px; border-left: 4px solid var(--danger); border-radius: 12px; background: var(--surface); box-shadow: 0 5px 20px rgba(30,41,59,.06); }
.mistake-card p { margin: 0 0 10px; font-family: var(--font-heading); font-weight: 550; }
.mistake-card span { color: var(--success); font-size: 15px; font-weight: 650; }
.error-screen { max-width: 600px; margin: auto; text-align: center; }
.error-screen h1 { font-size: 36px; }
.error-screen code { padding: 2px 5px; border-radius: 4px; background: #e2e8f0; }

.site-footer { min-height: 90px; padding-block: 24px; border-top: 1px solid rgba(15,118,110,.15); color: var(--muted); font-size: 14px; }
.site-footer span:first-child { font-family: var(--font-heading); color: var(--text); font-weight: 600; }

@media (max-width: 680px) {
  .site-header, .site-footer, main { width: min(100% - 24px, 960px); }
  .site-header { min-height: 72px; }
  .screen { padding-top: 36px; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature-card { min-height: auto; display: grid; grid-template-columns: 34px 1fr; column-gap: 14px; padding: 18px; }
  .feature-card svg { grid-row: span 2; margin: 4px 0 0; }
  .feature-card strong { align-self: end; }
  .start-actions, .result-actions { flex-direction: column; }
  .start-actions .button, .result-actions .button { width: 100%; }
  .quiz-topbar { grid-template-columns: auto 1fr auto; }
  .question-count { text-align: center; }
  .score-live { font-size: 0; }
  .score-live span { font-size: 14px; }
  .question-card { padding: 24px 18px; border-radius: 20px; }
  .answer { grid-template-columns: 36px minmax(0, 1fr) auto; padding: 12px; }
  .next-button { width: 100%; }
  .score-card { padding: 18px 8px; }
  .score-card strong { font-size: 25px; }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (max-width: 420px) {
  .header-stat { display: none; }
}

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

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --primary: #5eead4;
    --primary-hover: #99f6e4;
    --primary-soft: #123d3a;
    --background: #071a1a;
    --surface: #102727;
    --surface-alt: #163232;
    --text: #edfdf9;
    --muted: #b3cfcb;
    --border: #38645e;
    --success: #86efac;
    --success-soft: #143b28;
    --danger: #fca5a5;
    --danger-soft: #482020;
    --shadow: 0 18px 50px rgba(0, 0, 0, .28);
  }
  body { background: radial-gradient(circle at 85% 4%, rgba(45,212,191,.11), transparent 28rem), var(--background); }
  .brand-mark, .button-primary { background: #0f766e; color: white; }
  .button-primary:hover { background: #115e59; }
  .feature-card { background: rgba(16,39,39,.88); }
  .button-secondary, .answer { background: var(--surface); }
  .button-secondary:hover, .answer:hover:not(:disabled) { background: var(--surface-alt); }
  .answer-letter { background: #214541; }
  .progress-track { background: #284b47; }
  .error-screen code { background: #263e3e; }
}
