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

body {
    overflow: hidden;
    background: #0a0a0a;
    font-family: 'Fira Code', monospace;
    color: #e0e0e0;
    cursor: crosshair;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* TITLE SCREEN */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #1a0808 0%, #2a1010 30%, #0d0d0d 100%);
}

#title-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 80%, rgba(180, 30, 0, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

#title-content {
    position: relative;
    text-align: center;
    z-index: 1;
}

#game-title {
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: clamp(2rem, 7vw, 5rem);
    color: #cc2200;
    letter-spacing: 0.15em;
    text-shadow: 0 0 40px rgba(200, 30, 0, 0.5), 0 0 80px rgba(200, 30, 0, 0.2);
    line-height: 1.1;
}

#game-subtitle {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: #ff4422;
    letter-spacing: 0.5em;
    margin-top: 0.2em;
    text-shadow: 0 0 30px rgba(255, 60, 20, 0.4);
}

#story-text {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.8rem, 1.8vw, 1.1rem);
    color: #998877;
    margin: 2em auto;
    max-width: 500px;
    line-height: 1.8;
}

#start-btn {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.3em;
    color: #ffcc44;
    background: transparent;
    border: 2px solid #ffcc44;
    padding: 15px 50px;
    cursor: pointer;
    transition: all 0.3s;
    animation: pulse-glow 2s ease-in-out infinite;
}

#start-btn:hover {
    background: rgba(255, 204, 68, 0.15);
    box-shadow: 0 0 30px rgba(255, 204, 68, 0.3);
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 204, 68, 0.2); }
    50% { box-shadow: 0 0 25px rgba(255, 204, 68, 0.4); }
}

#controls-info {
    margin-top: 2em;
    font-size: 0.75rem;
    color: #665544;
    letter-spacing: 0.1em;
}

#controls-info span {
    color: #998877;
    font-weight: 700;
}

#title-footer {
    position: absolute;
    bottom: 20px;
    z-index: 1;
}

#title-footer a {
    color: #443322;
    text-decoration: none;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    transition: color 0.3s;
}

#title-footer a:hover {
    color: #887766;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#hud-left {
    position: absolute;
    top: 20px;
    left: 20px;
}

#status-bar, #stamina-container {
    margin-bottom: 8px;
}

#status-label, #stamina-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: #aa8866;
    margin-bottom: 3px;
}

#health-bar-container, #stamina-bar-container {
    width: 180px;
    height: 8px;
    background: rgba(30, 20, 15, 0.8);
    border: 1px solid #443322;
}

#health-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #cc2200, #ff4422);
    transition: width 0.3s;
}

#stamina-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #2266aa, #44aaff);
    transition: width 0.1s;
}

#hud-right {
    position: absolute;
    top: 20px;
    right: 20px;
    text-align: right;
}

#distance-display {
    font-size: 1rem;
    font-weight: 700;
    color: #ffcc44;
    text-shadow: 0 0 10px rgba(255, 204, 68, 0.3);
    letter-spacing: 0.1em;
}

#compass-container {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

#compass {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #443322;
    background: rgba(20, 15, 10, 0.8);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#compass-needle {
    width: 2px;
    height: 20px;
    background: linear-gradient(180deg, #ffcc44 50%, #443322 50%);
    transform-origin: center center;
    transition: transform 0.2s;
}

#compass-label {
    position: absolute;
    top: 2px;
    font-size: 0.5rem;
    color: #665544;
}

/* Warning overlay */
#warning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: inset 0 0 150px rgba(200, 30, 0, 0.6);
}

#detection-warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

#detection-text {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #ff2200;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    animation: flash-warning 0.5s ease-in-out infinite;
}

@keyframes flash-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#detection-timer {
    font-size: 3rem;
    color: #ff4400;
    font-weight: 900;
    margin-top: 10px;
}

#heartbeat-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(100, 10, 0, 0.3));
    opacity: 0;
}

/* Controls Hint */
#controls-hint {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: rgba(10, 8, 6, 0.9);
    border: 1px solid #443322;
    padding: 20px 30px;
    text-align: center;
    font-size: 0.85rem;
    color: #998877;
    line-height: 2;
    animation: fade-in 0.5s;
}

.key {
    color: #ffcc44;
    font-weight: 700;
}

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

/* Death Screen */
#death-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: rgba(10, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-red 1s;
}

@keyframes fade-red {
    0% { background: rgba(200, 30, 0, 0.8); }
    100% { background: rgba(10, 0, 0, 0.95); }
}

#death-content {
    text-align: center;
}

#death-title {
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: clamp(1.5rem, 4vw, 3rem);
    color: #cc2200;
    text-shadow: 0 0 40px rgba(200, 30, 0, 0.6);
    margin-bottom: 20px;
}

#death-distance {
    color: #887766;
    font-size: 1rem;
    margin-bottom: 30px;
}

#retry-btn, #play-again-btn {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    color: #ffcc44;
    background: transparent;
    border: 2px solid #ffcc44;
    padding: 12px 40px;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s;
}

#retry-btn:hover, #play-again-btn:hover {
    background: rgba(255, 204, 68, 0.15);
    box-shadow: 0 0 30px rgba(255, 204, 68, 0.3);
}

/* Victory Screen */
#victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: rgba(5, 10, 15, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

#victory-content {
    text-align: center;
}

#victory-title {
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    color: #ffcc44;
    text-shadow: 0 0 40px rgba(255, 200, 50, 0.5);
    margin-bottom: 20px;
}

#victory-time {
    color: #aa9966;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

#victory-detail {
    font-family: 'Cinzel', serif;
    font-style: italic;
    color: #776655;
    font-size: 0.95rem;
    margin-bottom: 30px;
    max-width: 400px;
}

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    z-index: 15;
    pointer-events: none;
}

#joystick-area {
    position: absolute;
    bottom: 30px;
    left: 30px;
    pointer-events: all;
}

#joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(30, 25, 20, 0.6);
    border: 2px solid rgba(100, 80, 60, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

#joystick-knob {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(100, 80, 60, 0.6);
    border: 1px solid rgba(150, 120, 90, 0.5);
    transition: transform 0.05s;
}

#mobile-sprint-btn {
    position: absolute;
    bottom: 50px;
    right: 30px;
    pointer-events: all;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    color: #44aaff;
    background: rgba(30, 40, 60, 0.6);
    border: 2px solid rgba(68, 170, 255, 0.4);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    cursor: pointer;
    letter-spacing: 0.05em;
}