:root {
    --horror-dark: #050508;
    --horror-darker: #020203;
    --horror-red: #8b0000;
    --horror-red-bright: #e63946;
    --horror-green: #2a9d8f;
    --horror-yellow: #f4a261;
    --horror-text: #f1faee;
    --horror-muted: #626a7e;
    --glass-bg: rgba(10, 10, 15, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
    cursor: url('https://cdn.custom-cursor.com/db/9681/32/horror-zombie-eye-cursor-32.png'), auto;
}

body {
    background-color: var(--horror-darker);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
}

html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Cinematic Grain Effect */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    background: url(https://grainy-gradients.vercel.app/noise.svg);
    opacity: 0.05;
}

.horror-scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: linear-gradient(to bottom,
            rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    opacity: 0.1;
}

.screen-overlay {
    background: radial-gradient(circle at center, rgba(10, 10, 15, 0.4) 0%, rgba(0, 0, 0, 0.9) 100%);
    backdrop-filter: blur(12px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#main-menu {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(10, 10, 15, 0.9)),
        url('../assets/main_bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Glitch Effect */
.glitch-text {
    position: relative;
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
        -0.025em -0.05em 0 rgba(0, 255, 0, 0.75),
        0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    animation: glitch 500ms infinite;
}

@keyframes glitch {
    0% {
        text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.05em -0.025em 0 rgba(0, 255, 0, 0.75),
            -0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }

    14% {
        text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.05em -0.025em 0 rgba(0, 255, 0, 0.75),
            -0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
    }

    15% {
        text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    49% {
        text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
            0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
            -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    50% {
        text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    99% {
        text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
            0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 -0.05em 0 rgba(0, 0, 255, 0.75);
    }

    100% {
        text-shadow: -0.025em 0 0 rgba(255, 0, 0, 0.75),
            -0.025em -0.025em 0 rgba(0, 255, 0, 0.75),
            -0.025em -0.05em 0 rgba(0, 0, 255, 0.75);
    }
}

/* Scrollbar styling for any scrollable panels */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: var(--horror-red);
    border-radius: 3px;
}

/* Custom UI Elements */
.font-horror {
    font-family: 'Creepster', cursive;
}

.font-hud {
    font-family: 'Orbitron', sans-serif;
}

.font-mono {
    font-family: 'Roboto Mono', monospace;
}

/* Transitions */
.fade-transition {
    transition: opacity 0.5s ease-in-out, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Range Input Styling */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

input[type=range]::-webkit-slider-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--horror-red);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -5px;
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.5);
}

/* HUD Pulse Glow for critical HP */
.hp-critical {
    animation: hp-glow 1s infinite alternate;
}

@keyframes hp-glow {
    from {
        box-shadow: 0 0 5px rgba(230, 57, 70, 0.5);
    }

    to {
        box-shadow: 0 0 20px rgba(230, 57, 70, 0.8);
    }
}

/* Shooting Flash */
#screen-flash.active {
    opacity: 0.15;
    background-color: white;
}

/* Damage Vignette */
.damage-hit {
    box-shadow: inset 0 0 80px rgba(230, 57, 70, 0.8) !important;
    opacity: 1 !important;
}

/* CRT Screen Effect Overlay */
.crt::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

/* Enhanced Crosshair Styling */
#crosshair {
    pointer-events: none;
    z-index: 1000;
}

#crosshair>div {
    pointer-events: none;
}

/* Crosshair center dot with glow */
#crosshair .bg-horror-red {
    box-shadow: 0 0 8px rgba(230, 57, 70, 0.8), 0 0 15px rgba(230, 57, 70, 0.4);
}

/* Hit marker animation */
#hit-marker {
    pointer-events: none;
    z-index: 999;
}

#hit-marker.show {
    opacity: 1 !important;
    transform: scale(1) !important;
}

.menu-button {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    color: var(--horror-text);
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 0.2rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    border-radius: 4px;
}

.menu-button:hover {
    background: rgba(230, 57, 70, 0.15);
    border-color: var(--horror-red-bright);
    color: var(--horror-red-bright);
    box-shadow: 0 0 30px rgba(230, 57, 70, 0.4), inset 0 0 10px rgba(230, 57, 70, 0.2);
    transform: scale(1.02) translateX(5px);
    letter-spacing: 0.3rem;
}

.menu-button::after {
    content: '[';
    position: absolute;
    left: 10px;
    opacity: 0;
    transition: 0.3s;
}

.menu-button:hover::after {
    opacity: 1;
    left: 20px;
}

.menu-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent);
    transition: 0.5s;
}

.menu-button:hover::before {
    left: 100%;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: 12px;
}

/* Virtual Controls Styling */
#virtual-controls button {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    cursor: pointer !important;
}

#v-fire {
    animation: fire-pulse 2s infinite;
}

@keyframes fire-pulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(230, 57, 70, 0.4);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 40px rgba(230, 57, 70, 0.7);
        transform: scale(1.05);
    }
}

/* Landscape Mobile Fixes */
@media (max-height: 500px) and (orientation: landscape) {
    .font-horror.text-9xl {
        font-size: 5rem !important;
        line-height: 1 !important;
    }

    .font-horror.text-8xl {
        font-size: 4rem !important;
    }

    .mb-20 {
        margin-bottom: 1.5rem !important;
    }

    .mb-16 {
        margin-bottom: 1rem !important;
    }

    .mb-12 {
        margin-bottom: 0.75rem !important;
    }

    .menu-button {
        padding: 0.5rem 1rem !important;
        font-size: 0.75rem !important;
    }

    nav.w-72 {
        width: 14rem !important;
        gap: 0.5rem !important;
    }

    /* Adjust Main Menu Footer */
    #main-menu .absolute.bottom-12 {
        bottom: 1rem !important;
    }

    /* HUD Adjustments */
    #gameplay-hud .absolute.top-6 {
        top: 0.5rem !important;
    }

    #gameplay-hud .absolute.top-8 {
        top: 0.5rem !important;
        right: 0.5rem !important;
    }

    #hud-ammo-current {
        font-size: 3rem !important;
    }

    #hud-wave-num {
        font-size: 1.5rem !important;
    }

    /* Virtual Controls position for landscape */
    #virtual-controls .bottom-12 {
        bottom: 1rem !important;
    }

    #virtual-controls .left-12 {
        left: 1rem !important;
    }

    #virtual-controls .right-12 {
        right: 1rem !important;
    }

    /* Panels scaling */
    .glass-panel.p-8 {
        padding: 1rem !important;
    }
}

/* Base Responsive */
@media (max-width: 640px) {
    .font-horror.text-9xl {
        font-size: 6rem;
    }

    #hud-hp-bar-container {
        width: 150px !important;
    }
}