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

body {
    font-family: 'Arial', sans-serif;
    background: #1a1a2e;
    color: white;
    overflow: hidden;
    touch-action: none; /* Prevent default touch behaviors */
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: none;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    color: #ff6b6b;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    pointer-events: none;
}

#ui div {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #4ecdc4;
}

#health {
    color: #4ecdc4;
}

#ammo {
    color: #ffd93d;
}

#score {
    color: #ff6b6b;
}

/* Mobile Controls */
#mobileControls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

#leftThumbControls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.control-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid #4ecdc4;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
    pointer-events: auto;
}

.control-btn:active {
    background: rgba(78, 205, 196, 0.3);
    transform: scale(0.95);
}

.control-btn span {
    pointer-events: none;
}

#movementArea {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: 150px;
    pointer-events: auto;
}

#movementJoystick {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #4ecdc4;
    background: rgba(0, 0, 0, 0.6);
    position: relative;
    cursor: pointer;
}

#joystickHandle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4ecdc4;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

#instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    z-index: 100;
    border: 3px solid #4ecdc4;
    max-width: 400px;
}

#instructions h2 {
    color: #4ecdc4;
    margin-bottom: 20px;
    font-size: 24px;
}

#instructions p {
    margin-bottom: 10px;
    font-size: 16px;
    color: #ffd93d;
}

#instructions p:last-child {
    margin-top: 20px;
    color: #ff6b6b;
    font-weight: bold;
    animation: pulse 2s infinite;
}

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

.hidden {
    display: none !important;
}

/* Damage flash effect */
.damage-flash {
    animation: damageFlash 0.3s ease-out;
}

@keyframes damageFlash {
    0% { background-color: rgba(255, 0, 0, 0); }
    50% { background-color: rgba(255, 0, 0, 0.3); }
    100% { background-color: rgba(255, 0, 0, 0); }
}

/* Mute/unmute flash effects */
.muted-flash {
    animation: mutedFlash 0.2s ease-out;
}

.unmuted-flash {
    animation: unmutedFlash 0.2s ease-out;
}

@keyframes mutedFlash {
    0% { background-color: rgba(255, 255, 255, 0); }
    50% { background-color: rgba(255, 255, 255, 0.2); }
    100% { background-color: rgba(255, 255, 255, 0); }
}

@keyframes unmutedFlash {
    0% { background-color: rgba(0, 255, 0, 0); }
    50% { background-color: rgba(0, 255, 0, 0.2); }
    100% { background-color: rgba(0, 255, 0, 0); }
}

/* Mobile/Desktop Detection */
.mobile-only {
    display: none;
}

/* Orientation Warning */
#orientationWarning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

#orientationContent {
    text-align: center;
    color: white;
    padding: 40px;
}

#rotateIcon {
    font-size: 60px;
    margin-bottom: 20px;
    animation: rotatePhone 2s ease-in-out infinite;
}

#orientationContent h2 {
    color: #4ecdc4;
    font-size: 24px;
    margin-bottom: 15px;
}

#orientationContent p {
    color: #ffd93d;
    font-size: 16px;
}

@keyframes rotatePhone {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(15deg); }
    100% { transform: rotate(0deg); }
}

/* Immortality blinking effect */
.immortal-blink {
    animation: immortalBlink 0.3s ease-in-out infinite;
}

@keyframes immortalBlink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* Game Over Screen */
#gameOverScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
}

#fadeOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    opacity: 0;
    animation: fadeIn 1s ease-out forwards;
}

#gameOverContent {
    position: relative;
    text-align: center;
    z-index: 301;
    opacity: 0;
    animation: gameOverAppear 2s ease-out 1s forwards;
}

#gameOverTitle {
    font-size: 120px;
    font-weight: bold;
    color: #ff0000;
    text-shadow: 
        5px 5px 0px #800000,
        10px 10px 0px #400000,
        15px 15px 20px rgba(0,0,0,0.8),
        0 0 30px #ff0000,
        0 0 60px #ff0000;
    margin: 0;
    letter-spacing: 8px;
    transform: perspective(500px) rotateX(20deg);
    animation: bloodDrip 3s ease-in-out infinite;
}

#finalScore {
    font-size: 36px;
    color: #ff6b6b;
    margin: 30px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

#restartHint {
    font-size: 24px;
    color: #ffd93d;
    margin-top: 40px;
    animation: pulse 2s infinite;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 0.9; }
}

@keyframes gameOverAppear {
    from { 
        opacity: 0; 
        transform: scale(0.5) translateY(50px);
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0);
    }
}

@keyframes bloodDrip {
    0% { 
        text-shadow: 
            5px 5px 0px #800000,
            10px 10px 0px #400000,
            15px 15px 20px rgba(0,0,0,0.8),
            0 0 30px #ff0000,
            0 0 60px #ff0000;
    }
    50% { 
        text-shadow: 
            6px 8px 0px #800000,
            12px 16px 0px #400000,
            18px 24px 25px rgba(0,0,0,0.9),
            0 0 40px #ff0000,
            0 0 80px #ff0000;
    }
    100% { 
        text-shadow: 
            5px 5px 0px #800000,
            10px 10px 0px #400000,
            15px 15px 20px rgba(0,0,0,0.8),
            0 0 30px #ff0000,
            0 0 60px #ff0000;
    }
}

/* Mobile Styles */
@media (max-width: 768px), (hover: none) {
    .mobile-only {
        display: block;
    }
    
    #desktopControls {
        display: none;
    }
    
    #crosshair {
        font-size: 16px;
    }
    
    #ui {
        top: 10px;
        left: 10px;
    }
    
    #ui div {
        padding: 8px 12px;
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    #instructions {
        max-width: 320px;
        padding: 20px;
    }
    
    #instructions h2 {
        font-size: 20px;
    }
    
    #instructions p {
        font-size: 14px;
    }
    
    /* Mobile Game Over */
    #gameOverTitle {
        font-size: 60px !important;
        letter-spacing: 4px !important;
    }
    
    #finalScore {
        font-size: 24px !important;
    }
    
    #restartHint {
        font-size: 18px !important;
    }
}

/* Portrait orientation - show rotation warning */
@media (max-width: 768px) and (orientation: portrait) {
    #orientationWarning {
        display: flex !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) and (orientation: landscape) {
    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    #movementArea {
        width: 120px;
        height: 120px;
    }
    
    #joystickHandle {
        width: 30px;
        height: 30px;
    }
    
    #leftThumbControls {
        bottom: 15px;
        left: 15px;
        gap: 10px;
    }
    
    #movementArea {
        bottom: 15px;
        right: 15px;
    }
}