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

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700&family=Exo+2:wght@300;400;600&display=swap');

body {
    font-family: 'Exo 2', sans-serif;
    background: linear-gradient(135deg, #0a0a2a 0%, #1a1a40 50%, #2d2b55 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    /* Simple safe area support */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* Futuristic background effects */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 255, 0.1) 0%, transparent 50%);
    animation: background-pulse 8s ease-in-out infinite;
    z-index: -1;
}

@keyframes background-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Mobile-specific background fixes */
@media (max-width: 768px) {
    /* Simplify animations for mobile performance */
    body::before {
        animation: background-pulse-mobile 8s ease-in-out infinite;
    }
    
    @keyframes background-pulse-mobile {
        0%, 100% { opacity: 0.3; }
        50% { opacity: 0.5; }
    }
    
    /* Ensure proper background rendering on mobile */
    body {
        background-attachment: fixed;
    }
    
    /* Optimize particle effects for mobile */
    .particle {
        animation: float-mobile 6s ease-in-out infinite;
    }
    
    @keyframes float-mobile {
        0%, 100% {
            transform: translateY(0) rotate(0deg);
            opacity: 0.2;
        }
        50% {
            transform: translateY(-15px) rotate(90deg);
            opacity: 0.6;
        }
    }
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: rgba(10, 10, 30, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    width: 100%;
    height: 100%;
    max-width: 360px;
    max-height: 520px;
    background: linear-gradient(to bottom, #001122 0%, #003366 50%, #004488 100%);
    display: block;
}

.score {
    position: absolute;
    top: max(15px, env(safe-area-inset-top, 0px));
    left: max(15px, env(safe-area-inset-left, 0px));
    font-size: 24px;
    font-weight: 600;
    color: #00ffff;
    text-shadow: 
        0 0 10px #00ffff,
        0 0 20px #00ffff,
        0 0 30px #00ffff;
    z-index: 10;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.game-over, .start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    color: #00ffff;
    text-align: center;
    backdrop-filter: blur(5px);
}

.game-over h2, .start-screen h2 {
    font-size: 36px;
    margin-bottom: 25px;
    text-shadow: 
        0 0 10px #00ffff,
        0 0 20px #00ffff;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    letter-spacing: 2px;
    animation: text-glitch 3s ease-in-out infinite;
}

.start-screen p {
    font-size: 18px;
    margin-bottom: 35px;
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff;
    font-weight: 300;
}

button {
    background: linear-gradient(45deg, #00ffff, #ff00ff);
    border: none;
    padding: 18px 35px;
    font-size: 20px;
    font-weight: 600;
    color: #000;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.5),
        0 0 40px rgba(255, 0, 255, 0.3);
    transition: all 0.3s ease;
    font-family: 'Orbitron', monospace;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transform: rotate(45deg);
    animation: button-shine 2s ease-in-out infinite;
}

@keyframes button-shine {
    0% { transform: rotate(45deg) translateX(-100%); }
    100% { transform: rotate(45deg) translateX(100%); }
}

button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.7),
        0 0 60px rgba(255, 0, 255, 0.4);
    background: linear-gradient(45deg, #ff00ff, #00ffff);
}

button:active {
    transform: translateY(0) scale(1);
    box-shadow: 
        0 0 10px rgba(0, 255, 255, 0.5),
        0 0 20px rgba(255, 0, 255, 0.3);
}

#game-over {
    display: none;
}

#start-screen {
    display: flex;
}

@keyframes text-glitch {
    0%, 100% {
        text-shadow: 
            0 0 10px #00ffff,
            0 0 20px #00ffff,
            0 0 30px #00ffff;
        transform: translateX(0);
    }
    33% {
        text-shadow: 
            0 0 15px #ff00ff,
            0 0 25px #ff00ff,
            0 0 35px #ff00ff;
        transform: translateX(2px);
    }
    66% {
        text-shadow: 
            0 0 12px #00ff00,
            0 0 22px #00ff00,
            0 0 32px #00ff00;
        transform: translateX(-2px);
    }
}

/* Futuristic scanlines effect */
.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(0, 255, 255, 0.05) 50%,
        rgba(255, 0, 255, 0.05) 50%
    );
    background-size: 100% 3px;
    z-index: 5;
    pointer-events: none;
    animation: scanlines-move 0.5s linear infinite;
}

@keyframes scanlines-move {
    0% { transform: translateY(0); }
    100% { transform: translateY(3px); }
}

/* Holographic border effect */
.game-container::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 2px solid transparent;
    border-radius: 15px;
    pointer-events: none;
    z-index: 1;
    animation: hologram-border 4s ease-in-out infinite;
}

@keyframes hologram-border {
    0%, 100% {
        border-image: linear-gradient(45deg, #00ffff, #ff00ff, #00ffff) 1;
        box-shadow: 
            0 0 15px rgba(0, 255, 255, 0.6),
            0 0 30px rgba(255, 0, 255, 0.4);
    }
    50% {
        border-image: linear-gradient(45deg, #ff00ff, #00ffff, #ff00ff) 1;
        box-shadow: 
            0 0 25px rgba(255, 0, 255, 0.7),
            0 0 50px rgba(0, 255, 255, 0.5);
    }
}

/* Floating particles effect */
.floating-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.particle {
    position: absolute;
    background: rgba(0, 255, 255, 0.3);
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.3;
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
        opacity: 0.8;
    }
}

/* Digital rain effect (optional) */
.digital-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 95%, rgba(0, 255, 255, 0.1) 100%);
    background-size: 100% 4px;
    animation: digital-rain 0.5s linear infinite;
    pointer-events: none;
    z-index: 3;
}

@keyframes digital-rain {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

/* Retry popup styles */
.retry-popup {
    background: rgba(0, 0, 0, 0.9);
    padding: 25px;
    border-radius: 15px;
    border: 2px solid #ff00ff;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.6);
    text-align: center;
    margin-top: 20px;
    backdrop-filter: blur(10px);
}

.retry-popup h3 {
    color: #00ffff;
    font-size: 20px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px #00ffff;
    font-family: 'Orbitron', monospace;
}

.retry-count {
    font-size: 24px;
    color: #ff00ff;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #ff00ff;
    font-family: 'Orbitron', monospace;
}

.retry-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.retry-buttons button {
    padding: 12px 20px;
    font-size: 16px;
    min-width: 120px;
}

#watch-ad-btn {
    background: linear-gradient(45deg, #ffff00, #ff9900);
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.5);
}

#watch-ad-btn:hover {
    background: linear-gradient(45deg, #ff9900, #ffff00);
    box-shadow: 0 0 30px rgba(255, 255, 0, 0.7);
}

/* Cooldown state for retry popup */
.cooldown-active .retry-popup {
    border-color: #888;
    box-shadow: 0 0 20px rgba(136, 136, 136, 0.4);
}

.cooldown-active .retry-count {
    color: #888;
    text-shadow: none;
}

.cooldown-active #play-again-btn {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Watch Ad button should never look disabled */
#watch-ad-btn {
    /* Ensure it always looks enabled */
    opacity: 1 !important;
    cursor: pointer !important;
}

.cooldown-active #watch-ad-btn {
    /* Even during cooldown, watch ad button should look normal */
    opacity: 1 !important;
    cursor: pointer !important;
}

/* Responsive design */
@media (max-width: 400px) {
    .game-container {
        width: 320px;
        height: 480px;
        margin: 0 20px;
    }
    
    .game-over h2, .start-screen h2 {
        font-size: 28px;
    }
    
    button {
        padding: 15px 25px;
        font-size: 16px;
    }
    
    .retry-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .retry-buttons button {
        min-width: 100%;
    }
}
