/* =========================================================
   Emmas Lern-Eisdiele – gemeinsame Styles
   Eisdielen-Palette: Pistazie, Vanille, Himbeere, Tinte,
   Waffel, Minze, Blaubeere, Zitrone
   ========================================================= */
:root {
    --pistazie: #CDEBC0;
    --vanille: #FFF8E1;
    --himbeere: #E8446F;
    --himbeere-dunkel: #B8284F;
    --tinte: #2B2350;
    --waffel: #D9954A;
    --minze: #3CC4A8;
    --minze-dunkel: #17806C;
    --blaubeere: #5B8DEF;
    --zitrone: #F2B544;

    --line: 4px;
    --radius: 26px;
    --shadow: 0 6px 0 var(--tinte);
    --font: "Nunito", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
    font-family: var(--font);
    color: var(--tinte);
    background-color: var(--pistazie);
    background-image:
        radial-gradient(circle at 20px 30px, var(--himbeere) 2.5px, transparent 3.5px),
        radial-gradient(circle at 95px 62px, var(--vanille) 2.5px, transparent 3.5px),
        radial-gradient(circle at 48px 112px, var(--blaubeere) 2.5px, transparent 3.5px),
        radial-gradient(circle at 122px 18px, var(--zitrone) 2.5px, transparent 3.5px),
        radial-gradient(circle at 132px 124px, var(--himbeere) 2.5px, transparent 3.5px);
    background-size: 150px 150px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

button { font-family: var(--font); touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--blaubeere); outline-offset: 3px; }
input { -webkit-user-select: text; user-select: text; }

.app { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- Karten im Sticker-Stil ---------- */
.card {
    background: var(--vanille);
    border: var(--line) solid var(--tinte);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

/* Markise der Eisdiele mit gewelltem Rand */
.awning {
    height: 34px;
    margin: 0 -2px;
    background: repeating-linear-gradient(90deg, var(--himbeere) 0 36px, var(--vanille) 36px 72px);
    position: relative;
}
.awning::after {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 100%;
    height: 18px;
    background:
        radial-gradient(circle at 18px 0, var(--himbeere) 17px, transparent 18px),
        radial-gradient(circle at 54px 0, var(--vanille) 17px, transparent 18px);
    background-size: 72px 18px;
    background-repeat: repeat-x;
    filter: drop-shadow(0 3px 0 rgba(43, 35, 80, .18));
}

/* ---------- Spielkarte ---------- */
.game { padding: 0 18px 20px; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-top: 26px; }
.level-tag {
    font-weight: 900; font-size: 1.2rem;
    background: var(--tinte); color: var(--vanille);
    padding: 5px 14px; border-radius: 999px; white-space: nowrap;
}
.streak {
    font-weight: 900; font-size: 1.15rem;
    background: var(--zitrone); border: 3px solid var(--tinte);
    padding: 2px 10px; border-radius: 999px; white-space: nowrap;
}
.streak.bump { animation: bump .35s cubic-bezier(.3, 1.8, .5, 1); }
.tools { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
    width: 44px; height: 44px;
    border: 3px solid var(--tinte); border-radius: 14px;
    background: #fff; font-size: 1.25rem; line-height: 1;
    box-shadow: 0 3px 0 var(--tinte); cursor: pointer; padding: 0;
    color: var(--tinte);
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }

.dots { display: flex; gap: 6px; justify-content: center; margin: 16px 0 12px; }
.dot {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2.5px solid var(--tinte); background: #fff;
    transition: transform .2s, background-color .2s;
}
.dot.now { background: var(--zitrone); transform: scale(1.3); }
.dot.ok { background: var(--minze); }
.dot.bad { background: var(--himbeere); }

.stage { position: relative; }
.placeholder { font-size: 4rem; }

.feedback {
    min-height: 2.9rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 800; text-align: center; line-height: 1.2;
}
.feedback span { animation: praise .45s cubic-bezier(.3, 1.6, .5, 1); }
.feedback.good { color: var(--minze-dunkel); }
.feedback.bad { color: var(--himbeere-dunkel); }

/* ---------- Eis-Countdown ---------- */
.icebar { padding: 14px 16px 16px; }
.icebar-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 900; font-size: 1.1rem; }
.ice-open { background: var(--himbeere); color: #fff; border: 3px solid var(--tinte); border-radius: 999px; padding: 1px 10px; font-size: .95rem; font-weight: 900; white-space: nowrap; }
.scoops { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin: 10px 0 8px; }
.scoop {
    aspect-ratio: 1;
    border-radius: 50% 50% 42% 42%;
    border: 3px solid var(--tinte);
    background: #fff;
}
.scoop.full { background: var(--c); }
.scoop.pop { animation: scoopPop .7s cubic-bezier(.3, 1.8, .5, 1) both; animation-delay: .35s; }
.ice-text { font-weight: 800; text-align: center; }

/* ---------- Overlays ---------- */
.overlay {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(43, 35, 80, .55);
    display: flex; align-items: center; justify-content: center;
    padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
    overflow-y: auto;
}
.overlay.solid { background: rgba(43, 35, 80, .95); }
.sheet {
    width: 100%; max-width: 420px; margin: auto;
    padding: 0 22px 24px; text-align: center;
    animation: sheetIn .45s cubic-bezier(.2, 1.4, .4, 1);
}
.eyebrow {
    margin-top: 30px;
    font-weight: 900; letter-spacing: .14em; text-transform: uppercase;
    font-size: .85rem; color: var(--himbeere-dunkel);
}
.big { font-size: clamp(2.2rem, 10vw, 3.2rem); font-weight: 900; line-height: 1.05; margin: 6px 0 10px; }
.huge { font-size: clamp(4.5rem, 24vw, 6.5rem); font-weight: 900; line-height: 1; margin: 0 0 8px; }
.lead { font-size: 1.2rem; font-weight: 700; margin: 8px 0; line-height: 1.35; }
.small { font-size: .98rem; font-weight: 600; margin: 8px 0; line-height: 1.4; opacity: .8; }
.pill {
    display: inline-flex; gap: 6px; align-items: center;
    background: #fff; border: 3px solid var(--tinte); border-radius: 999px;
    padding: 6px 14px; font-weight: 800; font-size: 1.1rem;
}
.btn {
    display: block; width: 100%; margin-top: 20px; padding: 15px;
    font-weight: 900; font-size: 1.45rem; color: #fff;
    background: var(--himbeere);
    border: var(--line) solid var(--tinte); border-radius: 20px;
    box-shadow: 0 6px 0 var(--tinte); cursor: pointer;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--tinte); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.secondary { background: #fff; color: var(--tinte); }
.btn.danger { background: #fff; color: var(--himbeere-dunkel); }
.btn.small { font-size: 1.1rem; padding: 10px 14px; margin-top: 12px; box-shadow: 0 4px 0 var(--tinte); }
.btn.late { animation: fadeUp .4s ease-out both; animation-delay: 1.6s; }

.new-row { margin-top: 16px; }
.new-row b { display: block; font-size: 1.15rem; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.chip {
    min-width: 2.7em; padding: 5px 6px;
    background: var(--zitrone); border: 3px solid var(--tinte); border-radius: 12px;
    font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums;
    animation: scoopPop .5s cubic-bezier(.3, 1.8, .5, 1) both;
    animation-delay: calc(var(--i) * 70ms + 250ms);
}

.stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 4px 0; }
.star { width: 64px; height: 64px; }
.star:nth-child(2) { width: 80px; height: 80px; }
.star path { fill: #fff; stroke: var(--tinte); stroke-width: 6; stroke-linejoin: round; }
.star.on path { fill: var(--zitrone); }
.star.on { animation: starIn .6s cubic-bezier(.3, 1.8, .5, 1) both; animation-delay: calc(var(--i) * 280ms + 250ms); }

.mini-ice { margin-top: 14px; background: #fff; border: 3px solid var(--tinte); border-radius: 18px; padding: 10px 12px 12px; }
.mini-ice .scoops { margin: 0 0 8px; }

.icecream { width: 170px; height: 235px; display: block; margin: 4px auto 0; overflow: visible; transform-origin: 50% 100%; animation: wobble 2.2s ease-in-out 1.6s infinite; }
.icecream .sc { transform-box: fill-box; transform-origin: center; animation: drop .55s cubic-bezier(.3, 1.5, .5, 1) both; }
.icecream .sc1 { animation-delay: .2s; }
.icecream .sc2 { animation-delay: .55s; }
.icecream .sc3 { animation-delay: .9s; }
.icecream .sc4 { animation-delay: 1.25s; }

.link-btn {
    display: inline-block;
    margin-top: 18px; background: none; border: 0; padding: 6px 10px;
    font-weight: 700; font-size: .9rem; color: var(--tinte); opacity: .6;
    cursor: pointer; position: relative; overflow: hidden; border-radius: 10px;
}
.link-btn::after {
    content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 0;
    background: var(--himbeere);
}
.link-btn.holding::after { width: 100%; transition: width 1.2s linear; }
.link-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 12px; }
.link-row .link-btn { margin-top: 12px; }

/* ---------- Fach-Auswahl ---------- */
.subjects { display: grid; gap: 14px; margin-top: 16px; }
.subject-card {
    display: flex; align-items: center; gap: 14px;
    width: 100%; padding: 14px 16px; text-align: left;
    background: #fff; color: var(--tinte);
    border: var(--line) solid var(--tinte); border-radius: 22px;
    box-shadow: 0 6px 0 var(--tinte);
    cursor: pointer; position: relative;
    animation: fadeUp .4s ease-out both;
    animation-delay: calc(var(--i) * 90ms + 150ms);
}
.subject-card:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--tinte); }
.subject-emoji {
    flex: none; width: 64px; height: 64px;
    display: grid; place-items: center;
    font-size: 2.3rem; line-height: 1;
    background: var(--accent, var(--zitrone));
    border: 3px solid var(--tinte); border-radius: 18px;
}
.subject-title { display: block; font-weight: 900; font-size: 1.55rem; line-height: 1.1; }
.subject-meta { display: block; font-weight: 700; font-size: .95rem; opacity: .75; margin-top: 3px; }
.subject-card .ice-open { position: absolute; top: -12px; right: -8px; }

.sync-line { min-height: 1.4em; }

/* ---------- Eltern-Bereich ---------- */
.parent-subject { margin-top: 18px; text-align: left; }
.parent-subject h3 { margin: 0; font-size: 1.25rem; font-weight: 900; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; margin-top: 10px; }
.stat { background: #fff; border: 3px solid var(--tinte); border-radius: 14px; padding: 7px 10px; font-weight: 700; font-size: .9rem; }
.stat b { display: block; font-size: 1.35rem; font-weight: 900; }
.field { display: flex; gap: 8px; margin-top: 12px; align-items: stretch; }
.field input {
    flex: 1; min-width: 0;
    font-family: var(--font); font-weight: 800; font-size: 1.25rem; text-align: center;
    border: 3px solid var(--tinte); border-radius: 14px; padding: 8px; background: #fff; color: var(--tinte);
}
.field .btn { width: auto; margin-top: 0; }
.parent-sep { border: 0; border-top: 3px dashed rgba(43, 35, 80, .25); margin: 20px 0 4px; }

/* ---------- Motivations-Effekte ---------- */
.particle {
    position: fixed; z-index: 50; pointer-events: none;
    font-size: 1.7rem; line-height: 1;
    animation: fly .9s cubic-bezier(.2, .8, .4, 1) forwards;
}
.banner {
    position: fixed; left: 50%; top: 36%; z-index: 60; pointer-events: none;
    background: var(--zitrone); border: 4px solid var(--tinte); box-shadow: var(--shadow);
    border-radius: 20px; padding: 10px 20px;
    font-weight: 900; font-size: 1.6rem; white-space: nowrap;
    animation: banner 1.5s cubic-bezier(.3, 1.5, .5, 1) forwards;
}
.shake { animation: shake .42s; }

#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 55; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-12px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-8px); } 80% { transform: translateX(5px); } }
@keyframes bump { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.18); } }
@keyframes taskIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes praise { from { opacity: 0; transform: translateY(10px) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(40px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes scoopPop { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes starIn { 0% { transform: scale(0) rotate(-90deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes drop { 0% { transform: translateY(-260px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(0); } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fly {
    0% { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
    70% { opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.15) rotate(var(--rot)); opacity: 0; }
}
@keyframes banner {
    0% { transform: translate(-50%, -50%) scale(.3) rotate(-8deg); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.08) rotate(3deg); opacity: 1; }
    35% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
    80% { transform: translate(-50%, -62%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -90%) scale(.9); opacity: 0; }
}

/* sehr schmale Handys: Kopfzeile mit Knoepfen, Level und Serie passt sonst nicht */
@media (max-width: 360px) {
    .game { padding: 0 14px 18px; }
    .topbar, .tools { gap: 6px; }
    .level-tag { font-size: 1rem; padding: 4px 10px; }
    .streak { font-size: 1rem; padding: 1px 7px; }
    .icon-btn { width: 38px; height: 38px; font-size: 1.1rem; }
    .subject-emoji { width: 54px; height: 54px; font-size: 2rem; }
    .subject-title { font-size: 1.35rem; }
}

@media (max-height: 700px) {
    .dots { margin: 12px 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
