:root {
  --bg: #0f172a;
  --bg-2: #16213b;
  --karte: #1e293b;
  --karte-2: #273449;
  --rand: #334155;
  --text: #e8eef7;
  --leise: #94a3b8;
  --primaer: #38bdf8;
  --primaer-dunkel: #0284c7;
  --gut: #22c55e;
  --gut-bg: #14361f;
  --schlecht: #ef4444;
  --schlecht-bg: #3d1a1a;
  --warn: #f59e0b;
  --radius: 14px;
  --schatten: 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Muss vor allen Klassen stehen, die display setzen (.btn, .modal, .etikett,
   .zeichen-bild): sonst gewinnt deren display gegen das hidden-Attribut und
   versteckte Elemente bleiben sichtbar. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------------------------------------------------------------- Kopf */
.kopf {
  position: sticky; top: 0; z-index: 30;
  background: rgba(15, 23, 42, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rand);
  padding: .7rem 1rem .4rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
}
.marke {
  display: flex; align-items: center; gap: .5rem;
  color: var(--text); text-decoration: none;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em;
}
.marke-punkt {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primaer); box-shadow: 0 0 12px var(--primaer);
}
.marke-leise { color: var(--leise); font-weight: 500; font-size: .85rem; }

.nav {
  display: flex; gap: .35rem; margin-top: .55rem;
  overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: 0 0 auto;
  padding: .45rem .85rem; border-radius: 999px;
  color: var(--leise); text-decoration: none;
  font-size: .9rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.nav a.aktiv { background: var(--primaer); color: #04263a; }
.nav a:not(.aktiv):hover { background: var(--karte); color: var(--text); }

.huelle { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* -------------------------------------------------------------- Typo */
h1 { font-size: 1.5rem; margin: .3rem 0 .2rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; letter-spacing: -.01em; }
.unterzeile { color: var(--leise); margin: 0 0 1.2rem; font-size: .95rem; }
.leise { color: var(--leise); }

/* ------------------------------------------------------------- Karten */
.karte {
  background: var(--karte); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--schatten);
}
.gitter { display: grid; gap: .75rem; }
.gitter-2 { grid-template-columns: repeat(2, 1fr); }
.gitter-3 { grid-template-columns: repeat(3, 1fr); }

/* Kacheln auf der Startseite */
.kachel {
  display: block; text-decoration: none; color: var(--text);
  background: var(--karte); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 1rem;
  transition: transform .12s ease, border-color .12s ease;
}
.kachel:active { transform: scale(.98); }
.kachel:hover { border-color: var(--primaer); }
.kachel-titel { font-weight: 700; font-size: 1.02rem; margin-bottom: .2rem; }
.kachel-text { color: var(--leise); font-size: .86rem; line-height: 1.4; }
.kachel-icon { font-size: 1.5rem; line-height: 1; margin-bottom: .5rem; display: block; }

/* Zahlen */
.zahl { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.zahl-klein { font-size: .78rem; color: var(--leise); text-transform: uppercase;
              letter-spacing: .06em; font-weight: 600; }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .8rem 1.2rem; border-radius: 12px; border: 1px solid var(--rand);
  background: var(--karte-2); color: var(--text);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  text-decoration: none; font-family: inherit;
  transition: transform .1s ease;
}
.btn:active { transform: scale(.97); }
.btn-voll { width: 100%; }
.btn-primaer {
  background: var(--primaer); color: #04263a; border-color: var(--primaer);
}
.btn-primaer:hover { background: #7dd3fc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ----------------------------------------------------------- Antworten */
.antwort {
  display: flex; align-items: flex-start; gap: .7rem;
  width: 100%; text-align: left;
  padding: .85rem .9rem; margin-bottom: .55rem;
  background: var(--karte-2); border: 2px solid var(--rand);
  border-radius: 12px; color: var(--text);
  font-size: .97rem; font-family: inherit; line-height: 1.45;
  cursor: pointer; transition: border-color .12s, background .12s;
}
.antwort:hover:not(:disabled) { border-color: var(--leise); }
.antwort.gewaehlt { border-color: var(--primaer); background: #1c3a4d; }
.antwort.richtig { border-color: var(--gut); background: var(--gut-bg); }
.antwort.falsch { border-color: var(--schlecht); background: var(--schlecht-bg); }
.antwort:disabled { cursor: default; }
.antwort-markierung {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--rand); display: grid; place-items: center;
  font-size: .8rem; font-weight: 800; margin-top: .1rem;
}
.antwort.gewaehlt .antwort-markierung { border-color: var(--primaer); color: var(--primaer); }
.antwort.richtig .antwort-markierung { border-color: var(--gut); color: var(--gut); }
.antwort.falsch .antwort-markierung { border-color: var(--schlecht); color: var(--schlecht); }

/* ---------------------------------------------------------- Rückmeldung */
.rueckmeldung {
  margin-top: .9rem; padding: .9rem; border-radius: 12px;
  border-left: 4px solid var(--rand); background: var(--karte-2);
  font-size: .92rem;
}
.rueckmeldung.gut { border-left-color: var(--gut); background: var(--gut-bg); }
.rueckmeldung.schlecht { border-left-color: var(--schlecht); background: var(--schlecht-bg); }
.rueckmeldung-titel { font-weight: 700; margin-bottom: .3rem; }
.rueckmeldung-quelle {
  margin-top: .5rem; font-size: .78rem; color: var(--leise);
  font-family: ui-monospace, Menlo, monospace;
}

/* ------------------------------------------------------------- Etiketten */
.etikett {
  display: inline-block; padding: .18rem .5rem; border-radius: 6px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; background: var(--karte-2); color: var(--leise);
  border: 1px solid var(--rand);
}
.etikett-punkte { background: #3b2a10; color: var(--warn); border-color: #5c4318; }
.etikett-gut { background: var(--gut-bg); color: var(--gut); border-color: #1d5c33; }
.etikett-schlecht { background: var(--schlecht-bg); color: var(--schlecht); border-color: #6b2020; }

/* -------------------------------------------------------------- Balken */
.balken { height: 8px; border-radius: 99px; background: var(--karte-2); overflow: hidden; }
.balken-fuell { height: 100%; background: var(--primaer); border-radius: 99px;
                transition: width .4s ease; }
.balken-fuell.gut { background: var(--gut); }
.balken-fuell.warn { background: var(--warn); }
.balken-fuell.schlecht { background: var(--schlecht); }

/* ------------------------------------------------------------- Zeichen */
.zeichen-gitter {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: .6rem;
}
.zeichen-feld {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 12px;
  padding: .6rem; text-align: center; cursor: pointer;
}
.zeichen-feld:hover { border-color: var(--primaer); }
.zeichen-feld img { width: 100%; height: 62px; object-fit: contain; }
.zeichen-feld .nr { font-size: .68rem; color: var(--leise); margin-top: .35rem;
                    font-family: ui-monospace, monospace; }
.zeichen-bild {
  background: #fff; border-radius: 12px; padding: .8rem;
  display: grid; place-items: center; margin-bottom: .9rem;
}
.zeichen-bild img { height: 128px; width: auto; max-width: 100%; object-fit: contain; }

/* --------------------------------------------------------- Umschalter */
/* Segmentierte Auswahl (Kreuzung/Kreisel, Leicht/Mittel/Schwer): immer EINE
   Zeile. Die Standard-.reihe würde umbrechen, sobald die Beschriftung wächst. */
.umschalter { display: flex; gap: .4rem; flex-wrap: nowrap; margin-bottom: .5rem; }
.umschalter .btn {
  flex: 1 1 0; min-width: 0; padding: .7rem .35rem;
  font-size: .92rem; white-space: nowrap;
}

/* -------------------------------------------------------------- Film */
.film {
  background: #fff; border-radius: 12px; overflow: hidden;
  aspect-ratio: 400 / 260; width: 100%;
}
.film svg { display: block; width: 100%; height: 100%; }

/* ------------------------------------------------------------ Vorfahrt */
.kreuzung {
  background: #fff; border-radius: 12px; overflow: hidden;
  aspect-ratio: 1 / 1; max-width: 340px; margin: 0 auto .9rem;
}
.kreuzung svg { display: block; width: 100%; height: 100%; }
.reihen-knopf {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .7rem .8rem; margin-bottom: .5rem;
  background: var(--karte-2); border: 2px solid var(--rand);
  border-radius: 12px; color: var(--text); font-family: inherit;
  font-size: .95rem; font-weight: 600; cursor: pointer;
}
.reihen-knopf:disabled { opacity: .45; }
.reihen-knopf .punkt {
  width: 16px; height: 16px; border-radius: 4px; flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, .4);
}
.reihen-knopf .platz {
  margin-left: auto; font-size: .8rem; color: var(--primaer); font-weight: 800;
}

/* ------------------------------------------------------------- Dialog */
.modal {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .8);
  display: grid; place-items: center; padding: 1rem; z-index: 50;
}
.modal-box {
  background: var(--karte); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 1.2rem;
  max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto;
}

/* ------------------------------------------------------------- Sonstiges */
.fortschritt-kopf {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .5rem; font-size: .85rem; color: var(--leise);
}
.stapel > * + * { margin-top: .75rem; }
.reihe { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.zentriert { text-align: center; }
.feld {
  width: 100%; padding: .85rem; border-radius: 12px;
  border: 1px solid var(--rand); background: var(--karte-2);
  color: var(--text); font-size: 1rem; font-family: inherit;
}
.feld:focus { outline: 2px solid var(--primaer); outline-offset: 1px; }
.hinweis {
  padding: .8rem; border-radius: 10px; background: var(--karte-2);
  border-left: 3px solid var(--warn); font-size: .88rem; color: var(--leise);
}

@media (max-width: 420px) {
  h1 { font-size: 1.3rem; }
  /* Die Kennzahlen bleiben dreispaltig – die Zahlen sind kurz, und zwei oben
     plus eine allein darunter sieht wie ein Fehler aus. */
  .gitter-3 { grid-template-columns: repeat(3, 1fr); }
  .gitter-3 .zahl { font-size: 1.3rem; }
  .gitter-3 .zahl-klein { font-size: .68rem; letter-spacing: .03em; }
  .nav a { padding: .4rem .7rem; font-size: .85rem; }
}
