/* Grundlayout: links die Tafel, rechts die Leiste mit allen Tönen; Farben und Schriften stehen in tokens.css */
html {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px var(--font-ui);
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 34vw, 370px);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}
/* Leiste oben über die ganze Breite: links der Titel, in der Mitte die drei Tafeln, rechts Speichern, Liedersammlung,
   Einstellungen, Konto und der Knopf zum Einklappen. Die Spalten hängen nicht vom Inhalt ab: Fehlt rechts ein Knopf
   (Speichern beim Üben, Konto ohne Backend), bleibt die Mitte, wo sie ist. --rw ist so breit wie die rechte Gruppe
   mit allen Knöpfen; beide Seiten sind mindestens so breit, die Mitte bekommt den Rest bis 500 px. */
.topbar {
  --rw: 268px;
  grid-column: 1 / -1; display: grid; align-items: start; gap: 12px;
  grid-template-columns: minmax(var(--rw), 1fr) minmax(0, 500px) minmax(var(--rw), 1fr);
}
.topbar .title { justify-self: start; align-self: stretch; display: flex; align-items: center; max-height: 56px; padding-left: 6px; }
.topbar .tabs { background: var(--panel); }
.areanav { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* Rechte Gruppe: eine Leiste wie die Reiter in der Mitte (gleich hoch, gleiche Fläche), darin gleich große Knöpfe nur
   mit Symbol (der Name bleibt für Vorlesen und Tests im Knopf), Trennstriche vor dem Konto und vor dem Einklappen */
.topright {
  justify-self: end; display: flex; align-items: center; min-height: 56px; padding: 5px 4px;
  background: var(--panel); border-radius: 14px;
}
.headbtns { display: flex; align-items: center; gap: 2px; }
.headbtns::after, #accMount::before { content: ""; flex: none; width: 2px; height: 24px; margin: 0 5px; border-radius: 1px; background: var(--line); }
#accMount::before { margin-left: 3px; }
:is(.headbtns, .savewrap, .topright) > .btn {
  position: relative; width: 46px; height: 46px; min-height: 46px; padding: 0;
  border: 0; border-radius: 10px; background: none; color: var(--fg);
}
:is(.headbtns, .savewrap, .topright) > .btn .ico { width: 1.45rem; height: 1.45rem; }
:is(.headbtns, .savewrap, .topright) > .btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:is(.headbtns, .savewrap, .topright) > .btn:is([aria-expanded="true"], :active:not(:disabled)) { background: var(--btn); box-shadow: 0 1px 4px var(--shadow); transform: none; }
.topright .topfold { color: var(--muted); }
/* Konto (shared/header.js): Personen-Symbol wie die Knöpfe daneben, Avatar als Kreis; leer nimmt es keinen Platz */
#accMount:empty { display: none; }
.headbtns .kopf-person { width: 46px; height: 46px; border: 0; border-radius: 10px; background: none; }
.headbtns .kopf-person[aria-expanded="true"] { background: var(--btn); box-shadow: 0 1px 4px var(--shadow); }
.headbtns .kopf-avatar { width: 46px; height: 46px; }
.headbtns .kopf-menue { z-index: 40; }
/* Schmal (iPad im Hochformat): Titel und rechte Gruppe so breit wie nötig, die Mitte nimmt den Platz dazwischen. Die
   rechte Spalte ist fest so breit wie die Gruppe mit allen Knöpfen, damit die Mitte auch hier stehen bleibt. */
@media (max-width: 900px) {
  .topbar { gap: 8px; grid-template-columns: auto minmax(0, 1fr) var(--rw); }
}
.app.notop { grid-template-rows: minmax(0, 1fr); }
.app.notop > .topbar { display: none; }
/* eingeklappt: ein kleiner Griff oben in der Mitte holt sie zurück */
.topshow {
  position: fixed; top: 0; left: 50%; z-index: 25; transform: translateX(-50%);
  display: flex; align-items: center; gap: .35rem; padding: 2px 14px 4px;
  border: 2px solid var(--btn-line); border-top: 0; border-radius: 0 0 12px 12px;
  background: var(--btn); color: var(--muted); font: 800 .72rem var(--font-ui); cursor: pointer;
}
.topshow .ico { width: 1rem; height: 1rem; }
/* Leiste eingeklappt: die Tafel nimmt die ganze Breite */
.app.collapsed { grid-template-columns: minmax(0, 1fr); }
.app.collapsed > .side { display: none; }
/* Beim Üben gehört die ganze Breite der Tafel: Spiele und ihre Einstellungen stehen auf der Tafel, nicht in der Leiste */
.app.practice { grid-template-columns: minmax(0, 1fr); }
.app.practice > .side, .app.practice .fab.sidetoggle { display: none; }
/* Vorführen: nur die Tafel mit den runden Knöpfen, ohne Leisten und mit schmalem Rand */
body.present { padding: 4px max(4px, env(safe-area-inset-right, 0px)) 4px max(4px, env(safe-area-inset-left, 0px)); }
.present .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.present .app > .topbar, .present .app > .side, .present .topshow, .present .fab.sidetoggle { display: none; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- Knöpfe ---------- */
.btn {
  font: 800 .95rem var(--font-ui);
  color: var(--fg); background: var(--btn);
  border: 2px solid var(--btn-line); border-radius: 12px;
  min-height: 48px; padding: 0 .6rem;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  cursor: pointer; touch-action: manipulation;
}
a.btn { text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.on { background: var(--fg); color: var(--board); border-color: var(--fg); }
.btn .big { font: 700 1.5rem/1 var(--font-display); }
.btn .small { font-size: .78rem; font-weight: 700; }
.btn.danger { color: var(--danger); }
.btn.confirm { background: var(--danger); border-color: var(--danger); color: var(--board); }
/* Die Zeichnungen der Symbole liegen oben in app/index.html; das Sprite selbst nimmt keinen Platz ein */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1.25rem; height: 1.25rem; flex: none; }
.btn .big .ico { width: 1.5rem; height: 1.5rem; display: block; }
.sym { display: block; height: 100%; width: auto; overflow: visible; }
/* Taktart als zwei Zahlen übereinander (auf der Tafel und auf den Knöpfen) */
.mtr {
  display: inline-flex; flex-direction: column; align-items: center;
  font-family: var(--font-display); font-weight: 700; line-height: .9;
}

/* Namensfeld zum Speichern (im Menü und in der Leiste) */
.saverow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.saverow input {
  font: 700 16px var(--font-ui); color: var(--fg); background: var(--btn);
  border: 2px solid var(--btn-line); border-radius: 12px;
  min-height: 48px; padding: 0 .75rem; min-width: 0;
  -webkit-user-select: text; user-select: text;
}

/* ---------- Rahmen der Tafel, gemeinsam für alle Bereiche ---------- */
.boardwrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.toast {
  position: absolute; left: 50%; bottom: 36px; z-index: 20;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 48px);
  background: var(--fg); color: var(--board);
  padding: 10px 16px; border-radius: 12px;
  font-weight: 800; font-size: .95rem; line-height: 1.3; text-align: center;
  box-shadow: 0 8px 20px var(--shadow); pointer-events: none;
}
.toast.warn { background: var(--danger); }
.board {
  flex: 1; min-height: 0; display: flex;
  background: var(--board);
  border: 10px solid var(--frame);
  border-radius: 18px 18px 6px 6px;
  box-shadow: 0 2px 0 var(--frame-edge), inset 0 2px 10px var(--shadow);
  overflow-x: auto; overflow-y: hidden;
}
/* Abspielen, Einzählen, Metronom: runde Knöpfe unten rechts auf der Tafel, über den Zeichen */
.playfab {
  position: absolute; right: 24px; bottom: 30px; z-index: 15;
  display: flex; align-items: center; gap: 10px;
}
/* Vorführen: immer oben rechts in der Ecke der Tafel (innerhalb des Rahmens), auch in Spielen und auf deren Startseite */
.fab.presentfab { position: absolute; top: 20px; right: 24px; z-index: 17; width: 44px; height: 44px; }
.fab.presentfab .ico { width: 1.3rem; height: 1.3rem; }
/* Schreiben im Vorführen: Stift links neben „Vorführen“, die schmale Leiste unter der Tafel (pen.js) */
.fab.penfab { position: absolute; top: 20px; right: 78px; z-index: 17; width: 44px; height: 44px; }
.fab.penfab .ico { width: 1.3rem; height: 1.3rem; }
.penbar {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 18px;
  padding: 8px 4px 2px;
}
.penbar > * { flex: none; }
.penning .playfab { bottom: calc(var(--penh, 0px) + 30px); }
.penbar .values { display: flex; gap: 6px; }
.penbar .values .btn { width: 58px; min-height: 58px; }
.penbar .values .sym { height: 2.1rem; }
.penbar .values .vgap { display: none; }
.penbar .palette { display: flex; gap: 6px; }
.penbar .pal { display: contents; }
.penbar .note { width: 50px; font-size: 1.5rem; }
.penbar .palette [data-more] { display: none; }
.penbar .steps { display: grid; grid-template-columns: repeat(7, 50px); gap: 4px; }
.penbar .steps .btn { min-height: 44px; font-size: 1.3rem; }
.penbar > .btn { flex-direction: column; gap: .1rem; min-width: 58px; min-height: 58px; padding: .25rem .4rem; }
.penbar > .btn .small { font-size: .62rem; }
.penbar > .btn .big .ico { width: 1.4rem; height: 1.4rem; }
.penbar .zbtns { display: flex; gap: 4px; }
.penbar .zbtns .btn { width: 46px; min-height: 58px; font-size: 1.5rem; }
.fab {
  display: grid; place-items: center; width: 52px; height: 52px; padding: 0;
  border: 2px solid var(--btn-line); border-radius: 50%; background: var(--btn); color: var(--fg);
  box-shadow: 0 3px 10px var(--shadow); cursor: pointer; touch-action: manipulation;
}
.fab .ico { width: 1.5rem; height: 1.5rem; }
.fab.on { background: var(--fg); color: var(--board); border-color: var(--fg); }
.fab.play { width: 80px; height: 80px; background: var(--fg); color: var(--board); border-color: var(--fg); }
.fab.play .ico { width: 2.3rem; height: 2.3rem; }
.fab.play.on { background: var(--danger); border-color: var(--danger); }
/* Ein-/Ausklappen: großer Griff am rechten Rand der Tafel, senkrecht in der Mitte; eingeklappt zeigt der Pfeil nach links */
.fab.sidetoggle { position: absolute; top: 50%; right: 10px; z-index: 15; width: 52px; height: 84px; border-radius: 26px; transform: translateY(-50%); }
.fab.sidetoggle .ico { width: 1.7rem; height: 1.7rem; }
.app.collapsed .fab.sidetoggle .ico { transform: scaleX(-1); }
/* Tempo: die Zahl groß, darunter klein „Tempo“; offen wie die anderen Schalter dunkel */
.fab.tempo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.fab.tempo .tnum { font: 800 1.05rem/1 var(--font-ui); }
.fab.tempo .tlbl { font: 800 .5rem/1 var(--font-ui); letter-spacing: .04em; text-transform: uppercase; opacity: .75; }
.fab.tempo[aria-expanded="true"] { background: var(--fg); color: var(--board); border-color: var(--fg); }
/* Beschriftung unter den kleinen runden Knöpfen (data-lbl): gehört zum Knopf, ein Tipp darauf zählt mit */
.playfab { gap: 14px; }
.playfab .fab[data-lbl] { position: relative; }
.playfab .fab[data-lbl]::after {
  content: attr(data-lbl); position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  padding: 1px 5px; border-radius: 6px; background: color-mix(in srgb, var(--board) 85%, transparent);
  font: 800 .66rem/1.2 var(--font-ui); color: var(--muted); white-space: nowrap;
}
.playfab .fab.on[data-lbl]::after, .playfab .fab[aria-expanded="true"]::after { color: var(--fg); }
.fab.tempo .tlbl { display: none; }
.tempopop {
  position: absolute; right: 0; bottom: calc(100% + 12px); width: min(340px, calc(100vw - 48px));
  padding: 12px 14px 10px; border: 2px solid var(--btn-line); border-radius: 18px;
  background: var(--btn); box-shadow: 0 8px 24px var(--shadow);
}
.tempopop .tphead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font: 800 .74rem var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tempopop .tphead output { font-size: 1rem; letter-spacing: 0; text-transform: none; color: var(--fg); }
.tempopop .tprow { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 10px; align-items: center; }
.tempopop .tprow .btn { padding: 0; }
.tempopop input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--fg); }
.tempopop .tpscale { display: flex; justify-content: space-between; padding: 0 58px; font: 700 .7rem var(--font-ui); color: var(--muted); }
.fab .cnt4 { display: flex; gap: 2px; align-items: flex-end; }
.fab .cnt4 i { font: 800 .62rem/1 var(--font-ui); font-style: normal; }
.fab .cnt4 i:first-child { font-size: .95rem; }
.tray {
  height: 12px; margin-inline: 10%;
  background: var(--frame);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 0 var(--frame-edge);
}

@media (max-width: 600px) { /* nur Handys; ein iPad (ab 768 px) behält die Leiste an der Seite */
  /* Die Tafel füllt den Bildschirm unter der Leiste oben (dvh: ohne die Adressleiste des Browsers mitzuzählen) */
  html, body { height: 100dvh; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  /* Startseite des Spiels: Platz unten für die runden Knöpfe, nichts ragt über die Tafel hinaus */
  .gameintro { grid-template-columns: minmax(0, 1fr); padding: 16px; overflow-y: auto; }
  .gintro { min-width: 0; }
  .topshow { white-space: nowrap; font-size: .85rem; padding: 6px 18px 8px; }
  .topshow span { font-size: 0; }
  .topshow span::after { content: "Menü, Lieder, Bereiche"; font-size: .85rem; }
  .gameintro .gintro { gap: 12px; }
  .gameintro .gintro h2 { font-size: 1.5rem; }
  .gameintro .gintro p { font-size: 1rem; line-height: 1.4; }
  .gameintro .gintro .gbtn.big { margin-top: 0; min-width: 0; width: 100%; height: 60px; font-size: 1.2rem; white-space: nowrap; }
  /* Nur ansehen und abspielen: nichts zum Schreiben (die Leiste bleibt eingeklappt, Speichern entfällt). Rein per CSS,
     damit schon der erste Render stimmt und nichts erst nach dem Laden per JS (.phone, .collapsed) verschwindet. */
  .app > .side, .fab.sidetoggle, .savewrap { display: none; }
  /* Leiste oben auf dem Handy: Titel und Knöpfe in einer Zeile (nur Symbole), darunter Reiter und Schreiben/Üben */
  .topbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 8px; }
  .topbar .title { justify-self: stretch; font-size: 1.15rem; letter-spacing: .02em; padding-left: 2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar .areanav { grid-column: 1 / -1; grid-row: 2; }
  .topright { min-height: 52px; padding: 4px 3px; }
  :is(.headbtns, .savewrap, .topright) > .btn, .headbtns :is(.kopf-person, .kopf-avatar) { width: 44px; height: 44px; min-height: 44px; }
  .headbtns::after, #accMount::before { margin: 0 3px; }
  .tab { font-size: .9rem; letter-spacing: 0; min-height: 44px; }
  /* Runde Knöpfe auf der Tafel kleiner und bei Bedarf in zwei Reihen, damit nichts links herausragt */
  .playfab { left: 10px; right: 10px; bottom: 26px; gap: 22px 8px; flex-wrap: wrap; justify-content: flex-end; }
  .playfab .fab { width: 42px; height: 42px; }
  .playfab .fab.play { width: 62px; height: 62px; }
  .playfab .fab.play .ico { width: 1.8rem; height: 1.8rem; }
  .fab.presentfab { top: 16px; right: 16px; width: 40px; height: 40px; }
  .fab.penfab { top: 16px; right: 64px; width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled) { transform: none; }
}

/* ---------- Verdecken (alle Bereiche) ---------- */
/* Tuch: deckt ab einer Zeile alles ab, mit einem Hinweis oben; ein Tipp darauf deckt die nächste Zeile auf */
.cloth {
  position: relative; z-index: 4;
  display: flex; justify-content: center; align-items: flex-start;
  border: 2px dashed var(--btn-line); border-radius: 14px;
  background: repeating-linear-gradient(135deg, var(--panel) 0 16px, var(--board) 16px 32px);
  cursor: pointer; touch-action: manipulation;
}
.clothtip {
  margin-top: 10px; padding: 6px 14px; border-radius: 999px;
  background: var(--btn); border: 2px solid var(--btn-line); color: var(--muted);
  font: 800 .85rem var(--font-ui); white-space: nowrap; pointer-events: none;
}
/* ?-Karte über einem Zeichen. Das „?“ in der Grundschrift (Playwrite DE Grund) in ihrer kräftigsten echten Stärke 400:
   Fetter gibt es die Schrift nicht, ein nachgebautes Fett sähe nicht mehr nach Grundschrift aus. */
.qcard {
  display: grid; place-items: center;
  border-radius: 12px; background: var(--card, var(--fg)); color: var(--card-fg, var(--board));
  font: 400 1.6rem/1 var(--font-display); box-shadow: 0 3px 8px var(--shadow);
  cursor: pointer;
}
/* Rhythmus und Notenblatt sind schwarz gezeichnet; dort ist die Karte türkis, damit sie nicht wie ein Notenzeichen
   wirkt (Türkis gehört zu keinem Ton). Die Farbnoten behalten die dunkle Karte, die sich von den bunten Punkten abhebt. */
.grid.rhy, .sheet { --card: #0f766e; --card-fg: #fff; }
/* Leiste: Schalter fürs Mitspielen unter den Knöpfen */
.btn.stephide { width: 100%; margin-top: 6px; min-height: 44px; font-size: .85rem; }

/* ---------- Üben und Spielen (alle Bereiche) ---------- */
/* Leiste des Spiels unten auf der Tafel: beim Echo in der Mitte, beim Quiz über die ganze Breite (die runden Knöpfe
   machen dann Platz) */
.gamebar {
  position: absolute; left: 24px; bottom: 30px; z-index: 16;
  display: flex; align-items: flex-end; gap: 10px;
}
.gamebar.echo { left: 50%; transform: translateX(-50%); align-items: center; }
.gamebar.quiz { right: 24px; }
.boardwrap.game-quiz .playfab { display: none; }
/* Unten auf der Tafel bleibt so viel frei, dass die Leiste nichts verdeckt */
.boardwrap.game-echo .grid { padding-bottom: 116px; }
.boardwrap.game-quiz .grid { padding-bottom: 170px; } /* dazu der Hinweis über der Leiste */
.boardwrap.game-quiz .sheet { padding-bottom: 230px; }
.gbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 70px; height: 70px; padding: 0 10px; border-radius: 20px;
  border: 2px solid var(--btn-line); background: var(--btn); color: var(--fg); box-shadow: 0 3px 10px var(--shadow);
  font: 800 .7rem/1.1 var(--font-ui); cursor: pointer; touch-action: manipulation;
}
.gbtn .ico { width: 1.6rem; height: 1.6rem; }
.gbtn.main { background: var(--fg); color: var(--board); border-color: var(--fg); min-width: 96px; }
/* Großer Knopf in der Mitte (Rhythmus-Echo: Auflösen, danach Neuer Rhythmus): Zeichen neben der Schrift */
.gbtn.big { flex-direction: row; gap: 10px; min-width: 240px; height: 76px; padding: 0 26px; font-size: 1.15rem; }
.gbtn.big .ico { width: 2rem; height: 2rem; }
.gbtn:disabled { opacity: .4; cursor: default; }
.gbtn:active:not(:disabled) { transform: scale(.96); }
.gctl { display: flex; gap: 8px; flex: none; }
.gctl .gbtn { min-width: 62px; height: 62px; }
/* Antworten: wie eine Klaviatur (Stammtöne unten, Halbtöne darüber dazwischen) oder runde Farbpunkte in einer Reihe */
.qkeys { flex: 1; min-width: 0; padding: 8px; border-radius: 18px; background: var(--btn); border: 2px solid var(--btn-line); box-shadow: 0 3px 10px var(--shadow); }
.qkeys.piano { display: grid; gap: 5px 3px; }
.qkeys.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.qkey {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 58px; padding: 0 1px; border: 0; border-radius: 12px;
  background: var(--c); color: #000; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .16);
  font: 700 1.25rem/1 var(--font-display); cursor: pointer; touch-action: manipulation; overflow: hidden;
}
.qkey.black { min-height: 44px; font-size: .92rem; border-radius: 10px; }
.qkey.black span + span { font-size: .85em; }
/* Namen tippen: die Knöpfe ohne Farbe (sie würde die Antwort verraten); der richtige färbt sich mit der Lösung */
.qkey.plain:not(.right):not(.shown):not(.wrong) { background: var(--board); color: var(--fg); box-shadow: inset 0 0 0 2px var(--btn-line), inset 0 -4px 0 rgba(0, 0, 0, .16); }
.qkeys.row .qkey { flex: 0 1 64px; min-width: 40px; aspect-ratio: 1; min-height: 0; border-radius: 50%; font-size: 1.6rem; }
/* Wörter (höher, tiefer, gleich; Schritt, Sprung; Nummern der Rhythmen): breite Knöpfe ohne Farbe */
.qkeys.words { display: flex; justify-content: center; gap: 10px; }
.qkeys.words .qkey {
  flex: 1 1 150px; max-width: 190px; min-height: 66px; flex-direction: row; gap: .4rem;
  background: var(--board); color: var(--fg); box-shadow: inset 0 0 0 2px var(--btn-line), inset 0 -4px 0 rgba(0, 0, 0, .16);
  padding: 0 6px; text-align: center; font: 800 1.35rem/1.1 var(--font-ui); /* lange Namen brechen notfalls um */
}
.qkeys.words .qkey .ico { width: 1.6rem; height: 1.6rem; }
/* Viele Antworten (Rhythmus legen, Notenwerte) brechen um; die Knöpfe sind dafür schmaler (ab 150 px), so passen mehr
   in eine Reihe und die Leiste verdeckt weniger von der Tafel. Liednamen in kleinerer Schrift */
.qkeys.words { flex-wrap: wrap; }
.qkeys.words .qkey.name { font-size: 1rem; line-height: 1.15; padding: 0 .6rem; text-align: center; }
/* Bausteine von „Rhythmus legen“: ihre Notenzeichen nebeneinander */
.qkey .blk { display: flex; align-items: flex-end; }
.qkey .blk .sym { height: 3.8rem; width: auto; margin: -.4rem -.2rem; }
/* Ohne Antwortknöpfe (Note setzen: getippt wird auf die Notenlinien) stehen die Knöpfe der Leiste rechts */
.gamebar.quiz .gfeed + .gctl { margin-left: auto; }
/* Rückmeldung: richtig grün, falsch rot. Farbige Knöpfe bekommen einen Ring (ihre Farbe bleibt zu sehen, ein falscher
   ohne Farbe verrät sie auch jetzt nicht), Wörter werden ganz grün oder rot. Nur mit „Lösung“ gezeigt: grün umrandet */
.qkey.right, .qkey.shown { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .16), 0 0 0 4px var(--board), 0 0 0 8px var(--ok); }
.qkey.right { animation: qright .5s ease; }
.qkeys .qkey.wrong { opacity: .5; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .16), 0 0 0 4px var(--board), 0 0 0 8px var(--bad); animation: qwrong .4s ease; }
.qkeys .qkey.plain.wrong { background: var(--board); color: var(--fg); }
.qkeys.words .qkey.right { background: var(--ok); color: #fff; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2); }
.qkeys.words .qkey.shown { color: var(--ok); box-shadow: inset 0 0 0 4px var(--ok), inset 0 -4px 0 rgba(0, 0, 0, .16); }
.qkeys.words .qkey.wrong { background: var(--bad); color: #fff; opacity: .85; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2); }
@keyframes qright { 40% { transform: scale(1.15); } }
@keyframes qwrong { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
/* Hinweis mittig über der Leiste: grün „Richtig!“, rot „Leider falsch“, grün umrandet „Das ist die Lösung“ */
.gfeed {
  position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 10px 24px 10px 16px; border-radius: 999px;
  background: var(--btn); color: #fff; box-shadow: 0 3px 10px var(--shadow);
  font: 800 1.35rem/1.1 var(--font-ui); white-space: nowrap; pointer-events: none;
}
.gfeed .ico { width: 1.9rem; height: 1.9rem; flex: none; }
.gfeed.right { background: var(--ok); animation: qpop .35s ease; }
.gfeed.wrong { background: var(--bad); animation: qshake .4s ease; }
.gfeed.shown { color: var(--ok); box-shadow: inset 0 0 0 3px var(--ok), 0 3px 10px var(--shadow); animation: qpop .35s ease; }
@keyframes qpop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
@keyframes qshake { 20%, 60% { transform: translateX(calc(-50% - 6px)); } 40%, 80% { transform: translateX(calc(-50% + 6px)); } }
/* Die Frage groß über der Tafel; unten bleibt Platz für die Leiste */
.quizview {
  position: absolute; top: 10px; left: 10px; right: 10px; bottom: 22px; z-index: 12;
  display: grid; place-items: center; padding: 16px 16px 200px; border-radius: 8px;
  background: var(--board); color: var(--fg);
}
/* Startseite eines Spiels: Name, Erklärung für die Kinder und „Los geht's!“ mittig auf der Tafel */
.gameintro {
  position: absolute; top: 10px; left: 10px; right: 10px; bottom: 22px; z-index: 14;
  display: flex; flex-direction: column; align-items: center; padding: 24px 80px; overflow-y: auto; border-radius: 8px;
  background: var(--board); color: var(--fg);
}
.gintro { max-width: 680px; display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }
.gintro h2 { margin: 0; font: 800 2.6rem/1.1 var(--font-ui); }
.gintro p { margin: 0; font: 700 1.5rem/1.45 var(--font-ui); text-wrap: pretty; }
/* Solange die Galerie oder die Karte eines Spiels auf der Tafel steht, gibt es nichts abzuspielen: Die Karte hat ihren eigenen Knopf */
.boardwrap:has(.gameintro:not([hidden])) .playfab { display: none; }
.gintro .gbtn.big { margin-top: 8px; min-width: 280px; height: 84px; font-size: 1.4rem; }
/* Vor „Abspielen“ ist die Leiste blass, nur dieser Knopf und „Ende“ nicht */
.gamebar.gated .qkey, .gamebar.gated .gbtn:not([data-act="end"]):not([data-act="start"]) { opacity: .4; }
/* Schmale Tafel (z. B. iPad im Hochformat): Die Leiste des Echos rückt über die runden Knöpfe; beim Quiz stehen die
   Knöpfe anhören, Lösung, Ende über den Antworten, die so die ganze Breite bekommen */
.boardwrap { container-type: inline-size; }
@container (max-width: 880px) {
  .gamebar.echo { bottom: 124px; }
  .boardwrap.game-echo .grid { padding-bottom: 210px; }
  .gamebar.quiz { flex-direction: column; align-items: stretch; gap: 8px; }
  .gamebar.quiz .gctl { order: -1; justify-content: flex-end; }
  .qkey { font-size: 1.05rem; }
  .qkey.black { font-size: .78rem; }
  .quizview { padding-bottom: 290px; }
  .boardwrap.game-quiz .grid { padding-bottom: 250px; }
  .boardwrap.game-quiz .sheet { padding-bottom: 310px; }
}
@media (prefers-reduced-motion: reduce) {
  .qkey.right, .qkeys .qkey.wrong, .gfeed { animation: none; }
}

/* Ladeschirm: deckt die noch leere Seite ab, bis main.js alles aufgebaut hat (bootDone), damit nichts halb fertig aufblitzt */
.boot {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; justify-items: center; gap: 16px;
  background: var(--bg); color: var(--fg); transition: opacity .2s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot .bootname { font: 700 1.6rem var(--font-ui); letter-spacing: .02em; }
.boot .bootdots { display: flex; gap: 8px; }
.boot .bootdots i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); animation: bootpulse 1s ease-in-out infinite; }
.boot .bootdots i:nth-child(2) { animation-delay: .15s; }
.boot .bootdots i:nth-child(3) { animation-delay: .3s; }
@keyframes bootpulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .boot { transition: none; }
  .boot .bootdots i { animation: none; }
}

/* ---------- Startbildschirm ---------- */
/* Der Titel oben links führt dorthin zurück */
.title > button { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
/* Über der ganzen App: drei Bereiche nebeneinander, in jedem die Kacheln „schreiben“ und „Üben und Spielen“ */
.start {
  position: fixed; inset: 0; z-index: 60; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
  background: var(--bg); /* dasselbe Grün wie hinter der Tafel */
}
/* Senkrecht mittig über automatische Ränder statt justify-content: Ist der Inhalt höher als der Bildschirm, beginnt er
   oben und lässt sich ganz scrollen, statt oben abgeschnitten zu werden */
.start > .stitle { margin-top: auto; }
.start > .sareas { margin-bottom: auto; }
/* Farben nur des Startbildschirms: drei warme Töne zum Salbeigrün der App
   (Honig, Orange, Rot); auf den Flächen nur pastellig beigemischt */
:root {
  --s-card: var(--btn);
  --s-rhy: #e9b949; --s-mel: #f39200; --s-lied: #dc4a3a;
}
@media (prefers-color-scheme: dark) {
  :root { --s-tint: 13%; }
}
/* Zurück zur Website: dezent oben links, auf dem Handy über dem Titel; Ziel mindestens 44px hoch */
.shome {
  position: absolute; top: max(14px, env(safe-area-inset-top, 0px)); left: max(14px, env(safe-area-inset-left, 0px));
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px 0 8px; border-radius: 99px;
  font: 700 .95rem/1 var(--font-ui); color: var(--muted); text-decoration: none; touch-action: manipulation;
  background: color-mix(in srgb, var(--s-card) 70%, transparent);
}
.shome svg { width: 1.1rem; height: 1.1rem; transform: rotate(180deg); }
.shome:active { color: var(--fg); }
.stitle { margin: 0; font: 800 clamp(2rem, 5vw, 3.2rem)/1.1 var(--font-ui); letter-spacing: .04em; text-transform: uppercase; }
.ssub { margin: 0 0 22px; font: 700 clamp(1.05rem, 2vw, 1.35rem) var(--font-ui); color: var(--muted); }
.sareas { width: 100%; max-width: 1180px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
/* Jeder Bereich hat seinen Pastellton (--acc): Spalte, Bildkreis und Rand der Kacheln; die Schrift bleibt neutral */
.sarea[data-area="rhy"] { --acc: var(--s-rhy); }
.sarea[data-area="mel"] { --acc: var(--s-mel); }
.sarea[data-area="lied"] { --acc: var(--s-lied); }
.sarea {
  display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: 28px;
  background: color-mix(in srgb, var(--acc) var(--s-tint, 22%), var(--s-card));
  box-shadow: 0 1px 2px var(--shadow), 0 10px 28px color-mix(in srgb, var(--acc) 14%, transparent);
}
.sarea h2 { margin: 0; display: flex; align-items: center; gap: .75rem; font: 800 clamp(1.4rem, 2.6vw, 2rem)/1.1 var(--font-ui); }
/* Bild des Bereichs in einem Kreis aus der Kachelfarbe */
.sart { display: grid; place-items: center; flex: none; width: 3.2rem; height: 3.2rem; border-radius: 50%; background: var(--s-card); color: var(--fg); box-shadow: 0 2px 6px color-mix(in srgb, var(--acc) 30%, transparent); }
.sart svg { width: 2rem; height: 2rem; }
.shead { margin: 0 0 4px; min-height: 2.7em; font: 700 .98rem/1.35 var(--font-ui); color: var(--muted); }
/* Kachel: Symbol im Kreis, Name und Text, Pfeil nach rechts. Sie schrumpft nicht unter ihren Inhalt, sonst ragt ein
   langer Text (z. B. die Spiele) auf schmalen Kacheln über den Rand */
.stile {
  position: relative; flex: 1 0 auto; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  min-height: 150px; padding: 18px 16px 18px 18px; border: 2px solid color-mix(in srgb, var(--acc) 40%, var(--s-card)); border-radius: 22px; text-align: left;
  background: var(--s-card); color: var(--fg); cursor: pointer; touch-action: manipulation;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--acc) 30%, var(--s-card)), 0 6px 16px color-mix(in srgb, var(--acc) 14%, transparent);
  transition: transform .08s, box-shadow .08s;
}
/* Antippen: die Kachel sinkt auf ihren Schatten */
.stile:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--acc) 30%, var(--s-card)), 0 2px 6px color-mix(in srgb, var(--acc) 14%, transparent); }
.sicon { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: 50%; background: color-mix(in srgb, var(--acc) 28%, var(--s-card)); }
.sicon svg { width: 1.35rem; height: 1.35rem; }
.stile[data-part="play"] .sicon { background: color-mix(in srgb, var(--acc) 60%, var(--s-card)); }
.sbody { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; overflow-wrap: break-word; }
.sbody > * { max-width: 100%; }
.stile .sname { font: 800 1.4rem/1.15 var(--font-ui); }
.stile .stext { font: 700 .95rem/1.35 var(--font-ui); color: var(--muted); }
.sgo { width: 1.3rem; height: 1.3rem; color: var(--muted); opacity: .55; }
.slast { padding: 3px 8px; border-radius: 99px; background: color-mix(in srgb, var(--acc) 30%, var(--s-card)); font: 800 .7rem/1 var(--font-ui); letter-spacing: .05em; text-transform: uppercase; }
@media (max-width: 900px) { /* schmal: die Bereiche untereinander, die beiden Kacheln eines Bereichs nebeneinander */
  .sareas { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sarea { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px; }
  .sarea h2, .shead { grid-column: 1 / -1; }
  .shead { min-height: 0; margin: 0; }
  .stile { min-height: 110px; padding: 14px 16px; }
  .stile .sname { font-size: 1.2rem; }
}
@media (max-width: 600px) { /* Handy: auch die beiden Kacheln eines Bereichs untereinander */
  .sarea { grid-template-columns: minmax(0, 1fr); }
  .stile { min-height: 0; }
  .shome { position: static; align-self: flex-start; }
}

/* Leere Tafel: Hinweis mit Pfeil zur Leiste, unten in der Mitte über den leeren Plätzen (emptyhint.js).
   Tipps gehen durch auf die Tafel; er wippt sanft, damit man ihn bemerkt */
.emptyhint {
  position: absolute; left: 50%; top: 58%; z-index: 14; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 14px; max-width: min(480px, 88%);
  padding: 14px 18px 14px 22px; border-radius: 18px;
  background: var(--btn); border: 2px solid var(--btn-line); box-shadow: 0 6px 20px var(--shadow);
  pointer-events: none;
}
.emptyhint p { margin: 0; font: 800 1.08rem/1.35 var(--font-ui); color: var(--fg); }
.emptyhint > .ico { flex: none; width: 2.2rem; height: 2.2rem; color: var(--fg); animation: hintnudge 1.6s ease-in-out infinite; }
@keyframes hintnudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(7px); } }
@media (prefers-reduced-motion: reduce) { .emptyhint > .ico { animation: none; } }
/* × oben rechts auf der Ecke: schließt den Hinweis für den Bereich; als Einziges am Hinweis antippbar, 44px groß */
.emptyhint .hintclose {
  position: absolute; top: -20px; right: -20px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border-radius: 50%; border: 2px solid var(--btn-line); background: var(--btn); color: var(--fg); box-shadow: 0 2px 8px var(--shadow);
  pointer-events: auto; cursor: pointer; touch-action: manipulation;
}
.emptyhint .hintclose .ico { width: 1.1rem; height: 1.1rem; }
