:root {
  color-scheme: light dark;
  --bg: #f7f4ed;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #18211f;
  --muted: #66716e;
  --line: #dbe2df;
  --brand: #1d5b4f;
  --brand-strong: #16483f;
  --brand-soft: #dcece7;
  --wrong: #9b3d36;
  --wrong-soft: #f6e3e0;
  --shadow: 0 18px 50px rgb(29 48 43 / 9%);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 100% 0, rgb(65 132 116 / 12%), transparent 30rem),
    var(--bg);
}

button, input, select { font: inherit; }
button, .button { min-height: 48px; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.9rem, 7vw, 2.8rem); letter-spacing: -.045em; }
h2 { font-size: 1.35rem; letter-spacing: -.025em; }

.shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin-inline: auto;
  padding: max(24px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.eyebrow {
  margin-bottom: .4rem;
  color: var(--brand);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.muted { color: var(--muted); line-height: 1.55; }
.topbar, .quiz-header, .section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar { margin-bottom: 30px; }
.topbar h1 { margin-bottom: 0; }
.quiet, .quiet-link {
  border: 0;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
}
.section-heading { align-items: end; }
.section-heading h2 { margin-bottom: 0; }
.total { color: var(--muted); white-space: nowrap; }
.stats-filter {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 16px;
}
.stats-filter label { font-size: .78rem; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0 28px;
}
.slot-card {
  display: grid;
  gap: 4px;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.slot-card span { color: var(--muted); font-size: .72rem; }
.slot-card strong { font-size: 1.25rem; }

.panel, .auth-card, .quiz-card {
  padding: clamp(22px, 6vw, 38px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card {
  width: min(100%, 460px);
  margin: max(6vh, 24px) auto 0;
}
.stack { display: grid; gap: 18px; }
label { display: grid; gap: 7px; font-weight: 650; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-strong);
}
fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}
legend { margin-bottom: 10px; font-weight: 750; }
.choice { grid-template-columns: 22px 1fr; align-items: center; font-weight: 500; }
.choice input { width: 20px; min-height: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

button, .button {
  display: inline-grid;
  place-items: center;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: var(--surface-strong);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent);
  outline-offset: 2px;
}
.primary { border-color: var(--brand); color: white; background: var(--brand); }
.primary:active { background: var(--brand-strong); }
.notice { margin-bottom: 20px; padding: 13px 15px; border-radius: 12px; background: var(--brand-soft); }
.notice-error { color: var(--wrong); background: var(--wrong-soft); }

.quiz-header { margin: 4px 0 12px; color: var(--muted); font-size: .9rem; }
.progress { height: 5px; margin-bottom: 28px; overflow: hidden; border-radius: 999px; background: var(--line); }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .25s ease; }
.quiz-card { min-height: calc(100dvh - 130px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.prompt {
  margin: clamp(38px, 8vh, 90px) 0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: clamp(2.7rem, 12vw, 4.6rem);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}
.prompt[lang="de"], .prompt[lang="en"] { font-family: inherit; font-size: clamp(2rem, 8vw, 3.2rem); }
.answer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.answer-grid button { min-height: 62px; font-size: 1.06rem; }
.result-mark { font-size: 1.1rem; font-weight: 850; }
.is-correct .result-mark { color: var(--brand); }
.is-wrong .result-mark { color: var(--wrong); }
.solution {
  display: grid;
  gap: 8px;
  margin: 24px 0;
  padding: 18px;
  border-radius: 15px;
  background: var(--brand-soft);
}
.solution strong { font-size: 1.35rem; }
.solution small { color: var(--muted); line-height: 1.4; }
.sticky-action { position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); margin-top: 32px; }
.sticky-action button { width: 100%; }
.complete { text-align: center; }
.completion-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  border-radius: 50%;
  color: white;
  background: var(--brand);
  font-size: 2rem;
  font-weight: 850;
}

@media (max-width: 480px) {
  .shell { padding-inline: max(14px, env(safe-area-inset-left)); }
  .slot-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .stats-filter { grid-template-columns: 1fr 1fr; }
  .stats-filter label:first-child { grid-column: 1 / -1; }
  .panel, .auth-card, .quiz-card { padding: 21px 17px; border-radius: 20px; }
  .answer-grid:has(button:nth-of-type(1)[lang="de"]),
  .answer-grid:has(button:nth-of-type(1)[lang="en"]) { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131717;
    --surface: #1a201e;
    --surface-strong: #202725;
    --text: #eef4f1;
    --muted: #a1aca8;
    --line: #35413d;
    --brand: #67baa5;
    --brand-strong: #4fa38e;
    --brand-soft: #213d36;
    --wrong: #f09b91;
    --wrong-soft: #472a28;
    --shadow: 0 18px 50px rgb(0 0 0 / 28%);
  }
  .primary { color: #0e241e; }
}

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