:root {
  --bg: #f4f3fb;
  --surface: #ffffff;
  --surface-2: #eceaf8;
  --text: #1c1b2e;
  --muted: #625f7a;
  --line: #dcd9ee;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #e4e2fd;
  --good: #15803d;
  --good-soft: #dcfce7;
  --bad: #c2410c;
  --bad-soft: #ffedd5;
  --gold: #b45309;
  --gold-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(28, 27, 46, .06), 0 4px 14px rgba(28, 27, 46, .07);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12111d;
    --surface: #1d1c2c;
    --surface-2: #28263b;
    --text: #ecebf7;
    --muted: #a3a0bd;
    --line: #34324a;
    --accent: #8b85ff;
    --accent-text: #12111d;
    --accent-soft: #2c2a55;
    --good: #4ade80;
    --good-soft: #163624;
    --bad: #fb923c;
    --bad-soft: #3e2414;
    --gold: #fbbf24;
    --gold-soft: #3a2e10;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-stats { display: flex; gap: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.top-stats span { display: inline-flex; align-items: center; gap: 3px; }
.top-stats svg { width: 16px; height: 16px; }
.icon-btn {
  border: 0; background: transparent; padding: 8px; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

/* Grundbausteine */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 13px 18px; cursor: pointer; font-weight: 650;
  background: var(--accent); color: var(--accent-text); min-height: 48px;
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.good { background: var(--good); color: var(--surface); }
.btn.bad { background: var(--bad); color: var(--surface); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
h2 { font-size: 17px; margin: 0 0 10px; }

/* Startseite */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.ring { width: 76px; height: 76px; position: relative; }
.ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.ring circle { stroke-width: 8; fill: none; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--accent); transition: stroke-dashoffset .6s ease; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; text-align: center; line-height: 1.1; }
.level { font-size: 22px; font-weight: 750; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s ease; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 7px 12px; font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip[aria-pressed="true"] .muted { color: inherit; opacity: .75; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.mode {
  text-align: left; border: 0; cursor: pointer; background: var(--surface); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; min-height: 118px;
}
.mode:active { transform: scale(.98); }
.mode .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.mode b { font-size: 16px; }
.mode span { font-size: 13px; color: var(--muted); line-height: 1.3; }
.mode.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 0; }
.mode.wide div { display: flex; flex-direction: column; }

/* Lernkarte */
.progress { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.progress .bar { flex: 1; margin: 0; }
.progress span { font-size: 14px; font-weight: 600; color: var(--muted); min-width: 44px; text-align: right; }
.combo { color: var(--gold); font-weight: 700; }

.q-card { text-align: center; padding: 26px 16px; }
.q-de { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.q-main { font-size: 34px; font-weight: 750; letter-spacing: .3px; word-break: break-word; }
.q-label { display: inline-block; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.speak {
  border: 0; background: var(--accent-soft); color: var(--accent); width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; cursor: pointer; vertical-align: middle;
}
.speak:active { transform: scale(.92); }
.speak.big { width: 84px; height: 84px; }
.speak.big svg { width: 38px; height: 38px; }

.forms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.form { background: var(--surface-2); border-radius: 12px; padding: 10px 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.form small { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.form b { font-size: 18px; word-break: break-word; }
.form .ipa { font-size: 13px; color: var(--muted); font-family: "Noto Sans", "Lucida Sans Unicode", "Segoe UI", sans-serif; }
.form .speak { width: 34px; height: 34px; }
.form .speak svg { width: 18px; height: 18px; }
.boxes { display: inline-flex; gap: 3px; vertical-align: middle; }
.boxes i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.boxes i.on { background: var(--good); }

/* Eingabe */
.field { margin-top: 12px; text-align: left; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; font-size: 22px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--surface); outline: none;
}
.field input:focus { border-color: var(--accent); }
.field input.ok { border-color: var(--good); background: var(--good-soft); }
.field input.no { border-color: var(--bad); background: var(--bad-soft); }
.solution { margin-top: 6px; font-size: 18px; letter-spacing: .5px; }
.solution .m { color: var(--bad); text-decoration: underline; text-decoration-thickness: 2px; font-weight: 700; }
.solution .h { color: var(--good); font-weight: 700; }
.feedback { font-weight: 700; margin-top: 12px; min-height: 24px; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--bad); }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions > * { flex: 1; }

.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.pop { animation: pop .3s; }
@keyframes pop { 50% { transform: scale(1.06); } }

/* Blitzrunde */
.timer { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.timer i { display: block; height: 100%; background: var(--gold); width: 100%; transition: width .2s linear; }
.score-line { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 10px; }
.options { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  border: 2px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px;
  font-size: 20px; font-weight: 650; cursor: pointer; min-height: 56px;
}
.opt.ok { border-color: var(--good); background: var(--good-soft); }
.opt.no { border-color: var(--bad); background: var(--bad-soft); }

/* Paare */
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pairs .col { display: grid; gap: 10px; align-content: start; }
.tile {
  border: 2px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 8px;
  min-height: 56px; cursor: pointer; font-weight: 600; font-size: 16px; transition: opacity .3s, transform .1s;
}
.tile.sel { border-color: var(--accent); background: var(--accent-soft); }
.tile.no { border-color: var(--bad); background: var(--bad-soft); }
.tile.done { opacity: 0; pointer-events: none; transform: scale(.9); }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 10px; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); font-weight: 700; box-shadow: var(--shadow); }

/* Ergebnis */
.result { text-align: center; padding: 28px 16px; }
.result .big { font-size: 46px; font-weight: 800; color: var(--accent); }
.badge { display: inline-block; background: var(--gold-soft); color: var(--gold); padding: 4px 12px; border-radius: 99px; font-weight: 700; margin-top: 8px; }

/* Liste */
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 12px; font-size: 16px; }
.vlist { list-style: none; margin: 0; padding: 0; }
.vlist li { background: var(--surface); border-radius: 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.vlist .head { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; }
.vlist .head div { flex: 1; min-width: 0; }
.vlist .head b { display: block; }
.vlist .head span { font-size: 13px; color: var(--muted); }
.vlist .forms { margin: 0; padding: 0 12px 12px; }

/* Einstellungen */
.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set select, .set input[type=range] { max-width: 60%; }
.set select { padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.switch { width: 24px; height: 24px; accent-color: var(--accent); }
.hint { background: var(--gold-soft); color: var(--text); border-radius: 12px; padding: 12px; font-size: 14px; margin-bottom: 14px; }
.hint b { color: var(--gold); }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600;
  transition: transform .3s ease; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
#toast:not(.show) { visibility: hidden; transition: transform .3s ease, visibility 0s .3s; }
#toast.show { transform: translateX(-50%) translateY(0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 360px) {
  .q-main { font-size: 28px; }
  .form b { font-size: 16px; }
}
