:root {
  --bg: #14100c; --panel: #221a13; --panel2: #2d231a; --text: #f3e9dc; --muted: #a8957f;
  --amber: #f5a623; --green: #4cc38a; --red: #ef5b5b; --blue: #5aa9ff; --linie: #3b2f24;
  --auf-akzent: #20150a; --akzent-schatten: #a8710f; --hg: #14100c;
  --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--hg); background-color: var(--bg); background-attachment: fixed; color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#app { height: 100dvh; display: flex; flex-direction: column; padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l); }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Kopfzeile */
.kopf { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 52px; }
.kopf h1 { margin: 0; font-size: 20px; flex: 1; letter-spacing: .2px; }
.ikon { width: 44px; height: 44px; border-radius: 12px; background: var(--panel); font-size: 20px; line-height: 1; display: grid; place-items: center; }
.ikon:active { background: var(--panel2); }

/* Knöpfe */
.knopf { background: var(--amber); color: var(--auf-akzent); font-weight: 700; padding: 14px 18px; border-radius: 14px; font-size: 17px; min-height: 52px; box-shadow: 0 3px 0 var(--akzent-schatten); }
.knopf:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--akzent-schatten); }
.knopf.zweit { background: var(--panel2); color: var(--text); box-shadow: 0 3px 0 #120d09; }
.knopf.gruen { background: var(--green); box-shadow: 0 3px 0 #2a8660; color: #07231a; }
.knopf[disabled] { opacity: .45; }
.reihe { display: flex; gap: 10px; }
.reihe > * { flex: 1; }

/* Startseite */
.stat { padding: 4px 14px 12px; }
.rang { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rang b { font-size: 18px; }
.xpleiste { height: 10px; border-radius: 6px; background: var(--panel2); margin-top: 6px; overflow: hidden; }
.xpleiste > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--amber), #ffd36b); border-radius: 6px; transition: width .5s; }
.streak { background: var(--panel); padding: 6px 12px; border-radius: 20px; font-weight: 700; white-space: nowrap; }
.inhalt { padding: 0 14px 24px; display: flex; flex-direction: column; gap: 12px; }
.karte { background: var(--panel); border-radius: 16px; padding: 14px; }
.karte h2 { margin: 0 0 4px; font-size: 17px; }
.klein { color: var(--muted); font-size: 14px; }
.welt { margin-top: 8px; }
.welt h3 { margin: 6px 2px 2px; font-size: 18px; }
.welt .klein { margin: 0 2px 8px; }
.level { width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--panel); margin-bottom: 8px; min-height: 64px; }
.level:active { background: var(--panel2); }
.level .nr { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-weight: 800; color: var(--amber); }
.level .txt { flex: 1; min-width: 0; }
.level .txt b { display: block; }
.level .sterne { font-size: 18px; letter-spacing: 2px; color: #ffd24a; white-space: nowrap; }
.level.zu { opacity: .45; }
.level.neu { outline: 2px solid var(--amber); }
.mini { height: 5px; border-radius: 3px; background: var(--panel2); margin-top: 6px; overflow: hidden; }
.mini > i { display: block; height: 100%; background: var(--green); }

/* Bogen / Dialog */
.dunkel { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.bogen { background: var(--panel); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + var(--sa-b)); display: flex; flex-direction: column; gap: 12px; max-height: 90dvh; overflow: auto; }
.bogen h2 { margin: 0; }
.bogen textarea, .bogen select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--linie); border-radius: 12px; padding: 12px; font: inherit; user-select: text; -webkit-user-select: text; }
.bogen textarea { min-height: 110px; resize: vertical; }
.merk { background: var(--panel2); border-left: 4px solid var(--amber); padding: 10px 12px; border-radius: 8px; }

/* Lektion */
.lektion { flex: 1; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: 'kopf' 'prompt' 'brett' 'steuer'; }
.lkopf { grid-area: kopf; display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.lkopf .ikon { width: 40px; height: 40px; }
.balken { flex: 1; height: 12px; border-radius: 8px; background: var(--panel2); overflow: hidden; }
.balken > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #8be3b8); width: 0; transition: width .35s; }
.chip { font-weight: 700; background: var(--panel); padding: 5px 10px; border-radius: 14px; white-space: nowrap; font-size: 15px; }
.chip.combo { color: #ff9b4d; }
.prompt { grid-area: prompt; padding: 4px 16px 8px; text-align: center; }
.phase { font-size: 13px; color: var(--amber); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.frage { font-size: 24px; font-weight: 800; margin: 2px 0; }
.frage em { font-style: normal; color: var(--amber); }
.lehr { color: var(--muted); font-size: 15px; min-height: 40px; }
.brett { grid-area: brett; position: relative; min-height: 0; padding: 0 4px; }
.brett canvas { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.notenbox { grid-area: brett; position: relative; min-height: 0; padding: 0 4px; }
.notenbox canvas { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.notenklein { height: 190px; margin: 2px 0 4px; }
.notenklein canvas { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.steuer { grid-area: steuer; padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.tasten { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.taste { background: var(--panel2); font-size: 22px; font-weight: 800; border-radius: 12px; min-height: 56px; box-shadow: 0 3px 0 #120d09; }
.taste:active { transform: translateY(2px); box-shadow: 0 1px 0 #120d09; }
.taste.ok { background: var(--green); color: #07231a; }
.taste.nein { background: var(--red); color: #2b0707; }
.meldung { min-height: 44px; text-align: center; font-weight: 700; font-size: 15px; line-height: 1.3; }
.meldung.ok { color: var(--green); }
.meldung.nein { color: var(--red); }
.zeit { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin: 4px 24px 0; }
.zeit > i { display: block; height: 100%; width: 100%; background: var(--amber); transform-origin: left; }
.zeit > i.lauf { animation: zeitab linear forwards; }
@keyframes zeitab { to { transform: scaleX(0); background: var(--red); } }
@media (orientation: landscape) and (max-height: 520px) {
  .lektion { grid-template-columns: minmax(0, 1fr) 280px; grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: 'kopf kopf' 'brett prompt' 'brett steuer'; }
  .lkopf { padding: 4px 12px; }
  .frage { font-size: 20px; }
  .prompt { padding-top: 0; align-self: start; }
  .steuer { align-self: end; }
  .taste { min-height: 46px; font-size: 20px; }
  .tasten { grid-template-columns: repeat(4, 1fr); }
  .notenklein { height: 170px; }
  .lehr { min-height: 0; font-size: 14px; }
}

/* Ergebnis */
.zentrum { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; text-align: center; overflow: auto; }
.zentrum > :first-child { margin-top: auto; }
.zentrum > :last-child { margin-bottom: auto; }
.sterneGross { font-size: 54px; letter-spacing: 6px; color: #ffd24a; }
.sterneGross span { display: inline-block; opacity: .22; filter: grayscale(.8); }
.sterneGross span.an { opacity: 1; filter: none; animation: pop .5s ease-out both; }
.sterneGross span:nth-child(2).an { animation-delay: .25s; }
.sterneGross span:nth-child(3).an { animation-delay: .5s; }
@keyframes pop { 0% { transform: scale(0.2) rotate(-30deg); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
.werte { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 420px; }
.werte div { background: var(--panel); border-radius: 12px; padding: 10px 6px; }
.werte b { display: block; font-size: 22px; }
.knopfspalte { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; }

/* Karte, Einstellungen */
.legende { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; color: var(--muted); padding: 4px 14px; }
.legende { color: var(--text); font-size: 13px; }
.legende .lg { display: inline-flex; align-items: center; gap: 6px; }
.legende i { display: inline-block; width: 18px; height: 18px; border-radius: 50%; box-sizing: border-box; }
.kartenbrett { flex: 1; min-height: 220px; padding: 0 8px; }
.kartenbrett canvas { width: 100%; height: 100%; display: block; }
.zeile { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--linie); }
.schalter { appearance: none; width: 54px; height: 32px; border-radius: 16px; background: var(--panel2); position: relative; border: 0; flex: none; }
.schalter::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform .2s; }
.schalter.an { background: #2b5d46; }
.schalter.an::after { transform: translateX(22px); background: var(--green); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sa-b)); transform: translateX(-50%); background: #000d; padding: 10px 16px; border-radius: 20px; z-index: 30; max-width: 90vw; text-align: center; }
.drehhinweis { text-align: center; color: var(--muted); font-size: 13px; padding: 2px 8px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Melodie */
.notenreihe { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 2px; }
.nchip { min-width: 44px; padding: 8px 10px; border-radius: 12px; background: var(--panel2); font-weight: 800; font-size: 20px; color: var(--muted); }
.nchip.jetzt { background: var(--amber); color: var(--auf-akzent); transform: scale(1.12); }
.nchip.fertig { background: #2b5d46; color: var(--green); }

/* Mikrofon-Test */
.kartenknopf { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; min-height: 64px; }
.kartenknopf:active { background: var(--panel2); }
.kartenknopf .ik { font-size: 28px; }
.livebox { text-align: center; }
.liveNote { font-size: 56px; font-weight: 800; line-height: 1.1; color: var(--amber); min-height: 62px; }
.stimm { position: relative; height: 18px; margin: 10px 8px 4px; background: var(--panel2); border-radius: 9px; }
.stimm .mitte { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--muted); }
.nadel { position: absolute; top: -4px; width: 12px; height: 26px; margin-left: -6px; border-radius: 6px; background: var(--red); left: 50%; transition: left .08s; }
.nadel.gut { background: var(--green); }
.pegel { height: 8px; background: var(--panel2); border-radius: 5px; margin-top: 10px; overflow: hidden; }
.pegel > i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .06s; }
.saitenzeile { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--linie); }
.saitenzeile:last-child { border-bottom: 0; }
.saitenzeile .zustand { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.saitenzeile.ok .zustand { color: var(--green); font-weight: 700; }
.saitenzeile.oktave .zustand { color: var(--amber); font-weight: 700; }
.saitenzeile.ok b::before { content: '✓ '; color: var(--green); }

/* Feedback mit Screenshot */
.vorschau { display: flex; gap: 10px; align-items: flex-start; }
.vorschau:empty { display: none; }
.vorschau img { max-height: 140px; max-width: 60%; border-radius: 10px; border: 1px solid var(--linie); object-fit: contain; }
.klein-knopf { min-height: 44px; padding: 8px 14px; font-size: 15px; box-shadow: none; }
.textfeld { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--linie); border-radius: 12px; padding: 12px; font: inherit; margin-bottom: 8px; user-select: text; -webkit-user-select: text; }
.bogen .reihe:last-child { position: sticky; bottom: calc(-1 * var(--sa-b)); background: var(--panel); padding-top: 8px; }
@media (max-height: 500px) {
  .bogen { max-width: 640px; gap: 8px; padding-top: 12px; }
  .bogen textarea { min-height: 56px; }
  .vorschau img { max-height: 64px; }
}

/* Theorie- und Praxis-Strang */
.legende { display: grid; gap: 8px; margin: 6px 0 4px; }
.legende .klein { margin: 0 2px; }
.strangtag { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 12px; border-radius: 12px; border-left: 5px solid var(--blue); background: var(--panel); }
.strangtag span { color: var(--muted); font-size: 14px; }
.strangtag.theorie { border-left-color: var(--blue); }
.strangtag.praxis { border-left-color: var(--green); }
.level.theorie { border-left: 5px solid var(--blue); }
.level.praxis { border-left: 5px solid var(--green); background: linear-gradient(90deg, rgba(76,195,138,.12), var(--panel) 60%); }
.level.praxis .nr { color: var(--green); }
.level.theorie .nr { color: var(--blue); }
.strangchip { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; margin-bottom: 3px; }
.strangchip.theorie { background: rgba(90,169,255,.18); color: var(--blue); }
.strangchip.praxis { background: rgba(76,195,138,.2); color: var(--green); }
.bogen > .strangchip { align-self: flex-start; margin: 0; }

/* Stile: Karten und Knöpfe passen sich dem gewählten Stil an */
[data-stil="gaming"] .karte, [data-stil="gaming"] .level, [data-stil="gaming"] .strangtag { border: 1px solid var(--linie); box-shadow: 0 0 14px rgba(34,180,255,.14); }
[data-stil="gaming"] .knopf { box-shadow: 0 0 14px rgba(34,180,255,.55), 0 3px 0 var(--akzent-schatten); }
[data-stil="premium"] .karte, [data-stil="premium"] .level, [data-stil="premium"] .strangtag { border: 1px solid var(--linie); }
[data-stil="premium"] .knopf { background: linear-gradient(180deg, #f6d27a, #d9a73a); }
[data-stil="flat"] .knopf, [data-stil="flat"] .knopf:active, [data-stil="flat"] .taste, [data-stil="flat"] .taste:active { box-shadow: none; }
[data-stil="flat"] .karte, [data-stil="flat"] .level { box-shadow: none; }

/* Stil-Auswahl in den Einstellungen */
.stilraster { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
@media (min-width: 640px), (orientation: landscape) and (min-height: 0px) { .stilraster { grid-template-columns: repeat(4, 1fr); } }
.stilkachel { text-align: left; background: var(--panel2); border-radius: 14px; padding: 8px; border: 2px solid transparent; min-height: 44px; display: flex; flex-direction: column; gap: 6px; }
.stilkachel.gewaehlt { border-color: var(--amber); }
.stilkachel canvas { width: 100%; height: 84px; display: block; border-radius: 8px; }
.stilkachel b { display: block; font-size: 15px; }
.stilkachel span { font-size: 13px; color: var(--muted); }
.stilkachel .haken { color: var(--amber); font-weight: 800; }

/* Module (Startseite) und Kompetenzprofil */
.modul h3 { margin: 14px 0 0; }
.modul .ziel { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.modul.bald { opacity: .62; }
.modul.bald ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.baldchip { display: inline-block; background: var(--panel2); border-radius: 10px; padding: 2px 8px; font-size: 12px; font-weight: 700; margin-left: 6px; color: var(--muted); }
.profilzeile { background: var(--panel); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.profilzeile .kopfz { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.profilzeile .zustand { font-weight: 800; font-size: 13px; white-space: nowrap; }
.profilzeile .z0 { color: var(--muted); } .profilzeile .z1 { color: var(--amber); } .profilzeile .z2 { color: var(--green); } .profilzeile .z3 { color: var(--blue); }
.stufen4 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
.stufen4 i { height: 8px; border-radius: 4px; background: var(--panel2); }
.stufen4 i.an { background: var(--amber); }
.profilzeile.z2 .stufen4 i.an { background: var(--green); } .profilzeile.z3 .stufen4 i.an { background: var(--blue); }
