:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2d2a3e;
  --muted: #7a7690;
  --brand: #6c5ce7;
  --ok: #20bf6b;
  --warn: #fa8231;
  --late: #eb3b5a;
  --radius: 18px;
  --shadow: 0 4px 0 rgba(45, 42, 62, .12);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 17px; -webkit-tap-highlight-color: transparent;
}
header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--brand); color: #fff;
}
header h1 { margin: 0; font-size: 22px; cursor: pointer; }
.head-btns { display: flex; gap: 8px; }
button {
  font: inherit; border: none; cursor: pointer; border-radius: 14px;
  padding: 12px 18px; background: var(--brand); color: #fff; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .08s;
}
button:active { transform: translateY(2px); box-shadow: none; }
button.icon { background: rgba(255,255,255,.2); padding: 8px 12px; font-size: 20px; box-shadow: none; }
button.ghost { background: #eee9ff; color: var(--brand); }
button.danger { background: #ffe3e8; color: var(--late); }
button.small { padding: 6px 10px; font-size: 14px; border-radius: 10px; }
main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }
h2 { margin: 18px 0 10px; }
h3 { margin: 16px 0 8px; color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: .05em; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* Kinder-Auswahl */
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.kid-tile {
  background: var(--card); border-radius: 24px; padding: 22px 10px; text-align: center;
  box-shadow: var(--shadow); cursor: pointer; border-bottom: 6px solid var(--c);
}
.kid-tile .emo { font-size: 56px; }
.kid-tile .nm { font-size: 22px; font-weight: 800; margin-top: 6px; }
.kid-tile .st { color: var(--muted); margin-top: 4px; }

/* Kind-Ansicht */
.kid-head { display: flex; align-items: center; gap: 12px; }
.kid-head .emo { font-size: 44px; }
.stars { margin-left: auto; font-size: 20px; font-weight: 800; background: #fff3c4; padding: 6px 14px; border-radius: 999px; }
.task {
  display: flex; align-items: center; gap: 14px; background: var(--card);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  border-left: 8px solid var(--c, var(--brand));
}
.task.late { border-left-color: var(--late); }
.task .check {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 4px solid #d9d4f0;
  background: #fff; font-size: 24px; padding: 0; box-shadow: none; color: transparent;
}
.task.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.t-title { font-weight: 800; }
.t-sub { font-size: 14px; color: var(--muted); }
.pill { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: #eee9ff; color: var(--brand); font-weight: 700; }
.pill.late { background: #ffe3e8; color: var(--late); }
.progress { height: 14px; background: #eee; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: linear-gradient(90deg, #20bf6b, #26de81); border-radius: 999px; transition: width .5s; }
.empty { text-align: center; padding: 30px 10px; font-size: 18px; }
.empty .big { font-size: 60px; }

/* Unteraufgaben */
.items { list-style: none; padding: 0; margin: 10px 0 0; }
.items li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px dashed #eee; }
.items li.done span { text-decoration: line-through; color: var(--muted); }
.icheck {
  flex: none; width: 32px; height: 32px; border-radius: 9px; border: 3px solid #d9d4f0;
  background: #fff; padding: 0; box-shadow: none; color: transparent; font-size: 16px;
}
.items li.done .icheck { background: var(--ok); border-color: var(--ok); color: #fff; }
.plan-block { border-bottom: 2px solid #f1eefb; padding-bottom: 8px; margin-bottom: 10px; }
.topic-in { font-weight: 800; }
.item-row { display: grid; grid-template-columns: 18px 1fr 40px; gap: 6px; margin: 0 0 6px 24px; align-items: center; }
.item-row input { padding: 6px 8px; font-size: 15px; }
.add-item { margin-left: 24px; }

/* Formulare */
label { display: block; font-weight: 700; margin: 10px 0 4px; font-size: 15px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px;
  border: 2px solid #e2dff0; background: #fff; color: var(--ink);
}
textarea { min-height: 120px; }
input[type=checkbox] { width: auto; transform: scale(1.4); margin-right: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan-row { display: grid; grid-template-columns: 140px 1fr 40px; gap: 6px; margin-bottom: 6px; }
.plan-row input { padding: 6px 8px; font-size: 15px; }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button.active { background: var(--ink); }
details summary { cursor: pointer; font-weight: 800; padding: 4px 0; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick span { font-size: 28px; cursor: pointer; padding: 4px; border-radius: 10px; }
.emoji-pick span.sel { background: #eee9ff; }

/* Party */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100%; height: 100%; }
#party {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
#party .party-text {
  font-size: clamp(34px, 9vw, 72px); font-weight: 900; color: #fff; text-align: center;
  text-shadow: 0 4px 0 var(--brand), 0 0 30px rgba(108,92,231,.6);
  animation: pop .7s cubic-bezier(.2, 1.6, .4, 1) both, wobble 1.2s .7s ease-in-out infinite;
  padding: 0 20px;
}
#party.mega { background: radial-gradient(circle, rgba(108,92,231,.55), rgba(45,42,62,.7)); animation: disco 0.6s linear infinite; }
@keyframes pop { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1) rotate(0); } }
@keyframes wobble { 0%,100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(3deg) scale(1.06); } }
@keyframes disco { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
.hidden { display: none !important; }
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 14px;
}
@media (max-width: 520px) {
  .plan-row { grid-template-columns: 1fr 40px; margin-bottom: 6px; }
  .item-row { margin-left: 8px; }
  .add-item { margin-left: 8px; }
  .plan-row input[type=date] { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ================= Spiel ================= */
.hud { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; flex-wrap: wrap; }
.hud-i { background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 18px; box-shadow: var(--shadow); }
.hud-i.fire { background: linear-gradient(90deg, #ffecd2, #fcb69f); }
.hud-pack { margin-left: auto; background: linear-gradient(135deg, #ff6b6b, #feca57); }
.hud-pack:disabled { background: #ddd; color: #999; }
.pulse { animation: pulse 1.1s ease-in-out infinite; }
.pulse-txt { color: var(--late); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(255,107,107,.25); } }
.kid-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.kid-tabs button { background: #fff; color: var(--ink); padding: 8px 4px; font-size: 13px; display: flex; flex-direction: column; align-items: center; }
.kid-tabs button span { font-size: 24px; }
.kid-tabs button.active { background: var(--brand); color: #fff; }
button:disabled { opacity: .5; cursor: default; }

/* Karte */
.gcard {
  --w: 104px; width: var(--w); height: calc(var(--w) * 1.42); position: relative; flex: none;
  border-radius: 12px; padding: 6px; border: 4px solid var(--rc);
  background: linear-gradient(160deg, var(--a), var(--b)); color: #fff; cursor: pointer;
  display: flex; flex-direction: column; box-shadow: 0 4px 10px rgba(0,0,0,.15); overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.gc-top { display: flex; justify-content: space-between; gap: 2px; font-size: 10px; font-weight: 900; line-height: 1.1; }
.gc-name { overflow: hidden; }
.gc-art { flex: 1; display: flex; align-items: center; justify-content: center; font-size: calc(var(--w) * .42);
  background: rgba(255,255,255,.25); border-radius: 8px; margin: 4px 0; text-shadow: none; }
.gc-text { font-size: 8px; line-height: 1.15; min-height: 2.3em; opacity: .95; }
.gc-bot { display: flex; justify-content: space-between; font-size: 10px; font-weight: 900; margin-top: 2px; }
.gc-stars { color: #fff6a8; }
.gc-lvl { position: absolute; top: 22px; right: 4px; background: var(--ink); color: #fff; font-size: 10px; font-weight: 900; padding: 1px 6px; border-radius: 999px; }
.gc-new { position: absolute; top: 22px; left: -2px; background: #ff3b6b; color: #fff; font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 0 999px 999px 0; animation: pulse 1s infinite; }
.gcard.locked { background: #ece9f5; color: #a9a4c0; text-shadow: none; cursor: default; }
.gcard.locked .sil { filter: brightness(0) opacity(.18); background: transparent; }
.center { text-align: center; } .center-row { justify-content: center; margin-top: 16px; }
.r-epic::after, .r-legendary::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%);
  background-size: 250% 100%; animation: holo 2.6s linear infinite;
}
.r-legendary { box-shadow: 0 0 18px #ffd34e; }
.r-legendary::after { background: linear-gradient(115deg, transparent 25%, rgba(255,0,200,.35) 38%, rgba(255,255,255,.6) 45%, rgba(0,220,255,.35) 52%, transparent 65%); background-size: 250% 100%; }
@keyframes holo { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; justify-items: center; }

/* Overlay */
#overlay { position: fixed; inset: 0; z-index: 45; background: rgba(30,20,60,.82); display: flex; align-items: center; justify-content: center; padding: 20px; }
.popup { background: #fff; border-radius: 24px; padding: 24px; text-align: center; max-width: 340px; width: 100%; animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; }
.pop-title { font-weight: 900; color: var(--brand); text-transform: uppercase; letter-spacing: .08em; }
.pop-name { font-size: 26px; font-weight: 900; margin-top: 10px; }
.pop-tier { font-size: 20px; font-weight: 900; }
.pop-sub { color: var(--muted); margin: 6px 0 14px; }
.pop-sub.light { color: #fff; font-size: 20px; font-weight: 800; }
.zoom { text-align: center; color: #fff; }
.zoom .gcard { --w: 240px; margin: 0 auto; animation: pop .4s both; }
.zoom .gc-text { font-size: 15px; } .zoom .gc-top, .zoom .gc-bot { font-size: 18px; } .zoom .gc-lvl { top: 36px; font-size: 16px; }

/* Pack */
.pack {
  width: 120px; height: 170px; margin: 0 auto; border-radius: 14px; position: relative;
  background: linear-gradient(135deg, #6c5ce7, #ff6b9d 50%, #feca57); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 900; box-shadow: 0 8px 24px rgba(0,0,0,.35); cursor: pointer; overflow: hidden;
}
.pack b { font-size: 30px; letter-spacing: .05em; } .pack span { font-size: 20px; letter-spacing: .3em; }
.pack em { font-style: normal; font-size: 40px; color: #fff6a8; }
.pack::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 14px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.5) 0 6px, transparent 6px 12px); }
.pack::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.5) 45%, transparent 60%); background-size: 250% 100%; animation: holo 2s linear infinite; }
.mini-pack { width: 56px; height: 80px; border-radius: 8px; flex: none; }
.mini-pack b { font-size: 14px; } .mini-pack span { font-size: 9px; }
.big-pack { width: 180px; height: 255px; }
.big-pack b { font-size: 44px; } .big-pack span { font-size: 26px; }
.wiggle { animation: wig 1s ease-in-out infinite; }
.shake { animation: shake .35s; }
.burst { animation: burst .45s forwards; }
@keyframes wig { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes shake { 0%,100% { transform: translate(0) rotate(0); } 25% { transform: translate(-8px) rotate(-5deg) scale(1.05); } 75% { transform: translate(8px) rotate(5deg) scale(1.08); } }
@keyframes burst { to { transform: scale(2.2); opacity: 0; filter: brightness(3); } }
.opening { text-align: center; width: 100%; }
.flip-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.flip { width: 104px; height: 148px; perspective: 800px; cursor: pointer; animation: pop .5s both; }
.flip:nth-child(2) { animation-delay: .12s; } .flip:nth-child(3) { animation-delay: .24s; }
.flip-in { position: relative; width: 100%; height: 100%; transition: transform .6s; transform-style: preserve-3d; }
.flip.on .flip-in { transform: rotateY(180deg); }
.flip .back, .flip .front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip .front { transform: rotateY(180deg); }
.flip .back { border-radius: 12px; border: 4px solid #fff; background: repeating-linear-gradient(45deg, #6c5ce7 0 10px, #5b4bd6 10px 20px); display: flex; align-items: center; justify-content: center; }
.back-logo { width: 56px; height: 56px; border-radius: 50%; background: #feca57; color: #6c5ce7; font-size: 34px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
/* Vorfreude: seltene Karten leuchten schon verdeckt */
.flip.glow-rare:not(.on) .back { box-shadow: 0 0 16px #3b8cff; }
.flip.glow-epic:not(.on) .back { box-shadow: 0 0 22px #b04cff; animation: wig .5s infinite; }
.flip.glow-legendary:not(.on) .back { box-shadow: 0 0 34px #ffd34e; animation: wig .3s infinite; }
@media (max-width: 380px) { .flip { width: 96px; height: 136px; } .flip .gcard { --w: 96px; } }
.float-gem { position: fixed; left: 50%; top: 40%; z-index: 80; transform: translateX(-50%); font-size: 34px; font-weight: 900; color: #fff;
  text-shadow: 0 3px 0 #5b4bd6, 0 0 20px #6c5ce7; pointer-events: none; animation: floatUp 1.6s ease-out forwards; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -110px) scale(1); } }

/* Abzeichen */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge-card { text-align: center; margin: 0; }
.b-name { font-weight: 900; margin-top: 6px; }
.medal {
  width: 74px; height: 74px; margin: 0 auto; position: relative;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  background: radial-gradient(circle at 35% 30%, #fff 0 8%, var(--tc) 45%, color-mix(in srgb, var(--tc) 60%, #000) 100%);
  display: flex; align-items: center; justify-content: center; font-size: 34px;
}
.medal i { position: absolute; bottom: 8px; font-style: normal; font-size: 8px; color: #fff; letter-spacing: 1px; text-shadow: 0 1px 1px rgba(0,0,0,.5); }
.medal.off { filter: grayscale(1) opacity(.35); }
.medal.big { width: 140px; height: 140px; font-size: 66px; animation: medalIn 1s cubic-bezier(.2,1.4,.4,1) both; }
.medal.big i { font-size: 14px; bottom: 16px; }
@keyframes medalIn { from { transform: scale(0) rotateY(720deg); } to { transform: scale(1) rotateY(0); } }
.shop-item { display: flex; align-items: center; gap: 12px; }

/* ===== Level, Pack-Balken ===== */
.lvl-row { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); margin-bottom: 10px; cursor: pointer; }
.lvl-circle { width: 54px; height: 54px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; color: #fff; background: conic-gradient(from 180deg, #6c5ce7, #ff6b9d, #feca57, #6c5ce7); box-shadow: inset 0 0 0 4px rgba(255,255,255,.5); }
.lvl-title { font-weight: 900; }
.progress.xp { height: 10px; margin-top: 4px; } .progress.xp > div { background: linear-gradient(90deg, #6c5ce7, #a29bfe); }
.meter-row { display: flex; align-items: center; gap: 8px; margin: -4px 0 10px; }
.meter-row > span:first-child { font-size: 22px; }
.progress.meter { flex: 1; height: 16px; margin: 0; } .progress.meter > div { background: linear-gradient(90deg, #ff6b6b, #feca57); }

/* ===== Album-Serien ===== */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chip { flex: none; background: #fff; color: var(--ink); font-size: 14px; padding: 8px 12px; border-radius: 999px; box-shadow: var(--shadow); white-space: nowrap; }
.chip.active { background: var(--brand); color: #fff; }
.locked-chip { opacity: .5; display: inline-flex; align-items: center; font-weight: 700; }
.craft { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); font-size: 12px; padding: 4px 8px; border-radius: 999px; background: #6c5ce7; box-shadow: none; white-space: nowrap; }
.craft.off { background: #bbb; }

/* ===== Entwicklungen & Editionen ===== */
.gcard.evo { border-width: 5px; box-shadow: 0 0 0 2px #fff, 0 0 18px var(--rc); }
.gcard.evo .gc-art { background: radial-gradient(circle, rgba(255,255,255,.7), rgba(255,255,255,.1) 70%); animation: aura 2s ease-in-out infinite; position: relative; }
.evo-crown { position: absolute; top: -4px; right: 2px; font-size: calc(var(--w) * .16); }
@keyframes aura { 0%,100% { box-shadow: inset 0 0 10px rgba(255,255,255,.6); } 50% { box-shadow: inset 0 0 26px #fff; } }
.gc-ed { position: absolute; bottom: 20px; right: -2px; font-size: 9px; font-weight: 900; padding: 1px 6px; border-radius: 999px 0 0 999px; background: #222; color: #ffd34e; }
.ed-gold { border-color: #ffc928 !important; } .ed-gold:not(.locked) { background: linear-gradient(160deg, #ffe58a, var(--a) 40%, var(--b)); }
.ed-diamond { border-color: #5ee3ff !important; } .ed-diamond:not(.locked) { background: linear-gradient(160deg, #e0fbff, var(--a) 40%, var(--b)); }
.ed-rainbow { border-image: linear-gradient(45deg, red, orange, yellow, green, blue, violet) 1 !important; }
.evolving { animation: evolving 1.3s ease-in forwards; }
@keyframes evolving { 0% { filter: brightness(1); } 40% { transform: scale(1.1) rotate(-4deg); } 60% { transform: scale(1.1) rotate(4deg); filter: brightness(2.5); } 100% { transform: scale(1.2); filter: brightness(6) saturate(0); } }
.evolved-in { animation: pop .6s cubic-bezier(.2,1.6,.4,1) both; }
.medal.legend { animation: disco 2s linear infinite; }

/* ===== Popups ===== */
.lvl-big { font-size: 80px; font-weight: 900; line-height: 1.1; background: linear-gradient(135deg, #6c5ce7, #ff6b9d, #feca57);
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: medalIn 1s both; }
.series-next { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 54px; margin: 6px 0; }
.series-next b { font-size: 22px; }
