@font-face {
  font-family: Fredoka;
  src: url(fonts/fredoka.woff2) format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #f5f3ff;
  --card: #fff;
  --ink: #1f1b3a;
  --muted: #6a6685;
  --line: #e4defa;
  --brand: #6c4dff;
  --star: #ffb800;
  --ok: #10b981;
  --no: #f0484e;
  --me: var(--brand); /* Farbe des angemeldeten Profils */
  --r: 22px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131127;
    --card: #1e1b3a;
    --ink: #f4f2ff;
    --muted: #a5a1c8;
    --line: #322d5c;
    --brand: #8f78ff;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  margin: 0;
  font: 400 17px/1.35 Fredoka, ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; font-weight: 600; line-height: 1.15; }
h2 { font-size: 23px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 26px 4px 10px; }
small { font-size: 14px; color: var(--muted); }
b { font-weight: 600; }
button, .chip { touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 2px; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.page { padding: 0 16px; }
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* ---------- Knöpfe ---------- */

.btn {
  --c: var(--brand);
  display: block; width: 100%;
  padding: 15px 18px;
  border-radius: 16px;
  background: var(--c); color: #fff;
  font-weight: 600; text-align: center;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c), #000 24%);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 transparent; }
.btn:disabled { filter: grayscale(.7) opacity(.55); pointer-events: none; }
.btn.small { width: auto; min-width: 44px; min-height: 44px; padding: 9px 14px; font-size: 15px; border-radius: 13px; box-shadow: 0 3px 0 color-mix(in srgb, var(--c), #000 24%); }
.btn.ok { --c: var(--ok); }
.btn.no { --c: var(--no); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.ghost.small { box-shadow: 0 3px 0 var(--line); }
.link { display: block; width: 100%; padding: 12px; text-align: center; color: var(--muted); font-weight: 500; }
.link.danger { color: var(--no); }

/* ---------- Kopf ---------- */

.hero {
  position: relative; overflow: hidden;
  padding: calc(env(safe-area-inset-top) + 18px) 20px 22px;
  border-radius: 0 0 34px 34px;
  color: #fff;
  background: linear-gradient(150deg, var(--me), color-mix(in srgb, var(--me), #1b0f66 38%));
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: #fff; opacity: .1; }
.hero::before { width: 220px; height: 220px; right: -70px; top: -90px; }
.hero::after { width: 130px; height: 130px; left: -40px; bottom: -60px; }
.hero > * { position: relative; z-index: 1; }
.hero small { color: rgb(255 255 255 / .94); }
.hero .name { font-size: 24px; font-weight: 600; line-height: 1.1; }

.avatar {
  flex: none; display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%;
  font-size: 30px; line-height: 1;
  background: color-mix(in srgb, var(--c, var(--me)) 22%, var(--card));
  border: 3px solid var(--c, var(--me));
}
.avatar.s { width: 38px; height: 38px; font-size: 21px; border-width: 2px; }
.hero .avatar { background: rgb(255 255 255 / .25); border-color: rgb(255 255 255 / .7); }

.bell { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font-size: 22px; background: rgb(255 255 255 / .2); }
.bell i { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--no); color: #fff; font: 600 12px/20px Fredoka, sans-serif; text-align: center; }

.stats { display: flex; gap: 10px; margin-top: 18px; }
.stat { flex: 1; padding: 12px 14px; border-radius: 20px; background: rgb(255 255 255 / .17); }
.stat b { display: block; font-size: 34px; font-weight: 600; line-height: 1.05; }
.stat.pop b { animation: pop .5s cubic-bezier(.34, 1.56, .64, 1); }

.level { margin-top: 14px; }
.level .row { justify-content: space-between; font-size: 15px; margin-bottom: 7px; }
.bar { height: 12px; border-radius: 6px; background: rgb(255 255 255 / .25); overflow: hidden; }
.bar i { display: block; height: 100%; min-width: 12px; border-radius: 6px; background: linear-gradient(90deg, #fff, #ffe27a); transition: width .6s cubic-bezier(.2, .9, .3, 1); }
.bar.tint { background: var(--line); }
.bar.tint i { background: linear-gradient(90deg, var(--c, var(--brand)), color-mix(in srgb, var(--c, var(--brand)), #fff 35%)); }

.plain-head { padding: calc(env(safe-area-inset-top) + 22px) 4px 6px; }
.plain-head .bell { background: var(--card); border: 2px solid var(--line); }

/* ---------- Karten ---------- */

.card { background: var(--card); border: 2px solid var(--line); border-bottom-width: 5px; border-radius: var(--r); padding: 14px; }
.card.flat { border-bottom-width: 2px; }

.task { display: flex; align-items: center; gap: 14px; width: 100%; transition: transform .12s, border-color .2s, background .2s; }
button.task:active { transform: scale(.98); }
.ico { position: relative; flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 17px; font-size: 28px; line-height: 1; background: color-mix(in srgb, var(--c, var(--me)) 14%, transparent); }
.txt { flex: 1; min-width: 0; }
.txt b { display: block; overflow-wrap: anywhere; }
.pts { color: color-mix(in srgb, var(--star), var(--ink) 30%); font-weight: 600; font-size: 15px; }

.check { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--line); font-size: 22px; color: #fff; }
.task.pending, .task.approved { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--card)); }
.task.pending .check, .task.approved .check { background: var(--ok); border-color: var(--ok); }
.task.pending .check { background: color-mix(in srgb, var(--ok) 55%, var(--card)); border-style: dashed; }
.task.rejected { border-color: color-mix(in srgb, var(--no) 50%, var(--line)); }
.task.rejected small { color: var(--no); }
.task.taken { opacity: .55; }
.task.just .check { animation: pop .45s cubic-bezier(.34, 1.56, .64, 1); }

.banner { display: flex; align-items: center; gap: 12px; margin-top: 16px; background: color-mix(in srgb, var(--brand) 10%, var(--card)); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.banner .ico { background: none; width: 40px; }

.empty { text-align: center; padding: 34px 20px; }
.empty .big { font-size: 60px; line-height: 1.1; margin-bottom: 8px; }
.empty .btn { margin-top: 18px; }

.shop { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reward { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 18px 12px 14px; }
.reward .big { font-size: 46px; line-height: 1.1; }
.reward .foot { width: 100%; margin-top: auto; padding-top: 8px; }
.pill { display: inline-block; padding: 3px 11px; border-radius: 20px; background: color-mix(in srgb, var(--star) 22%, var(--card)); color: color-mix(in srgb, var(--star), var(--ink) 45%); font-weight: 600; font-size: 15px; }

.list { padding: 4px 14px; }
.list > * { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border-top: 2px solid var(--line); }
.list > :first-child { border-top: 0; }
.list .ico { width: 44px; height: 44px; border-radius: 14px; font-size: 23px; }
.chev { color: var(--muted); font-size: 22px; }

.kid-head { display: flex; align-items: center; gap: 12px; }
.mini { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 2px solid var(--line); }
.kid .bar { margin: 12px 0 10px; height: 10px; }
.mini .em { width: 28px; text-align: center; font-size: 20px; }
.mini .st { font-size: 18px; }
.nudge { width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 12%, transparent); font-size: 18px; text-align: center; }

.code { display: block; font-size: 34px; font-weight: 600; letter-spacing: .12em; margin: 2px 0 6px; }

.ico i { position: absolute; right: -6px; bottom: -6px; font-size: 15px; font-style: normal; }
.acts { margin-top: 12px; gap: 8px; }
.acts .btn { flex: 1; padding: 9px 6px; white-space: nowrap; }
.pair .btn { flex: 1; }
.goals { margin-top: 16px; display: grid; gap: 12px; }
.goal .row { justify-content: space-between; font-size: 15px; margin-bottom: 6px; }
.goal .bar { height: 10px; }
.tomorrow { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 15px; }
.hint { display: block; margin: 8px 4px 0; }
.reward { position: relative; }
.wish { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border-radius: 50%; font-size: 20px; text-align: center; filter: grayscale(1) opacity(.45); }
.wish.on { filter: none; background: color-mix(in srgb, var(--star) 25%, transparent); }
.rev { margin-top: 12px; }
.rev small { display: block; margin-top: 6px; }
.rev .banner { margin-top: 12px; }
.week { display: flex; justify-content: space-between; margin: 14px 0 6px; }
.week span { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.week i { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); }
.week .full i { background: var(--ok); border-color: var(--ok); }
.week .half i { border-color: var(--ok); background: linear-gradient(90deg, var(--ok) 50%, transparent 50%); }
.week .none i { border-color: var(--no); }
.week .off i { border-style: dashed; }
.week .later { opacity: .4; }

/* ---------- Navigation ---------- */

.nav {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.nav button { flex: 1; max-width: 124px; display: grid; justify-items: center; gap: 1px; padding: 7px 2px; border-radius: 16px; font-size: 13px; font-weight: 500; color: var(--muted); }
.nav button span { font-size: 25px; line-height: 1.15; filter: grayscale(.9) opacity(.75); transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), filter .2s; }
.nav button.on { color: var(--brand); background: color-mix(in srgb, var(--brand) 13%, transparent); }
.nav button.on span { filter: none; transform: scale(1.12); }

/* ---------- Anmeldung ---------- */

.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: calc(env(safe-area-inset-top) + 24px) 24px 32px; margin-bottom: calc(-96px - env(safe-area-inset-bottom)); }
.logo { width: 92px; height: 92px; border-radius: 26px; margin: 0 auto; box-shadow: 0 10px 30px color-mix(in srgb, var(--brand) 40%, transparent); }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.who button { display: grid; justify-items: center; gap: 8px; padding: 20px 8px 14px; font-weight: 600; font-size: 19px; }
.avatar.xl { width: 84px; height: 84px; font-size: 48px; border-width: 4px; margin: 0 auto; }
.who button:active { transform: scale(.96); }
.dots { display: flex; justify-content: center; gap: 16px; margin: 6px 0; }
.dots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); transition: background .15s, transform .15s; }
.dots i.on { background: var(--me); border-color: var(--me); transform: scale(1.15); }
.dots.shake { animation: shake .4s; }
.keys { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; justify-content: center; }
.keys button { height: 76px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); border-bottom-width: 5px; font-size: 28px; font-weight: 500; text-align: center; transition: transform .08s; }
.keys button:active { transform: translateY(3px); border-bottom-width: 2px; }
.keys .none { visibility: hidden; }

/* ---------- Formulare ---------- */

.field { display: block; margin-top: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 4px 7px; }
input[type=text], input[type=number], input[type=date], input:not([type]), textarea, select {
  width: 100%; padding: 14px 15px;
  font: inherit; color: var(--ink);
  background: var(--card); border: 2px solid var(--line); border-radius: 16px;
  appearance: none; -webkit-appearance: none;
}
textarea { resize: none; min-height: 96px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
.pin-in { letter-spacing: .5em; font-size: 22px; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 48px; height: 48px; padding: 0 12px; border-radius: 15px; border: 2px solid var(--line); background: var(--card); font-size: 16px; font-weight: 500; white-space: nowrap; transition: transform .15s cubic-bezier(.34, 1.56, .64, 1); }
.chip.e span { font-size: 25px; padding: 0; }
.chip input:checked + span { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 13%, var(--card)); box-shadow: inset 0 0 0 1px var(--brand); transform: scale(1.06); }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 2px; }
.chip.col span { padding: 0; background: var(--v); border-color: transparent; border-radius: 50%; }
.chip.col input:checked + span { background: var(--v); border-color: var(--card); box-shadow: 0 0 0 3px var(--v); }

.weekdays { display: none; margin-top: 8px; }
form:has([name=repeat][value=days]:checked) .weekdays { display: flex; }

.tpls { display: flex; gap: 8px; overflow-x: auto; margin: 14px -20px 0; padding: 0 20px 6px; scrollbar-width: none; }
.tpls::-webkit-scrollbar { display: none; }
.field .tpls { margin-top: 0; }
.tpls button { flex: none; padding: 8px 13px; border-radius: 20px; background: color-mix(in srgb, var(--brand) 11%, var(--card)); color: var(--brand); font-size: 15px; font-weight: 500; white-space: nowrap; }

/* ---------- Sheet ---------- */

#sheet {
  width: 100%; max-width: 520px; max-height: 92dvh;
  margin: auto auto 0; padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  border: 0; border-radius: 30px 30px 0 0;
  background: var(--bg); color: var(--ink);
  overflow-y: auto; overscroll-behavior: contain;
}
#sheet[open] { animation: up .32s cubic-bezier(.2, .9, .3, 1.08); }
#sheet::backdrop { background: rgb(18 12 48 / .55); animation: fade .25s; }
#sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
#sheet .btn { margin-top: 22px; }
#sheet .btn + .btn { margin-top: 12px; }
#sheet .btn.small { margin-top: 0; }
#sheet p { color: var(--muted); margin-top: 6px; }
.msg { padding: 13px 2px; border-top: 2px solid var(--line); }
.msg:first-of-type { border-top: 0; }
.msg.new b::after { content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 8px; border-radius: 50%; background: var(--no); }
.msg div { overflow-wrap: anywhere; }

#toast {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: calc(104px + env(safe-area-inset-bottom));
  width: fit-content; max-width: 88vw; margin: 0 auto;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: 22px;
  background: var(--ink); color: var(--bg); font-weight: 500; text-align: center;
  transition: opacity .2s, transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
#toast.on { opacity: 1; transform: none; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------- Spiele ---------- */

.game { margin-top: 14px; text-align: center; -webkit-user-select: none; user-select: none; }
.g-stage { display: block; width: 100%; height: min(62dvh, 520px); margin-bottom: 10px; border-radius: var(--r); border: 3px solid var(--ink); touch-action: none; }

/* ---------- Bewegung ---------- */

.enter > * { animation: rise .4s cubic-bezier(.2, .9, .3, 1) backwards; }
.enter > :nth-child(2) { animation-delay: .04s; }
.enter > :nth-child(3) { animation-delay: .08s; }
.enter > :nth-child(4) { animation-delay: .12s; }
.enter > :nth-child(n+5) { animation-delay: .16s; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.25); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after, ::backdrop { animation: none !important; transition: none !important; }
}
