/* SpraWi-Trainer — Design: „Seminarraum trifft Arcade"
   Ruhige Papier-Oberfläche, Farbe nur in den Spielmomenten.
   Keine externen Fonts/Requests (DSGVO): Systemschriften. */

:root {
  --paper: #f3f5f1;
  --card: #ffffff;
  --ink: #1c2420;
  --muted: #5c6660;
  --line: #d8ded6;
  --green: #4f7f0e;       /* TU-Dortmund-Grün, abgedunkelt für Kontrast */
  --green-soft: #e8f0da;
  --green-deep: #2f4d08;
  --red: #be3e2c;
  --red-soft: #f6e3df;
  --amber: #d99a1b;
  --amber-soft: #f7ecd4;
  --shadow: 0 1px 2px rgba(28, 36, 32, 0.06), 0 8px 24px rgba(28, 36, 32, 0.07);
  --radius: 14px;
  --serif: ui-serif, 'Iowan Old Style', 'Palatino Nova', Palatino, Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151a16;
    --card: #1e2620;
    --ink: #e9eee8;
    --muted: #9aa69c;
    --line: #2f3a31;
    --green: #93c744;
    --green-soft: #26331a;
    --green-deep: #b9e078;
    --red: #e06a52;
    --red-soft: #3d221c;
    --amber: #e8b84b;
    --amber-soft: #3a2f16;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Grundgerüst ---------- */

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.wordmark {
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark .slash { color: var(--green); font-weight: 400; }
.wordmark small {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

nav.top-nav { display: flex; gap: 18px; }
nav.top-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
}
nav.top-nav a:hover { color: var(--ink); }
nav.top-nav a.active { color: var(--ink); border-bottom-color: var(--green); }

main { flex: 1; padding-top: 28px; }

footer.bottom {
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding-top: 16px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: space-between;
}
footer.bottom a { color: var(--muted); }

/* ---------- Typografie ---------- */

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 2rem; font-weight: 600; }
h2 { font-size: 1.4rem; font-weight: 600; }

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--green);
  font-weight: 650;
  margin: 0 0 6px;
}

.lead { color: var(--muted); max-width: 56ch; margin: 0 0 26px; }

.ipa { font-family: var(--sans); }
.ipa .slash { color: var(--green); }

/* ---------- Bausteine ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
@media (prefers-color-scheme: dark) {
  .btn.primary { color: #10160b; }
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--ink); opacity: 1; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.big { font-size: 1.05rem; padding: 13px 30px; }

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

input[type='text'] {
  font: inherit;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  width: 100%;
}
input[type='text']:focus { border-color: var(--green); outline: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* ---------- Startseite: Modus-Karten ---------- */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 34px;
}

.mode-card {
  text-align: left;
  font: inherit;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.mode-card:hover { transform: translateY(-2px); border-color: var(--green); }
.mode-card .glyph {
  font-family: var(--serif);
  font-size: 1.7rem;
  color: var(--green);
  line-height: 1;
}
.mode-card .name { font-weight: 650; font-size: 1.05rem; }
.mode-card .desc { color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.mode-card.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 16px; }
.mode-card.wide .desc { margin-left: auto; text-align: right; }
@media (max-width: 620px) {
  .mode-card.wide { flex-direction: column; align-items: flex-start; }
  .mode-card.wide .desc { margin-left: 0; text-align: left; }
}

/* ---------- Themenauswahl ---------- */

.topic-list { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 24px; }

.topic-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.topic-row:hover { border-color: var(--green); }
.topic-row input { accent-color: var(--green); width: 18px; height: 18px; flex-shrink: 0; }
.topic-row .t-title { font-weight: 550; }
.topic-row .t-meta { margin-left: auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.topic-row .t-acc { font-size: 0.8rem; font-weight: 650; white-space: nowrap; }
.topic-row .t-acc.good { color: var(--green); }
.topic-row .t-acc.bad { color: var(--red); }

.setup-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.count-picker { display: flex; gap: 6px; }
.count-picker button {
  font: inherit;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.count-picker button.sel { background: var(--green); border-color: var(--green); color: #fff; font-weight: 650; }
@media (prefers-color-scheme: dark) {
  .count-picker button.sel { color: #10160b; }
}

/* ---------- Quiz ---------- */

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
.game-head .score { font-weight: 650; color: var(--ink); }

.progress-track {
  height: 5px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 26px;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width 0.25s ease;
}
.progress-fill.timer { transition: none; }
.progress-fill.warn { background: var(--amber); }
.progress-fill.crit { background: var(--red); }

.q-topic { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--green); font-weight: 650; margin-bottom: 8px; }
.q-text {
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.35;
  margin-bottom: 24px;
  text-wrap: balance;
}

.options { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .options { grid-template-columns: 1fr 1fr; } }

.opt {
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.1s ease, transform 0.08s ease;
}
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt:active:not(:disabled) { transform: scale(0.99); }
.opt .key {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.opt:disabled { cursor: default; }
.opt.sel { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.right .key { border-color: var(--green); color: var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .key { border-color: var(--red); color: var(--red); }
.opt.faded { opacity: 0.5; }

.explain {
  margin-top: 20px;
  border-left: 3px solid var(--green);
  background: var(--card);
  border-radius: 0 12px 12px 0;
  padding: 14px 16px;
  font-size: 0.95rem;
}
.explain.neg { border-left-color: var(--red); }
.explain .verdict { font-weight: 700; margin-bottom: 4px; }
.explain .verdict.ok { color: var(--green); }
.explain .verdict.no { color: var(--red); }

.next-row { margin-top: 22px; display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Ergebnis ---------- */

.result-hero { text-align: center; padding: 30px 0 10px; }
.result-hero .big-num {
  font-family: var(--serif);
  font-size: 3.4rem;
  font-weight: 650;
  line-height: 1;
}
.result-hero .big-num .of { font-size: 1.6rem; color: var(--muted); font-weight: 400; }
.result-hero p { color: var(--muted); }

.result-list { margin: 20px 0; display: flex; flex-direction: column; gap: 8px; }
.result-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 0.92rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.result-item .mark { font-weight: 700; flex-shrink: 0; }
.result-item .mark.ok { color: var(--green); }
.result-item .mark.no { color: var(--red); }

/* ---------- Karteikarten ---------- */

.flash-wrap { perspective: 1200px; margin: 10px 0 20px; }
.flashcard {
  position: relative;
  width: 100%;
  min-height: 260px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.3, 0.9, 0.4, 1);
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  display: block;
}
.flashcard.flipped { transform: rotateX(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  gap: 10px;
}
.flash-face .side-label {
  position: absolute;
  top: 14px;
  left: 18px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.flash-face.back { transform: rotateX(180deg); }
.flash-face .flash-text { font-family: var(--serif); font-size: 1.35rem; line-height: 1.35; }
.flash-face.back .flash-text { font-family: var(--sans); font-size: 1.05rem; }
.flash-hint { text-align: center; color: var(--muted); font-size: 0.82rem; margin-bottom: 14px; }
.flash-actions { display: flex; justify-content: center; gap: 12px; }
.flash-actions .btn.know { background: var(--green); border-color: var(--green); }
.flash-actions .btn.again { background: transparent; color: var(--red); border-color: var(--red); }

@media (prefers-reduced-motion: reduce) {
  .flashcard { transition: none; }
  * { animation: none !important; }
}

/* ---------- Zuordnen ---------- */

.sort-item {
  text-align: center;
  font-family: var(--serif);
  font-size: 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 20px;
  margin-bottom: 18px;
}
.cat-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.cat-btn {
  font: inherit;
  font-weight: 600;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 12px;
  cursor: pointer;
}
.cat-btn:hover:not(:disabled) { border-color: var(--ink); }
.cat-btn.right { border-color: var(--green); background: var(--green-soft); }
.cat-btn.wrong { border-color: var(--red); background: var(--red-soft); }
.cat-btn:disabled { cursor: default; }

/* ---------- Paare ---------- */

.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.match-btn {
  font: inherit;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 13px;
  cursor: pointer;
  text-align: center;
  min-height: 48px;
  transition: opacity 0.25s ease, border-color 0.1s ease;
}
.match-btn:hover:not(:disabled) { border-color: var(--ink); }
.match-btn.sel { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; }
.match-btn.done { opacity: 0.35; border-color: var(--green); cursor: default; }
.match-btn.shake { animation: shake 0.3s ease; border-color: var(--red); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- Multiplayer ---------- */

.room-code {
  font-family: var(--serif);
  font-size: 3rem;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 10px 0 4px;
  text-indent: 0.35em;
}
.room-code-label { text-align: center; color: var(--muted); font-size: 0.85rem; margin-bottom: 18px; }

.player-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 22px; }
.player-chip {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.92rem;
  font-weight: 550;
}
.player-chip.host { border-color: var(--amber); }
.player-chip.host::after { content: ' ★'; color: var(--amber); }
.player-chip.gone { opacity: 0.4; text-decoration: line-through; }

.mp-status { color: var(--muted); font-size: 0.9rem; text-align: center; margin: 14px 0; }

.scoreboard { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; }
.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.score-row .rank { font-family: var(--serif); font-weight: 700; width: 26px; color: var(--muted); }
.score-row.me { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.score-row .pname { font-weight: 600; }
.score-row .gain { margin-left: auto; font-size: 0.85rem; color: var(--green); font-weight: 650; }
.score-row .gain.zero { color: var(--muted); font-weight: 400; }
.score-row .pts { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 60px; text-align: right; }
.score-row.top1 { border-color: var(--amber); background: var(--amber-soft); }

.podium-name { font-family: var(--serif); font-size: 2rem; text-align: center; margin: 6px 0 2px; }
.podium-sub { text-align: center; color: var(--muted); margin-bottom: 20px; }

.answered-note { text-align: center; color: var(--muted); font-size: 0.88rem; margin-top: 16px; }

.wait-pulse { text-align: center; font-family: var(--serif); font-size: 1.3rem; padding: 40px 0; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ---------- Fehler / Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(90vw, 480px);
}

/* ---------- Textseiten ---------- */

.prose { max-width: 62ch; }
.prose h2 { margin-top: 28px; }
.prose p, .prose li { color: var(--ink); font-size: 0.95rem; }
.prose .note { color: var(--muted); font-size: 0.85rem; }

.divider { border: none; border-top: 1px solid var(--line); margin: 30px 0; }

.stat-strip { display: flex; gap: 22px; flex-wrap: wrap; margin: 4px 0 30px; }
.stat-strip .stat .n { font-family: var(--serif); font-size: 1.6rem; font-weight: 650; line-height: 1.1; }
.stat-strip .stat .l { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- Gamification ---------- */

.level-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.level-card:hover { border-color: var(--green); }
.level-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.level-name { font-weight: 700; }
.level-meta { color: var(--muted); font-size: 0.9rem; }
.level-track { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.level-track.big { height: 12px; max-width: 480px; }
.level-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--amber)); border-radius: 99px; }
.level-sub { margin-top: 8px; font-size: 0.8rem; color: var(--muted); }

.error-card { border-color: var(--red); margin-bottom: 18px; }
.error-card .glyph { color: var(--red); }
.error-card:hover { border-color: var(--red); }

.mastery-list { display: flex; flex-direction: column; gap: 9px; }
.mastery-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 90px; gap: 12px; align-items: center; }
.m-title { font-size: 0.9rem; font-weight: 550; }
.m-track { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.m-fill { display: block; height: 100%; border-radius: 99px; background: var(--line); }
.m-fill.good { background: var(--green); }
.m-fill.mid { background: var(--amber); }
.m-fill.bad { background: var(--red); }
.m-val { font-size: 0.8rem; color: var(--muted); text-align: right; white-space: nowrap; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.badge.won { border-color: var(--amber); }
.badge.locked { opacity: 0.5; }
.badge .b-icon { font-size: 1.6rem; }
.badge .b-name { font-weight: 650; font-size: 0.88rem; }
.badge .b-desc { font-size: 0.74rem; color: var(--muted); }

/* ---------- Folienbezug ---------- */

.folie-link { color: var(--green); font-weight: 600; text-decoration: none; }
.folie-link:hover { text-decoration: underline; }

.t-col { display: flex; flex-direction: column; min-width: 0; }
.t-session { font-size: 0.76rem; color: var(--muted); }

.flash-page {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.result-item .fix { display: block; font-size: 0.84rem; color: var(--muted); margin-top: 3px; }
.result-item.is-wrong { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }

/* ---------- Folien-Viewer ---------- */

.folien-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.folien-nav { display: flex; align-items: center; justify-content: center; gap: 12px; }
.folien-pos { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.95rem; }
.folien-pos input {
  width: 56px;
  text-align: center;
  font: inherit;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  background: var(--card);
  color: var(--ink);
}
.folien-topics { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.topic-chip {
  font-size: 0.76rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.topic-chip:hover { border-color: var(--ink); color: var(--ink); }
.topic-chip.cur { border-color: var(--green); color: var(--green); font-weight: 650; }
.folien-frame {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.folien-frame img { display: block; width: 100%; height: auto; }
.folien-hint { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 10px; }
