/* Deutsch Quest — playful but disciplined.
   Colour carries meaning (correct/wrong/accent); chrome stays calm.
   Light + dark both wired. Mobile-first. */

:root {
  --bg: #fdf6ec;
  --surface: #ffffff;
  --surface-2: #fbf1e4;
  --ink: #241c15;
  --ink-2: #6b5d4f;
  --ink-3: #9c8d7d;
  --line: #ece0cf;
  --accent: #c2410c;        /* pretzel-brown orange: interaction only */
  --accent-ink: #ffffff;
  --good: #15803d;
  --good-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --streak: #ea580c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(60, 40, 10, 0.10);
  --shadow-sm: 0 2px 8px rgba(60, 40, 10, 0.08);
  --font: "Fredoka", "Baloo 2", ui-rounded, "Segoe UI Rounded", "Nunito",
          system-ui, -apple-system, "Segoe UI", sans-serif;
  --maxw: 560px;
}

html[data-theme="dark"] {
  --bg: #1a1410;
  --surface: #241c16;
  --surface-2: #2d241c;
  --ink: #f6ecdf;
  --ink-2: #c3b4a3;
  --ink-3: #8c7c6b;
  --line: #3a2f25;
  --accent: #fb923c;
  --accent-ink: #1a1410;
  --good: #4ade80;
  --good-bg: #14331f;
  --bad: #f87171;
  --bad-bg: #3a1818;
  --streak: #fb923c;
  --shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(194,65,12,0.06), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(234,88,12,0.06), transparent 42%);
}

.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;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(14px, 4vw, 22px);
}

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 2px 10px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { font-size: 26px; }
.brand-name { font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 19px; cursor: pointer; line-height: 1;
  display: grid; place-items: center; transition: transform .15s, border-color .15s;
}
.icon-btn:hover { transform: rotate(-12deg); border-color: var(--accent); }
.theme-dark { display: none; }
html[data-theme="dark"] .theme-light { display: none; }
html[data-theme="dark"] .theme-dark { display: inline; }

/* ---- Stage / screens ---- */
.stage { flex: 1; display: flex; }
.screen {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 6px 0 20px; animation: pop .28s ease;
}
.is-hidden { display: none !important; }

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.headline {
  font-size: clamp(26px, 7vw, 34px); line-height: 1.08; margin: 10px 0 6px;
  letter-spacing: -0.02em; font-weight: 700;
}
.subhead { color: var(--ink-2); font-size: 15.5px; line-height: 1.5; margin: 0 4px 18px; max-width: 44ch; }
.subhead em { color: var(--accent); font-style: normal; font-weight: 600; }

/* ---- Mascot ---- */
.mascot-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.mascot-big svg { width: 148px; height: 148px; }
.mascot-wrap svg { width: 112px; height: 112px; display: block; }
.mascot-wrap.react-good svg { animation: bounce .5s ease; }
.mascot-wrap.react-bad svg  { animation: shake .45s ease; }
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  30% { transform: translateY(-16px) rotate(-4deg); }
  60% { transform: translateY(-4px) rotate(3deg); }
}
@keyframes shake {
  0%,100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-7px) rotate(-3deg); }
  40% { transform: translateX(7px) rotate(3deg); }
  60% { transform: translateX(-5px) rotate(-2deg); }
  80% { transform: translateX(5px) rotate(2deg); }
}

.speech {
  margin-top: 10px;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 10px 15px; font-size: 15px;
  font-weight: 500; color: var(--ink); box-shadow: var(--shadow-sm);
  max-width: 42ch; min-height: 1.2em; position: relative;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s;
}
.speech.show { opacity: 1; transform: none; }
.speech::before {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-bottom-color: var(--line);
}
.speech::after {
  content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom-color: var(--surface);
}
.speech.good { border-color: var(--good); background: var(--good-bg); }
.speech.good::after { border-bottom-color: var(--good-bg); }
.speech.good::before { border-bottom-color: var(--good); }
.speech.bad { border-color: var(--bad); background: var(--bad-bg); }
.speech.bad::after { border-bottom-color: var(--bad-bg); }
.speech.bad::before { border-bottom-color: var(--bad); }

/* ---- Category grid (start) ---- */
.cat-grid {
  border: 0; margin: 0 0 16px; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; width: 100%;
}
.cat-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 12px 13px; text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
}
.cat-chip:hover { transform: translateY(-1px); }
.cat-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cat-chip .cc-emoji { font-size: 22px; }
.cat-chip .cc-label { font-size: 13.5px; font-weight: 600; line-height: 1.15; }
.cat-chip .cc-count { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.cat-chip.is-on { border-color: var(--accent); background: var(--surface-2); }
.cat-chip.is-on::after { content: "✓"; margin-left: auto; color: var(--accent); font-weight: 700; }
.cat-chip:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- Direction segmented ---- */
.dir-row { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; justify-content: center; }
.dir-label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; }
.seg-btn {
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 999px;
  transition: color .15s;
}
.seg-btn.is-active { background: var(--accent); color: var(--accent-ink); }
.seg-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- HUD ---- */
.hud { display: flex; gap: 10px; width: 100%; margin-bottom: 10px; }
.hud-item {
  flex: 1; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 6px; display: flex; flex-direction: column; gap: 1px;
}
.hud-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.hud-item strong { font-size: 20px; font-weight: 700; }
.hud-streak .flame { font-size: 15px; margin-left: 1px; opacity: .35; transition: opacity .2s, transform .2s; }
.hud-streak.hot .flame { opacity: 1; transform: scale(1.2); }
.hud-streak.hot strong { color: var(--streak); }

/* ---- Progress ---- */
.progress { width: 100%; height: 9px; background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width .4s cubic-bezier(.2,.8,.2,1); }

/* ---- Question card ---- */
.qcard { width: 100%; margin-top: 16px; }
.q-kicker { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; margin: 0 0 4px; }
.q-prompt { font-size: clamp(24px, 6.5vw, 30px); font-weight: 700; margin: 0 0 18px; letter-spacing: -0.01em; }

.answers { display: grid; gap: 10px; }
.answer {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); color: var(--ink);
  border-radius: var(--radius); padding: 15px 17px; font: inherit; font-size: 17px; font-weight: 600;
  display: flex; align-items: center; gap: 11px; transition: border-color .12s, background .12s, transform .08s;
}
.answer .idx {
  width: 26px; height: 26px; flex: none; border-radius: 7px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 13px; color: var(--ink-2); font-weight: 700;
}
.answer:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.answer:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.answer:disabled { cursor: default; }
.answer.correct { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.answer.correct .idx { background: var(--good); color: #fff; }
.answer.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.answer.wrong .idx { background: var(--bad); color: #fff; }
.answer .mark { margin-left: auto; font-size: 18px; }

/* ---- Buttons ---- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 999px;
  border: 2px solid transparent; padding: 13px 24px; font-size: 16px;
  transition: transform .1s, filter .15s, background .15s; margin-top: 6px;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-lg { padding: 15px 34px; font-size: 18px; margin-top: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.fine { font-size: 12.5px; color: var(--ink-3); margin-top: 14px; }

/* ---- Scoreboard (results) ---- */
.scoreboard { display: flex; gap: 10px; width: 100%; margin: 8px 0 22px; }
.sb-item { flex: 1; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 15px 8px; }
.sb-k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; margin-bottom: 3px; }
.sb-item strong { font-size: 27px; font-weight: 700; }
.done-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.done-actions .btn { width: 100%; max-width: 320px; }

.foot { text-align: center; padding: 14px 0 22px; color: var(--ink-3); font-size: 12px; }

@media (max-width: 380px) {
  .cat-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
