/* ============================================================
   Crass — zentrale Design-Tokens (Art-Direction: storybook/cute)
   Eine Lichtung im warmen Licht: Grün + Holz + Creme, weiche
   Rundungen, einheitliche Outlines. Alle Farben NUR über Tokens.
   ============================================================ */
:root {
    /* Palette */
    --meadow:        #8fbf6f;   /* Lichtungs-Grün, hell */
    --meadow-deep:   #4f7a3d;   /* Wald-Grün, dunkel */
    --meadow-soft:   #d7e8c5;   /* zartes Blattgrün */
    --wood:          #8b5e3c;   /* Hütten-Holz */
    --wood-dark:     #5f4027;   /* Holz-Schatten */
    --cream:         #fdf6e8;   /* Papier/Karten */
    --cream-dim:     #f3e7cf;
    --ink:           #3a2e28;   /* Outlines & Text */
    --ink-soft:      #6b5d54;

    /* Ei-/Drachen-Akzente */
    --egg-normal:    #f4ebd6;   /* Perlweiß/Creme — hübsch, aber schlicht */
    --egg-normal-2:  #c9b691;   /* Sprenkel */
    --egg-silver:    #c6d8e8;
    --egg-silver-2:  #7fa6c9;
    --egg-gold:      #eec25a;
    --egg-gold-2:    #c08c1a;
    --earth:         #a98a6b;   /* erdiger Akzent (Normal-Drache) */

    /* Status-Farben */
    --ok:            #5a9e4b;
    --warn:          #d9932e;
    --bad:           #c65f45;
    --loyal:         #c76b8f;   /* Loyalitäts-Herz */

    /* Geometrie & Effekte */
    --radius:        16px;
    --radius-s:      10px;
    --outline-w:     2.5px;     /* einheitliche SVG/UI-Outline-Stärke */
    --shadow:        0 6px 18px rgba(58, 46, 40, .18);
    --shadow-soft:   0 2px 8px rgba(58, 46, 40, .12);

    --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    /* Mobile: niemals horizontal scrollen */
    overflow-x: clip;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(ellipse 120% 60% at 50% -10%, #fff3c9 0%, transparent 55%),
        linear-gradient(180deg, var(--meadow-soft) 0%, var(--meadow) 60%, var(--meadow-deep) 100%);
    background-attachment: fixed;
}

h1, h2, h3 { margin: 0 0 .4em; }
p { margin: .3em 0; }

/* ---------- Bausteine ---------- */
.card {
    background: var(--cream);
    border: var(--outline-w) solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.btn {
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    color: var(--ink);
    background: var(--cream-dim);
    border: var(--outline-w) solid var(--ink);
    border-radius: var(--radius-s);
    padding: 10px 18px;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--ink);
    transition: transform .06s ease, box-shadow .06s ease, background .15s;
    touch-action: manipulation; /* kein Doppeltipp-Zoom auf Buttons */
}
.btn:hover:not(:disabled) { background: #fff; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--meadow); }
.btn.primary:hover:not(:disabled) { background: #a3d284; }
.btn.gold { background: var(--egg-gold); }
.btn.small { font-size: .85rem; padding: 6px 12px; box-shadow: 0 2px 0 var(--ink); }

.linklike {
    background: none;
    border: none;
    color: var(--wood-dark);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    padding: 4px;
}

input, select {
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: var(--outline-w) solid var(--ink);
    border-radius: var(--radius-s);
    padding: 10px 12px;
    width: 100%;
}
input:focus, select:focus, .btn:focus-visible, .tab:focus-visible {
    outline: 3px solid var(--egg-gold);
    outline-offset: 1px;
}
label { display: block; margin: 12px 0 4px; font-weight: bold; font-size: .92rem; }

.hidden { display: none !important; }

/* ---------- Toasts ---------- */
#toasts {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100vw - 24px));
}
.toast {
    background: var(--cream);
    border: var(--outline-w) solid var(--ink);
    border-radius: var(--radius-s);
    box-shadow: var(--shadow);
    padding: 10px 14px;
    font-weight: bold;
    animation: toast-in .25s ease;
}
.toast.ok    { border-color: var(--ok); }
.toast.error { border-color: var(--bad); color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Auth ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px 48px;
}
.auth-hero { text-align: center; margin-bottom: 18px; }
.auth-hero h1 { font-size: 2.6rem; letter-spacing: .04em; text-shadow: 0 2px 0 rgba(255,255,255,.5); }
.auth-hero .tagline { color: var(--wood-dark); font-weight: bold; }
.auth-logo { filter: drop-shadow(var(--shadow-soft)); }
#auth-card { width: min(420px, 100%); }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
    flex: 1;
    font: inherit;
    font-weight: bold;
    padding: 8px;
    background: var(--cream-dim);
    border: var(--outline-w) solid var(--ink);
    border-radius: var(--radius-s);
    cursor: pointer;
}
.tab.active { background: var(--meadow); }

.pane button[type="submit"] { margin-top: 16px; width: 100%; }
.form-msg { min-height: 1.4em; font-weight: bold; margin-top: 10px; text-align: center; }
.form-msg.error { color: var(--bad); }
.form-msg.ok { color: var(--ok); }

/* Honeypot: visuell & für Screenreader raus, für Bots im DOM */
.hp-field {
    position: absolute !important;
    left: -9999px !important;
    width: 1px; height: 1px;
    overflow: hidden;
}

/* ============================================================
   App-Shell: Handy-Spiel-Aufbau — fixer Kompakt-Header oben,
   Screen in der Mitte, fixe Bottom-Tab-Bar. Kein Seiten-Scrollen;
   nur echte Listen scrollen innerhalb ihres Screens.
   ============================================================ */
body.view-game { overflow: hidden; }

#app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 560px;          /* Desktop: wie ein Handy-Spiel zentriert */
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(58, 46, 40, .25);
    background: transparent;
}

.topbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    background: var(--cream);
    border-bottom: var(--outline-w) solid var(--ink);
    z-index: 50;
}
.topbar-logo { flex: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
    font-size: .85rem;
    background: var(--cream-dim);
    border: 2px solid var(--ink);
    border-radius: 999px;
    padding: 4px 10px;
    white-space: nowrap;
}
.chip-dragon {
    font: inherit;
    font-size: .85rem;
    font-weight: bold;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}
.chip-dragon small { font-weight: normal; color: var(--ink-soft); }
.chip-coins { margin-left: auto; }
.chip-pulse { animation: chip-pulse .5s ease; }
@keyframes chip-pulse { 40% { scale: 1.12; } }

.iconbtn {
    font-size: 1.15rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
    border-radius: var(--radius-s);
    touch-action: manipulation;
}
.iconbtn:hover { background: var(--cream-dim); }

#screen {
    flex: 1;
    min-height: 0;
    position: relative;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
.loading { text-align: center; color: var(--ink-soft); padding: 40px 0; }

/* Scrollende Listen-Screens (Shop, Lager, Ei-Auswahl, Admin) */
.screen-scroll {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px 20px;
}
.screen-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.screen-head h2 { margin: 0; font-size: 1.2rem; }

/* ---------- Bottom-Tab-Bar ---------- */
.tabbar {
    flex: none;
    display: flex;
    background: var(--cream);
    border-top: var(--outline-w) solid var(--ink);
    padding-bottom: env(safe-area-inset-bottom); /* iPhone Home-Indicator */
    z-index: 50;
}
.tabbtn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font: inherit;
    font-size: .68rem;
    font-weight: bold;
    color: var(--ink-soft);
    background: none;
    border: none;
    padding: 7px 2px 6px;
    cursor: pointer;
    touch-action: manipulation;
    min-height: 52px;
}
.tabbtn .tab-ico {
    font-size: 1.35rem;
    line-height: 1.1;
    transition: transform .15s ease;
}
.tabbtn.active { color: var(--ink); }
.tabbtn.active .tab-ico { transform: translateY(-2px) scale(1.15); }
.tabbtn.active span:last-child {
    background: var(--meadow);
    border-radius: 999px;
    padding: 0 8px;
}

/* ---------- Ei-Auswahl ---------- */
.egg-select { text-align: center; }
.egg-select h2 { margin-top: 24px; }
.egg-select-hint { color: var(--ink-soft); margin-bottom: 20px; }
.egg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    max-width: 860px;
    margin: 0 auto;
}
.egg-card {
    background: var(--cream);
    border: var(--outline-w) solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform .15s ease;
}
.egg-card:not(.locked):hover { transform: translateY(-4px); }
.egg-card.locked { opacity: .88; filter: saturate(.8); }
.egg-card.locked .btn, .egg-card.locked h3 { opacity: .75; }
.egg-card .egg { width: 110px; height: auto; }
.egg-card p { color: var(--ink-soft); font-size: .92rem; min-height: 3.2em; }
.lock-badge { font-weight: bold; color: var(--ink-soft); padding: 10px; }

/* Ei-Farben: eine Form; das intakte Ei trägt einen Gradient (egg-shell-grad),
   Schalen-Bruchstücke bekommen die flache Typ-Farbe über Tokens. */
.egg-shell, .egg-shell-grad { stroke: var(--ink); stroke-width: var(--outline-w); }
.egg-shadow { fill: var(--ink); opacity: .15; }
.egg--normal .egg-shell { fill: var(--egg-normal); }
.egg--silver .egg-shell { fill: var(--egg-silver); }
.egg--gold   .egg-shell { fill: var(--egg-gold); }
/* Gold: sanftes Schatz-Glühen */
.egg-glow { animation: egg-glow 2.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes egg-glow { 0%, 100% { opacity: .65; scale: 1; } 50% { opacity: 1; scale: 1.08; } }

/* ============================================================
   Lichtung — EIN Screen, kein Scrollen, der Drache ist der Star
   ============================================================ */
.clearing {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.scene-stage {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}
.scene { display: block; width: 100%; height: 100%; }
.scene .ink, .scene .ink * { stroke: var(--ink); stroke-width: var(--outline-w); stroke-linecap: round; stroke-linejoin: round; }
.status-hint { color: var(--ink-soft); font-size: .9rem; }

/* Kompaktes HUD: Mini-Ringe als Overlay oben in der Szene */
.hud {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 6px;
    z-index: 5;
}
.hud-stat {
    position: relative;
    width: 42px;
    height: 42px;
    background: color-mix(in srgb, var(--cream) 88%, transparent);
    border: 2px solid var(--ink);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    touch-action: manipulation;
}
.hud-stat svg { position: absolute; inset: 4px; width: auto; height: auto; }
.hud-ico { font-size: .8rem; z-index: 1; }
.hud-detail {
    position: absolute;
    top: 56px;
    left: 8px;
    z-index: 6;
    padding: 8px 12px;
    font-size: .85rem;
}
.hud-detail p { margin: 2px 0; }

/* Aktionsleiste unter der Szene: Fenster-Status + große Haupt-Aktion */
.action-bar {
    flex: none;
    padding: 8px 14px 10px;
    background: var(--cream);
    border-top: var(--outline-w) solid var(--ink);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    text-align: center;
}
.big-action {
    font-size: 1.1rem;
    padding: 12px 18px;
    width: 100%;
}
.big-action small { font-weight: normal; opacity: .75; font-size: .8rem; }
.feed-window { margin: 0; font-size: .88rem; min-height: 1.3em; }
.feed-window.window-open { color: var(--ok); font-weight: bold; }

.hatch-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 0;
    font-size: 1rem;
}
.hatch-bar {
    height: 12px;
    background: var(--cream-dim);
    border: 2px solid var(--ink);
    border-radius: 999px;
    overflow: hidden;
}
.hatch-bar span { display: block; height: 100%; background: var(--egg-gold); border-radius: 999px; }
.hatch-caption { margin: 4px 0; font-weight: bold; font-size: 1.05rem; }
.hatch-bar span { transition: width .4s linear; }

/* Ei antippen: schwebendes "+1 s" und Mini-Hüpfer */
.tap-plus {
    position: absolute;
    z-index: 9;
    font-weight: bold;
    font-size: .95rem;
    color: var(--wood-dark);
    text-shadow: 0 1px 0 var(--cream);
    pointer-events: none;
    animation: tap-plus-up .85s ease-out forwards;
}
@keyframes tap-plus-up {
    0% { opacity: 0; translate: 0 4px; scale: .7; }
    20% { opacity: 1; scale: 1.1; }
    100% { opacity: 0; translate: 0 -34px; scale: 1; }
}
#scene-egg { cursor: pointer; }
#scene-egg.egg-tapped { animation: egg-tap-pop .16s ease; transform-box: fill-box; transform-origin: 50% 90%; }
@keyframes egg-tap-pop { 40% { scale: 1.05 .95; } }

/* ---------- Spielzeitfenster ---------- */
.playtime-setup { max-width: 440px; margin: 0 auto; text-align: center; }
.playtime-setup h2 { margin-top: 18px; }
.playtime-setup p { text-align: left; }
.playtime-setup .big-action { margin-top: 14px; }
.play-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 16px 0;
    font-weight: bold;
}
.play-form select { width: auto; padding: 8px 10px; }
.paused-badge {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translateX(-50%);
    z-index: 6;
    background: color-mix(in srgb, var(--cream) 94%, transparent);
    border: 2px solid var(--ink);
    border-radius: var(--radius-s);
    box-shadow: var(--shadow);
    padding: 8px 14px;
    font-weight: bold;
    font-size: .9rem;
    text-align: center;
}

/* Ei-Auswahl: Preis & Tempo */
.egg-price {
    font-size: .72rem;
    border: 2px solid var(--ink);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
    background: var(--cream-dim);
    white-space: nowrap;
}
.egg-price.free { background: var(--meadow-soft); }
.egg-price.silver { background: var(--egg-silver); }
.egg-price.gold { background: var(--egg-gold); }
.egg-speed { font-size: .78rem; font-weight: bold; color: var(--wood-dark); }

/* Aktionszeile: Füttern groß + Streicheln daneben */
.action-row { display: flex; gap: 8px; }
.action-row #btn-feed { flex: 1; }
.pet-btn { flex: none; width: 76px; font-size: 1.05rem; }
.pet-btn.pet-ready { background: var(--meadow-soft); animation: pet-glow 2.4s ease-in-out infinite; }
@keyframes pet-glow { 0%, 100% { box-shadow: 0 3px 0 var(--ink); } 50% { box-shadow: 0 3px 0 var(--ink), 0 0 14px var(--loyal); } }

/* ---------- Gefahr! (Raubvogel / Wespen) ---------- */
.danger-banner {
    position: absolute;
    top: 8px;
    right: 8px;
    max-width: 60%;
    z-index: 8;
    background: color-mix(in srgb, var(--cream) 92%, transparent);
    border: 2px solid var(--bad);
    border-radius: var(--radius-s);
    padding: 6px 10px;
    font-weight: bold;
    font-size: .82rem;
    text-align: right;
    animation: danger-blink 1.2s ease-in-out infinite;
}
@keyframes danger-blink { 0%, 100% { border-color: var(--bad); } 50% { border-color: var(--egg-gold-2); } }
.danger-actor {
    position: absolute;
    z-index: 7;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    line-height: 0;
    transition: left .5s ease, top .5s ease;
    filter: drop-shadow(0 3px 4px rgba(58, 46, 40, .35));
    touch-action: manipulation;
    animation: danger-hover 2.2s ease-in-out infinite;
}
@keyframes danger-hover { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }
.danger-actor.danger-hit { animation: danger-flinch .3s ease; }
@keyframes danger-flinch { 40% { scale: .82; rotate: -14deg; } }
.hawk-body { animation: hawk-tilt 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes hawk-tilt { 0%, 100% { rotate: -6deg; } 50% { rotate: 6deg; } }
.wasp { animation: wasp-buzz .35s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes wasp-buzz { 0%, 100% { translate: 0 0; } 25% { translate: 1.5px -1.5px; } 75% { translate: -1.5px 1.5px; } }

/* Bottom-Sheet (Futterwahl, Taufen) */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(58, 46, 40, .4);
    z-index: 90;
}
.sheet {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: min(560px, 100%);
    background: var(--cream);
    border: var(--outline-w) solid var(--ink);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    z-index: 95;
    animation: sheet-up .22s ease;
    text-align: center;
}
@keyframes sheet-up { from { translate: 0 40px; opacity: 0; } }
.sheet h3 { margin-bottom: 12px; }
.sheet-grid { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sheet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font: inherit;
    font-weight: bold;
    font-size: .85rem;
    background: var(--cream-dim);
    border: 2px solid var(--ink);
    border-radius: var(--radius-s);
    padding: 10px 14px;
    cursor: pointer;
    min-width: 92px;
    touch-action: manipulation;
}
.sheet-item:hover { background: #fff; }
.sheet-item small { color: var(--ink-soft); font-weight: normal; }

/* ---------- Drache: Farbvarianten je Ei-Typ (nur Tokens) ---------- */
.dragon .d-claw { fill: none; }
.scene .dragon .ink, .scene .dragon.ink, .train-arena-svg .dragon .ink, .train-arena-svg .dragon.ink {
    stroke-width: 2px;
}
.dragon .d-mouth { fill: #d66f83; }
.dragon .d-cheek { fill: var(--loyal); }

.dragon--normal .d-main        { fill: #35a7b4; }
.dragon--normal .d-main-dark   { fill: #1d7d8d; }
.dragon--normal .d-belly       { fill: #f1dfbd; }
.dragon--normal .d-accent      { fill: #3b8d5f; }
.dragon--normal .d-membrane    { fill: #8a6db4; }
.dragon--normal .d-iris        { fill: #5740a0; }
.dragon--normal .d-mark        { fill: #177888; }

.dragon--silver .d-main        { fill: #9fcfe4; }
.dragon--silver .d-main-dark   { fill: #5f91b2; }
.dragon--silver .d-belly       { fill: #edf6fb; }
.dragon--silver .d-accent      { fill: #6d9fba; }
.dragon--silver .d-membrane    { fill: #7a69ac; }
.dragon--silver .d-iris        { fill: #4a4b93; }
.dragon--silver .d-mark        { fill: #5c91a8; }

.dragon--gold .d-main          { fill: #eac05a; }
.dragon--gold .d-main-dark     { fill: #b67922; }
.dragon--gold .d-belly         { fill: #fff0ca; }
.dragon--gold .d-accent        { fill: #b66d20; }
.dragon--gold .d-membrane      { fill: #89518f; }
.dragon--gold .d-iris          { fill: #4d397b; }
.dragon--gold .d-mark          { fill: #a66e20; }

/* ---------- Leben & Micro-Animationen (Compositor-freundlich) ---------- */
/* Drache atmet ruhig */
.d-breathe { animation: d-breathe 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 92%; }
@keyframes d-breathe { 0%, 100% { scale: 1; } 50% { scale: 1.018 0.988; } }
/* …blinzelt hin und wieder */
.d-lid { animation: d-blink 5.2s infinite; transform-box: fill-box; transform-origin: 50% 8%; scale: 1 0; }
.d-eye:last-of-type .d-lid { animation-delay: .07s; }
@keyframes d-blink { 0%, 93.5%, 100% { scale: 1 0; } 95.5%, 97.5% { scale: 1 1; } }
/* …und wedelt mit dem Schwanz */
.d-tail { animation: d-tail 3.8s ease-in-out infinite; transform-box: fill-box; transform-origin: 24% 62%; }
@keyframes d-tail { 0%, 100% { rotate: 0deg; } 40% { rotate: 7deg; } 70% { rotate: -3deg; } }
/* Flügel leben nur sehr subtil, damit der Drache nicht nervös wirkt */
.d-wing { transform-box: fill-box; transform-origin: 50% 35%; }
.scene .dragon:not(.dragon-fly) .d-wing-l { animation: d-wing-snug 5.8s ease-in-out infinite; }
.scene .dragon:not(.dragon-fly) .d-wing-r { animation: d-wing-snug 5.8s ease-in-out infinite reverse; }
@keyframes d-wing-snug { 0%, 100% { rotate: 0deg; } 50% { rotate: -2deg; } }
/* Reaktion beim Füttern: freudiger Hüpfer */
.dragon-happy-jump { animation: d-jump .7s cubic-bezier(.3, 1.6, .5, 1); transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes d-jump { 0%, 100% { translate: 0 0; } 35% { translate: 0 -26px; } 60% { translate: 0 0; } 78% { translate: 0 -10px; } }

/* Kaminrauch steigt auf */
.smoke { animation: smoke-rise 5s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes smoke-rise { 0% { translate: 0 4px; opacity: .3; } 45% { opacity: 1; } 100% { translate: 0 -16px; opacity: 0; } }

/* Schmetterlinge flattern umher */
.butterfly { animation: b-fly 9s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.b-wings { animation: b-flap .5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes b-fly {
    0%, 100% { translate: 0 0; }
    25% { translate: 34px -22px; }
    50% { translate: -12px -36px; }
    75% { translate: -30px -10px; }
}
@keyframes b-flap { 0%, 100% { scale: 1 1; } 50% { scale: .45 1; } }

/* Glutpartikel schweben nach oben */
.mote { animation: mote-drift 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes mote-drift {
    0% { translate: 0 8px; opacity: 0; }
    30%, 60% { opacity: .8; }
    100% { translate: 6px -44px; opacity: 0; }
}

/* Gräser & Blumen wiegen sich im Wind */
.tuft { animation: tuft-sway 4.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.tuft:nth-of-type(odd) { animation-delay: 1.4s; }
@keyframes tuft-sway { 0%, 100% { rotate: -2.5deg; } 50% { rotate: 2.5deg; } }

/* Herzchen beim Füttern */
.heart-burst {
    position: absolute;
    font-size: 1.5rem;
    pointer-events: none;
    animation: heart-up 1.3s ease-out forwards;
    z-index: 5;
}
@keyframes heart-up {
    0% { opacity: 0; translate: 0 0; scale: .4; }
    18% { opacity: 1; scale: 1.1; }
    100% { opacity: 0; translate: 0 -90px; scale: 1; }
}

/* Barrierefreiheit & schwache Geräte: Micro-Animationen abschaltbar */
@media (prefers-reduced-motion: reduce) {
    .d-breathe, .d-lid, .d-tail, .d-wing, .smoke, .butterfly, .b-wings, .mote, .tuft,
    .egg-glow, .egg-wiggle, .egg-wiggle-origin, .dragon-fly, .sparkles path {
        animation: none !important;
    }
}

/* ---------- Schlüpfen: Wackeln, Plopp, Funkeln ---------- */
.egg-wiggle, .egg-wiggle-origin { animation: egg-wiggle 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 85%; }
@keyframes egg-wiggle {
    0%, 62%, 100% { rotate: 0deg; }
    68% { rotate: -4deg; }
    76% { rotate: 4deg; }
    84% { rotate: -2.5deg; }
    92% { rotate: 2deg; }
}
.dragon-pop { animation: dragon-pop .6s cubic-bezier(.2, 1.6, .4, 1); transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes dragon-pop { from { scale: .2; opacity: 0; } to { scale: 1; opacity: 1; } }
.sparkles path { animation: sparkle 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.sparkles path:nth-child(2) { animation-delay: .25s; }
.sparkles path:nth-child(3) { animation-delay: .5s; }
.sparkles path:nth-child(4) { animation-delay: .75s; }
.sparkles path:nth-child(5) { animation-delay: 1s; }
@keyframes sparkle { 0%, 100% { scale: .6; opacity: .4; } 50% { scale: 1.15; opacity: 1; } }

.name-form { display: flex; gap: 8px; margin: 6px 0 12px; }
.name-form input { flex: 1; }

/* ---------- Admin-Panel ---------- */
.admin-panel { max-width: 760px; margin: 0 auto; }
.admin-panel h3 { margin-top: 18px; }
.admin-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: .9rem; }
.admin-row input, .admin-row select { width: auto; padding: 6px 8px; }
.btn.danger { background: var(--bad); color: #fff; }

/* ---------- Minispiel (füllt den Screen, kein Scrollen) ---------- */
.minigame {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.mg-hint { margin: 0 0 8px; font-size: .82rem; }
.mg-meta { display: flex; gap: 14px; font-size: .95rem; }
.mg-area {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    border: var(--outline-w) solid var(--ink);
    border-radius: var(--radius-s);
    background:
        linear-gradient(180deg, #cfe6f5 0%, var(--meadow-soft) 55%, var(--meadow) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.mg-start { width: auto; }
.mg-berry {
    position: absolute;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    line-height: 0;
}
.mg-berry.mg-caught { animation: mg-pop .18s ease forwards; }
@keyframes mg-pop { to { transform: scale(1.7); opacity: 0; } }

/* ---------- Lager ---------- */
.inv-list { list-style: none; padding: 0; margin: 12px 0; }
.inv-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    border: 2px solid var(--ink);
    border-radius: var(--radius-s);
    background: var(--cream-dim);
    margin-bottom: 6px;
}
.inv-name { flex: 1; font-weight: bold; }
.inv-empty { color: var(--ink-soft); font-style: italic; justify-content: center; }
.cap-track {
    height: 12px;
    background: var(--cream-dim);
    border: 2px solid var(--ink);
    border-radius: 999px;
    overflow: hidden;
    margin: 4px 0 10px;
}
.cap-fill { display: block; height: 100%; background: var(--egg-gold); border-radius: 999px; transition: width .4s ease; }

/* ---------- Shop: dichtes 2-Spalten-Grid mit Item-Grafiken ---------- */
.shop-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.shop-tabs .tab { flex: 1; }
.shop-grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font: inherit;
    text-align: center;
    background: var(--cream);
    border: 2px solid var(--ink);
    border-radius: var(--radius-s);
    padding: 10px 8px;
    cursor: pointer;
    box-shadow: 0 2.5px 0 var(--ink);
    transition: transform .08s ease, box-shadow .08s ease;
    touch-action: manipulation;
}
.item-card:active:not(:disabled) { transform: translateY(2.5px); box-shadow: 0 0 0 var(--ink); }
.item-card .item-name { font-weight: bold; font-size: .88rem; }
.item-card .item-desc { font-size: .72rem; color: var(--ink-soft); min-height: 2.2em; }
.item-card .item-price {
    font-weight: bold;
    font-size: .85rem;
    background: var(--cream-dim);
    border: 1.5px solid var(--ink);
    border-radius: 999px;
    padding: 2px 10px;
    margin-top: 2px;
}
/* Wertigkeit: seltene/edle Artikel heben sich ab */
.item-card.rare { background: linear-gradient(160deg, #f2f7fb, var(--cream)); border-color: var(--egg-silver-2); }
.item-card.rare .item-price { border-color: var(--egg-silver-2); }
.item-card.epic {
    background: linear-gradient(160deg, #fdf3d3, var(--cream));
    border-color: var(--egg-gold-2);
    position: relative;
    overflow: hidden;
}
.item-card.epic::after {
    content: "";
    position: absolute;
    top: -60%; left: -70%;
    width: 40%; height: 220%;
    background: linear-gradient(105deg, transparent, rgba(255,255,255,.7), transparent);
    transform: rotate(12deg);
    animation: epic-sheen 3.2s ease-in-out infinite;
}
@keyframes epic-sheen { 0%, 60%, 100% { left: -70%; } 30% { left: 130%; } }
.item-card.epic .item-price { border-color: var(--egg-gold-2); background: #fdeaa8; }
.item-card.bought { animation: bought-pop .5s ease; }
@keyframes bought-pop { 30% { transform: scale(1.06); } }

/* Kauf-Animation: Item fliegt zum Coins-Chip */
.fly-item {
    position: fixed;
    z-index: 120;
    pointer-events: none;
    margin: -23px 0 0 -23px;
    transition: transform .65s cubic-bezier(.4, 0, .7, 1), opacity .65s ease;
}

/* ---------- Flug-Training: Arena mit animiertem Drachen ---------- */
.training {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.train-top { flex: none; padding: 8px 12px 4px; }
.train-meta { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.train-pips { display: flex; gap: 4px; }
.train-pip {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    background: var(--cream-dim);
    border: 2px solid var(--ink);
    border-radius: var(--radius-s);
    padding: 4px 2px;
    font-size: .95rem;
    opacity: .55;
}
.train-pip small { font-size: .58rem; font-weight: bold; }
.train-pip.done { background: var(--meadow-soft); opacity: 1; }
.train-pip.next { opacity: 1; border-color: var(--egg-gold-2); background: #fdf3d3; }
.train-arena {
    flex: 1;
    min-height: 0;
    position: relative;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.train-arena-svg { width: 100%; height: 100%; max-height: 100%; }
.train-done { font-size: 1.1rem; text-align: center; margin: 4px 0; }
.train-help { text-align: center; margin: 0; font-size: .88rem; }

/* Übungs-Animationen des Drachen (je Stufe eine eigene Bewegung) */
.t-dragon { transform-box: fill-box; transform-origin: 50% 90%; }
.t-anim-1 { animation: t-balance 2.2s ease-in-out infinite; }          /* balanciert */
@keyframes t-balance { 0%, 100% { rotate: -7deg; } 50% { rotate: 7deg; } }
.t-anim-2 { animation: t-flaplift 1.4s ease-in-out infinite; }         /* Flügelkraft */
@keyframes t-flaplift { 0%, 100% { translate: 0 0; } 50% { translate: 0 -16px; } }
.t-anim-2 .d-wing { animation: t-flap .35s ease-in-out infinite; transform-box: fill-box; transform-origin: 80% 40%; }
.t-anim-2 .d-wing-l { transform-origin: 90% 40%; }
@keyframes t-flap { 0%, 100% { rotate: 0deg; } 50% { rotate: -34deg; } }
.t-anim-3 { animation: t-hop 1.1s cubic-bezier(.3, 0, .6, 1) infinite; } /* Absprung */
@keyframes t-hop { 0%, 100% { translate: 0 0; scale: 1 1; } 18% { scale: 1.06 .92; } 45% { translate: 0 -34px; scale: .97 1.04; } 80% { translate: 0 0; } }
.t-anim-4 { animation: t-glide 3.6s ease-in-out infinite; }             /* Gleiten */
@keyframes t-glide { 0%, 100% { translate: -26px 0; rotate: -4deg; } 50% { translate: 26px -12px; rotate: 4deg; } }
.t-anim-4 .d-wing { animation: t-flap 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 80% 40%; }
.t-anim-5 { animation: t-dive 1.8s ease-in-out infinite; }              /* Sturzflug */
@keyframes t-dive {
    0%, 100% { translate: -36px -34px; rotate: 24deg; scale: .9; }
    50% { translate: 26px 14px; rotate: -10deg; scale: 1.05; }
}
/* Treffer-Boost: kurzer Extra-Schub */
.t-boost { filter: drop-shadow(0 0 6px var(--egg-gold)); }
.t-wind { animation: t-wind 1.6s linear infinite; }
@keyframes t-wind { 0% { translate: 26px 0; opacity: 0; } 30%, 70% { opacity: .6; } 100% { translate: -20px 0; opacity: 0; } }
.t-cloud { animation: t-cloud 5s ease-in-out infinite; }
@keyframes t-cloud { 0%, 100% { translate: 0 0; } 50% { translate: -14px 4px; } }

.tr-bar {
    position: relative;
    height: 40px;
    border: var(--outline-w) solid var(--ink);
    border-radius: 999px;
    background: var(--cream-dim);
    margin: 14px 0;
    overflow: hidden;
}
.tr-zone {
    position: absolute;
    top: 0; bottom: 0;
    background: var(--egg-gold);
    opacity: .8;
}
.tr-marker {
    position: absolute;
    top: 3px; bottom: 3px;
    width: 10px;
    margin-left: -5px;
    border-radius: 999px;
    background: var(--ink);
}
.tr-bar.tr-hit  { animation: tr-flash-ok .25s ease; }
.tr-bar.tr-miss { animation: tr-flash-bad .25s ease; }
@keyframes tr-flash-ok  { 50% { box-shadow: inset 0 0 0 4px var(--ok); } }
@keyframes tr-flash-bad { 50% { box-shadow: inset 0 0 0 4px var(--bad); } }
.tr-tap { display: block; margin: 0 auto; min-width: 220px; }

/* Fliegender Drache über der Lichtung */
.dragon-fly { animation: dragon-bob 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes dragon-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -14px; } }

/* (Fütterung: Fenster-Status & Sheet-Stile stehen im Lichtungs-Abschnitt) */

/* ---------- Mobile-First: Touch & schmale Screens ---------- */

/* Touch-Geräte: großzügige Tap-Targets (≥ 44px), keine Hover-Abhängigkeit */
@media (pointer: coarse) {
    .btn, .btn.small, .tab, .linklike, .sheet-item {
        min-height: 44px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    input, select { min-height: 44px; }
    .iconbtn { min-width: 40px; min-height: 40px; }
    .tr-bar { height: 48px; }
    .egg-card:not(.locked):hover { transform: none; } /* Hover-Effekte neutralisieren */
}

@media (max-width: 600px) {
    .auth-hero h1 { font-size: 2rem; }
    .card { padding: 16px; }
    .name-form { flex-direction: column; }
    .admin-row input, .admin-row select { flex: 1; }
    .egg-grid { grid-template-columns: 1fr; }
}

/* Sehr niedrige Viewports (Landscape-Handy): HUD kompakter */
@media (max-height: 480px) {
    .hud-stat { width: 34px; height: 34px; }
    .big-action { padding: 8px 14px; font-size: 1rem; }
}
