/* Mobile-First CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    /* Layered background: BG.png on top with CSS gradient fallback for fast loading */
    background: 
        linear-gradient(135deg, rgba(26, 26, 46, 0.6), rgba(22, 33, 62, 0.6), rgba(15, 52, 96, 0.6)), 
        url('BG.png'),
        radial-gradient(ellipse at top, rgba(30, 30, 60, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(15, 25, 45, 0.4) 0%, transparent 50%),
        linear-gradient(180deg, 
            #1a1a2e 0%, 
            #16213e 25%, 
            #0f3460 50%, 
            #0e2954 75%, 
            #0d1b3c 100%
        );
    background-size: cover, cover, 100% 100%, 100% 100%, 100% 100%;
    background-position: center, center, center, center, center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: relative;
    
    /* NUCLEAR OPTION - Maximum mobile webview optimization */
    overscroll-behavior: none !important;
    touch-action: none !important;
    -ms-touch-action: none !important;
    -webkit-touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -ms-user-select: none !important;
    -moz-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Game SVG Container */
svg {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    
    /* Touch optimization */
    touch-action: none !important;
    -webkit-touch-action: none !important;
    -ms-touch-action: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    pointer-events: auto !important;
}

/* Game UI - Score and Timer */
#game-ui {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

#score-display, #timer-display {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid #00ffff;
    border-radius: 15px;
    padding: 10px 20px;
    color: #ffffff;
    font-weight: bold;
    font-size: 1.2em;
    text-shadow: 0 0 10px #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

#score {
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
}

#timer {
    color: #ffff00;
    text-shadow: 0 0 10px #ffff00;
}

#timer.warning {
    color: #ff4444 !important;
    text-shadow: 0 0 15px #ff4444 !important;
    animation: pulse 1s infinite;
}

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

/* Game Overlay - Start/Game Over Screens */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.screen {
    text-align: center;
    color: white;
    max-width: 90%;
    padding: 40px 20px;
}

.screen h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 0 0 20px #00ffff;
    color: #00ffff;
}

.screen p {
    font-size: 1.2em;
    margin-bottom: 30px;
    color: #cccccc;
}

.screen button {
    background: linear-gradient(45deg, #00ffff, #0099cc);
    border: none;
    border-radius: 25px;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(0, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.screen button:hover, .screen button:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 255, 0.6);
    background: linear-gradient(45deg, #00ccff, #0077aa);
}

.screen button:active {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

/* Countdown Display */
#countdown-display {
    margin-top: 30px;
}

#countdown-display h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #ffffff;
    text-shadow: 0 0 15px #00ffff;
}

#countdown-number {
    font-size: 4em;
    font-weight: bold;
    color: #00ffff;
    text-shadow: 0 0 30px #00ffff;
    animation: pulse 1s infinite;
}

/* Blur effect for game over */
.game-blur {
    filter: blur(10px);
    transition: filter 0.5s ease;
}

/* Instructions */
#instructions {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

#instructions span {
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    opacity: 0.8;
    border: 1px solid #555;
    backdrop-filter: blur(5px);
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    #game-ui {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    
    #score-display, #timer-display {
        padding: 8px 15px;
        font-size: 1em;
        border-radius: 12px;
    }
    
    .screen h1 {
        font-size: 2em;
    }
    
    .screen p {
        font-size: 1em;
    }
    
    .screen button {
        padding: 12px 30px;
        font-size: 1.1em;
    }
    
    #instructions span {
        font-size: 0.8em;
        padding: 8px 15px;
    }
}

@media (max-width: 480px) {
    #game-ui {
        top: 5px;
        left: 5px;
        right: 5px;
    }
    
    #score-display, #timer-display {
        padding: 6px 12px;
        font-size: 0.9em;
        border-radius: 10px;
    }
    
    .screen h1 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }
    
    .screen p {
        font-size: 0.9em;
        margin-bottom: 25px;
    }
    
    .screen button {
        padding: 10px 25px;
        font-size: 1em;
    }
    
    #instructions {
        bottom: 20px;
    }
    
    #instructions span {
        font-size: 0.7em;
        padding: 6px 12px;
    }
}

/* Container optimization for mobile webview */
#container {
    touch-action: none !important;
    -webkit-touch-action: none !important;
    -ms-touch-action: none !important;
    -webkit-touch-callout: none !important;
    pointer-events: auto !important;
}

/* High contrast for better visibility */
.hit, .bullseye, .miss {
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
}

/* Enhanced bow and arrow visibility with subtle effects */
#bow {
    filter: drop-shadow(0 0 2px rgba(0, 255, 255, 0.4));
}

.arrow-angle {
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.6));
}

#target {
    filter: drop-shadow(0 0 4px rgba(244, 83, 28, 0.5));
}

/* Subtle bow string glow - much more toned down */
#bow path {
    animation: bowStringGlow 4s ease-in-out infinite alternate;
}

@keyframes bowStringGlow {
    0% { 
        filter: drop-shadow(0 0 1px rgba(0, 255, 255, 0.3));
    }
    100% { 
        filter: drop-shadow(0 0 3px rgba(0, 255, 255, 0.5));
    }
}

/* Loading Screen Styles */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
    color: white;
    max-width: 300px;
    padding: 40px 20px;
}

.loading-content h2 {
    font-size: 1.8em;
    margin-bottom: 30px;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}

.loading-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #00ffff, #0099cc);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.loading-content p {
    font-size: 1em;
    color: #cccccc;
    margin-top: 15px;
}

/* Loading animation */
@keyframes loadingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.loading-content h2 {
    animation: loadingPulse 2s ease-in-out infinite;
}