/* ============================================================================
 * AIMAIMAIM - GLOBAL STYLESHEET (eine zentrale Datei für alle Seiten)
 * ----------------------------------------------------------------------------
 *  1. Lokale Pixel-Fonts (kein Google Fonts / keine Dritt-Seiten)
 *  2. Basis / Reset (pro Seite via body-Klasse: .page-hub | .page-game | .page-store)
 *  3. Geteilte UI-Bausteine (Karten, Buttons, Animationen, Scrollbar)
 *  4. Spiel-spezifische Styles (Canvas, Retro-Grid, Feedback ...)
 *  5. Index-/Hub-Layout (Sterne, Stadt, Mauer, Menü-Buttons)
 *  6. Footer + Legal-Modal (von js/ui-footer.js injiziert)
 * ========================================================================== */

/* --- 1. FONTS ------------------------------------------------------------- */
@font-face {
    font-display: swap; font-family: 'Press Start 2P'; font-style: normal; font-weight: 400;
    src: url('../assets/fonts/press-start-2p-v16-latin-regular.woff2') format('woff2');
}
@font-face {
    font-display: swap; font-family: 'VT323'; font-style: normal; font-weight: 400;
    src: url('../assets/fonts/vt323-v18-latin-regular.woff2') format('woff2');
}

/* --- 2. BASIS / RESET ----------------------------------------------------- */
* { box-sizing: border-box; }
body {
    background-color: #060913;
    color: #f8fafc;
    font-family: 'VT323', monospace;
    margin: 0;
    user-select: none;
}
::selection { background-color: #ef4444; }
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: #060913; border-left: 4px solid #0f1423; }
::-webkit-scrollbar-thumb { background: #334155; border: 4px solid #060913; }
::-webkit-scrollbar-thumb:hover { background: #475569; }
* { scrollbar-width: auto; scrollbar-color: #334155 #060913; }

/* Spiel-Seiten brauchen Maus + Desktop-Größe */
body.page-game { overflow: hidden; min-width: 1024px; min-height: 700px; }
/* Hub funktioniert auch mobil (Gear-Up soll erreichbar sein) */
body.page-hub  { width: 100vw; height: 100vh; overflow: hidden; }
/* Store darf scrollen */
body.page-store { min-height: 100vh; }

img { image-rendering: pixelated; }

/* --- 3. GETEILTE UI-BAUSTEINE -------------------------------------------- */
.stat-card { background: #0f1423; border: 4px solid #334155; box-shadow: 6px 6px 0px rgba(0,0,0,1); }

.btn-pop { transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer; }
.btn-pop:hover { transform: translateY(-2px); }
.btn-pop:active { transform: translateY(2px) scale(0.97); box-shadow: none !important; }

.game-sel-card {
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border: 4px solid #334155; background: #0f1423; cursor: pointer;
    box-shadow: 4px 4px 0px rgba(0,0,0,1);
}
.game-sel-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0px rgba(0,0,0,1); }
.game-sel-card:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0px rgba(0,0,0,1); }
.game-sel-card.selected-tac { border-color: #10b981; background: #064e3b; }
.game-sel-card.selected-trk { border-color: #d946ef; background: #4a044e; }

input[type="number"], select { border: 4px solid #334155; box-shadow: inset 4px 4px 0px rgba(0,0,0,0.5); outline: none; }

/* --- 4. SPIEL-STYLES ------------------------------------------------------ */
.bg-retro-grid {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.015) 2px, transparent 2px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 2px, transparent 2px);
    background-size: 40px 40px;
    background-position: center center;
}
canvas { cursor: none; background-color: transparent; display: block; image-rendering: pixelated; }

.feedback-text {
    pointer-events: none; position: absolute; font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem; text-transform: uppercase; text-shadow: 2px 2px 0px rgba(0,0,0,1);
    animation: fadeUp 0.6s steps(4) forwards;
}
@keyframes fadeUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-40px) scale(0.8); }
}

.fade-screen { opacity: 0; transform: scale(0.98); transition: opacity 0.3s ease-out, transform 0.3s ease-out; }
.fade-screen.active { opacity: 1; transform: scale(1); }
.overlay-transition { transition: opacity 0.4s ease-in-out; }

@keyframes scaleUpFade {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    40% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); } 10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); } 30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); } 50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); } 70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); } 90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(0px, 0px) rotate(0deg); }
}
@keyframes shakeHeavy {
    0% { transform: translate(3px, 3px) rotate(0deg); } 10% { transform: translate(-3px, -4px) rotate(-2deg); }
    20% { transform: translate(-5px, 0px) rotate(2deg); } 30% { transform: translate(5px, 4px) rotate(0deg); }
    40% { transform: translate(3px, -3px) rotate(2deg); } 50% { transform: translate(-3px, 4px) rotate(-2deg); }
    60% { transform: translate(-5px, 3px) rotate(0deg); } 70% { transform: translate(5px, 3px) rotate(-2deg); }
    80% { transform: translate(-3px, -3px) rotate(2deg); } 90% { transform: translate(3px, 4px) rotate(0deg); }
    100% { transform: translate(0px, 0px) rotate(0deg); }
}
.shake-active { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; }
.shake-heavy { animation: shakeHeavy 0.4s cubic-bezier(.36,.07,.19,.97) both; }

@keyframes t1-tgt { 0%, 45% { transform: translate(-30px, -20px); } 50%, 95% { transform: translate(30px, 20px); } 100% { transform: translate(-30px, -20px); } }
@keyframes t1-ch { 0%, 5% { transform: translate(0px, 0px); border-color: white; } 15%, 40% { transform: translate(-30px, -20px); border-color: #10b981; } 50%, 55% { transform: translate(0px, 0px); border-color: white; } 65%, 90% { transform: translate(30px, 20px); border-color: #10b981; } 100% { transform: translate(0px, 0px); border-color: white; } }
@keyframes t2-tgt { 0% { transform: translate(-60px, 10px); } 100% { transform: translate(60px, 10px); } }
@keyframes t2-ch { 0%, 20% { transform: translate(0px, -20px); border-color: white; } 30%, 80% { transform: translate(20px, 10px); border-color: #10b981; } 100% { transform: translate(60px, 10px); border-color: white; } }
@keyframes t3-tgt { 0%, 20% { transform: translate(-20px, 0px); opacity: 0; } 30%, 80% { transform: translate(-20px, 0px); opacity: 1; } 90%, 100% { transform: translate(-20px, 0px); opacity: 0; } }
@keyframes t3-ch { 0%, 35% { transform: translate(40px, 0px); border-color: white; } 45%, 75% { transform: translate(-20px, 0px); border-color: #10b981; } 85%, 100% { transform: translate(40px, 0px); border-color: white; } }
@keyframes tr1-tgt { 0%, 100% { transform: translateX(-40px); } 50% { transform: translateX(40px); } }
@keyframes tr1-ch { 0%, 10% { transform: translateX(0px); border-color: white; } 15%, 85% { transform: translateX(-40px); border-color: #d946ef; } 50% { transform: translateX(40px); border-color: #d946ef; } 90%, 100% { transform: translateX(0px); border-color: white; } }
@keyframes tr2-tgt { 0%, 100% { transform: translateY(-30px); } 50% { transform: translateY(30px); } }
@keyframes tr2-ch { 0%, 10% { transform: translateY(0px); border-color: white; } 15%, 85% { transform: translateY(-30px); border-color: #d946ef; } 50% { transform: translateY(30px); border-color: #d946ef; } 90%, 100% { transform: translateY(0px); border-color: white; } }
@keyframes tr4-tgt { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(40px, -20px); } 50% { transform: translate(0, 0); } 75% { transform: translate(-40px, 20px); } }
@keyframes tr4-ch { 0%, 10% { transform: translate(0, 0); border-color: white; } 15%, 85% { border-color: #d946ef; } 15%, 100% { transform: translate(0, 0); } 30% { transform: translate(40px, -20px); } 50% { transform: translate(0, 0); } 70% { transform: translate(-40px, 20px); } 90%, 100% { border-color: white; } }

@keyframes move-mouse-straight {
    0%, 15% { left: 0%; transform: translateX(-50%); }
    85%, 100% { left: 100%; transform: translateX(-50%); }
}
.mouse-anim { animation: move-mouse-straight 2.5s infinite ease-in-out; }

.modal-prose h2 { font-family: 'Press Start 2P', cursive; font-size: 1.2rem; margin-bottom: 1.5rem; color: #10b981; }
.modal-prose p { margin-bottom: 1rem; line-height: 1.5; font-size: 1.2rem; }
.modal-prose ul { list-style-type: square; padding-left: 1.5rem; margin-bottom: 1.5rem; font-size: 1.2rem; line-height: 1.5; color: #cbd5e1; }
.modal-prose li { margin-bottom: 0.5rem; }
.modal-prose a { color: #34d399; text-decoration: underline; text-underline-offset: 3px; user-select: text; }
.modal-prose a:hover { color: #6ee7b7; }
.aim-modal__content { user-select: text; }
/* Legal-Texte: Sprachumschalter DE / EN */
.legal-doc[data-show="de"] [data-lang="en"], .legal-doc[data-show="en"] [data-lang="de"] { display: none; }
.legal-lang { display: flex; gap: 0.5rem; margin: -0.25rem 3rem 1.75rem 0; }
.legal-lang button {
    font-family: 'Press Start 2P', cursive; font-size: 9px; letter-spacing: 1px;
    padding: 0.55rem 0.75rem; background: #060913; color: #64748b;
    border: 2px solid #334155; box-shadow: 2px 2px 0 #000; cursor: pointer;
}
.legal-lang button:hover { color: #cbd5e1; }
.legal-doc[data-show="de"] .legal-lang button[data-l="de"],
.legal-doc[data-show="en"] .legal-lang button[data-l="en"] { color: #34d399; border-color: #10b981; }
.legal-note { font-size: 1rem !important; color: #64748b; margin-top: 1.5rem; }
.modal-prose .accent-green { color: #34d399; font-weight: bold; margin-top: 1rem; margin-bottom: 0.5rem; }
.modal-prose .accent-amber { color: #fbbf24; font-weight: bold; margin-top: 1rem; margin-bottom: 0.5rem; }

/* --- 5. INDEX / HUB-LAYOUT ------------------------------------------------ */
.pointer-events-none { pointer-events: none; }
.absolute { position: absolute; }
.relative { position: relative; }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}
.star-twinkle { animation: twinkle 3s infinite ease-in-out; }

#stars-container { inset: 0; z-index: 0; }

.city-bg {
    bottom: calc(max(7.5vh, 62.5px) - 30px);
    left: 0; width: 100%; height: auto; min-height: 220px;
    object-fit: cover; object-position: bottom center; z-index: 0;
    filter: blur(1px) brightness(1.05) contrast(0.9) opacity(0.9);
}
.wall-bg {
    bottom: 0; left: 0; width: 100%; height: 7.5vh; min-height: 62.5px; max-height: 8.75vh;
    object-fit: cover; object-position: top center; z-index: 5;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.content-wrapper {
    position: relative; z-index: 10; display: flex; flex-direction: column;
    align-items: center; justify-content: center; height: 100%; padding: 0 1rem; padding-bottom: 12vh;
}
.logo-mobile { position: absolute; top: 2.5rem; left: 50%; transform: translateX(-50%); width: 7rem; display: block; z-index: 20; }
.logo-desktop { position: absolute; top: 2.5rem; left: 3rem; width: 9rem; z-index: 20; display: none; }
.menu-core-container { display: flex; flex-direction: column; align-items: center; }
.select-title { width: 410px; max-width: 90vw; margin-bottom: 2rem; }
.buttons-container { display: flex; flex-direction: column; gap: 10px; width: 390px; max-width: 90vw; }
.menu-item { position: relative; width: 100%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform 0.1s ease; }
.menu-item:hover { z-index: 10; }
.menu-item .img-normal { position: relative; width: 100%; height: auto; opacity: 1; display: block; transition: opacity 0.15s ease; }
/* Aktiv-Grafik = Normal-Grafik + 3D-Schatten rechts/unten (viewBox 170.99 statt
   169.34). Oben links bündig + gleiche Skalierung -> Rahmen liegt deckungsgleich. */
.menu-item .img-active { position: absolute; top: 0; left: 0; width: calc(100% * 170.99 / 169.34); max-width: none; height: auto; opacity: 0; transition: opacity 0.15s ease; }
.menu-item:hover .img-normal { opacity: 0; }
.menu-item:hover .img-active { opacity: 1; }
.menu-item:active { transform: scale(0.97); }
.menu-item.disabled { cursor: not-allowed; }
.menu-item.disabled:active { transform: none; }
.menu-item.disabled img { width: 100%; height: auto; display: block; opacity: 0.8; }

/* "BETA"-Fähnchen am Warm-Up-Button: Option ist da, aber noch nicht voll
   bewertet. pointer-events:none, damit Hover/Klick des Buttons frei bleiben. */
.beta-badge {
    position: absolute; top: -10px; right: -8px; z-index: 12;
    background: #f59e0b; color: #000;
    font-family: 'Press Start 2P', cursive; font-size: 9px; line-height: 1;
    padding: 5px 7px; border: 2px solid #000; box-shadow: 2px 2px 0 #000;
    transform: rotate(8deg); pointer-events: none; letter-spacing: 1px;
}
.mobile-only { display: block; }
.desktop-only { display: none; }

@media (min-width: 768px) {
    .logo-mobile { display: none; }
    .logo-desktop { display: block; }
    .select-title { width: 650px; margin-bottom: 2.5rem; }
    .buttons-container { width: 600px; gap: 12px; }
    .mobile-only { display: none; }
    .desktop-only { display: block; }
}

/* --- 5b. CITY-SZENE (geteilt, injiziert von js/ui-scene.js) -------------- */
/* Hintergrund-Layer mit Sternen, City und Wall – dieselbe Optik wie der Hub. */
.scene-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.scene-bg #stars-container { position: absolute; }
.scene-bg .city-bg, .scene-bg .wall-bg { position: absolute; }

/* Crossfade des Szenen-Layers beim Betreten */
.scene-fade { opacity: 0; transition: opacity 0.5s ease-in-out; }
.scene-fade.is-in { opacity: 1; }

/* Sanfter Seiten-Einblendung (kein JS nötig – endet immer sichtbar) */
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
body.with-scene { animation: pageIn 0.45s ease-out; }
/* Ausblenden vor dem Verlassen (Back-Pfeil) -> Crossfade-Gefühl */
body.page-out { opacity: 0; transition: opacity 0.28s ease-in; }

/* Overlay-Hintergrund auf Szene-Seiten transparent: die City wird der
   Hintergrund, die Panels (solide Karten) liegen darauf. Hebt bg-zinc-950/80
   und bg-retro-grid auf. */
body.with-scene #overlay { background-color: transparent !important; background-image: none !important; }

/* Overlay offen (Setup/Roadmap/Ergebnis): Spiel-Canvas ausblenden, City zeigen. */
body.with-scene.overlay-open #gameCanvas { opacity: 0; }
/* Overlay zu (aktives Spielen): Szene + Back-Pfeil treten zurück. */
body.with-scene:not(.overlay-open) .scene-bg,
body.with-scene:not(.overlay-open) .scene-back { opacity: 0; pointer-events: none; }
.scene-bg, .scene-back { transition: opacity 0.3s ease; }

/* Auf Szene-Seiten ersetzt der Back-Pfeil das Heim-Logo */
body.with-scene .home-logo { display: none; }

/* CT/T-Figuren: vor der Mauer (z 6), hinter dem Menü; untere 20% abgeschnitten. */
.scene-ct, .scene-t { position: fixed; z-index: 6; pointer-events: none; width: auto; }
.scene-ct { left: 8%; height: 55vh; bottom: -11vh; }    /* vorne links, schaut nach rechts */
.scene-t  { right: 8%; height: 52vh; bottom: -10.4vh; }  /* rechts, schaut nach links */
/* Schmale Screens (Handy hochkant): Figuren kleiner und an die Ränder gerückt,
   damit sie sich nicht überdecken und das Menü frei bleibt. */
@media (max-width: 767px) {
    .scene-ct { left: -12vw; height: 36vh; bottom: -7.2vh; }
    .scene-t  { right: -12vw; height: 34vh; bottom: -6.8vh; }
    .aim-footer { padding: 0.6rem 0.9rem 0.75rem; gap: 0.45rem; flex-direction: column-reverse; align-items: center; }
    .aim-footer__links { gap: 0.9rem; }
    .aim-footer__badge { font-size: 7px; white-space: nowrap; }
    .aim-footer__emoji { font-size: 0.8rem; }
}

/* Gear-Up (Store): Szene am SEITENENDE verankern (nicht fixed), Nachtblau füllt
   durchgängig nach oben -> beim Scrollen steht der Hintergrund korrekt. */
body.page-store { position: relative; }
body.page-store.scene-on { background: #060913; }
body.page-store .scene-bg { position: absolute; top: auto; bottom: 0; height: 60vh; }
body.page-store .scene-ct, body.page-store .scene-t { position: absolute; }
/* Footer fließt ans Ende des Inhalts (erst hinscrollen), wie im Hauptmenü. */
body.page-store .aim-footer { position: static; margin-top: 3rem; }

/* Zurück-Pfeil */
.scene-back {
    position: fixed; top: 1.5rem; left: 1.5rem; z-index: 60;
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: #18181b; color: #f8fafc;
    font-family: 'Press Start 2P', cursive; font-size: 11px; letter-spacing: 1px;
    padding: 0.75rem 1rem; border: 4px solid #000; box-shadow: 4px 4px 0 #000;
    text-decoration: none; cursor: pointer; pointer-events: auto;
    transition: transform 0.1s ease, background 0.15s ease, opacity 0.2s ease;
}
.scene-back:hover { background: #27272a; transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #000; }
.scene-back:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
.scene-back__arrow { width: 0.85em; height: 0.85em; display: inline-block; }

.aim-footer {
    position: fixed; bottom: 0; left: 0; width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 0.9rem 1.25rem; box-sizing: border-box;
    z-index: 100; pointer-events: none;
}
.aim-footer__links { display: flex; gap: 1.25rem; pointer-events: auto; }
.aim-footer__link {
    background: none; border: none; cursor: pointer;
    font-family: 'Press Start 2P', cursive; font-size: 10px; letter-spacing: 0.5px;
    color: #94a3b8; text-shadow: 1px 1px 0 #000; transition: color 0.15s ease;
}
.aim-footer__link:hover { color: #34d399; }
.aim-footer__cookie { display: flex; align-items: center; gap: 0.4rem; opacity: 0.7; pointer-events: auto; }
.aim-footer__emoji { font-size: 1rem; line-height: 1; }
.aim-footer__badge { font-family: 'Press Start 2P', cursive; font-size: 9px; letter-spacing: 0.5px; color: #64748b; text-shadow: 1px 1px 0 #000; }

.aim-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 999;
    display: none; align-items: center; justify-content: center; padding: 1rem;
}
.aim-modal.open { display: flex; }
.aim-modal__box {
    background: #0f1423; border: 4px solid #334155; box-shadow: 8px 8px 0 #000;
    width: 100%; max-width: 42rem; max-height: 80vh; overflow-y: auto; padding: 2rem; position: relative;
}
.aim-modal__close {
    position: absolute; top: 1rem; right: 1rem; background: none; border: none; cursor: pointer;
    font-family: 'Press Start 2P', cursive; font-size: 1.25rem; color: #64748b;
}
.aim-modal__close:hover { color: #fff; }
.aim-modal__content { color: #cbd5e1; font-family: 'VT323', monospace; }

/* --- 6b. HEIM-LOGO (injiziert von js/ui-footer.js, alle Unterseiten) ------ */
/* Oben LINKS wie in index.html. Bewusst position:absolute (NICHT fixed):
   es hat seinen eigenen Platz oben und scrollt mit dem Dokument weg, statt
   ueber dem Inhalt kleben zu bleiben. */
.home-logo {
    position: absolute; top: 1.25rem; left: 1.5rem;
    width: 4.5rem; z-index: 90; display: block; cursor: pointer;
    opacity: 0.85; pointer-events: auto;
    filter: drop-shadow(2px 2px 0 #000);
    transition: opacity 0.2s ease, transform 0.15s ease;
}
.home-logo img { width: 100%; display: block; }
.home-logo:hover { opacity: 1; transform: scale(1.06); transform-origin: top left; }
.home-logo.is-hidden { opacity: 0; pointer-events: none; }
/* In den Stages (Get-Sens & Warm-Up) 15% groesser als auf der Store-Seite. */
body.page-game .home-logo { width: 5.2rem; }
/* Store-Seite: oben Platz fuer das Logo schaffen, damit es den Inhalt nicht
   anschneidet (nur wenn das Logo wirklich injiziert wurde). */
body.page-store.has-home-logo { padding-top: 7rem; }
