:root {
  --night: #0b1d3a; --night2: #17345f; --gold: #f4c542; --gold2: #e0a61a; --red: #d62839; --green: #1f8a5b;
  --ink: #13233d; --paper: #fffaf0; --muted: #8fa3c2; --card: #ffffff;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: #fff; background: radial-gradient(ellipse at top, #24497f 0%, var(--night) 60%) fixed;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
input, textarea { -webkit-user-select: text; user-select: text; font-family: var(--font); }
button { font-family: var(--font); cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Schnee */
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
#snow i { position: absolute; top: -10px; color: #fff; opacity: .7; animation: fall linear infinite; font-style: normal; }
@keyframes fall { to { transform: translate3d(var(--dx), 105vh, 0) rotate(240deg); } }
body.playing #snow { display: none; }

.screen { display: none; position: relative; z-index: 1; min-height: 100vh; }
.screen.active { display: block; }

/* Buttons */
.btn {
  border: 0; border-radius: 16px; padding: 12px 18px; font-size: 17px; font-weight: 700;
  background: #e8eef8; color: var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.18); transition: transform .1s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn-gold { background: linear-gradient(#ffd75e, var(--gold2)); color: #3b2500; }
.btn-big { font-size: 22px; padding: 16px 28px; border-radius: 20px; }
.btn-small { font-size: 14px; padding: 6px 12px; }
.btn-ghost { background: transparent; color: inherit; box-shadow: none; text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { background: #ffe1e1; color: #a1121f; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 0; font-size: 24px; background: rgba(255,255,255,.12); color: #fff;
}
.icon-btn.off { opacity: .45; }

/* Willkommen */
#welcome.active { display: flex; align-items: center; justify-content: center; padding: 24px; }
.welcome-card, .done-card {
  background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.18); border-radius: 28px; padding: 32px;
  max-width: 560px; width: 100%; text-align: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.big-emoji { font-size: 64px; }
.welcome-card h1 { font-size: 32px; margin: 8px 0; }
.welcome-card p { font-size: 19px; line-height: 1.4; }
.welcome-card label { display: block; font-size: 20px; font-weight: 700; margin: 20px 0 8px; }
.welcome-card input { width: 100%; font-size: 26px; padding: 12px 16px; border-radius: 16px; border: 0; text-align: center; margin-bottom: 20px; color: var(--ink); }

/* Kalender */
#calendar { padding: calc(16px + var(--safe-t)) 20px calc(24px + var(--safe-b)); max-width: 1300px; margin: 0 auto; }
.cal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cal-head h1 { font-size: clamp(24px, 3.6vw, 38px); margin: 0; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.cal-stats { margin-top: 6px; font-size: 18px; color: #dbe6f7; display: flex; gap: 16px; flex-wrap: wrap; }
.cal-stats b { color: var(--gold); }
.head-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.banner { margin: 14px 0 10px; padding: 12px 16px; border-radius: 16px; background: rgba(244,197,66,.15); border: 2px solid rgba(244,197,66,.45); font-size: 19px; font-weight: 600; }
.progress { height: 12px; background: rgba(255,255,255,.12); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ffe9a3); border-radius: 8px; transition: width .6s; }

.doors { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px; }
.door { position: relative; aspect-ratio: 1 / 1.08; perspective: 900px; cursor: pointer; }
.door .behind {
  position: absolute; inset: 0; border-radius: 16px; background: linear-gradient(#fff8e6, #f3e2b8);
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,.08);
}
.door .behind .b-icon { font-size: 40px; }
.door .behind .b-num { font-weight: 800; font-size: 15px; margin-top: 2px; }
.door .behind .b-state { font-size: 13px; font-weight: 700; margin-top: 4px; padding: 2px 8px; border-radius: 10px; }
.door.done .behind { background: linear-gradient(#fff3c4, #ffd75e); }
.door.done .b-state { background: var(--green); color: #fff; }
.door.opened .b-state { background: #ffb703; color: #3b2500; }
.door .panel {
  position: absolute; inset: 0; border-radius: 16px; transform-origin: left center; transition: transform .9s cubic-bezier(.3,.7,.3,1);
  display: flex; align-items: center; justify-content: center; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 6px 0 rgba(0,0,0,.25), inset 0 0 0 5px rgba(255,255,255,.18); overflow: hidden;
}
.door .panel::before { content: ""; position: absolute; inset: 10px; border: 2px dashed rgba(255,255,255,.35); border-radius: 10px; }
.door .panel .num { font-size: clamp(38px, 5vw, 52px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.25); position: relative; }
.door .panel .deco { position: absolute; top: 12px; right: 14px; font-size: 18px; opacity: .9; }
.door .panel .knob { position: absolute; right: 14px; top: 50%; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.door .panel .tag { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 800; }
.c0 .panel { background: linear-gradient(145deg, #e63946, #b01e2c); }
.c1 .panel { background: linear-gradient(145deg, #2a9d6f, #1a6e4c); }
.c2 .panel { background: linear-gradient(145deg, #3d6bd6, #2849a0); }
.c3 .panel { background: linear-gradient(145deg, #9b5de5, #6d3bb3); }
.door.locked .panel { filter: saturate(.55) brightness(.8); }
.door.locked .panel .tag { color: rgba(255,255,255,.7); }
.door.available .panel { box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 0 0 4px var(--gold), 0 0 24px rgba(244,197,66,.6); }
.door.today .panel { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 0 0 6px var(--gold), 0 0 40px rgba(244,197,66,.9); } }
.door.available .panel .tag { color: #3b2500; background: var(--gold); margin: 0 14px; border-radius: 8px; padding: 2px 0; }
.door.opened .panel { transform: rotateY(-78deg); }
.door.done .panel { transform: rotateY(-100deg); }
.door.opening .panel { transform: rotateY(-100deg); }
.door.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.cert-box { text-align: center; margin: 24px 0 8px; }
.preview-note { position: fixed; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); background: #ffb703; color: #3b2500; padding: 10px 16px; border-radius: 16px; font-weight: 700; z-index: 5; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }

/* Sheets (Workout, Eltern) */
.sheet.active { display: block; background: var(--paper); color: var(--ink); min-height: 100vh; }
.sheet-inner { max-width: 1100px; margin: 0 auto; padding: calc(14px + var(--safe-t)) 22px calc(40px + var(--safe-b)); }
.sheet-top { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.sheet-top .btn-ghost { padding-left: 0; font-size: 19px; }
.sheet h2 { font-size: clamp(28px, 4vw, 40px); margin: 8px 0 6px; }
.sheet .intro { font-size: 20px; line-height: 1.45; margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.chip { background: #eef2fa; border-radius: 12px; padding: 7px 12px; font-size: 16px; font-weight: 700; }
.chip.gold { background: #ffefb8; }
.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 20px; }
.start-row .btn-ghost { color: #4a5a78; font-size: 16px; }
.done-flag { background: #dff5e9; color: #145c3c; border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.preview-flag { background: #ffb703; color: #3b2500; border-radius: 12px; padding: 8px 12px; font-weight: 700; margin-top: 8px; display: inline-block; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 10px; flex-wrap: wrap; }
.section-title h3 { margin: 0; font-size: 24px; }
.section-title span { color: #5b6b88; font-size: 17px; font-weight: 600; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ex-card { background: #fff; border-radius: 20px; padding: 12px 14px; box-shadow: 0 2px 10px rgba(20,40,80,.08); display: flex; gap: 12px; align-items: flex-start; }
.ex-card svg { width: 130px; height: 104px; flex-shrink: 0; background: #f2f7ff; border-radius: 14px; }
.ex-card h4 { margin: 2px 0 4px; font-size: 19px; }
.ex-card p { margin: 0 0 4px; font-size: 15.5px; line-height: 1.35; color: #34435e; }
.ex-card .badge { display: inline-block; font-size: 13px; font-weight: 800; padding: 2px 8px; border-radius: 8px; background: #e4ecfa; color: #2849a0; margin-right: 4px; }
.ex-card .badge.test { background: #ffe3a3; color: #7a4b00; }
.ex-card .easier { color: #1f7a4d; font-weight: 600; }
.safety { margin-top: 28px; padding: 14px 16px; background: #fff1e0; border-radius: 16px; font-size: 16px; line-height: 1.4; }
.extra-box { margin-top: 22px; background: #fff; border-radius: 18px; padding: 14px 16px; font-size: 18px; box-shadow: 0 2px 10px rgba(20,40,80,.08); }
.tests-box { background: #fff7dd; border: 2px solid #ffd75e; border-radius: 18px; padding: 14px 16px; margin: 8px 0; color: var(--ink); }
.tests-box h4 { margin: 0 0 8px; font-size: 20px; }
.test-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0; font-size: 19px; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 48px; height: 48px; border-radius: 50%; border: 0; font-size: 26px; font-weight: 800; background: #e8eef8; color: var(--ink); }
.stepper output { min-width: 46px; text-align: center; font-size: 28px; font-weight: 900; }
.compare { font-size: 17px; color: #145c3c; font-weight: 700; }

/* Player */
#player.active { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: #0e2447; padding: calc(10px + var(--safe-t)) 18px calc(14px + var(--safe-b)); overflow: hidden; }
#player.rest { background: #0f3d33; }
#player.ready { background: #3a2a63; }
.p-top { display: flex; align-items: center; gap: 14px; }
.p-phase { flex: 1; font-size: 20px; font-weight: 800; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.p-time { font-size: 18px; font-weight: 700; color: #cbd8ee; font-variant-numeric: tabular-nums; }
.p-progress { height: 8px; background: rgba(255,255,255,.15); border-radius: 6px; margin: 10px 0; overflow: hidden; }
.p-progress div { height: 100%; width: 0; background: var(--gold); }
.p-main { flex: 1; display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; min-height: 0; align-items: center; }
.p-fig-wrap { position: relative; background: #f2f7ff; border-radius: 28px; height: 100%; max-height: 72vh; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.p-fig { width: 100%; height: 100%; }
.p-tag { position: absolute; top: 14px; left: 14px; z-index: 2; padding: 6px 12px; border-radius: 12px; font-weight: 800; font-size: 17px; background: var(--gold); color: #3b2500; }
.p-tag:empty { display: none; }
.p-info { text-align: center; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.p-label { font-size: 20px; font-weight: 800; color: var(--gold); min-height: 26px; }
.p-info h2 { font-size: clamp(30px, 4.4vw, 48px); margin: 4px 0 8px; line-height: 1.1; }
.p-cue { font-size: clamp(17px, 2vw, 21px); line-height: 1.4; margin: 0 0 6px; color: #e3ecfa; }
.p-easier { font-size: 16px; color: #9fe3bf; margin: 0 0 6px; min-height: 0; }
.ring-wrap { position: relative; width: min(34vh, 230px); height: min(34vh, 230px); margin: 6px 0; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.15); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--gold); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 326.7; transition: stroke .3s; }
#player.rest .ring-fg { stroke: #6ee7b7; }
.ring-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: min(11vh, 76px); font-weight: 900; font-variant-numeric: tabular-nums; }
.p-next { font-size: 17px; color: #cbd8ee; min-height: 24px; }
.p-next b { color: #fff; }
.p-controls { display: flex; justify-content: center; gap: 28px; margin-top: 10px; }
.ctrl { width: 70px; height: 70px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 28px; }
.ctrl-main { width: 86px; height: 86px; background: var(--gold); color: #3b2500; font-size: 34px; }
.p-toast { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.8); background: var(--gold); color: #3b2500; font-size: 34px; font-weight: 900; padding: 18px 30px; border-radius: 24px; opacity: 0; pointer-events: none; transition: all .3s; z-index: 5; text-align: center; }
.p-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#player.paused .ring-num { opacity: .5; }
#player.rest .p-label { font-size: 30px; color: #6ee7b7; }
#player.ready .p-label { font-size: 28px; }

@media (orientation: portrait) {
  .p-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
  .p-fig-wrap { max-height: 40vh; }
  .ring-wrap { width: min(24vh, 200px); height: min(24vh, 200px); }
}

/* Geschafft */
#done.active { display: flex; align-items: center; justify-content: center; padding: 24px; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.done-card { position: relative; z-index: 1; max-width: 640px; }
.done-card h1 { font-size: 40px; margin: 6px 0; color: var(--gold); }
.done-card p { font-size: 20px; line-height: 1.4; }
.reveal { margin: 18px 0; }
.extra-text { background: #fff; color: var(--ink); border-radius: 18px; padding: 16px 18px; font-size: 21px; line-height: 1.4; text-align: left; animation: pop .4s; }
.extra-text b { display: block; font-size: 16px; color: #b0781a; margin-bottom: 4px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.done-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 10px; }

/* Urkunde */
#certificate.active { display: block; padding: calc(14px + var(--safe-t)) 18px 30px; }
.cert-actions { display: flex; justify-content: space-between; max-width: 900px; margin: 0 auto 12px; }
.cert { max-width: 900px; margin: 0 auto; background: #fffdf5; color: #2b2010; border-radius: 10px; padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.cert-inner { border: 6px double #c9a227; border-radius: 6px; padding: 26px 30px; text-align: center; background: radial-gradient(circle at center, #fffef8, #fff6dc); }
.cert-stars { font-size: 30px; }
.cert-title { font-size: 58px; font-weight: 900; color: #b01e2c; letter-spacing: 6px; text-transform: uppercase; }
.cert-sub { font-size: 20px; font-weight: 700; color: #6b5420; }
.cert-name { font-size: 50px; font-weight: 900; margin: 18px 0 6px; color: #1a3d7c; border-bottom: 2px solid #c9a227; display: inline-block; padding: 0 30px 4px; }
.cert-text { font-size: 21px; line-height: 1.45; margin: 10px auto; max-width: 640px; }
.cert-figs { display: flex; justify-content: center; gap: 10px; margin: 8px 0; }
.cert-figs svg { width: 150px; height: 120px; }
.cert-table { margin: 8px auto 4px; border-collapse: collapse; font-size: 18px; }
.cert-table td, .cert-table th { padding: 6px 14px; border-bottom: 1px solid #e5d7a6; }
.cert-sign { display: flex; justify-content: space-around; margin-top: 30px; font-size: 15px; color: #6b5420; }
.cert-sign div { border-top: 1.5px solid #6b5420; padding-top: 4px; min-width: 200px; }

/* Eltern */
.parent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin: 14px 0 24px; }
.card { background: #fff; border-radius: 18px; padding: 14px 16px; box-shadow: 0 2px 10px rgba(20,40,80,.08); display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; }
.card p { margin: 0; font-size: 15px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 15px; }
.card label.check { flex-direction: row; align-items: center; gap: 8px; }
.card input[type=text], .card textarea { font-size: 18px; padding: 8px 10px; border-radius: 10px; border: 1.5px solid #cfd8e8; }
.card input[type=checkbox] { width: 22px; height: 22px; }
.pa-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pa-day { background: #fff; border-radius: 12px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; }
.pa-day button { border: 0; border-radius: 10px; padding: 6px 10px; font-weight: 800; font-size: 14px; min-width: 96px; }
.st-zu { background: #e8eef8; color: #4a5a78; }
.st-offen { background: #ffe3a3; color: #7a4b00; }
.st-geschafft { background: #c9f0da; color: #145c3c; }

/* Modals & Toast */
.modal { position: fixed; inset: 0; background: rgba(5,12,30,.7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-card { background: #fff; color: var(--ink); border-radius: 24px; padding: 22px; width: min(360px, 100%); text-align: center; }
.modal-card p { font-size: 19px; line-height: 1.4; }
.modal-buttons { display: flex; gap: 12px; justify-content: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 10px 0 16px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #4a5a78; }
.pin-dots span.on { background: #4a5a78; }
.pin-dots.wrong { animation: shake .4s; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.pin-pad button { height: 60px; border-radius: 16px; border: 0; font-size: 26px; font-weight: 800; background: #eef2fa; color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(30px + var(--safe-b)); transform: translateX(-50%) translateY(30px); background: #fff; color: var(--ink); padding: 14px 20px; border-radius: 18px; font-size: 18px; font-weight: 700; box-shadow: 0 8px 30px rgba(0,0,0,.35); opacity: 0; transition: all .3s; z-index: 60; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media print {
  body { background: #fff !important; }
  #snow, .no-print { display: none !important; }
  .screen:not(#certificate) { display: none !important; }
  #certificate { padding: 0 !important; }
  .cert { box-shadow: none; max-width: none; }
  @page { size: A4 landscape; margin: 12mm; }
}
