/* Base Reset and Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --neon-cyan: #00ffff;
    --neon-magenta: #ff00ff;
    --neon-green: #00ff00;
    --neon-yellow: #ffff00;
    --neon-red: #ff0044;
    --neon-blue: #0088ff;
    --neon-pink: #ff1493;
    --bg-dark: #000011;
    --text-glow: 0 0 10px currentColor, 0 0 20px currentColor, 0 0 40px currentColor;
    --box-glow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Courier New', 'Consolas', monospace;
    color: var(--neon-cyan);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Game Container */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* HUD Overlay */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
    font-size: 24px;
    text-shadow: var(--text-glow);
}

#score-display {
    font-size: 32px;
    font-weight: bold;
}

#high-score-display {
    font-size: 18px;
    color: var(--neon-magenta);
    text-shadow: 0 0 10px var(--neon-magenta), 0 0 20px var(--neon-magenta);
}

#lives-display {
    display: flex;
    gap: 8px;
}

.life-icon {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid var(--neon-pink);
    filter: drop-shadow(0 0 5px var(--neon-pink));
}

#wave-display {
    font-size: 18px;
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green), 0 0 20px var(--neon-green);
}

/* Screen Overlays */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 17, 0.9);
    z-index: 100;
    backdrop-filter: blur(5px);
}

.screen.active {
    display: flex;
}

.screen-content {
    text-align: center;
    padding: 40px;
    max-width: 500px;
    width: 90%;
}

/* Game Title */
.game-title {
    font-size: 72px;
    font-weight: bold;
    color: var(--neon-cyan);
    text-shadow: var(--text-glow);
    letter-spacing: 10px;
    margin-bottom: 0;
    animation: pulse 2s ease-in-out infinite;
}

.game-subtitle {
    font-size: 48px;
    color: var(--neon-magenta);
    text-shadow: 0 0 10px var(--neon-magenta), 0 0 20px var(--neon-magenta), 0 0 40px var(--neon-magenta);
    letter-spacing: 30px;
    margin-bottom: 40px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        text-shadow: var(--text-glow);
    }
    50% {
        opacity: 0.8;
        text-shadow: 0 0 5px currentColor, 0 0 10px currentColor;
    }
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 30px 0;
}

.menu-btn {
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: inherit;
    font-size: 20px;
    padding: 15px 40px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 3px;
    transition: all 0.2s ease;
    box-shadow: var(--box-glow), inset 0 0 20px rgba(0, 255, 255, 0.1);
}

.menu-btn:hover,
.menu-btn:focus {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan), inset 0 0 30px rgba(0, 255, 255, 0.3);
    transform: scale(1.05);
    outline: none;
}

.menu-btn:active {
    transform: scale(0.98);
}

.high-score-menu {
    margin-top: 40px;
    font-size: 18px;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow), 0 0 20px var(--neon-yellow);
}

.reset-btn {
    background: transparent;
    border: 1px solid var(--neon-red);
    color: var(--neon-red);
    font-family: inherit;
    font-size: 12px;
    padding: 5px 12px;
    margin-left: 15px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s ease;
    vertical-align: middle;
}

.reset-btn:hover {
    background: rgba(255, 0, 68, 0.2);
    box-shadow: 0 0 10px var(--neon-red);
}

.reset-btn:active {
    transform: scale(0.95);
}

/* Share Button */
.share-btn {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 10px var(--neon-green), 0 0 20px var(--neon-green), inset 0 0 20px rgba(0, 255, 0, 0.1);
}

.share-btn:hover,
.share-btn:focus {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 20px var(--neon-green), 0 0 40px var(--neon-green), inset 0 0 30px rgba(0, 255, 0, 0.3);
}

/* How To Play Screen */
.controls-section {
    margin: 25px 0;
    text-align: left;
}

.controls-section h3 {
    color: var(--neon-magenta);
    text-shadow: 0 0 10px var(--neon-magenta);
    margin-bottom: 15px;
    font-size: 16px;
    letter-spacing: 2px;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    font-size: 14px;
}

.key {
    background: rgba(0, 255, 255, 0.2);
    padding: 4px 10px;
    border: 1px solid var(--neon-cyan);
    border-radius: 4px;
    font-size: 12px;
    margin: 0 5px;
}

.score-item {
    padding: 5px 0;
    font-size: 14px;
    color: var(--neon-green);
}

/* Game Over Screen */
.final-score {
    font-size: 36px;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow), 0 0 20px var(--neon-yellow);
    margin: 20px 0;
}

.new-record {
    font-size: 24px;
    color: var(--neon-magenta);
    text-shadow: 0 0 10px var(--neon-magenta), 0 0 20px var(--neon-magenta);
    animation: flash 0.5s ease-in-out infinite;
}

.new-record.hidden {
    display: none;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Touch Controls */
#touch-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 50;
    pointer-events: none;
}

#touch-controls.visible {
    display: flex;
}

#touch-left,
#touch-right {
    display: flex;
    gap: 15px;
    pointer-events: auto;
}

#touch-center {
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

.touch-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-size: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3), inset 0 0 15px rgba(0, 255, 255, 0.1);
    transition: all 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn.small {
    width: 50px;
    height: 50px;
    font-size: 16px;
}

.touch-btn:active,
.touch-btn.active {
    background: rgba(0, 255, 255, 0.4);
    box-shadow: 0 0 20px var(--neon-cyan), inset 0 0 20px rgba(0, 255, 255, 0.3);
    transform: scale(0.95);
}

#touch-fire {
    border-color: var(--neon-red);
    color: var(--neon-red);
    box-shadow: 0 0 10px rgba(255, 0, 68, 0.3), inset 0 0 15px rgba(255, 0, 68, 0.1);
}

#touch-fire:active,
#touch-fire.active {
    background: rgba(255, 0, 68, 0.4);
    box-shadow: 0 0 20px var(--neon-red), inset 0 0 20px rgba(255, 0, 68, 0.3);
}

#touch-thrust {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3), inset 0 0 15px rgba(0, 255, 0, 0.1);
}

#touch-thrust:active,
#touch-thrust.active {
    background: rgba(0, 255, 0, 0.4);
    box-shadow: 0 0 20px var(--neon-green), inset 0 0 20px rgba(0, 255, 0, 0.3);
}

#touch-hyperspace {
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.3), inset 0 0 15px rgba(255, 0, 255, 0.1);
}

#touch-hyperspace:active {
    background: rgba(255, 0, 255, 0.4);
    box-shadow: 0 0 20px var(--neon-magenta), inset 0 0 20px rgba(255, 0, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 48px;
        letter-spacing: 5px;
    }

    .game-subtitle {
        font-size: 32px;
        letter-spacing: 15px;
    }

    #hud {
        font-size: 16px;
        padding: 10px 15px;
    }

    #score-display {
        font-size: 24px;
    }

    #high-score-display,
    #wave-display {
        font-size: 14px;
    }

    .life-icon {
        border-left-width: 7px;
        border-right-width: 7px;
        border-bottom-width: 14px;
    }

    .menu-btn {
        font-size: 16px;
        padding: 12px 30px;
    }

    .screen-content {
        padding: 20px;
    }

    .controls-section h3 {
        font-size: 14px;
    }

    .control-item {
        font-size: 12px;
    }

    .key {
        font-size: 10px;
        padding: 3px 6px;
    }

    .touch-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .touch-btn.small {
        width: 45px;
        height: 45px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 36px;
    }

    .game-subtitle {
        font-size: 24px;
        letter-spacing: 10px;
    }

    #touch-controls {
        padding: 15px;
    }

    .touch-btn {
        width: 55px;
        height: 55px;
        font-size: 20px;
    }

    .touch-btn.small {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }

    #touch-left,
    #touch-right {
        gap: 10px;
    }
}

/* Landscape phone adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    #touch-controls {
        padding: 10px 20px;
    }

    .touch-btn {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }

    .touch-btn.small {
        width: 35px;
        height: 35px;
        font-size: 10px;
    }

    #hud {
        padding: 5px 15px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus styles for keyboard navigation */
.menu-btn:focus-visible {
    outline: 2px solid var(--neon-yellow);
    outline-offset: 4px;
}

/* Hide touch controls on non-touch devices by default */
@media (hover: hover) and (pointer: fine) {
    #touch-controls {
        display: none !important;
    }
}
