/* Notenleser – Gestaltung (Computer und Handy) */

:root {
  --hintergrund: #f6f4ef;
  --flaeche: #ffffff;
  --text: #1f2328;
  --leise: #6b6f76;
  --haupt: #2f6fb3;
  --haupt-dunkel: #245a93;
  --gruen: #2ea44f;
  --rot: #d73a49;
  --gold: #e3a008;
  --gesperrt: #b9bcc2;
  --rand: #d9d6cf;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--hintergrund);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button { font: inherit; color: inherit; }

.knopf {
  border: 1px solid var(--rand);
  background: var(--flaeche);
  border-radius: 10px;
  padding: 0.7em 1.2em;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}
.knopf:hover { border-color: var(--haupt); }
.knopf-haupt { background: var(--haupt); border-color: var(--haupt); color: #fff; }
.knopf-haupt:hover { background: var(--haupt-dunkel); }
.knopf-leise { background: transparent; }
.knopf-klein { padding: 0.4em 0.8em; min-height: 36px; font-size: 0.9rem; }
.knopf-gefahr { color: var(--rot); border-color: #e9b7bd; }
.knopf-gefahr:hover { border-color: var(--rot); }
.knopf:disabled { opacity: 0.55; cursor: default; }
.knopf:disabled:hover { border-color: var(--rand); }

.kopf {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  /* „Zurück" oben links, Titel in der Mitte (A28) */
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  padding-top: max(0.6rem, env(safe-area-inset-top));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  background: var(--hintergrund);
  border-bottom: 1px solid var(--rand);
}
.kopf > .knopf { justify-self: start; }
.kopf h1 { margin: 0; font-size: 1.3rem; text-align: center; }

.untertitel { color: var(--leise); margin: 0.2rem 0 1rem; }

/* ---------- Hauptmenü (A28) ---------- */

.menue {
  max-width: 420px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 2rem 1rem;
  padding-top: max(2rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.menue-titel { margin: 0 0 0.8rem; text-align: center; font-size: 1.8rem; }
.menue-knopf {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 76px;
  padding: 0.8rem 1rem;
  border: 1px solid var(--rand);
  border-radius: 14px;
  background: var(--flaeche);
  box-shadow: 0 3px 0 var(--rand);
  cursor: pointer;
  touch-action: manipulation;
}
.menue-knopf:hover { border-color: var(--haupt); }
.menue-name { font-size: 1.25rem; font-weight: 700; }
.menue-info { font-size: 0.85rem; color: var(--leise); }
.menue-info:empty { display: none; }
.menue-link {
  margin-top: auto;
  padding-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--leise);
}

/* ---------- Stufenübersicht ---------- */

.pfad {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
.abschnitt h2 {
  margin: 1.5rem 0 0.5rem;
  padding: 0.5rem 0.8rem;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 10px;
  font-size: 1.05rem;
  text-align: center;
}
.stufenliste {
  list-style: none;
  margin: 0;
  padding: 0;
}
.stufe { display: flex; justify-content: center; margin: 0.35rem 0; }
/* Versatz höchstens so weit, wie neben dem Knopf Platz ist (kein Überstehen am Handy) */
.stufe[data-versatz="1"] .stufen-knopf,
.stufe[data-versatz="3"] .stufen-knopf { position: relative; }
.stufe[data-versatz="1"] .stufen-knopf { left: clamp(0px, calc((100% - 260px) / 2), 48px); }
.stufe[data-versatz="3"] .stufen-knopf { left: calc(-1 * clamp(0px, calc((100% - 260px) / 2), 48px)); }

.stufen-knopf {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 260px;
  max-width: 100%;
  padding: 0.3rem;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}
.stufen-knopf:disabled { cursor: default; }
.kreis {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--haupt);
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  box-shadow: 0 4px 0 var(--haupt-dunkel);
}
.stufe.abgeschlossen .kreis { background: var(--gold); box-shadow: 0 4px 0 #b57f05; }
.stufe.gesperrt .kreis { background: var(--gesperrt); box-shadow: 0 4px 0 #9a9da3; }
.stufe.aktuell .kreis {
  outline: 4px solid rgba(47, 111, 179, 0.35);
  outline-offset: 3px;
  transform: scale(1.08);
}
.stufen-text { display: flex; flex-direction: column; min-width: 0; }
.stufen-titel { font-size: 0.95rem; }
.stufe.gesperrt .stufen-titel { color: var(--leise); }
.stufen-info { font-size: 0.9rem; color: var(--leise); min-height: 1.2em; }
.stufe.aktuell .stufen-info { color: var(--haupt); font-weight: 700; }
.sterne { color: var(--gold); letter-spacing: 0.1em; font-size: 1.05rem; }
.schloss { width: 15px; height: 15px; vertical-align: -2px; color: var(--leise); }

/* ---------- Lektionswahl ---------- */

.dialog-hintergrund {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dialog {
  background: var(--flaeche);
  border-radius: 14px;
  padding: 1.2rem;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
}
.dialog h2 { margin: 0; }
.lektionsliste { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.lektion-knopf { display: flex; justify-content: space-between; align-items: center; text-align: left; }
.lektion-knopf.gesperrt { color: var(--leise); background: #f0efeb; cursor: default; }

/* ---------- Lektion ---------- */

/* Lektion und Versuch im freien Modus */
.spiel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.lektion-kopf {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.4rem 0.8rem;
  padding-top: max(0.4rem, env(safe-area-inset-top));
  padding-left: max(0.8rem, env(safe-area-inset-left));
  padding-right: max(0.8rem, env(safe-area-inset-right));
  border-bottom: 1px solid var(--rand);
}
.fortschritt { flex: 1 1 auto; min-width: 0; }
.fortschritt-zeile { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; }
.lektion-titel { color: var(--leise); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fortschritt-text { font-weight: 700; white-space: nowrap; }
.balken { height: 8px; background: #e4e1da; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.balken-fuellung { height: 100%; width: 0; background: var(--gruen); transition: width 0.2s; }
.serie { font-size: 0.85rem; white-space: nowrap; }
.wiederholung-hinweis {
  flex: 0 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--haupt);
  padding: 0.2rem;
}

.notenbild-bereich {
  flex: 1 1 auto;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  background: var(--flaeche);
}
.notenbild { width: 100%; height: 100%; max-width: 640px; display: block; }

.klaviatur-bereich {
  flex: 0 0 auto;
  height: clamp(120px, 38vh, 260px);
  padding-bottom: env(safe-area-inset-bottom);
  background: #2b2b2b;
}
.klaviatur-scroll {
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.klaviatur {
  position: relative;
  display: flex;
  height: 100%;
  width: 100%;
  /* A10: weiße Tasten nie schmaler als 40 px – sonst waagerecht scrollen */
  min-width: calc(var(--weisse) * 40px);
  max-width: 1100px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}
.klaviatur-breit {
  max-width: none;
}
.taste {
  border: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.taste.weiss {
  flex: 1 1 0;
  min-width: 0;
  background: #fff;
  border-right: 1px solid #9a9a9a;
  border-radius: 0 0 5px 5px;
  color: #444;
  padding-bottom: 6px;
}
.taste.schwarz {
  position: absolute;
  top: 0;
  height: 60%;
  z-index: 2;
  background: #1c1c1c;
  border-radius: 0 0 4px 4px;
  color: #eee;
  padding-bottom: 4px;
}
.tastenname { font-size: clamp(0.6rem, 2.2vw, 0.9rem); pointer-events: none; line-height: 1.1; text-align: center; }
/* Umbruch nur nach dem „/" (<wbr>), nie innerhalb eines Namens */
.tastenname.klein { font-size: clamp(0.45rem, 1.4vw, 0.65rem); word-break: keep-all; overflow-wrap: normal; hyphens: none; }
.taste.schwarz .tastenname { padding: 0 1px; }

.taste.loesung { background: var(--gruen) !important; color: #fff; }
.taste.blink-gruen { animation: blinkGruen 0.3s ease-out; }
.taste.blink-rot { animation: blinkRot 0.35s ease-out; }
@keyframes blinkGruen { 0%, 60% { background: var(--gruen); color: #fff; } }
@keyframes blinkRot { 0%, 60% { background: var(--rot); color: #fff; } }

/* Tonart als Text über dem System (A30) */
.tonart-text {
  flex: 0 0 auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--leise);
  padding: 0.25rem 0 0;
  background: var(--flaeche);
}
.tonart-text.blinken { animation: tonartBlinken 1.2s ease-out; }
@keyframes tonartBlinken {
  0%, 40% { color: var(--haupt); transform: scale(1.35); }
  20%, 60% { color: var(--text); }
  100% { transform: scale(1); }
}

/* Freier Modus: Punkte und Leben (A31) */
.frei-punkte { flex: 1 1 auto; text-align: center; font-size: 1rem; }
.leben-anzeige { white-space: nowrap; font-size: 1.3rem; line-height: 1; color: var(--rot); letter-spacing: 0.1em; }
.herz.verloren { color: var(--gesperrt); }

/* Handy quer: niedrige Höhe */
@media (max-height: 480px) {
  .lektion-kopf { padding-top: 0.2rem; padding-bottom: 0.2rem; }
  .knopf-klein { min-height: 30px; padding: 0.2em 0.6em; }
  .klaviatur-bereich { height: 42vh; }
}

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

.ergebnis-inhalt {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
}
.ergebnis-inhalt h2 { font-size: 1.7rem; margin: 0 0 0.3rem; }
.sterne-gross { color: var(--gold); font-size: 2.6rem; letter-spacing: 0.15em; }
.ergebnis-werte {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
}
.ergebnis-werte div {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 0.7rem 1.2rem;
  min-width: 130px;
}
.ergebnis-werte dt { color: var(--leise); font-size: 0.85rem; }
.ergebnis-werte dd { margin: 0.2rem 0 0; font-size: 1.6rem; font-weight: 700; }
.ergebnis-fehler h3 { font-size: 1rem; margin: 1rem 0 0.3rem; }
.ergebnis-fehler p { margin: 0; font-size: 1.1rem; }
.hinweis { color: var(--rot); }
.knopfreihe { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1.5rem; }
.neuer-highscore { color: var(--gold); font-size: 1.5rem; font-weight: 700; margin: 0.3rem 0; }

/* ---------- Mein Code (A34–A37) ---------- */

.code-inhalt {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}
.code-block { display: flex; flex-direction: column; gap: 0.8rem; }
.code-eingabe-bereich { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.4rem; }
.code-eingabe-bereich label { font-size: 0.9rem; color: var(--leise); }
.code-eingabe {
  font: inherit;
  font-size: 1.1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche);
  text-transform: uppercase;
}
.code-gross {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: clamp(1.3rem, 6.5vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  word-break: break-word;
}
.hinweis-aufschreiben {
  margin: 0;
  padding: 0.8rem 1rem;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: #fff8e6;
  font-weight: 700;
}
.code-status { margin: 0; text-align: center; color: var(--leise); }
.hinweis-box, .meldung {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
}
.meldung { color: var(--rot); border-color: #e9b7bd; }
.dialog-text { margin: 0; font-size: 1.05rem; }

/* ---------- Einstellungen ---------- */

.einstellungen-inhalt {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.schalter-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  cursor: pointer;
}
.schalter-zeile input { width: 24px; height: 24px; flex: 0 0 auto; }

/* ---------- Impressum & Datenschutz (A40) ---------- */

a.knopf { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.rechtstext {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  line-height: 1.5;
}
.rechtstext h2 { margin: 1.5rem 0 0.5rem; font-size: 1.25rem; }
.rechtstext h3 { margin: 1rem 0 0.3rem; font-size: 1rem; }
