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

body {
    font-family: 'Special Elite', cursive;
    background: #000;
    color: #e0e0e0;
    overflow: hidden;
    cursor: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

body.mobile-device {
    cursor: auto;
}

.hidden {
    display: none !important;
}

/* Screens */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0a0a 50%, #0a0a0a 100%);
}

/* Start Screen */
#start-screen {
    background: radial-gradient(ellipse at center, #1a0505 0%, #000 70%);
}

.glitch-container {
    position: relative;
    margin-bottom: 20px;
}

.glitch {
    font-family: 'Creepster', cursive;
    font-size: 6rem;
    color: #ff0000;
    text-shadow: 
        0 0 10px #ff0000,
        0 0 20px #ff0000,
        0 0 40px #ff0000,
        0 0 80px #ff0000;
    animation: glitch 2s infinite;
    letter-spacing: 0.1em;
}

@keyframes glitch {
    0%, 100% { 
        text-shadow: 
            0 0 10px #ff0000,
            0 0 20px #ff0000,
            0 0 40px #ff0000;
        transform: translate(0);
    }
    20% { 
        text-shadow: 
            -2px 0 #00ffff,
            2px 0 #ff00ff;
        transform: translate(-2px, 2px);
    }
    40% { 
        text-shadow: 
            2px 0 #00ffff,
            -2px 0 #ff00ff;
        transform: translate(2px, -2px);
    }
    60% { 
        text-shadow: 
            0 0 10px #ff0000,
            0 0 20px #ff0000;
        transform: translate(-1px, 1px);
    }
    80% { 
        text-shadow: 
            2px 0 #ff00ff,
            -2px 0 #00ffff;
        transform: translate(1px, -1px);
    }
}

.tagline {
    font-size: 1.5rem;
    color: #888;
    margin-bottom: 40px;
    font-style: italic;
    animation: flicker 3s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
    52% { opacity: 0.4; }
    54% { opacity: 0.9; }
    70% { opacity: 0.7; }
    72% { opacity: 1; }
}

.instructions {
    background: rgba(20, 0, 0, 0.8);
    border: 1px solid #330000;
    padding: 30px 50px;
    border-radius: 5px;
    margin-bottom: 40px;
    max-width: 500px;
}

.instructions h3 {
    color: #ff3333;
    margin-bottom: 20px;
    font-size: 1.3rem;
    text-align: center;
}

.instructions ul {
    list-style: none;
    margin-bottom: 20px;
}

.instructions li {
    margin: 10px 0;
    font-size: 1rem;
}

.key {
    background: #220000;
    border: 1px solid #440000;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: monospace;
    color: #ff6666;
    margin-right: 10px;
}

.warning {
    color: #ff4444;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 15px;
    animation: pulse-text 2s infinite;
}

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

.pulse-btn {
    font-family: 'Creepster', cursive;
    font-size: 1.5rem;
    padding: 15px 50px;
    background: linear-gradient(180deg, #440000 0%, #220000 100%);
    border: 2px solid #660000;
    color: #ff3333;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: button-pulse 2s infinite;
}

@keyframes button-pulse {
    0%, 100% { 
        box-shadow: 0 0 10px #ff0000, 0 0 20px #ff000066;
    }
    50% { 
        box-shadow: 0 0 20px #ff0000, 0 0 40px #ff000066;
    }
}

.pulse-btn:hover {
    background: linear-gradient(180deg, #660000 0%, #330000 100%);
    transform: scale(1.05);
    box-shadow: 0 0 30px #ff0000;
}

.headphones {
    margin-top: 30px;
    color: #666;
    font-size: 0.9rem;
}

/* Game UI */
#game-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: rgba(255, 255, 255, 0.5);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    font-family: monospace;
}

#battery-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid #333;
}

#battery-icon {
    font-size: 24px;
}

#battery-bar {
    width: 100px;
    height: 15px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 3px;
    overflow: hidden;
}

#battery-level {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00ff00, #88ff00);
    transition: width 0.3s, background 0.3s;
}

#battery-level.low {
    background: linear-gradient(90deg, #ff0000, #ff4400);
    animation: battery-warning 0.5s infinite;
}

@keyframes battery-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#battery-text {
    font-size: 14px;
    color: #aaa;
    min-width: 40px;
}

/* Inventory */
#inventory {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
}

.inv-slot {
    width: 70px;
    height: 70px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.inv-slot.has-item {
    opacity: 1;
    border-color: #00ff00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.slot-icon {
    font-size: 28px;
    margin-bottom: 5px;
}

.slot-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
}

/* Interaction Prompt */
#interact-prompt {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 30px;
    border-radius: 8px;
    border: 1px solid #444;
    animation: prompt-bounce 1s infinite;
}

@keyframes prompt-bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

.key-prompt {
    background: #222;
    border: 2px solid #555;
    padding: 8px 15px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 18px;
    color: #fff;
}

#interact-text {
    font-size: 16px;
    color: #ccc;
}

/* Message Display */
#message-display {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 15px 40px;
    border-radius: 5px;
    font-size: 18px;
    color: #ffcc00;
    border: 1px solid #444;
    animation: message-fade 0.3s ease;
}

@keyframes message-fade {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Jump Scare Overlay */
#jumpscare-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

#jumpscare-overlay img {
    max-width: 100%;
    max-height: 100%;
    animation: jumpscare-shake 0.1s infinite;
}

@keyframes jumpscare-shake {
    0%, 100% { transform: translate(0, 0) scale(1.1); }
    25% { transform: translate(-10px, 10px) scale(1.15); }
    50% { transform: translate(10px, -10px) scale(1.1); }
    75% { transform: translate(-5px, -5px) scale(1.12); }
}

/* Vignette Effect */
#vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 0%, transparent 40%, rgba(0,0,0,0.8) 100%);
    z-index: 90;
}

/* Static Canvas */
#static-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    opacity: 0;
    z-index: 95;
    mix-blend-mode: overlay;
}

#static-canvas.active {
    opacity: 0.15;
    animation: static-flicker 0.05s infinite;
}

@keyframes static-flicker {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.2; }
}

/* Game Over Screen */
#gameover-screen {
    background: radial-gradient(ellipse at center, #200000 0%, #000 70%);
}

.blood-text {
    font-family: 'Creepster', cursive;
    font-size: 8rem;
    color: #8b0000;
    text-shadow: 
        0 0 10px #ff0000,
        0 0 20px #ff0000,
        0 0 40px #8b0000,
        0 5px 30px #000;
    animation: blood-drip 2s infinite;
    letter-spacing: 0.1em;
}

@keyframes blood-drip {
    0%, 100% { 
        text-shadow: 
            0 0 10px #ff0000,
            0 0 20px #ff0000,
            0 0 40px #8b0000,
            0 5px 30px #000;
    }
    50% { 
        text-shadow: 
            0 0 20px #ff0000,
            0 0 40px #ff0000,
            0 0 60px #8b0000,
            0 10px 40px #000;
    }
}

.death-message {
    font-size: 1.5rem;
    color: #666;
    margin: 30px 0 50px;
}

/* Win Screen */
#win-screen {
    background: radial-gradient(ellipse at center, #001a00 0%, #000 70%);
}

.escape-text {
    font-family: 'Creepster', cursive;
    font-size: 6rem;
    color: #00ff00;
    text-shadow: 
        0 0 10px #00ff00,
        0 0 20px #00ff00,
        0 0 40px #00aa00;
    letter-spacing: 0.1em;
}

.win-message {
    font-size: 1.5rem;
    color: #888;
    margin: 30px 0;
}

#stats {
    background: rgba(0, 50, 0, 0.3);
    padding: 20px 40px;
    border-radius: 10px;
    margin-bottom: 40px;
    border: 1px solid #004400;
}

#stats p {
    font-size: 1.2rem;
    color: #88ff88;
}

/* Loading Screen */
#loading-screen {
    background: #000;
}

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

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #333;
    border-top-color: #ff0000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 1.5rem;
    color: #666;
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Game Container */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

#game-container canvas {
    display: block;
}

/* Fear Effect Overlay */
.fear-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 85;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(139, 0, 0, 0.3) 100%);
    animation: fear-pulse 0.5s infinite;
}

@keyframes fear-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* Minimap */
#minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 200px;
    border: 2px solid #440000;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
}

/* Score Display */
#score-display {
    position: absolute;
    top: 80px;
    left: 20px;
    text-align: left;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid #333;
}

.score-main {
    font-family: 'Creepster', cursive;
    font-size: 1.8rem;
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

#current-score {
    font-size: 2.2rem;
    color: #00ff00;
    text-shadow: 0 0 15px rgba(0, 255, 0, 0.6);
}

.score-multiplier {
    font-size: 1rem;
    color: #ff6600;
    margin-top: 5px;
}

#score-multiplier {
    font-weight: bold;
    color: #ff9900;
}

/* Score popup animation */
.score-popup {
    position: absolute;
    font-family: 'Creepster', cursive;
    font-size: 1.5rem;
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
    animation: score-float 1s ease-out forwards;
    pointer-events: none;
}

@keyframes score-float {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

/* First person crosshair */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    font-family: monospace;
    pointer-events: none;
}

/* =========================
   Mobile Controls
   ========================= */
#mobile-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 150;
}

/* Joystick Zone - Left Half */
#joystick-zone {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 50%;
    height: 50%;
    pointer-events: auto;
    touch-action: none;
}

#joystick-base {
    position: absolute;
    left: 30px;
    bottom: 30px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(255, 0, 0, 0.6);
    border: 2px solid rgba(255, 100, 100, 0.8);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
    transition: transform 0.05s ease-out;
}

/* Look Zone - Right Half */
#look-zone {
    position: absolute;
    right: 0;
    top: 0;
    width: 50%;
    height: 70%;
    pointer-events: auto;
    touch-action: none;
}

/* Mobile Action Buttons */
#mobile-buttons {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.mobile-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid rgba(255, 0, 0, 0.5);
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.3);
    transition: all 0.15s ease;
}

.mobile-btn:active, .mobile-btn.active {
    background: rgba(255, 0, 0, 0.4);
    border-color: rgba(255, 100, 100, 0.8);
    transform: scale(0.95);
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.6);
}

#btn-sprint {
    background: rgba(0, 50, 0, 0.7);
    border-color: rgba(0, 255, 0, 0.5);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
}

#btn-sprint:active, #btn-sprint.active {
    background: rgba(0, 255, 0, 0.4);
    box-shadow: 0 0 25px rgba(0, 255, 0, 0.6);
}

#btn-flashlight {
    background: rgba(80, 60, 0, 0.7);
    border-color: rgba(255, 200, 0, 0.5);
    box-shadow: 0 0 15px rgba(255, 200, 0, 0.3);
}

#btn-flashlight:active {
    background: rgba(255, 200, 0, 0.4);
    box-shadow: 0 0 25px rgba(255, 200, 0, 0.6);
}

#btn-flashlight.off {
    opacity: 0.5;
    border-color: rgba(100, 100, 100, 0.5);
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .glitch {
        font-size: 3rem;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .instructions {
        padding: 20px 25px;
        max-width: 90%;
    }
    
    .instructions li {
        font-size: 0.9rem;
    }
    
    .pulse-btn {
        font-size: 1.2rem;
        padding: 12px 35px;
    }
    
    #battery-container {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
    }
    
    #score-display {
        top: 60px;
        left: 10px;
        padding: 8px 12px;
    }
    
    .score-main {
        font-size: 1.2rem;
    }
    
    #current-score {
        font-size: 1.5rem;
    }
    
    #minimap {
        width: 120px;
        height: 120px;
        bottom: 150px;
        right: 100px;
    }
    
    #inventory {
        bottom: 10px;
        gap: 10px;
    }
    
    .inv-slot {
        width: 50px;
        height: 50px;
    }
    
    .slot-icon {
        font-size: 20px;
    }
    
    .slot-label {
        font-size: 8px;
    }
    
    #interact-prompt {
        bottom: 80px;
        padding: 10px 20px;
    }
    
    .blood-text {
        font-size: 4rem;
    }
    
    .escape-text {
        font-size: 3rem;
    }
}

/* Landscape phone adjustments */
@media (max-height: 500px) {
    #joystick-base {
        width: 100px;
        height: 100px;
        left: 20px;
        bottom: 20px;
    }
    
    #joystick-stick {
        width: 40px;
        height: 40px;
    }
    
    .mobile-btn {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    #mobile-buttons {
        flex-direction: row;
        right: 15px;
        bottom: 15px;
        gap: 10px;
    }
    
    #minimap {
        width: 100px;
        height: 100px;
        top: 10px;
        right: 10px;
        bottom: auto;
    }
}

/* =========================
   Rotate Device Overlay
   ========================= */
#rotate-device {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0a0000 0%, #1a0505 50%, #0a0000 100%);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.rotate-content {
    text-align: center;
    color: #ff4444;
}

.phone-icon {
    font-size: 80px;
    animation: tilt-phone 1.5s ease-in-out infinite;
    display: inline-block;
}

@keyframes tilt-phone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.rotate-arrow {
    font-size: 50px;
    color: #ff6666;
    margin: 20px 0;
    animation: pulse 1s infinite;
}

.rotate-content p {
    font-family: 'Special Elite', cursive;
    font-size: 1.2rem;
    color: #aa6666;
    max-width: 250px;
    margin: 0 auto;
}

/* Show rotate overlay on mobile portrait mode */
@media screen and (max-width: 768px) and (orientation: portrait) {
    #rotate-device {
        display: flex !important;
    }
    
    #start-screen,
    #game-ui,
    #game-container,
    #gameover-screen,
    #win-screen {
        display: none !important;
    }
}

/* Hide rotate overlay in landscape */
@media screen and (orientation: landscape) {
    #rotate-device {
        display: none !important;
    }
}
