/* Base styles and resets */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-dark: #0a0a0a;
    --secondary-dark: #1a1a1a;
    --accent-color: #ff3300;
    --text-color: #ff8866;
    --danger-color: #ff0000;
    --safe-color: #00ff00;
    --warning-color: #ffff00;
    --ui-background: rgba(10, 0, 0, 0.8);
    --ui-border: 1px solid rgba(255, 0, 0, 0.6);
    --ui-glow: 0 0 10px rgba(255, 0, 0, 0.3);
}

@font-face {
    font-family: 'HorrorFont';
    src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.woff2') format('woff2');
}

body, html {
    width: 100%;
    height: 100%;
    overflow: auto; /* Changed from hidden to allow scrolling if needed */
    font-family: 'Courier New', monospace;
    background-color: var(--primary-dark);
    color: var(--text-color);
    user-select: none;
}

/* Game container */
.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1; /* Set explicit z-index */
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-color: var(--primary-dark); /* Ensure there's a background */
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: none;
    background-color: var(--primary-dark); /* Ensure canvas has a background */
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none; /* Ensure it doesn't block interaction */
}

/* Timer */
#timer-container {
    background-color: var(--ui-background);
    border: var(--ui-border);
    border-radius: 5px;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--ui-glow);
}

#timer-display {
    font-size: 28px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 5px rgba(255, 85, 0, 0.7);
    letter-spacing: 2px;
}

#time-label {
    font-size: 10px;
    margin-top: 5px;
    opacity: 0.8;
    letter-spacing: 1px;
}

/* Difficulty indicator */
#difficulty-indicator {
    background-color: var(--ui-background);
    border: var(--ui-border);
    border-radius: 5px;
    padding: 10px 15px;
    box-shadow: var(--ui-glow);
}

.creature-activity {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.activity-label {
    font-size: 10px;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.activity-meter {
    width: 120px;
    height: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

#threat-level {
    height: 100%;
    width: 20%;
    background: linear-gradient(to right, #00ff00, #ffff00, #ff0000);
    border-radius: 10px;
    transition: width 0.5s;
}

/* Battery meter */
/* Minimalist battery indicator */
.battery-minimal {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 6px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 1.5s;
}

/* Show battery when low or when toggling flashlight */
.battery-minimal.show {
    opacity: 0.8;
}

#battery-level-minimal {
    height: 100%;
    width: 100%;
    background: linear-gradient(to right, #ff3300, #ffcc00, #00cc00);
    border-radius: 3px;
    transition: width 0.5s;
}

/* Fade out effect for UI elements */
.fade-out {
    opacity: 0;
    transition: opacity 5s;
}

.fade-out.show {
    opacity: 0.8;
    transition: opacity 0.3s;
}

/* Warning indicator */
#warning-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 0, 0, 0.2);
    border: 2px solid rgba(255, 0, 0, 0.5);
    border-radius: 5px;
    padding: 15px 30px;
    text-align: center;
    animation: pulse 0.5s infinite alternate;
    z-index: 50; /* Ensure it's above other elements */
}

@keyframes pulse {
    from { box-shadow: 0 0 10px rgba(255, 0, 0, 0.5); }
    to { box-shadow: 0 0 20px rgba(255, 0, 0, 0.8); }
}

.warning-text {
    font-size: 24px;
    font-weight: bold;
    color: #ff0000;
    text-shadow: 0 0 5px #ff0000;
}

/* Game messages */
#game-messages {
    position: absolute;
    bottom: 100px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    transition: opacity 0.5s;
    z-index: 20; /* Ensure it's visible */
}

/* Controls reminder */
#controls-reminder {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 12px;
    opacity: 0;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px;
    transition: opacity 0.5s;
}

/* Danger effects */
@keyframes heartbeat {
    0% { filter: brightness(1); }
    50% { filter: brightness(0.9); }
    100% { filter: brightness(1); }
}

.danger-heartbeat {
    animation: heartbeat 1s infinite;
}

/* Vignette overlay */
#vignette-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.7) 100%);
    transition: background 0.5s;
}

/* Scratches overlay */
#scratches-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxkZWZzPjxmaWx0ZXIgaWQ9ImEiIHg9IjAlIiB5PSIwJSIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSI+PGZlVHVyYnVsZW5jZSB0eXBlPSJmcmFjdGFsTm9pc2UiIGJhc2VGcmVxdWVuY3k9Ii4wNSIgbnVtT2N0YXZlcz0iMiIvPjxmZURpZmZ1c2VMaWdodGluZyBsaWdodGluZy1jb2xvcj0iIzgwODA4MCIgc3VyZmFjZVNjYWxlPSIyIi8+PC9maWx0ZXI+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbHRlcj0idXJsKCNhKSIgb3BhY2l0eT0iLjA1Ii8+PC9zdmc+');
    opacity: 0.1;
}

/* Jump scare overlay */
#jump-scare-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background-size: cover;
    background-position: center;
    animation: jumpScare 0.5s;
    pointer-events: none;
}

@keyframes jumpScare {
    0% { opacity: 0; transform: scale(0.8); }
    10% { opacity: 1; transform: scale(1.1); }
    20% { transform: scale(0.9); }
    30% { transform: scale(1.05); }
    40% { transform: scale(0.95); }
    50% { transform: scale(1); }
    100% { opacity: 0; }
}

/* Game over screen */
#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.results-container {
    background-color: var(--secondary-dark);
    border: var(--ui-border);
    border-radius: 10px;
    padding: 30px;
    width: 80%;
    max-width: 500px;
    text-align: center;
    box-shadow: var(--ui-glow);
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

#game-over-title {
    font-size: 36px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--accent-color);
    font-family: 'HorrorFont', 'Courier New', monospace;
    letter-spacing: 2px;
}

#result-message {
    font-size: 18px;
    margin-bottom: 20px;
}

.immersion-note {
    margin-top: 15px;
    font-style: italic;
    opacity: 0.7;
    text-align: center;
    font-size: 14px;
}

.stats-container {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 14px;
    margin-bottom: 5px;
    opacity: 0.7;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
}

#restart-button {
    padding: 12px 30px;
    font-size: 18px;
    background: linear-gradient(to bottom, #ff4400, #aa0000);
    color: var(--text-color);
    border: 1px solid #ff6600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
    text-shadow: 0 0 5px #ff3300;
    position: relative;
    overflow: hidden;
}

#restart-button:hover {
    background: linear-gradient(to bottom, #ff5500, #cc0000);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.7);
    transform: scale(1.05);
}

#restart-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(255, 85, 0, 0.4);
}

#restart-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: skewX(-25deg);
    animation: buttonGlow 3s infinite;
}

/* Start screen */
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.85); /* Adjusted from 0.9 to 0.85 */
    z-index: 1000;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxkZWZzPjxmaWx0ZXIgaWQ9ImEiIHg9IjAlIiB5PSIwJSIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSI+PGZlVHVyYnVsZW5jZSB0eXBlPSJmcmFjdGFsTm9pc2UiIGJhc2VGcmVxdWVuY3k9Ii4wNSIgbnVtT2N0YXZlcz0iMiIvPjxmZURpZmZ1c2VMaWdodGluZyBsaWdodGluZy1jb2xvcj0iIzQ0MjIwMCIgc3VyZmFjZVNjYWxlPSIyIi8+PC9maWx0ZXI+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbHRlcj0idXJsKCNhKSIgb3BhY2l0eT0iLjI1Ii8+PC9zdmc+');
    padding: 20px;
    pointer-events: auto; /* Ensure it can be interacted with */
}

.game-title-container {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 48px;
    font-weight: bold;
    text-shadow: 0 0 20px var(--accent-color);
    font-family: 'HorrorFont', 'Courier New', monospace;
    letter-spacing: 3px;
    margin-bottom: 10px;
    color: var(--accent-color);
}

.subtitle {
    font-size: 20px;
    opacity: 0.8;
    letter-spacing: 5px;
    font-family: 'Courier New', monospace;
    color: #ff6600;
    text-shadow: 0 0 8px #ff3300;
    animation: subtitleFlicker 5s infinite alternate;
}

@keyframes subtitleFlicker {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    52% {
        opacity: 0.8;
    }
    54% {
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    72% {
        opacity: 0.6;
    }
    74% {
        opacity: 1;
    }
    100% {
        opacity: 0.9;
    }
}

.story-container {
    max-width: 600px;
    text-align: center;
    margin-bottom: 30px;
    line-height: 1.6;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
    border: 1px solid rgba(255, 85, 0, 0.3);
}

.difficulty-selector {
    margin-bottom: 30px;
    text-align: center;
}

.selector-label {
    font-size: 14px;
    margin-bottom: 10px;
    opacity: 0.8;
    letter-spacing: 2px;
}

.difficulty-options {
    display: flex;
    gap: 10px;
}

.difficulty-option {
    padding: 8px 20px;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 85, 0, 0.3);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 3px;
}

.difficulty-option:hover {
    background-color: rgba(255, 85, 0, 0.2);
    border-color: rgba(255, 85, 0, 0.6);
}

.difficulty-option.selected {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(255, 85, 0, 0.5);
}

.controls-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    max-width: 600px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-key {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}

.control-action {
    font-size: 14px;
}

#start-button {
    padding: 15px 40px;
    font-size: 20px;
    background: linear-gradient(to bottom, #ff4400, #aa0000);
    color: var(--text-color);
    border: 1px solid #ff6600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    font-weight: bold;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
    text-shadow: 0 0 5px #ff3300;
    position: relative;
    overflow: hidden;
}

#start-button:hover {
    background-color: #ff7730;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 85, 0, 0.4);
}

#start-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(255, 85, 0, 0.4);
}

#start-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: skewX(-25deg);
    animation: buttonGlow 3s infinite;
}

@keyframes buttonGlow {
    0% {
        left: -100%;
    }
    50%, 100% {
        left: 200%;
    }
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.volume-icon {
    font-size: 20px;
}

#volume-slider {
    appearance: none;
    width: 100px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    outline: none;
}

#volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 15px;
    height: 15px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

/* Loading screen - MODIFIED to fix black screen issue */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.85); /* Changed from solid black to semi-transparent */
    z-index: 2000;
    transition: opacity 0.5s; /* Add transition for smooth fade out */
}

.loading-container {
    text-align: center;
}

.loading-container h2 {
    font-size: 24px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    color: #ff0000; /* Adding color for visibility */
    animation: textFlicker 4s infinite alternate;
}

.loading-bar-container {
    width: 300px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 0, 0, 0.3);
}

#loading-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(to right, #aa0000, #ff3300, #ff0000);
    transition: width 0.5s;
    animation: loadingPulse 2s infinite;
}

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

#loading-text {
    font-size: 14px;
    opacity: 0.7;
    color: #ff6666; /* Adding color for visibility */
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Text styling for horror effect */
h1, #game-over-title, .warning-text, #timer-display, .blood-text {
    font-family: 'HorrorFont', 'Courier New', monospace;
    color: #ff0000;
    text-shadow: 
        0 0 10px #ff3300,
        0 0 20px #ff5500,
        0 0 30px #ff0000,
        0 0 40px #aa0000,
        0 0 2px #ffffff;
    letter-spacing: 3px;
    position: relative;
    animation: textFlicker 4s infinite alternate;

}

h1::after, #game-over-title::after, .warning-text::after {
    content: "";
    position: absolute;
    top: 0;
    left: 75%;
    width: 5px;
    height: 0;
    background: linear-gradient(to bottom, rgba(255,0,0,0.8), rgba(128,0,0,0.9));
    border-radius: 0 0 3px 3px;
    animation-delay: 2s;
}

/* Blood dripping animation */
@keyframes bloodDrip {
    0% {
        height: 0;
    }
    20% {
        height: 0;
    }
    30% {
        height: 20px;
    }
    40% {
        height: 30px;
    }
    50% {
        height: 40px;
    }
    80% {
        height: 40px;
        opacity: 1;
    }
    100% {
        height: 40px;
        opacity: 0;
    }
}

/* Text flickering effect */
@keyframes textFlicker {
    0% {
        color: #ff0000;
        text-shadow: 
            0 0 10px #ff3300,
            0 0 20px #ff5500,
            0 0 30px #ff0000,
            0 0 40px #aa0000,
            0 0 2px #ffffff;
    }
    3% {
        color: #990000;
        text-shadow: 
            0 0 5px #ff2200,
            0 0 10px #aa0000;
    }
    6% {
        color: #ff0000;
        text-shadow: 
            0 0 10px #ff3300,
            0 0 20px #ff5500,
            0 0 30px #ff0000,
            0 0 40px #aa0000,
            0 0 2px #ffffff;
    }
    8% {
        color: #770000;
        text-shadow: 
            0 0 3px #aa0000;
    }
    10% {
        color: #ff0000;
        text-shadow: 
            0 0 10px #ff3300,
            0 0 20px #ff5500,
            0 0 30px #ff0000,
            0 0 40px #aa0000,
            0 0 2px #ffffff;
    }
    20% {
        color: #ff0000;
        text-shadow: 
            0 0 10px #ff3300,
            0 0 20px #ff5500,
            0 0 30px #ff0000,
            0 0 40px #aa0000,
            0 0 2px #ffffff;
    }
    22% {
        color: #990000;
        text-shadow: none;
    }
    24% {
        color: #ff0000;
        text-shadow: 
            0 0 10px #ff3300,
            0 0 20px #ff5500,
            0 0 30px #ff0000,
            0 0 40px #aa0000,
            0 0 2px #ffffff;
    }
    75% {
        color: #ff0000;
        text-shadow: 
            0 0 10px #ff3300,
            0 0 20px #ff5500,
            0 0 30px #ff0000,
            0 0 40px #aa0000,
            0 0 2px #ffffff;
    }
    80% {
        color: #aa0000;
        text-shadow: 
            0 0 5px #ff2200,
            0 0 10px #aa0000;
    }
    100% {
        color: #ff0000;
        text-shadow: 
            0 0 10px #ff3300,
            0 0 20px #ff5500,
            0 0 30px #ff0000,
            0 0 40px #aa0000,
            0 0 2px #ffffff;
    }
}

/* Glitch effect for UI elements */
.timer-display, #difficulty-indicator, .results-container {
    position: relative;
    overflow: hidden;
}

.timer-display::before, #difficulty-indicator::before, .results-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 85, 0, 0.3), transparent);
    transform: skewX(-25deg);
    animation: scanLine 5s infinite;
}

@keyframes scanLine {
    0% {
        left: -100%;
    }
    50%, 100% {
        left: 200%;
    }
}

/* Blood splatter effect for background elements */
.game-container::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxkZWZzPjxmaWx0ZXIgaWQ9InNwbGF0dGVyIiB4PSIwJSIgeT0iMCUiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxmZVR1cmJ1bGVuY2UgdHlwZT0iZnJhY3RhbE5vaXNlIiBiYXNlRnJlcXVlbmN5PSIuMSIgbnVtT2N0YXZlcz0iMyIgc2VlZD0iNSIgc3RpdGNoVGlsZXM9InN0aXRjaCIvPjxmZURpc3BsYWNlbWVudE1hcCBpbj0iU291cmNlR3JhcGhpYyIgc2NhbGU9IjUwIi8+PC9maWx0ZXI+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9Im5vbmUiIGZpbHRlcj0idXJsKCNzcGxhdHRlcikiLz48L3N2Zz4=');
    background-size: cover;
    opacity: 0.04;
    z-index: 0;
    pointer-events: none;
}

/* Enhanced UI elements with pulsating effect */
#timer-container, #difficulty-indicator {
    border: 1px solid #ff3300;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    animation: uiPulse 4s infinite alternate;
}

@keyframes uiPulse {
    0% {
        box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    }
}

/* Whisper text effect */
.whisper-text {
    font-style: italic;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9em;
    letter-spacing: 1px;
    text-shadow: none;
    animation: whisperFade 5s infinite alternate;
}

@keyframes whisperFade {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.2;
    }
    100% {
        opacity: 0.6;
    }
}

/* Death message styling */
.death-message {
    margin-top: 20px;
    font-style: italic;
    color: #ff6666;
    font-size: 0.9em;
    opacity: 0.8;
}

/* Danger text */
.danger-text {
    color: #ff0000;
    font-weight: bold;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 0, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 0, 0, 0.7);
}

/* Background container - added to ensure there's visible content */
#background-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-dark);
    z-index: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    h1 {
        font-size: 36px;
    }
    
    .subtitle {
        font-size: 16px;
    }
    
    .controls-info {
        flex-direction: column;
        gap: 10px;
    }
    
    #battery-container {
        padding: 5px 10px;
    }
    
    #battery-meter {
        width: 100px;
    }
    
    #detection-radar {
        width: 120px;
        height: 120px;
    }
    
    .results-container {
        width: 90%;
        padding: 20px;
    }
    
    #timer-container, #difficulty-indicator {
        padding: 8px 12px;
    }
    
    #timer-display {
        font-size: 20px;
    }
    
    .story-container {
        padding: 15px;
        font-size: 14px;
    }
}

/* Additional animations for horror effect */
@keyframes flicker {
    0%, 19.999%, 22%, 62.999%, 64%, 64.999%, 70%, 100% {
        opacity: 0.99;
    }
    20%, 21.999%, 63%, 63.999%, 65%, 69.999% {
        opacity: 0.4;
    }
}

/* Flickering light animation for the entire game when in danger */
.danger-mode {
    animation: flicker 6s infinite;
}

/* Special effects for Halloween mode */
.halloween-mode .blood-text {
    color: #ff6600;
    text-shadow: 
        0 0 10px #ff8800,
        0 0 20px #ff6600,
        0 0 30px #ff4400,
        0 0 40px #ff2200,
        0 0 2px #ffffff;
}

/* Demonic text effect for extreme difficulty */
.nightmare-mode .blood-text {
    font-style: italic;
    color: #cc0000;
    text-shadow: 
        0 0 10px #aa0000,
        0 0 20px #880000,
        0 0 30px #660000,
        0 0 2px #330000;
    animation: demonicPulse 2s infinite alternate;
}

@keyframes demonicPulse {
    0% {
        text-shadow: 
            0 0 10px #aa0000,
            0 0 20px #880000,
            0 0 30px #660000,
            0 0 2px #330000;
    }
    100% {
        text-shadow: 
            0 0 15px #ff0000,
            0 0 25px #cc0000,
            0 0 35px #aa0000,
            0 0 45px #880000,
            0 0 3px #440000;
    }
}

/* Fixes for black screen issue */
/* Force background visibility */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-dark);
    z-index: -1;
}

/* Ensure buttons have proper contrast */
button {
    background-color: var(--accent-color);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Make sure loading screen doesn't block content permanently */
#loading-screen.completed {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-out;
}

/* Fix for darknessOverlay - ensure it doesn't block content completely */
.darkness-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85) !important; /* Use 0.85 instead of 0.98 */
    pointer-events: none;
    z-index: 5;
}

/* Fix for UI being blocked by overlays */
#ui-overlay {
    z-index: 20; /* Ensure UI is above darkness overlay */
}

/* Ensure visibility of controls */
#start-button, #restart-button, .difficulty-option {
    position: relative;
    z-index: 1010; /* Above all overlays */
}

/* Fix for vignette overlay potentially blocking content */
#vignette-overlay {
    pointer-events: none;
    background: radial-gradient(
        ellipse at center, 
        rgba(0, 0, 0, 0) 40%, 
        rgba(0, 0, 0, 0.6) 100%
    );
}

/* Emergency visibility for debugging */
.debug-mode * {
    border: 1px solid rgba(255, 0, 0, 0.3);
}

.debug-mode #loading-screen {
    border: 3px solid #ff0000;
}

/* Make sure start screen is visible */
#start-screen {
    opacity: 1 !important;
    transition: opacity 0.5s;
}

/* Canvas container fix */
#canvas-container {
    background-color: #0a0a0a; /* Ensure there's a background */
}

/* Ensure canvas doesn't have an overlay */
canvas {
    background-color: transparent; /* Remove background from canvas */
}