@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    /* ── Chrome (UI) ── */
    --bg:          #0d0f18;
    --bg-2:        #12141f;
    --surface:     #1a1e2c;
    --surface-2:   #232839;
    --silo-body:   #202537;
    --silo-rim:    #363d54;
    --silo-shadow: rgba(0,0,0,0.55);

    --text:        #eef1f8;
    --text-dim:    #9aa1ba;
    --text-mute:   #666e89;

    /* Blau ist inzwischen auch eine Spielfarbe (game.js PALETTE) – --accent
       bleibt für CTA/Links/Fokus-Ring auf der Menüseite (dort ohne Pucks), der
       Auswahl-Ring während des Spiels nutzt stattdessen --select-ring (neutral
       Weiß), damit er nie mit einem blauen Puck verwechselt werden kann. */
    --accent:      #6ea8fe;
    --accent-dim:  #3d5a96;
    --accent-glow: rgba(110,168,254,0.55);

    --select-ring:      #f8fafc;
    --select-ring-glow: rgba(248,250,252,0.6);

    --warn:        #fbbf24;
    --warn-glow:   rgba(251,191,36,0.45);
    --danger:      #f87171;

    --radius-lg:   22px;
    --radius-md:   14px;
    --radius-sm:   9px;

    --font-display: 'Fredoka', ui-rounded, sans-serif;
    --font-body:    'Inter', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

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

[hidden] { display: none !important; }

html, body {
    height: 100%;
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse 70% 45% at 50% -8%, rgba(110,168,254,0.10) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 82% 108%, rgba(168,85,247,0.08) 0%, transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow: hidden;
}

button { font-family: inherit; }
button:focus-visible, .text-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.screen {
    width: 100%;
    max-width: 560px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ════════════════════════ MENÜ ════════════════════════ */

#menu-screen {
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.menu-ambient {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.drift {
    position: absolute;
    bottom: -40px;
    width: 14px;
    height: 14px;
    border-radius: 40%;
    opacity: 0.28;
    animation: drift-up linear infinite;
}
.d1 { left: 8%;  background: #ef4444; animation-duration: 18s; animation-delay: -2s; }
.d2 { left: 22%; background: #14b8a6; animation-duration: 22s; animation-delay: -9s; }
.d3 { left: 40%; background: #eab308; animation-duration: 16s; animation-delay: -5s; }
.d4 { left: 58%; background: #a855f7; animation-duration: 24s; animation-delay: -14s; }
.d5 { left: 74%; background: #f97316; animation-duration: 19s; animation-delay: -7s; }
.d6 { left: 90%; background: #ec4899; animation-duration: 21s; animation-delay: -11s; }

@keyframes drift-up {
    from { transform: translateY(0) rotate(0deg); }
    to   { transform: translateY(-100vh) rotate(70deg); }
}

.menu-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 22px;
    max-width: 380px;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 14px;
}

.lid-mark {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(155deg, var(--surface-2), var(--silo-body) 60%);
    border: 3px solid var(--silo-rim);
    box-shadow: inset 0 3px 0 rgba(255,255,255,0.08), 0 0 0 4px rgba(110,168,254,0.12);
    position: relative;
    flex: none;
}
.lid-mark::after {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: conic-gradient(from 200deg,
        #ef4444, #f97316, #eab308, #84cc16, #10b981, #14b8a6, #a855f7, #ec4899, #ef4444);
}

.wordmark h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 40px;
    letter-spacing: 0.5px;
    color: var(--text);
}
.wordmark .slash { color: var(--accent); }

.tagline {
    color: var(--text-dim);
    font-size: 15px;
    max-width: 280px;
    line-height: 1.5;
}

.btn {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 18px;
    border: none;
    border-radius: 999px;
    padding: 15px 42px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    letter-spacing: 0.3px;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
    color: #0a0c14;
    background: linear-gradient(155deg, #8ec1ff, var(--accent) 55%, #4f7fd9);
    box-shadow: 0 6px 0 var(--accent-dim), 0 10px 24px rgba(110,168,254,0.25);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--accent-dim); }

.btn-ghost {
    color: var(--text);
    background: var(--surface-2);
    box-shadow: 0 4px 0 rgba(0,0,0,0.35);
}
.btn-ghost:active { box-shadow: 0 1px 0 rgba(0,0,0,0.35); }

.menu-stats {
    display: flex;
    gap: 36px;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 22px;
    color: var(--text);
}
.stat-label {
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-mute);
}

.menu-links {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-mute);
    font-size: 13px;
}
.text-link {
    background: none;
    border: none;
    color: var(--text-mute);
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.text-link:hover { color: var(--text-dim); }

/* ════════════════════════ SPIEL ════════════════════════ */

#game-screen { padding: 18px 18px 22px; }

#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#level-badge {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    color: var(--text-dim);
    background: var(--surface);
    padding: 8px 18px;
    border-radius: 999px;
}
#level-badge span { color: var(--text); }

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    color: var(--text-dim);
    font-size: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
    transition: transform 0.12s ease, color 0.12s ease;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:disabled:active { transform: none; }

#hud {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 22px 0 8px;
}

.odometer {
    display: flex;
    gap: 3px;
    background: #05060a;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04);
}
.odo-digit {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 26px;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
    width: 18px;
    text-align: center;
}
.odo-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-mute);
    margin-top: 6px;
}

#silo-field {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 22px 16px;
    padding: 10px 4px 20px;
}

.silo {
    --n: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.18s cubic-bezier(.34,1.56,.64,1);
}
.silo.selected { transform: translateY(-14px); }
.silo.shake { animation: silo-shake 0.32s ease; }
.silo.pour-out .silo-body { animation: tilt-out 0.32s ease; }
.silo.pour-in .silo-body { animation: tilt-in 0.34s ease; }

@keyframes silo-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(3px); }
}
@keyframes tilt-out {
    0% { transform: rotate(0deg); }
    35% { transform: rotate(-9deg); }
    100% { transform: rotate(0deg); }
}
@keyframes tilt-in {
    0% { transform: scale(1); }
    40% { transform: scale(1.05, 0.92); }
    100% { transform: scale(1); }
}

.silo-lid {
    width: calc(var(--slot-w, 54px) + 10px);
    height: 13px;
    border-radius: 7px;
    background: linear-gradient(155deg, var(--surface-2), var(--silo-rim));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 2px 3px rgba(0,0,0,0.4);
    margin-bottom: 3px;
    transition: box-shadow 0.4s ease, background 0.4s ease;
}
.silo.complete .silo-lid {
    background: linear-gradient(155deg, var(--lid-glow, var(--accent)), var(--silo-rim));
    box-shadow: 0 0 16px var(--lid-glow, var(--accent-glow)), inset 0 1px 0 rgba(255,255,255,0.3);
    animation: lid-snap 0.42s cubic-bezier(.34,1.56,.64,1);
}
@keyframes lid-snap {
    0%   { transform: translateY(-6px) scaleX(0.85); }
    55%  { transform: translateY(1px) scaleX(1.04); }
    100% { transform: translateY(0) scaleX(1); }
}

.silo-body {
    width: var(--slot-w, 54px);
    height: calc(var(--slot-h, 30px) * var(--n));
    background: linear-gradient(100deg, var(--silo-body) 0%, #262c40 45%, var(--silo-body) 100%);
    border: 2px solid var(--silo-rim);
    border-top: none;
    border-radius: 0 0 16px 16px;
    display: flex;
    flex-direction: column-reverse;
    padding: 3px;
    gap: 3px;
    box-shadow: inset 2px 0 4px rgba(0,0,0,0.35), inset -2px 0 4px rgba(0,0,0,0.35);
    position: relative;
    overflow: hidden;
}
.silo.selected .silo-body {
    box-shadow: inset 2px 0 4px rgba(0,0,0,0.35), inset -2px 0 4px rgba(0,0,0,0.35),
                0 0 0 3px var(--select-ring), 0 0 18px var(--select-ring-glow);
}

.silo-base {
    width: calc(var(--slot-w, 54px) + 16px);
    height: 8px;
    border-radius: 50%;
    background: var(--silo-shadow);
    filter: blur(2px);
    margin-top: 6px;
}

.puck {
    width: 100%;
    flex: 1 0 auto;
    border-radius: 8px;
    background: linear-gradient(165deg, var(--puck-hi), var(--puck-c) 55%, var(--puck-lo));
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.25), inset 0 -3px 4px rgba(0,0,0,0.25);
    position: relative;
    flex-shrink: 0;
}
.puck.entering { animation: puck-drop 0.3s cubic-bezier(.34,1.56,.64,1); }
.puck.leaving { animation: puck-pop 0.28s ease forwards; }
@keyframes puck-drop {
    0%   { transform: translateY(-14px) scale(1, 0.7); opacity: 0; }
    60%  { transform: translateY(2px) scale(1.02, 0.96); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes puck-pop {
    0%   { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-16px) scale(0.85, 0.7); opacity: 0; }
}

#action-row {
    display: flex;
    justify-content: center;
    gap: 14px;
}
.icon-btn.action {
    width: auto;
    height: 50px;
    border-radius: 25px;
    padding: 0 20px;
    gap: 8px;
    font-size: 17px;
}
.icon-btn.action .action-label {
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
}
.icon-btn.action.warn { color: var(--warn); }
.silo.hint-source .silo-body, .silo.hint-target .silo-body {
    animation: hint-pulse 1s ease-in-out infinite;
}
@keyframes hint-pulse {
    0%, 100% { box-shadow: inset 2px 0 4px rgba(0,0,0,0.35), inset -2px 0 4px rgba(0,0,0,0.35), 0 0 0 3px var(--warn), 0 0 14px var(--warn-glow); }
    50%      { box-shadow: inset 2px 0 4px rgba(0,0,0,0.35), inset -2px 0 4px rgba(0,0,0,0.35), 0 0 0 1px var(--warn), 0 0 4px var(--warn-glow); }
}

/* ════════════════════════ OVERLAYS ════════════════════════ */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(6,7,12,0.72);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 100;
}

.rules-card, .win-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px 26px;
    max-width: 420px;
    width: 100%;
    max-height: 82vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.rules-card h2, .win-card h2 {
    font-family: var(--font-display);
    font-size: 24px;
    margin-bottom: 14px;
}
.rules-card h3 {
    font-family: var(--font-display);
    font-size: 15px;
    margin: 16px 0 6px;
    color: var(--accent);
}
.rules-card p, .rules-card ul { color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.rules-card ul { padding-left: 20px; margin: 4px 0; }
.rules-card address { font-style: normal; color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.legal-sub { font-weight: 600; font-size: 13px; color: var(--text); margin: 14px 0 4px; }
.rules-card a { color: var(--accent); }

.rules-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
}

.win-card { text-align: center; }
.win-card p { color: var(--text-dim); margin-bottom: 20px; }
.win-actions { display: flex; flex-direction: column; gap: 10px; }

#confetti-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    top: 45%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    animation: confetti-burst 0.9s cubic-bezier(.16,.84,.44,1) forwards;
}
@keyframes confetti-burst {
    to {
        transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
        opacity: 0;
    }
}

@media (max-width: 380px) {
    .wordmark h1 { font-size: 34px; }
    .odo-digit { font-size: 22px; }
}

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