@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --neon-cyan: #00fff7;
    --neon-pink: #ff2d78;
    --neon-yellow: #ffe600;
    --deep-space: #04060f;
    --panel-bg: rgba(0, 255, 247, 0.05);
    --glow-cyan: 0 0 10px #00fff7, 0 0 30px #00fff780;
    --glow-pink: 0 0 10px #ff2d78, 0 0 30px #ff2d7880;
}

body {
    background: var(--deep-space);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Share Tech Mono', monospace;
    color: var(--neon-cyan);
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#game-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#hud {
    width: 480px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--neon-cyan);
    border-bottom: none;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    letter-spacing: 2px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-label {
    font-size: 9px;
    color: #00fff780;
    letter-spacing: 3px;
}

.hud-value {
    color: var(--neon-cyan);
    text-shadow: var(--glow-cyan);
    font-weight: 700;
    font-size: 15px;
}

#lives-display {
    display: flex;
    gap: 5px;
}

.life-icon {
    width: 12px;
    height: 12px;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background: var(--neon-pink);
    box-shadow: var(--glow-pink);
    transition: all 0.3s;
}

.life-icon.lost {
    background: #333;
    box-shadow: none;
}

canvas {
    display: block;
    border: 1px solid var(--neon-cyan);
    box-shadow: var(--glow-cyan), inset 0 0 60px rgba(0, 255, 247, 0.03);
    cursor: crosshair;
}

#footer-bar {
    width: 480px;
    display: flex;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--neon-cyan);
    border-top: none;
    font-size: 10px;
    color: #00fff760;
    letter-spacing: 2px;
}

/* Overlay screens */
#overlay {
    position: absolute;
    top: 50px;
    left: 0;
    width: 480px;
    height: 640px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(4, 6, 15, 0.92);
    z-index: 10;
    gap: 24px;
}

#overlay.hidden {
    display: none;
}

.overlay-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 42px;
    font-weight: 900;
    color: var(--neon-cyan);
    text-shadow: var(--glow-cyan);
    letter-spacing: 6px;
    text-align: center;
    line-height: 1.1;
}

.overlay-sub {
    font-size: 12px;
    color: #00fff790;
    letter-spacing: 4px;
    text-align: center;
}

.score-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow), 0 0 30px rgba(255, 230, 0, 0.5);
    letter-spacing: 4px;
}

.btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 4px;
    padding: 14px 40px;
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    cursor: pointer;
    text-shadow: var(--glow-cyan);
    box-shadow: var(--glow-cyan);
    transition: all 0.2s;
    clip-path: polygon(10px 0%, 100% 0%, calc(100% - 10px) 100%, 0% 100%);
}

.btn:hover {
    background: var(--neon-cyan);
    color: var(--deep-space);
    text-shadow: none;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    font-size: 11px;
    color: #00fff770;
    letter-spacing: 2px;
}

.controls-grid span {
    color: var(--neon-pink);
    text-shadow: var(--glow-pink);
}

.divider {
    width: 200px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
}

/* scanline effect */
#overlay::after,
canvas::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 255, 247, 0.015) 2px, rgba(0, 255, 247, 0.015) 4px);
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1 }
    50% { opacity: 0.4 }
}

.blink {
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes levelup {
    0% { transform: scale(1.5); opacity: 1 }
    100% { transform: scale(1); opacity: 0 }
}

#level-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 900;
    color: var(--neon-yellow);
    text-shadow: 0 0 20px var(--neon-yellow);
    pointer-events: none;
    opacity: 0;
    letter-spacing: 6px;
    white-space: nowrap;
    z-index: 20;
}

#level-flash.show {
    animation: levelup 1.5s ease-out forwards;
}

/* ─── MOBILE TOUCH CONTROLS ─── */
#mobile-controls {
    display: none;
    width: 480px;
    height: 130px;
    position: relative;
    background: rgba(0, 255, 247, 0.03);
    border: 1px solid rgba(0, 255, 247, 0.15);
    border-top: none;
}

/* Joystick base */
#joystick-zone {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid rgba(0, 255, 247, 0.3);
    background: rgba(0, 255, 247, 0.05);
    box-shadow: 0 0 20px rgba(0, 255, 247, 0.1), inset 0 0 20px rgba(0, 255, 247, 0.05);
    touch-action: none;
}

/* Cross guides inside joystick */
#joystick-zone::before,
#joystick-zone::after {
    content: '';
    position: absolute;
    background: rgba(0, 255, 247, 0.15);
    border-radius: 1px;
}
#joystick-zone::before {
    width: 1px; height: 80%;
    left: 50%; top: 10%;
    transform: translateX(-50%);
}
#joystick-zone::after {
    width: 80%; height: 1px;
    top: 50%; left: 10%;
    transform: translateY(-50%);
}

/* Joystick thumb/knob */
#joystick-knob {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(0, 255, 247, 0.6), rgba(0, 255, 247, 0.15));
    border: 2px solid var(--neon-cyan);
    box-shadow: var(--glow-cyan);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.1s;
    pointer-events: none;
}

/* Fire button */
#fire-btn {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(255, 45, 120, 0.4), rgba(255, 45, 120, 0.1));
    border: 2px solid var(--neon-pink);
    box-shadow: var(--glow-pink);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    touch-action: none;
    transition: all 0.1s;
}

#fire-btn .fire-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: 900;
    color: var(--neon-pink);
    text-shadow: var(--glow-pink);
    letter-spacing: 2px;
    pointer-events: none;
}

#fire-btn .fire-icon {
    font-size: 22px;
    line-height: 1;
    pointer-events: none;
}

#fire-btn:active,
#fire-btn.firing {
    background: radial-gradient(circle at 35% 35%, rgba(255, 45, 120, 0.8), rgba(255, 45, 120, 0.3));
    box-shadow: 0 0 20px #ff2d78, 0 0 50px #ff2d7880;
    transform: translateY(-50%) scale(0.94);
}

/* Label hints */
.ctrl-hint {
    position: absolute;
    font-size: 9px;
    color: rgba(0, 255, 247, 0.35);
    letter-spacing: 2px;
    font-family: 'Orbitron', sans-serif;
}
#hint-move { bottom: 8px; left: 44px; }
#hint-fire { bottom: 8px; right: 44px; }

/* Show mobile controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls {
        display: block;
    }

    /* Resize canvas area to fit screen better */
    #hud, canvas, #footer-bar, #mobile-controls {
        width: 100vw;
        max-width: 480px;
    }

    canvas {
        width: 100vw !important;
        max-width: 480px !important;
        height: auto !important;
        /* canvas still renders at 480x640, just display-scaled */
    }

    #overlay {
        width: 100vw;
        max-width: 480px;
    }

    body {
        justify-content: flex-start;
        padding-top: 0;
    }

    /* Hide keyboard hint in footer on mobile */
    #footer-bar {
        display: none;
    }

    #game-wrapper {
        width: 100vw;
        max-width: 480px;
    }
}
