:root {
  --gruen: #123a2b;
  --gruen2: #1b5040;
  --rot: #c8323c;
  --rot2: #e2525b;
  --gold: #f1c453;
  --creme: #fff8ec;
  --text: #fdf6ea;
  --matt: rgba(253, 246, 234, 0.7);
  --karte: rgba(255, 255, 255, 0.08);
  --rand: rgba(255, 255, 255, 0.14);
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, #1f5a47 0%, var(--gruen) 55%, #0b261c 100%) fixed;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(24px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
body.gesperrt { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* Schnee */
#schnee { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#schnee i { position: absolute; top: -10px; background: #fff; border-radius: 50%; animation: fallen linear infinite; }
@keyframes fallen { to { transform: translate3d(30px, 105vh, 0); } }

.kopf, .tabs, main { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; }
.kopf { text-align: center; padding: 22px 16px 6px; }
.kopf h1 { margin: 0; font-size: 2rem; letter-spacing: 0.5px; font-family: Georgia, "Times New Roman", serif; color: var(--gold); }
.kopf h1 span { display: block; font-size: 1.05rem; font-family: system-ui, sans-serif; color: var(--text); font-weight: 600; margin-top: 2px; }
.untertitel { margin: 8px 0 0; color: var(--matt); font-size: 0.95rem; }

.tabs { display: flex; gap: 8px; padding: 12px 16px; }
.tab { flex: 1; border: 1px solid var(--rand); background: var(--karte); padding: 10px; border-radius: 999px; font-weight: 600; }
.tab.aktiv { background: var(--creme); color: var(--gruen); border-color: var(--creme); }

main { padding: 0 16px; }
.ansicht { display: none; }
.ansicht.aktiv { display: block; animation: rein 0.25s ease; }
@keyframes rein { from { opacity: 0; transform: translateY(6px); } }

.hinweis { background: var(--karte); border: 1px dashed var(--rand); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 0.92rem; text-align: center; }

/* Türchen */
.raster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tuer {
  position: relative; aspect-ratio: 1 / 1.1; border: 0; padding: 0; background: #0b261c;
  border-radius: 12px; perspective: 600px; box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}
.tuer .innen { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.6rem; color: var(--gold); }
.tuer.erledigt .innen { color: #7be0a8; font-size: 2rem; font-weight: 700; }
.tuer .klappe {
  position: absolute; inset: 0; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--rot2), var(--rot));
  border: 2px solid rgba(255, 255, 255, 0.18);
  transform-origin: left center; transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.3, 1);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35); backface-visibility: hidden;
}
.tuer:nth-child(3n+2) .klappe { background: linear-gradient(145deg, #2f7d63, #1e6a51); }
.tuer:nth-child(5n+3) .klappe { background: linear-gradient(145deg, #f3d27a, #d9a93a); }
.tuer:nth-child(5n+3) .zahl { color: var(--gruen); }
.tuer.besonders .klappe { background: linear-gradient(145deg, #fff3d6, #f1c453); }
.tuer.besonders .zahl { color: var(--rot); }
.tuer .zahl { font-family: Georgia, serif; font-size: 1.8rem; font-weight: 700; color: var(--creme); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.tuer.offen .klappe { transform: rotateY(-105deg); }
.tuer.zu .klappe { filter: saturate(0.55) brightness(0.8); }
.tuer.heute .klappe { animation: leuchten 1.8s ease-in-out infinite; }
@keyframes leuchten { 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 22px var(--gold); } }
.tuer.wackeln { animation: wackeln 0.45s; }
@keyframes wackeln { 20%, 60% { transform: rotate(-4deg); } 40%, 80% { transform: rotate(4deg); } }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 10; background: rgba(5, 20, 14, 0.75); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; }
.overlay[hidden] { display: none; }
.blatt {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--creme); color: #23312b; border-radius: 22px 22px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: hoch 0.3s ease;
}
.blatt.mitte { text-align: center; }
@keyframes hoch { from { transform: translateY(40px); opacity: 0; } }
.schliessen { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.08); font-size: 1.1rem; }
.tag-nr { margin: 0; color: var(--rot); font-weight: 700; font-size: 0.9rem; }
.blatt h2 { margin: 4px 0 6px; font-family: Georgia, serif; color: var(--gruen); }
.tag-info { margin: 0 0 14px; font-size: 0.9rem; color: #5b6a63; }
.liste { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.liste details { background: #fff; border-radius: 12px; border: 1px solid #eadfcb; }
.liste summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px; font-weight: 600; cursor: pointer; }
.liste summary::-webkit-details-marker { display: none; }
.liste summary small { font-weight: 400; color: #7a877f; }
.liste .reg { font-size: 1.3rem; }
.liste .nm { flex: 1; }
.liste .dauer { font-size: 0.8rem; background: #eef4ef; color: var(--gruen2); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.liste details p { margin: 0 12px 10px; font-size: 0.92rem; line-height: 1.45; }
.liste .leichter { color: #6a7a71; font-style: italic; }

.knopf { display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px; font-size: 1.05rem; font-weight: 700; background: rgba(255, 255, 255, 0.15); }
.knopf.haupt { background: var(--rot); color: #fff; box-shadow: 0 4px 14px rgba(200, 50, 60, 0.4); }
.knopf.leise { background: transparent; color: #6a7a71; font-weight: 500; font-size: 0.92rem; margin-top: 6px; }

/* Training */
.training { background: var(--gruen); flex-direction: column; align-items: stretch; justify-content: space-between; padding: env(safe-area-inset-top) 18px calc(18px + env(safe-area-inset-bottom)); transition: background 0.4s; }
.training[data-typ="pause"] { background: #24384a; }
.training[data-typ="vorlauf"] { background: #3a2f1f; }
.training[data-typ="mobility"] { background: #3b2a4a; }
.tr-oben { position: relative; display: flex; align-items: center; justify-content: center; height: 64px; }
.tr-oben .schliessen { left: 0; right: auto; top: 13px; background: rgba(255, 255, 255, 0.12); color: #fff; }
.ton { position: absolute; right: 0; top: 13px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.12); }
.tr-schritte { display: flex; gap: 6px; }
.tr-schritte i { width: 26px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); }
.tr-schritte i.jetzt { background: var(--gold); }
.tr-schritte i.fertig { background: #7be0a8; }
.tr-mitte { text-align: center; max-width: 480px; margin: 0 auto; width: 100%; }
.tr-phase { margin: 0 0 10px; color: var(--matt); font-weight: 600; }
.tr-uhr { position: relative; width: min(62vw, 250px); aspect-ratio: 1; margin: 0 auto 14px; }
.tr-uhr svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.uhr-hg { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 12; }
.uhr-wert { fill: none; stroke: var(--gold); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 0.2s linear; }
.training[data-typ="pause"] .uhr-wert { stroke: #8ec5ff; }
.training[data-typ="mobility"] .uhr-wert { stroke: #d4a5ff; }
.tr-uhr span { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(3.5rem, 18vw, 5rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.training.pausiert .tr-uhr span { opacity: 0.4; }
#tr-name { margin: 0 0 8px; font-size: 1.6rem; font-family: Georgia, serif; }
.tr-seite { margin: 0 0 8px; display: inline-block; background: var(--gold); color: var(--gruen); font-weight: 800; padding: 6px 14px; border-radius: 999px; animation: puls 0.8s ease 3; }
@keyframes puls { 50% { transform: scale(1.1); } }
.tr-text { margin: 0 0 8px; line-height: 1.45; color: var(--text); }
.tr-leichter { margin: 0; font-size: 0.9rem; color: var(--matt); font-style: italic; }
.tr-unten { display: flex; gap: 10px; max-width: 480px; margin: 0 auto; width: 100%; }
.tr-unten .knopf { flex: 1; color: #fff; }
.tr-unten .knopf.leise { color: var(--matt); margin: 0; }

/* Geschafft */
.gross-emoji { font-size: 3.5rem; }
.wahl { display: flex; gap: 10px; justify-content: center; margin: 10px 0 4px; }
.wahl button { flex: 1; max-width: 110px; border: 2px solid #eadfcb; background: #fff; border-radius: 14px; padding: 10px 6px; font-size: 1.8rem; }
.wahl button span { display: block; font-size: 0.85rem; color: #5b6a63; }
.wahl button.gewaehlt { border-color: var(--rot); }
.neu-abzeichen { margin-top: 16px; }
.neu-abzeichen p { font-weight: 700; color: var(--rot); margin: 0 0 8px; }
.neu-abzeichen .abz { background: #fff; color: #23312b; border: 2px solid var(--gold); max-width: 220px; margin: 0 auto 8px; }

/* Statistik */
.karten { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.karte { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; justify-content: center; }
.karte strong { font-size: 2rem; color: var(--gold); line-height: 1.1; }
.karte span { color: var(--matt); font-size: 0.88rem; }
.karte.gross { grid-column: 1 / -1; position: relative; align-items: center; padding: 18px; }
.ring { width: 150px; height: 150px; transform: rotate(-90deg); }
.ring-hg { fill: none; stroke: rgba(255, 255, 255, 0.1); stroke-width: 10; }
.ring-wert { fill: none; stroke: #7be0a8; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text strong { font-size: 2.6rem; }

main h2 { font-size: 1.05rem; margin: 24px 0 10px; color: var(--creme); }
.streifen { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.punkt { display: inline-grid; place-items: center; aspect-ratio: 1; border-radius: 50%; font-size: 0.78rem; font-weight: 700; }
.streifen .punkt.erledigt { background: #7be0a8; color: var(--gruen); }
.streifen .punkt.verpasst { background: transparent; border: 2px dashed var(--rot2); color: var(--rot2); }
.streifen .punkt.zukunft { background: rgba(255, 255, 255, 0.08); color: var(--matt); }
.legende { font-size: 0.8rem; color: var(--matt); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.legende .punkt { width: 12px; height: 12px; margin-left: 6px; }
.legende .punkt.erledigt { background: #7be0a8; }
.legende .punkt.verpasst { border: 2px dashed var(--rot2); }
.legende .punkt.zukunft { background: rgba(255, 255, 255, 0.15); }

.gefuehl { display: grid; gap: 8px; }
.balken { display: grid; grid-template-columns: 90px 1fr 28px; align-items: center; gap: 10px; font-size: 0.92rem; }
.bb { height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bb i { display: block; height: 100%; background: var(--gold); border-radius: 6px; transition: width 0.6s ease; }
.bz { text-align: right; color: var(--matt); }

.abzeichen { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.abz { background: var(--karte); border: 1px solid var(--rand); border-radius: 14px; padding: 12px 8px; text-align: center; display: flex; flex-direction: column; gap: 3px; opacity: 0.5; }
.abz.an { opacity: 1; border-color: var(--gold); }
.abz span { font-size: 1.8rem; }
.abz strong { font-size: 0.85rem; }
.abz small { font-size: 0.72rem; color: var(--matt); }
.neu-abzeichen .abz small { color: #6a7a71; }

#konfetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: var(--creme); color: var(--gruen); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); max-width: 90vw; text-align: center; }

@media (min-width: 520px) { .raster { grid-template-columns: repeat(6, 1fr); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Testmodus */
.testleiste { position: relative; z-index: 5; max-width: 560px; margin: 8px auto 0; background: repeating-linear-gradient(45deg, #3a3210, #3a3210 10px, #2e280c 10px, #2e280c 20px); border: 2px solid var(--gold); border-radius: 14px; padding: 8px 12px; font-size: 0.9rem; }
.testleiste summary { font-weight: 700; color: var(--gold); cursor: pointer; }
.test-zeile { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.testleiste button, .testleiste select { background: var(--creme); color: var(--gruen); border: 0; border-radius: 10px; padding: 8px 12px; font: inherit; font-weight: 600; }
.testleiste select { flex: 1; }
.test-zeile button:not([aria-label]) { flex: 1; }
.testleiste input { width: 20px; height: 20px; accent-color: var(--gold); }
.test-raus { display: inline-block; margin-top: 8px; color: var(--matt); font-size: 0.82rem; }

.streifen .punkt.nachgeholt { background: rgba(123, 224, 168, 0.25); border: 2px solid #7be0a8; color: #7be0a8; }
.legende .punkt.nachgeholt { background: rgba(123, 224, 168, 0.25); border: 2px solid #7be0a8; }
.karte .klein { font-size: 0.72rem; color: var(--matt); opacity: 0.8; }

/* Adventskranz */
.kranz-box { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius); padding: 18px 12px 12px; text-align: center; }
.kranz { display: flex; justify-content: center; align-items: flex-end; gap: 18px; padding-bottom: 10px; border-bottom: 14px solid #2f7d63; border-radius: 0 0 40% 40% / 0 0 30% 30%; box-shadow: 0 6px 0 -2px #1e6a51; }
.kerze { display: flex; flex-direction: column; align-items: center; width: 44px; }
.kerze .wachs { display: block; width: 26px; height: 64px; border-radius: 5px 5px 3px 3px; background: linear-gradient(90deg, #8e2229, var(--rot2), #8e2229); opacity: 0.55; }
.kerze.an .wachs { opacity: 1; }
.kerze .flamme { display: block; width: 14px; height: 22px; margin-bottom: 3px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: transparent; }
.kerze.an .flamme { background: radial-gradient(ellipse at 50% 70%, #fff6c2 0%, #ffd34d 40%, #ff8a1f 75%, transparent 76%); box-shadow: 0 0 16px 4px rgba(255, 190, 60, 0.55); animation: flackern 1.6s ease-in-out infinite alternate; transform-origin: 50% 100%; }
@keyframes flackern { 0% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.08, 0.94) rotate(2deg); } 100% { transform: scale(0.95, 1.06) rotate(-1deg); } }
.kerze small { margin-top: 6px; font-size: 0.7rem; color: var(--matt); line-height: 1.3; order: 3; }
.kranz-text { margin: 12px 0 0; font-weight: 600; color: var(--gold); }

/* Muskelfigur */
.figur { display: block; width: 100%; max-width: 300px; margin: 0 auto; }
.figur .basis { fill: #ddd5c5; }
.figur .muskel { fill: #cbc1ad; }
.figur text { font-size: 7px; fill: #7a877f; font-family: system-ui, sans-serif; }
.fertig-figur-box { background: #fff; border: 1px solid #eadfcb; border-radius: 14px; padding: 12px; margin: 14px 0; }
.fertig-zwischen { margin: 0 0 6px; font-weight: 700; color: var(--gruen); }
.muskel-liste { text-align: left; font-size: 0.88rem; margin-top: 8px; }
.muskel-liste p { margin: 4px 0; }
.muskel-liste .punkt { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; aspect-ratio: auto; }
.muskel-liste .punkt.p { background: #c8323c; }
.muskel-liste .punkt.s { background: #f2a49c; }
.karte-figur { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius); padding: 14px; }
.karte-figur .figur .basis { fill: rgba(255, 255, 255, 0.10); }
.karte-figur .figur .muskel { fill: rgba(255, 255, 255, 0.16); }
.karte-figur .figur text { fill: var(--matt); }
.klein-text { font-weight: 400; font-size: 0.85rem; color: var(--matt); text-align: center; }
