@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

:root {
    --neon-cyan: #0ff;
    --neon-pink: #ff0055;
    --neon-green: #39ff14;
    --bg-dark: #05050f;
}

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

body {
    background-color: #020205;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    background-image: 
        linear-gradient(rgba(0, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
}

#game-container {
    position: relative;
    width: 95vw;
    height: calc(95vw * 0.75);
    max-width: 800px;
    max-height: 600px;
    background: var(--bg-dark);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.15), inset 0 0 50px rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 8px;
    overflow: hidden;
    container-type: size; /* Enables Container Queries */
}

@media (min-aspect-ratio: 4/3) {
    #game-container {
        height: 90vh;
        width: calc(90vh * 4 / 3);
    }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

body {
    touch-action: none;
    -webkit-touch-callout: none;
}

#hud {
    position: absolute;
    top: 2.5cqw;
    left: 2.5cqw;
    right: 2.5cqw;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.hud-text {
    font-size: clamp(12px, 2.75cqw, 22px);
    font-weight: 700;
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green), 0 0 10px var(--neon-green);
    background: rgba(0,0,0,0.5);
    padding: clamp(6px, 1.25cqw, 10px) clamp(10px, 1.875cqw, 15px);
    border-radius: 0.625cqw;
    border: 1px solid rgba(57, 255, 20, 0.3);
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 15, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    backdrop-filter: blur(4px);
    padding: 3cqw;
}

#overlay.active {
    opacity: 1;
    visibility: visible;
}

#title {
    font-size: clamp(24px, 8cqw, 64px);
    font-weight: 900;
    margin-bottom: 2.5cqw;
    letter-spacing: 0.75cqw;
    text-transform: uppercase;
    transition: color 0.3s, text-shadow 0.3s;
}

.title-cyan {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
}

.title-pink {
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink), 0 0 20px var(--neon-pink), 0 0 40px var(--neon-pink);
}

#instructions {
    font-size: clamp(11px, 2.25cqw, 18px);
    line-height: 1.6;
    color: #eee;
    margin-bottom: 3.75cqw;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.6);
    padding: clamp(10px, 2.5cqw, 20px);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 0.625cqw;
    max-width: 90%;
}

.key {
    color: var(--neon-cyan);
    font-weight: bold;
    text-shadow: 0 0 5px var(--neon-cyan);
}

#finalScore {
    font-size: clamp(16px, 3.5cqw, 28px);
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink), 0 0 20px var(--neon-pink);
    margin-bottom: 3.75cqw;
    font-weight: bold;
}

.mobile-only {
    display: none;
}

@media (pointer: coarse) {
    #mobile-controls {
        display: flex;
        position: absolute;
        bottom: 4cqw;
        right: 4cqw;
        flex-direction: column;
        gap: 2cqw;
        z-index: 15;
        pointer-events: auto;
    }

    .control-btn {
        width: 10cqw;
        height: 10cqw;
        min-width: 50px;
        min-height: 50px;
        max-width: 80px;
        max-height: 80px;
        border-radius: 50%;
        background: rgba(5, 5, 15, 0.6);
        border: 2px solid var(--neon-cyan);
        color: var(--neon-cyan);
        font-size: clamp(18px, 4cqw, 32px);
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        box-shadow: 0 0 1.25cqw rgba(0, 255, 255, 0.3);
        text-shadow: 0 0 0.625cqw var(--neon-cyan);
        transition: all 0.1s ease;
        outline: none;
        -webkit-tap-highlight-color: transparent;
    }

    .control-btn:active {
        background: var(--neon-cyan);
        color: #000;
        box-shadow: 0 0 20px var(--neon-cyan);
        text-shadow: none;
        transform: scale(0.95);
    }

    #overlay.active ~ #mobile-controls {
        display: none;
    }
}
