:root {
  --bg: #fff8ef;
  --card: #ffffff;
  --text: #2b2b3a;
  --muted: #7a7486;
  --primary: #ff7a59;
  --primary-dark: #e85f3e;
  --teal: #2fae9f;
  --yellow: #ffc83d;
  --red: #e5484d;
  --line: #efe4d6;
  --radius: 22px;
  --shadow: 0 6px 18px rgba(80, 50, 20, .10);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 18px/1.4 ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.screen {
  min-height: 100vh; min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- Kopfzeile ---------- */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.topbar-title { flex: 1; font-size: 24px; margin: 0; }
.icon-btn {
  width: 60px; height: 60px; flex: none;
  display: grid; place-items: center;
  font-size: 30px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.parent { font-size: 22px; opacity: .55; width: 48px; height: 48px; }
.icon-btn.star { background: var(--yellow); }

/* ---------- Zeitanzeige ---------- */
.timer {
  flex: 1; display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 999px; padding: 8px 18px 8px 10px;
  box-shadow: var(--shadow); min-width: 0;
}
.timer .t-icon { font-size: 30px; }
.timer .t-bar { flex: 1; height: 18px; background: #f3ebe0; border-radius: 999px; overflow: hidden; min-width: 40px; }
.timer .t-fill { height: 100%; background: var(--teal); border-radius: 999px; transition: width .6s, background .6s; }
.timer .t-text { font-weight: 800; font-size: 20px; white-space: nowrap; flex: none; }
.timer.is-low .t-fill { background: var(--yellow); }
.timer.is-low { animation: pulse 1.6s infinite; }
.timer.is-empty .t-fill { background: var(--red); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 200, 61, .45); } }

/* ---------- Kanal-Chips ---------- */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 999px; padding: 6px 16px 6px 6px;
  box-shadow: var(--shadow); font-weight: 700; font-size: 17px; max-width: 240px;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip img, .chip .chip-emoji { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font-size: 22px; background: #f3ebe0; }
.chip.active { background: var(--primary); color: #fff; }

/* ---------- Videoraster ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { text-align: left; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .12s; }
.tile:active { transform: scale(.97); }
.tile .thumb { aspect-ratio: 16/9; width: 100%; display: block; object-fit: cover; background: #eadfce; }
.tile .title { margin: 10px 14px 12px; font-weight: 700; font-size: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile.hidden-video { opacity: .3; filter: grayscale(1); position: relative; }
.tile.hidden-video::after { content: "ausgeblendet"; position: absolute; top: 8px; left: 8px; background: var(--red); color: #fff; font-size: 13px; padding: 2px 8px; border-radius: 8px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big-emoji { font-size: 72px; }

/* ---------- Player ---------- */
#screen-player { display: flex; flex-direction: column; gap: 12px; background: #1d1b24; }
.player-wrap { position: relative; flex: 1; min-height: 0; background: #000; border-radius: var(--radius); overflow: hidden; display: flex; }
.player-wrap:fullscreen { border-radius: 0; }
.player-wrap iframe, #yt-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.shield { position: absolute; inset: 0; z-index: 2; }
.shield.passthrough { pointer-events: none; }
.block { position: absolute; z-index: 3; }
.block-top { top: 0; left: 0; right: 0; height: 64px; }
.block-br { right: 0; bottom: 0; width: 140px; height: 60px; }
.paused-overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(0, 0, 0, .35); pointer-events: none; }
.paused-overlay span { width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .92); display: grid; place-items: center; font-size: 56px; color: var(--primary); padding-left: 10px; }
.upnext { position: absolute; inset: 0; z-index: 5; background: #1d1b24; overflow: auto; padding: 20px; color: #fff; }
.upnext h2 { margin: 0 0 16px; }
.upnext .tile { color: var(--text); }
.player-bar { display: flex; align-items: center; gap: 12px; }
.player-bar .icon-btn { background: #2e2b38; color: #fff; }

/* ---------- Aufgaben ---------- */
.timeup-hero { text-align: center; padding: 10px 20px 20px; }
.timeup-hero h1 { margin: 6px 0; }
.timeup-hero p { color: var(--muted); max-width: 560px; margin: 0 auto; }
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.task {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.task:active { transform: scale(.97); }
.task .t-emoji { font-size: 64px; line-height: 1.1; }
.task .t-name { font-weight: 800; font-size: 19px; }
.task .t-min { background: var(--teal); color: #fff; font-weight: 800; padding: 4px 14px; border-radius: 999px; }
.task.done { opacity: .45; }
.task.done .t-min { background: var(--muted); }

/* ---------- Karten / Knöpfe ---------- */
.center-card { max-width: 520px; margin: 10vh auto 0; text-align: center; background: var(--card); padding: 32px 24px; border-radius: 28px; box-shadow: var(--shadow); }
.big-emoji { font-size: 80px; line-height: 1.1; }
.btn { border-radius: 14px; padding: 10px 18px; font-weight: 700; background: #f3ebe0; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.danger { background: #fde4e4; color: var(--red); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.big { font-size: 20px; padding: 14px 28px; margin-top: 8px; }
.btn:disabled { opacity: .5; }

/* ---------- PIN ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(30, 25, 40, .55); display: grid; place-items: center; padding: 16px; }
.pin-card { background: var(--card); border-radius: 28px; padding: 24px; width: min(360px, 100%); text-align: center; box-shadow: var(--shadow); }
.pin-card h2 { margin: 0 0 4px; }
.pin-card p { margin: 0; color: var(--muted); }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 18px 0 6px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--primary); }
.pin-dots i.on { background: var(--primary); }
.pin-msg { min-height: 1.4em; color: var(--red) !important; font-size: 15px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.pin-pad button { height: 62px; border-radius: 16px; background: #f6efe6; font-size: 26px; font-weight: 700; }
.pin-pad button:active { background: #eadfce; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* ---------- Kanal-Auswahl ---------- */
.curate-card { background: var(--bg); border-radius: 24px; width: min(1000px, 100%); max-height: 90vh; overflow: auto; padding: 18px; }
.curate-card header { display: flex; align-items: center; gap: 12px; position: sticky; top: -18px; background: var(--bg); padding: 4px 0 8px; z-index: 1; }
.curate-card h2 { flex: 1; margin: 0; font-size: 20px; }

/* ---------- Elternbereich ---------- */
.parent { max-width: 860px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 12px; font-size: 20px; }
.panel .hint, .hint { color: var(--muted); font-size: 15px; margin: 6px 0 10px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.row label { flex: 1 1 200px; }
.field { border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; background: #fffdfa; width: 100%; min-width: 0; }
.field.num { width: 90px; text-align: center; }
.field.emoji { width: 64px; text-align: center; font-size: 22px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.stat { flex: 1 1 120px; min-width: 0; background: var(--bg); border-radius: 14px; padding: 10px 14px; }
.stat b { display: block; font-size: 26px; }
.src-list, .task-list { display: grid; gap: 10px; }
.src { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 14px; background: var(--bg); flex-wrap: wrap; }
.src img, .src .src-ph { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #eadfce; display: grid; place-items: center; font-size: 24px; flex: none; }
.src .src-info { flex: 1 1 160px; min-width: 0; }
.src .src-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src .src-info small { color: var(--muted); }
.src.off { opacity: .5; }
.task-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--bg); padding: 8px; border-radius: 14px; }
.task-row .field.name { flex: 1 1 160px; width: auto; }
.task-row small { color: var(--muted); }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: 24px; height: 24px; accent-color: var(--primary); }
textarea.field { min-height: 110px; font-family: ui-monospace, monospace; font-size: 13px; }
details summary { cursor: pointer; font-weight: 700; }

/* ---------- Feedback ---------- */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--text); color: #fff; padding: 12px 22px; border-radius: 999px; font-weight: 700; max-width: calc(100% - 32px); text-align: center; }
.celebrate { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(255, 248, 239, .9); text-align: center; font-size: 34px; font-weight: 800; }
.celebrate .big-emoji { font-size: 120px; animation: pop .6s ease-out; }
@keyframes pop { 0% { transform: scale(.2) rotate(-20deg); } 70% { transform: scale(1.2) rotate(8deg); } 100% { transform: scale(1); } }

/* ---------- Sterne & Belohnungen ---------- */
.star-btn {
  flex: none; height: 60px; padding: 0 18px; border-radius: 999px;
  background: var(--yellow); box-shadow: var(--shadow); font-size: 24px; font-weight: 800;
}
.star-btn:active { transform: scale(.95); }
.rewards-bar { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 16px; align-items: stretch; }
.rw-stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 18px; display: flex; flex-direction: column; justify-content: center; }
.rw-big { font-size: 28px; font-weight: 800; }
.rw-stat small { color: var(--muted); }
.rw-next { flex: 1 1 260px; display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 16px; text-align: left; }
.rw-sticker { font-size: 46px; line-height: 1; }
.rw-sticker.locked { filter: brightness(0) opacity(.25); }
.rw-progress { flex: 1; display: flex; flex-wrap: wrap; gap: 2px; font-size: 22px; }
.rw-progress i { font-style: normal; filter: grayscale(1) opacity(.3); }
.rw-progress i.on { filter: none; }
.rw-album { font-weight: 800; white-space: nowrap; }
.task.pending .t-min { background: var(--yellow); color: var(--text); }
.cel-sub { font-size: 20px; font-weight: 700; color: var(--muted); margin-top: 8px; }

.album-sub { text-align: center; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }
.sticker { aspect-ratio: 1; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; place-items: center; font-size: 60px; }
.sticker.locked { background: #f3ebe0; box-shadow: none; position: relative; }
.sticker.locked span { filter: brightness(0) opacity(.12); }
.sticker.locked small { position: absolute; bottom: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* ---------- Auswahl: PIN oder Anfrage ---------- */
.choice-card { background: var(--card); border-radius: 28px; padding: 24px; width: min(460px, 100%); text-align: center; display: grid; gap: 12px; }
.choice-card h2 { margin: 0; font-size: 26px; }
.choice-card p { margin: 0 0 4px; color: var(--muted); }
.choice { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; text-align: left; align-items: center; background: var(--bg); border-radius: 18px; padding: 14px 18px; }
.choice span { grid-row: span 2; font-size: 40px; }
.choice b { font-size: 19px; }
.choice small { color: var(--muted); }
.choice:active { transform: scale(.98); }

/* ---------- Konto ---------- */
.account h1 { margin: 6px 0; }
.account h2 { font-size: 18px; margin: 20px 0 10px; }
.acc-form { display: grid; gap: 10px; margin: 14px 0 6px; }
.acc-msg { color: var(--red); min-height: 1.4em; margin: 4px 0; }
.link { color: var(--primary-dark); font-weight: 700; text-decoration: underline; padding: 0; }
.row.center { justify-content: center; }
.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-card { background: var(--bg); border-radius: 18px; padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.role-card span { font-size: 44px; }
.role-card small { color: var(--muted); }
.role-pick { flex-direction: column; align-items: flex-start; }

/* ---------- Elternbereich: Anfragen ---------- */
.panel.attention { outline: 3px solid var(--yellow); }
.badge { background: var(--red); color: #fff; border-radius: 999px; padding: 0 10px; font-size: 15px; vertical-align: middle; }
.req { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--bg); border-radius: 14px; padding: 10px; margin-bottom: 8px; }
.req-emoji { font-size: 36px; }
.req-info { flex: 1 1 160px; }
.req-info b { display: block; }
.req-info small, .muted { color: var(--muted); font-weight: 400; }
.presets .preset { font-weight: 600; font-size: 15px; background: var(--bg); border: 2px dashed var(--line); }
.pair { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 520px) {
  .icon-btn { width: 52px; height: 52px; font-size: 26px; }
  .star-btn { height: 52px; padding: 0 12px; font-size: 20px; }
  .role-cards { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid.small { grid-template-columns: 1fr 1fr; }
  .tile .title { font-size: 14px; margin: 8px 10px; }
  .timer .t-text { font-size: 16px; }
  .timer { gap: 8px; padding-right: 12px; }
  .timer .t-bar { min-width: 24px; }
  .task-grid { grid-template-columns: 1fr 1fr; }
  .topbar-title { font-size: 20px; }
  .panel { padding: 14px; }
  .stat b { font-size: 22px; }
  .row label { flex-basis: 100%; }
  .task-row .field.name { flex-basis: calc(100% - 80px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
