@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --neon-cyan: #00f0ff;
    --neon-pink: #ff00aa;
    --neon-purple: #aa00ff;
    --neon-green: #00ff88;
    --neon-red: #ff0044;
    --neon-yellow: #ffee00;
    --neon-orange: #ff8800;
    --bg-dark: #050510;
    --bg-darker: #02020a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    background: #000;
    overflow: hidden;
    font-family: 'Press Start 2P', monospace;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    color: var(--neon-cyan);
    width: 100%;
    height: 100%;
    touch-action: none;
}

.hidden { display: none !important; }

/* ═══ ALLGEMEINE SCREENS ═══ */
.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh; height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══ STARTBILDSCHIRM ═══ */
#startScreen {
    background: radial-gradient(ellipse at center, #0a0a30 0%, #050518 60%, #02020a 100%);
    z-index: 50;
}

#startCanvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

#startContent {
    position: relative;
    z-index: 5;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(16px, 4vh, 40px);
}

#title {
    font-size: clamp(28px, 8vw, 64px);
    color: var(--neon-cyan);
    /* Scharfe dunkle Kontur + enger Schein: klar lesbar statt verwaschen */
    text-shadow:
        2px 0 0 #001820,
        -2px 0 0 #001820,
        0 2px 0 #001820,
        0 -2px 0 #001820,
        0 0 4px rgba(0,240,255,0.9),
        0 0 12px rgba(0,240,255,0.35);
    letter-spacing: clamp(2px, 1vw, 8px);
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

#startHighScore {
    font-size: clamp(10px, 2.5vw, 16px);
    color: var(--neon-yellow);
    text-shadow: 0 0 8px rgba(255,238,0,0.5);
}

#pressStart {
    font-size: clamp(12px, 3vw, 20px);
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink), 0 0 25px rgba(255,0,170,0.5);
    animation: blink 0.8s steps(2) infinite;
    cursor: pointer;
    padding: clamp(8px, 2vw, 16px) clamp(16px, 4vw, 32px);
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.15; }
}

#controls {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.5vh, 12px);
    margin-top: clamp(10px, 2vh, 20px);
}

.ctrl-row {
    font-size: clamp(7px, 1.8vw, 10px);
    color: rgba(0,240,255,0.6);
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 12px);
    justify-content: center;
}

.key {
    display: inline-block;
    border: 1px solid rgba(0,240,255,0.4);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--neon-cyan);
    min-width: 20px;
    text-align: center;
}

/* ═══ SPIELBILDSCHIRM ═══ */
#gameScreen {
    background: #02020a;
    flex-direction: column;
}

#hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 20;
    pointer-events: none;
    padding: clamp(6px, 1.5vh, 12px) clamp(10px, 3vw, 20px);
    padding-top: max(clamp(6px, 1.5vh, 12px), env(safe-area-inset-top));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 1vh, 8px);
}

.hud-top {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 700px;
    gap: clamp(6px, 2vw, 20px);
}

.hud-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(2px, 0.5vh, 4px);
}

.hud-label {
    font-size: clamp(7px, 1.5vw, 9px);
    color: rgba(0,240,255,0.5);
}

.hud-val {
    font-size: clamp(10px, 2.5vw, 14px);
    color: var(--neon-cyan);
}

#hudLives { color: var(--neon-green); }
#hudLevel { color: var(--neon-pink); }
#hudHigh { color: var(--neon-yellow); }
#hudSound { color: rgba(255,255,255,0.5); }

#powerupBar {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 12px);
    font-size: clamp(8px, 2vw, 11px);
}

#powerupName {
    color: var(--neon-green);
    min-width: 80px;
}

#powerupTimer {
    width: clamp(80px, 20vw, 150px);
    height: 6px;
    background: rgba(0,255,136,0.15);
    border: 1px solid rgba(0,255,136,0.4);
    overflow: hidden;
}

#powerupFill {
    height: 100%;
    background: var(--neon-green);
    width: 100%;
    transition: width 0.1s linear;
}

#gameCanvas {
    position: relative;
    z-index: 5;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    touch-action: none;
}

#bossBar {
    position: absolute;
    top: max(clamp(50px, 12vh, 80px), calc(env(safe-area-inset-top) + 50px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    width: clamp(200px, 50vw, 400px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

#bossHealth {
    width: 100%;
    height: 10px;
    background: rgba(255,0,68,0.1);
    border: 1px solid rgba(255,0,68,0.4);
    overflow: hidden;
}

#bossHealthFill {
    height: 100%;
    background: var(--neon-red);
    width: 100%;
    transition: width 0.2s;
}

/* ═══ TOUCH-CONTROLS ═══ */
#touchControls {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 25;
    display: none;
    pointer-events: none;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

#joystick {
    position: absolute;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: max(20px, env(safe-area-inset-left));
    width: clamp(100px, 22vw, 140px);
    height: clamp(100px, 22vw, 140px);
    border-radius: 50%;
    border: 2px solid rgba(0,240,255,0.3);
    background: rgba(0,20,40,0.3);
    pointer-events: auto;
    touch-action: none;
}

#joystickKnob {
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background: rgba(0,240,255,0.4);
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0,240,255,0.5);
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.05s;
    pointer-events: none;
}

#fireButton {
    position: absolute;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
    width: clamp(80px, 18vw, 120px);
    height: clamp(80px, 18vw, 120px);
    border-radius: 50%;
    border: 2px solid rgba(255,0,170,0.5);
    background: rgba(255,0,170,0.15);
    color: var(--neon-pink);
    font-size: clamp(10px, 2.5vw, 14px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    touch-action: none;
    text-shadow: 0 0 8px rgba(255,0,170,0.6);
}

#fireButton:active {
    background: rgba(255,0,170,0.35);
    box-shadow: 0 0 20px rgba(255,0,170,0.4);
}

#pauseBtn {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: max(15px, env(safe-area-inset-right));
    width: clamp(40px, 10vw, 50px);
    height: clamp(40px, 10vw, 50px);
    border: 1px solid rgba(0,240,255,0.4);
    background: rgba(0,20,40,0.4);
    color: var(--neon-cyan);
    font-size: clamp(12px, 3vw, 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    touch-action: none;
    border-radius: 4px;
}

body.touch #touchControls { display: block; }

/* ═══ OVERLAYS ═══ */
.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh; height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
    pointer-events: none;
}

#pauseOverlay {
    background: rgba(0,0,0,0.7);
}

#levelOverlay {
    z-index: 35;
}

.overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(12px, 3vh, 24px);
}

.overlay-content h2 {
    font-size: clamp(24px, 6vw, 48px);
    color: var(--neon-cyan);
    text-shadow: 0 0 12px var(--neon-cyan), 0 0 30px rgba(0,240,255,0.5);
}

#levelOverlay .overlay-content h2 {
    color: var(--neon-yellow);
    text-shadow: 0 0 12px var(--neon-yellow), 0 0 30px rgba(255,238,0,0.5);
    animation: levelShow 1.5s ease forwards;
}

@keyframes levelShow {
    0% { opacity: 0; transform: scale(0.5); }
    15% { opacity: 1; transform: scale(1); }
    80% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.2); }
}

.overlay-content p {
    font-size: clamp(10px, 2.5vw, 16px);
    color: var(--neon-cyan);
    opacity: 0.7;
    animation: blink 1.2s steps(2) infinite;
}

/* ═══ GAME OVER ═══ */
#gameOverScreen {
    background: rgba(0,0,0,0.92);
    z-index: 60;
}

#goTitle {
    font-size: clamp(28px, 7vw, 56px);
    color: var(--neon-red);
    /* Scharfe Kontur + enger Schein statt weichem Leuchten */
    text-shadow:
        2px 0 0 #200008,
        -2px 0 0 #200008,
        0 2px 0 #200008,
        0 -2px 0 #200008,
        0 0 4px rgba(255,0,68,0.9),
        0 0 12px rgba(255,0,68,0.35);
    margin-bottom: clamp(10px, 2vh, 20px);
    animation: goShake 0.5s ease;
}

@keyframes goShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.go-stat {
    font-size: clamp(10px, 2.5vw, 14px);
    color: var(--neon-cyan);
    line-height: 1.8;
}

.go-stat span {
    color: var(--neon-yellow);
}

#goRestart {
    font-size: clamp(10px, 2.5vw, 14px);
    color: var(--neon-green);
    text-shadow: 0 0 8px rgba(0,255,136,0.6);
    margin-top: clamp(16px, 4vh, 32px);
    animation: blink 1s steps(2) infinite;
    cursor: pointer;
    padding: clamp(8px, 2vw, 16px);
}

/* ═══ BESTENLISTE ═══ */
#startScores, #goScores {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 1vh, 8px);
}

.scores-title {
    font-size: clamp(8px, 2vw, 11px);
    color: var(--neon-purple);
    text-shadow: 0 0 8px rgba(170,0,255,0.6);
    letter-spacing: 1px;
}

#startScores ol, #goScores ol {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.5vh, 5px);
    min-width: clamp(160px, 40vw, 240px);
}

#startScores li, #goScores li {
    display: flex;
    justify-content: space-between;
    gap: clamp(10px, 3vw, 24px);
    font-size: clamp(7px, 1.8vw, 10px);
    color: rgba(0,240,255,0.75);
    border-bottom: 1px solid rgba(0,240,255,0.12);
    padding: 2px 4px;
}

#startScores li:first-child .s-score,
#goScores li:first-child .s-score {
    color: var(--neon-yellow);
    text-shadow: 0 0 8px rgba(255,238,0,0.6);
}

.s-level { color: rgba(255,0,170,0.7); }

#goRank {
    font-size: clamp(9px, 2.2vw, 12px);
    color: var(--neon-green);
    text-shadow: 0 0 8px rgba(0,255,136,0.6);
}

/* ═══ SCANLINES ═══ */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(0deg,
        rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
        rgba(0,0,0,0.1) 3px, rgba(0,0,0,0.1) 4px);
    pointer-events: none;
    z-index: 100;
}