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

body {
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    background-color: #222;
    color: #fff;
    touch-action: none; /* Prevent browser handling of touch events */
}

/* Game Screens */
.game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.game-screen.active {
    display: flex;
}

/* Loading Screen */
.loading-content {
    text-align: center;
}

.loading-bar {
    width: 300px;
    height: 20px;
    background-color: #333;
    border-radius: 10px;
    margin: 20px auto;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background-color: #ff6600;
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 18px;
    color: #ccc;
}

/* Menu Screen */
.menu-content {
    text-align: center;
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
}

.menu-content h1 {
    font-size: 36px;
    margin-bottom: 40px;
    color: #ff6600;
    text-shadow: 0 0 10px rgba(255, 102, 0, 0.7);
}

.menu-button {
    padding: 15px 40px;
    font-size: 24px;
    background-color: #ff6600;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: rgba(255, 102, 0, 0.5);
    user-select: none;
    outline: none;
}

.menu-button:hover {
    background-color: #ff8533;
    transform: scale(1.05);
}

.menu-button:focus {
    outline: 2px solid white;
}

/* Countdown Screen */
#countdown {
    font-size: 120px;
    font-weight: bold;
    color: #ff6600;
    text-shadow: 0 0 20px rgba(255, 102, 0, 0.9);
}

/* Game Screen */
#hud-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1001; /* Higher than mobile controls */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.hud-section {
    display: flex;
    align-items: center;
}

.left-section {
    justify-content: flex-start;
    flex: 1;
}

.center-section {
    justify-content: center;
    flex: 1;
}

.right-section {
    justify-content: flex-end;
    flex: 1;
}

.hud-element {
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border-radius: 5px;
    margin: 0 5px;
    background-color: rgba(255, 102, 0, 0.8);
    transition: all 0.3s ease;
}

#timer.warning, #missile-count.warning {
    background-color: rgba(255, 0, 0, 0.8);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

#controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    display: flex;
    z-index: 5;
}

#joystick-area {
    flex: 1;
    position: relative;
}

#acceleration-area {
    flex: 1;
    position: relative;
}

/* Game Over Screen */
.game-over-content {
    text-align: center;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 40px;
    border-radius: 10px;
}

.game-over-content h2 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #ff6600;
}

.game-over-content p {
    font-size: 24px;
    margin-bottom: 30px;
}

#final-score {
    font-weight: bold;
    color: #ff6600;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .menu-content h1 {
        font-size: 28px;
    }
    
    .menu-button {
        padding: 15px 40px;
        font-size: 22px;
        min-width: 200px;
        min-height: 60px;
        margin: 15px 0;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
    
    .menu-button.active {
        transform: scale(0.95);
        background-color: #ff8533;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    #countdown {
        font-size: 100px;
    }
    
    #timer, #score {
        font-size: 20px;
    }
    
    #hud-container {
        padding: 10px 5px;
    }
    
    .hud-element {
        font-size: 18px;
        padding: 6px 10px;
        margin: 0 2px;
    }
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    user-select: none;
}

#joystick-container, #buttons-container {
    position: absolute;
    bottom: 0;
    width: 50%;
    height: 100%;
    pointer-events: auto;
    background-color: transparent !important;
}

#joystick-container {
    left: 0;
}

#buttons-container {
    right: 0;
}

#joystick-base {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

#joystick-thumb {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.8);
    left: 30px;
    top: 30px;
    pointer-events: none;
}

#fire-button {
    position: absolute;
    right: 50px;
    bottom: 50px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: rgba(255, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 1px 1px 2px black;
    pointer-events: auto;
    user-select: none;
    transition: transform 0.1s ease, background-color 0.1s ease;
}

.action-button.active {
    transform: scale(0.9);
    background-color: rgba(255, 255, 255, 0.8) !important;
    color: #333 !important;
}

/* Media queries for mobile devices */
@media (max-width: 768px) {
    #fire-button {
        width: 120px;
        height: 120px;
        right: 30px;
        bottom: 30px;
    }
    
    #fire-button div {
        font-size: 40px !important;
    }
    
    #joystick-base {
        width: 120px;
        height: 120px;
    }
    
    #joystick-thumb {
        width: 50px;
        height: 50px;
        left: 35px;
        top: 35px;
    }
    
    /* Mobile HUD adjustments */
    #hud-container {
        padding: 8px 5px;
        flex-wrap: wrap;
        height: auto;
    }
    
    .hud-section {
        flex: 0 0 33.33%;
        padding: 2px;
        box-sizing: border-box;
    }
    
    .hud-element {
        font-size: 16px;
        padding: 5px 8px;
        margin: 0;
        width: 100%;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Ensure the music toggle button doesn't overlap with HUD */
    #music-toggle {
        top: 60px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* Score Popup */
.score-popup {
    position: absolute;
    font-size: 28px;
    font-weight: bold;
    color: #ffcc00;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 204, 0, 0.6);
    z-index: 100;
    pointer-events: none;
    transform: translate(-50%, -50%);
    opacity: 0;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 5px;
    background-color: rgba(0, 0, 0, 0.3);
}

.score-popup.animate {
    animation: popup-animation 1.5s ease-out forwards;
}

.score-popup.multiplier {
    color: #ff3300;
    font-size: 32px;
    text-shadow: 0 0 8px rgba(255, 51, 0, 0.8), 0 0 15px rgba(255, 51, 0, 0.5);
    background-color: rgba(0, 0, 0, 0.5);
}

@keyframes popup-animation {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -80%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -100%) scale(0.8);
        opacity: 0;
    }
}

/* Animation for score change */
.score-change {
    animation: score-pulse 0.3s ease-in-out;
}

@keyframes score-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: #ffcc00;
    }
    100% {
        transform: scale(1);
    }
}

/* Countdown animation */
#countdown.animate {
    animation: countdown-pulse 0.9s ease-in-out;
}

@keyframes countdown-pulse {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    20% {
        transform: scale(1.2);
        opacity: 1;
    }
    80% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

#music-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1000;
}

#music-toggle:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

#music-toggle:active {
    transform: scale(0.95);
}

/* Explosion Effects */
.explosion-flash {
    position: absolute;
    width: 300px;
    height: 300px;
    margin-left: -150px;
    margin-top: -150px;
    background: radial-gradient(
        circle, 
        rgba(255,255,255,1) 0%, 
        rgba(255,220,150,0.9) 30%,
        rgba(255,150,50,0.8) 50%,
        rgba(255,100,0,0) 80%
    );
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.1s ease-out, transform 0.4s ease-out;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 0 50px 20px rgba(255, 150, 0, 0.7);
}

.explosion-shockwave {
    position: absolute;
    width: 120px;
    height: 120px;
    margin-left: -60px;
    margin-top: -60px;
    border: 6px solid rgba(255, 150, 50, 0.8);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    pointer-events: none;
    z-index: 99;
    box-shadow: 0 0 30px 5px rgba(255, 150, 50, 0.5);
}

.explosion-shockwave.secondary {
    border: 4px solid rgba(255, 200, 100, 0.7);
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    box-shadow: 0 0 20px 3px rgba(255, 200, 100, 0.4);
} 