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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #0f0820, #1a0f2e, #2d0a4e);
    background-size: 400% 400%;
    animation: gradientShift 10s ease infinite;
    color: white;
    overflow: hidden;
    height: 100vh;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
}

#starfield {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(2px 2px at 20px 30px, #eee, transparent),
                radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
                radial-gradient(1px 1px at 90px 40px, #fff, transparent),
                radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent);
    background-repeat: repeat;
    background-size: 200px 150px;
    animation: twinkle 8s linear infinite;
    pointer-events: none;
}

@keyframes twinkle {
    from { transform: translateY(0); }
    to { transform: translateY(-150px); }
}

#hud {
    position: absolute;
    top: 15px;
    width: 800px;
    display: flex;
    justify-content: space-between;
    z-index: 10;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

#gameCanvas {
    border: 3px solid #8a2be2;
    border-radius: 12px;
    box-shadow: 
        0 0 30px rgba(138, 43, 226, 0.6),
        inset 0 0 20px rgba(138, 43, 226, 0.1);
    background: linear-gradient(to bottom, #2a0845, #000000);
}

#menu-overlay,
#pause-overlay,
#game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#game-title {
    font-size: 56px;
    background: linear-gradient(45deg, #ff6600, #ffaa00, #ff6600);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
    animation: pulse 2s infinite, gradientShift 3s ease infinite;
    text-align: center;
}

#subtitle {
    font-size: 20px;
    color: #8a2be2;
    margin-bottom: 30px;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 5px #8a2be2; }
    to { text-shadow: 0 0 20px #8a2be2, 0 0 30px #8a2be2; }
}

#menu-text {
    font-size: 28px;
    background: linear-gradient(45deg, #ffff00, #fff, #ffff00);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: blink 1.5s infinite, gradientShift 2s ease infinite;
    margin-bottom: 40px;
}

#instructions {
    text-align: center;
    font-size: 18px;
    color: #cccccc;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #8a2be2;
}

#instructions p {
    margin: 8px 0;
    transition: color 0.3s ease;
}

#instructions p:hover {
    color: #ffaa00;
}

#high-score {
    margin-top: 30px;
    font-size: 20px;
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
}

#pause-overlay h2,
#game-over-overlay h2 {
    font-size: 42px;
    color: #ff4444;
    margin-bottom: 20px;
    animation: pulse 1.5s infinite;
}

#pause-overlay p,
#game-over-overlay p {
    font-size: 20px;
    color: #ffffff;
    margin: 15px 0;
    text-align: center;
}

#score-message {
    font-size: 24px;
    color: #ffaa00;
    text-shadow: 0 0 15px #ffaa00;
    animation: glow 1s ease-in-out infinite alternate;
}

#mobile-controls {
    position: absolute;
    bottom: 30px;
    width: 100%;
    display: none;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 50;
}

#joystick-area {
    position: relative;
    width: 100px;
    height: 100px;
}

#joystick-base {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 4px solid #8a2be2;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.3), rgba(138, 43, 226, 0.1));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(138, 43, 226, 0.4);
}

#joystick-stick {
    position: absolute;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, #8a2be2, #6a1f82);
    border: 2px solid #fff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.1s;
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.8);
}

#fire-button {
    width: 80px;
    height: 80px;
    border: 4px solid #ff6600;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 102, 0, 0.9), rgba(255, 102, 0, 0.6));
    color: white;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 0 20px rgba(255, 102, 0, 0.6);
    transition: all 0.1s ease;
}

#fire-button:active {
    background: radial-gradient(circle, rgba(255, 102, 0, 1), rgba(255, 150, 0, 0.8));
    transform: scale(0.95);
    box-shadow: 0 0 30px rgba(255, 102, 0, 0.9);
}

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

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.4; }
}

/* Enhanced responsive design */
@media (max-width: 900px) {
    #gameCanvas {
        width: 90vw;
        height: auto;
    }
    
    #hud {
        width: 90vw;
        font-size: 16px;
        padding: 8px 15px;
    }
    
    #game-title {
        font-size: 36px;
    }
    
    #subtitle {
        font-size: 16px;
    }
    
    #menu-text {
        font-size: 20px;
    }
    
    #mobile-controls {
        display: flex !important;
    }
}

@media (max-width: 600px) {
    #game-title {
        font-size: 28px;
    }
    
    #subtitle {
        font-size: 14px;
    }
    
    #menu-text {
        font-size: 18px;
    }
    
    #instructions {
        font-size: 14px;
        padding: 15px;
    }
    
    #hud {
        font-size: 14px;
        padding: 6px 10px;
    }
    
    #joystick-base {
        width: 60px;
        height: 60px;
    }
    
    #joystick-stick {
        width: 20px;
        height: 20px;
    }
    
    #fire-button {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}

@media (max-width: 400px) {
    #mobile-controls {
        padding: 0 20px;
    }
    
    #game-title {
        font-size: 24px;
    }
    
    #instructions {
        font-size: 12px;
        padding: 10px;
    }
}