:root {
  --black: #1a1a2e;
  --dark: #16213e;
  --accent: #e63946;
  --gold: #f4a261;
  --blue: #457b9d;
  --light-blue: #a8dadc;
  --green: #2a9d8f;
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #212529;
  --muted: #6c757d;
  --border: #dee2e6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── NAV ── */
nav {
  background: var(--black);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.nav-logo { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.5px; cursor: pointer; }
.nav-logo span { color: var(--accent); }
.badge-level {
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: .25rem .7rem;
  border-radius: 999px;
}

/* ── NAV BUTTONS (Zurück / Hauptmenü) ── */
.nav-btns { display: flex; gap: .6rem; margin-bottom: 1.4rem; }
.nav-btn {
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: .5rem 1rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.nav-btn:hover { border-color: var(--blue); color: var(--blue); }

/* ── HERO ── */
.hero {
  background: linear-gradient(135deg, var(--black) 0%, var(--dark) 50%, #0f3460 100%);
  color: #fff;
  padding: 2.6rem 2rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: 'Deutsch';
  position: absolute; right: -1rem; top: -1rem;
  font-size: 10rem; font-weight: 900;
  color: rgba(255,255,255,.05);
  pointer-events: none;
}
.hero-inner { max-width: 1100px; margin: 0 auto; }
.hero h1 { font-size: 1.9rem; font-weight: 800; line-height: 1.25; }
.hero h1 span { color: var(--gold); }
.hero p { color: #adb5bd; margin-top: .5rem; font-size: .98rem; max-width: 640px; }

main { max-width: 1100px; margin: 0 auto; padding: 1.8rem 1.5rem 3rem; }

.section-title {
  font-size: 1.12rem; font-weight: 700; margin: 0 0 1.1rem;
  display: flex; align-items: center; gap: .5rem;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); margin-left: .5rem; }

/* ── MENU / MODULE CARDS ── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.1rem; }
.module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.module-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.module-card .card-color-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.module-card .icon { font-size: 2rem; margin-bottom: .6rem; }
.module-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .3rem; }
.module-card p { font-size: .83rem; color: var(--muted); line-height: 1.45; }
.module-card .pill-row { margin-top: .9rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.pill {
  font-size: .72rem; font-weight: 600; padding: .2rem .6rem;
  border-radius: 999px; background: #e9ecef; color: var(--muted);
}

/* ── UNIT LIST ── */
.unit-list { display: flex; flex-direction: column; gap: .7rem; }
.unit-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: .95rem 1.2rem; display: flex; align-items: center; gap: 1rem; cursor: pointer;
  transition: all .2s;
}
.unit-row:hover { border-color: var(--blue); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.unit-row .num {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue), #1d3557); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
}
.unit-row .info { flex: 1; min-width: 0; }
.unit-row .info h4 { font-size: .95rem; font-weight: 700; }
.unit-row .info p { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.unit-row .icon-big { font-size: 1.5rem; }
.unit-row .arrow { color: var(--muted); font-size: 1rem; }

/* ── UNIT DETAIL / EXAMPLES ── */
.grammar-tags { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0 1.4rem; }
.grammar-tags .tag {
  font-size: .75rem; padding: .25rem .7rem; border-radius: 999px; font-weight: 600;
  background: #e8f4fd; border: 1px solid #bee3f8; color: #2b6cb0;
}
.beispiel-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.3rem 1.5rem; margin-bottom: 1.1rem;
}
.beispiel-card h3 { font-size: 1rem; color: var(--blue); margin-bottom: .4rem; }
.beispiel-card .erkl { font-size: .86rem; color: var(--muted); margin-bottom: .8rem; line-height: 1.5; }
.beispiel-card ul { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.beispiel-card li {
  background: #f0f7ff; border-left: 4px solid var(--blue);
  border-radius: 0 8px 8px 0; padding: .6rem .9rem; font-size: .93rem;
}
.speak-btn {
  border: none; background: none; cursor: pointer; font-size: .95rem;
  margin-left: .4rem; opacity: .6;
}
.speak-btn:hover { opacity: 1; }

/* ── EXERCISES ── */
.exercise-panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; margin-bottom: 1.5rem;
}
.exercise-panel-header {
  background: linear-gradient(135deg, var(--blue), #1d3557);
  color: #fff; padding: 1.1rem 1.4rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.exercise-panel-header h2 { font-size: 1rem; font-weight: 700; }
.exercise-panel-header .subtitle { font-size: .8rem; color: rgba(255,255,255,.75); margin-top: 2px; }
.score-badge { background: var(--gold); color: var(--black); font-weight: 800; font-size: .8rem; padding: .3rem .7rem; border-radius: 999px; white-space: nowrap; }
.exercise-body { padding: 1.4rem; }
.question-text { font-size: .97rem; font-weight: 600; margin-bottom: 1rem; line-height: 1.55; }
.options { display: flex; flex-direction: column; gap: .6rem; }
.option {
  display: flex; align-items: center; gap: .7rem;
  border: 2px solid var(--border); border-radius: 10px;
  padding: .65rem 1rem; cursor: pointer; transition: all .15s;
  font-size: .92rem; background: var(--card);
  text-align: left; width: 100%; font-family: inherit;
}
.option:hover:not(:disabled) { border-color: var(--blue); background: #f0f7ff; }
.option:disabled { cursor: default; }
.option.correct { border-color: var(--green); background: #e6f7f5; }
.option.wrong { border-color: var(--accent); background: #fff0f0; }
.option-letter {
  width: 26px; height: 26px; border-radius: 50%;
  background: #e9ecef; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.option.correct .option-letter { background: var(--green); color: #fff; }
.option.wrong .option-letter { background: var(--accent); color: #fff; }
.gap-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.blank-input {
  border: none; border-bottom: 2px solid var(--blue);
  background: transparent; font-size: 1rem; color: var(--text);
  padding: .15rem .4rem; width: 180px; outline: none; font-family: inherit;
}
.blank-input:focus { border-bottom-color: var(--accent); }
.blank-input.ok { border-bottom-color: var(--green); color: var(--green); font-weight: 700; }
.blank-input.bad { border-bottom-color: var(--accent); color: var(--accent); }
.feedback { margin-top: 1rem; font-size: .9rem; font-weight: 600; min-height: 1.4em; }
.feedback.ok { color: var(--green); }
.feedback.bad { color: var(--accent); }
.exercise-footer { border-top: 1px solid var(--border); padding: .9rem 1.4rem; display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.btn { border: none; border-radius: 10px; padding: .6rem 1.4rem; font-size: .9rem; font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d3557; }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #21867a; }
.btn-red { background: var(--accent); color: #fff; }
.btn-red:hover { background: #c1121f; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.progress-dots { display: flex; gap: 5px; }
.pdot { width: 10px; height: 10px; border-radius: 50%; background: #dee2e6; }
.pdot.done-ok { background: var(--green); }
.pdot.done-bad { background: var(--accent); }
.pdot.current { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ── RESULT ── */
.result-box { text-align: center; padding: 2.5rem 1.5rem; }
.result-box .big { font-size: 3.4rem; }
.result-box h2 { margin: .6rem 0 .3rem; }
.result-box p { color: var(--muted); margin-bottom: 1.4rem; }

/* ── VORLESEN (reading + recording) ── */
.lese-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.lese-text-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.6rem 1.8rem; font-size: 1.12rem; line-height: 1.9; margin-bottom: 1.2rem;
}
.lese-text-box .w.hit { color: var(--green); font-weight: 600; }
.lese-text-box .w.miss { color: var(--accent); text-decoration: underline wavy; }
.rec-controls { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.2rem; }
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  animation: blink 1s infinite; display: inline-block; margin-right: .4rem;
}
@keyframes blink { 50% { opacity: .2; } }
.rec-status { font-size: .9rem; font-weight: 600; color: var(--muted); }
.rec-result {
  border-radius: 16px; padding: 1.4rem 1.6rem; margin-bottom: 1.2rem;
  border: 2px solid var(--border); background: var(--card);
}
.rec-result.good { border-color: var(--green); background: #e6f7f5; }
.rec-result.bad { border-color: var(--accent); background: #fff5f5; }
.rec-result h3 { font-size: 1.15rem; margin-bottom: .3rem; }
.rec-result .pct-big { font-size: 2.2rem; font-weight: 800; }
.rec-result.good .pct-big, .rec-result.good h3 { color: var(--green); }
.rec-result.bad .pct-big, .rec-result.bad h3 { color: var(--accent); }
.rec-result p { font-size: .9rem; color: var(--text); margin-top: .4rem; line-height: 1.5; }
.warn-box {
  background: #fff3cd; border: 1px solid #ffe69c; color: #856404;
  border-radius: 12px; padding: .9rem 1.2rem; font-size: .88rem; margin-bottom: 1.2rem; line-height: 1.5;
}

/* ── MEMORY ── */
.memory-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.2rem; flex-wrap: wrap; gap: .8rem;
}
.timer {
  font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--dark); background: var(--card); border: 2px solid var(--border);
  border-radius: 12px; padding: .3rem 1rem;
}
.timer.low { color: var(--accent); border-color: var(--accent); animation: blink 1s infinite; }
.memory-stats { font-size: .9rem; color: var(--muted); font-weight: 600; }
.memory-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .7rem;
  max-width: 720px; margin: 0 auto;
}
@media (max-width: 640px) { .memory-grid { grid-template-columns: repeat(4, 1fr); } }
.mem-card {
  aspect-ratio: 3 / 3.4; perspective: 600px; cursor: pointer; border: none; background: none; padding: 0;
}
.mem-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d; transition: transform .4s;
}
.mem-card.open .mem-inner, .mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; padding: .3rem; text-align: center;
}
.mem-back {
  background: linear-gradient(135deg, var(--blue), #1d3557);
  color: rgba(255,255,255,.85); font-size: 1.5rem;
}
.mem-front {
  background: var(--card); border: 2px solid var(--border);
  transform: rotateY(180deg); font-size: .82rem; line-height: 1.25;
}
.mem-front.emoji { font-size: 2.1rem; }
.mem-card.matched .mem-front { border-color: var(--green); background: #e6f7f5; }
.mem-card.matched { cursor: default; }

/* ── OVERLAY (memory result) ── */
.overlay {
  position: fixed; inset: 0; background: rgba(26,26,46,.82); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.overlay-card {
  background: var(--card); border-radius: 24px; padding: 2.8rem 2.5rem;
  text-align: center; max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: pop .35s ease;
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.overlay-card .big-icon { font-size: 4.5rem; line-height: 1; }
.overlay-card h2 { font-size: 1.6rem; margin: .8rem 0 .4rem; }
.overlay-card h2.win { color: var(--green); }
.overlay-card h2.lose { color: var(--accent); }
.overlay-card p { color: var(--muted); margin-bottom: 1.5rem; }
.overlay-card .btn-row { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }

/* confetti */
.confetti { position: fixed; top: -20px; font-size: 1.4rem; z-index: 310; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

footer {
  background: var(--black); color: #adb5bd;
  text-align: center; padding: 1.6rem;
  font-size: .8rem;
}
footer strong { color: #fff; }
