:root {
  color-scheme: light;
  --paper: #edf3ed;
  --surface: #fcfdf8;
  --ink: #172d33;
  --muted: #45616a;
  --line: #c9d6d0;
  --action: #134e42;
  --action-ink: #fffdf7;
  --tint: #e4f0e8;
  --well: #e3eee5;
  --accent: #236653;
  --focus: #1765ba;
  --good: #175841;
  --good-bg: #d9f3e3;
  --bad: #8f302c;
  --bad-bg: #fae8e2;
  --title-font: "Unbounded", system-ui, sans-serif;
  --body-font: "Manrope", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #10242b;
  --surface: #172f36;
  --ink: #f2f8f2;
  --muted: #b4ccc9;
  --line: #3e595e;
  --action: #a7f3cf;
  --action-ink: #16362e;
  --tint: #233f43;
  --well: #203a42;
  --accent: #9fe5c5;
  --focus: #88c7ff;
  --good: #b3f4cf;
  --good-bg: #214a3c;
  --bad: #ffd2c7;
  --bad-bg: #563530;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --paper: #10242b;
    --surface: #172f36;
    --ink: #f2f8f2;
    --muted: #b4ccc9;
    --line: #3e595e;
    --action: #a7f3cf;
    --action-ink: #16362e;
    --tint: #233f43;
    --well: #203a42;
    --accent: #9fe5c5;
    --focus: #88c7ff;
    --good: #b3f4cf;
    --good-bg: #214a3c;
    --bad: #ffd2c7;
    --bad-bg: #563530;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 500 1rem/1.55 var(--body-font);
  overflow-wrap: anywhere;
}

body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3, p, ul, figure, dd { margin: 0; }
h1 {
  font: 700 clamp(1.5rem, 5vw, 2rem)/1.26 var(--title-font);
  letter-spacing: -.025em;
}
h2, h3 { font-weight: 800; line-height: 1.32; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
ul { padding: 0; list-style: none; }
svg { display: block; max-width: 100%; }

button {
  appearance: none;
  border: 0;
  margin: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

:where(button, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.icon { width: 1.25rem; height: 1.25rem; flex: none; }
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }

.header-inner, .page {
  width: min(100%, 48rem);
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  flex-wrap: wrap;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: 10px;
}

.brand, .controls, .language {
  display: flex;
  align-items: center;
}
.brand { gap: .5rem; min-height: 48px; padding: 0; font: 700 1rem/1.3 var(--title-font); }
.brand-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: 10px;
  background: var(--action);
  color: var(--action-ink);
}
.controls { gap: .5rem; }
.language {
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2px;
}
.language button {
  min-width: 44px;
  min-height: 42px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 800;
}
.language button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px #142d3330;
}
.theme {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.page { padding-top: 18px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }
.hero, .card, .quiz-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 10px 28px #152f3310;
  min-width: 0;
}

.hero { display: grid; overflow: hidden; }
.hero-art { background: #18343c; display: grid; align-content: center; }
.hero-art svg { width: 100%; }
.hero-body { padding: 20px 18px 22px; }
.hero h1 { font-size: clamp(1.85rem, 8.2vw, 3rem); line-height: 1.08; }
.hero p { margin-block: .9rem 1.4rem; color: var(--muted); max-width: 34ch; }
.hero-actions { display: grid; gap: .65rem; }

.button {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: .65rem .9rem;
  border: 1px solid transparent;
  border-radius: 13px;
  text-align: left;
  font-weight: 800;
  line-height: 1.3;
  transition: box-shadow 160ms, background-color 160ms;
}
.primary { background: var(--action); color: var(--action-ink); }
.secondary { background: var(--surface); border-color: var(--line); }
.text-button {
  width: fit-content;
  min-height: 48px;
  padding: .25rem .5rem .25rem 0;
  color: var(--accent);
}
.text-button .icon { order: -1; }

@media (hover: hover) {
  .secondary:hover, .answer:not(:disabled):hover, .theme:hover { background: var(--tint); }
  .primary:hover { box-shadow: inset 0 0 0 2px currentColor; }
}
.button:active, .answer:not(:disabled):active, .theme:active { opacity: .82; }

.quiz-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .25rem .75rem;
}
.counter { color: var(--muted); }
.counter strong { color: var(--ink); font-variant-numeric: tabular-nums; }
progress {
  display: block;
  width: 100%;
  height: 8px;
  margin: 2px 0 14px;
  appearance: none;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: var(--line);
  color: var(--action);
}
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--action); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--action); border-radius: 99px; }

.quiz-card { padding: 10px; }
.visual {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: var(--well);
}
.visual-road { background: #21353d; }
.visual-road svg { width: 100%; max-width: 26rem; }
.visual-sign { min-height: 132px; }
.visual-sign svg { width: 108px; height: 108px; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: .45rem .5rem 0; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: .4rem; }
.legend i { display: inline-block; width: 12px; height: 12px; flex: none; border-radius: 4px; border: 1px solid #4a6860; }
.legend .you { background: #a7f3cf; }
.legend .other { background: #ffbe92; }
.legend .route { height: 3px; background: #4e9c80; border: none; }

.quiz-body { padding: 11px 5px 5px; }
.question-title {
  font: 800 clamp(1.28rem, 4vw, 1.7rem)/1.42 var(--body-font);
  letter-spacing: -.022em;
}
.term-link {
  display: inline;
  padding: 0;
  color: var(--accent);
  text-align: inherit;
  text-decoration: underline dotted 2px;
  text-underline-offset: .2em;
  letter-spacing: inherit;
}
.term-link:hover { text-decoration-style: solid; }
.hint { color: var(--muted); margin-top: .55rem; }
.answers, .review-list ul { display: grid; gap: .55rem; margin-top: .85rem; }
.answer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .6rem;
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .55rem .65rem;
  background: var(--surface);
  text-align: left;
  line-height: 1.35;
  font-weight: 700;
}
.answer:disabled { cursor: default; opacity: 1; }
.answer-letter {
  display: grid;
  width: 1.85rem;
  height: 1.85rem;
  place-items: center;
  border-radius: 7px;
  background: var(--tint);
}
.answer.right, .answer.wrong { border-color: currentColor; }
.right { color: var(--good); background: var(--good-bg); }
.wrong { color: var(--bad); background: var(--bad-bg); }
.answer-note { display: block; margin-top: .2rem; font-weight: 800; }

.feedback { margin-top: 1rem; }
.status {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: fit-content;
  border-radius: 10px;
  padding: .35rem .6rem;
  font-weight: 800;
  margin-bottom: .8rem;
}
.feedback h2 + p, .memory h3 + p { margin-top: .3rem; }
.trap, .memory {
  margin-top: .9rem;
  padding: .75rem .85rem;
  border-radius: 12px;
  background: var(--tint);
}
.trap { background: var(--bad-bg); color: var(--bad); }
.next-button { margin-top: 1rem; }

.result { padding: 1.35rem; text-align: center; }
.score { color: var(--accent); font: 700 1.65rem/1.3 var(--title-font); margin: .55rem 0; }
.score strong { font-size: 2.9rem; }
.review-list { margin-top: 1.25rem; }
.review-list > p { margin-top: .4rem; }
.review-number { color: var(--accent); }

.sign-intro { margin: .3rem 0 1.15rem; }
.sign-intro p { color: var(--muted); margin-top: .6rem; }
.sign-grid { display: grid; gap: .85rem; }
.sign-card { padding: 1rem; }
.sign-examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: .8rem; }
.sign-examples figure {
  flex: 1 1 112px;
  display: grid;
  align-content: start;
  justify-items: center;
  padding: .65rem .5rem;
  gap: .35rem;
  background: var(--well);
  border-radius: 12px;
  text-align: center;
}
.sign-examples svg { width: 78px; height: 78px; }
.sign-card dl { display: grid; gap: .7rem; margin: .9rem 0 0; }
.sign-card dt { font-weight: 800; }
.sign-card dd { color: var(--muted); }

dialog {
  display: none;
  position: fixed;
  inset: auto 0 0;
  margin: 0 auto;
  padding: 0;
  width: min(100%, 42rem);
  max-width: none;
  max-height: 88dvh;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--ink);
}
dialog[open] { display: block; animation: rise 180ms ease-out; }
dialog::backdrop { background: #0d20249c; }
.sheet-body { padding: 12px 18px max(18px, env(safe-area-inset-bottom)); }
.sheet-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--accent);
  font-weight: 800;
}
.sheet-body h2 { font-size: 1.5rem; margin: .4rem 0; }
.sheet-body .visual { margin-top: .8rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 42rem) {
  .header-inner, .page { padding-inline: 24px; }
  .page { padding-top: 24px; }
  .hero { grid-template-columns: .95fr 1.05fr; }
  .hero-body { padding: 26px 24px; }
  .quiz-card { max-width: 40rem; margin-inline: auto; padding: 14px; }
  .quiz-body { padding: 14px 12px 8px; }
  .quiz-top, progress { max-width: 40rem; margin-inline: auto; }
  .sign-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
