/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #00000c;
    overflow: hidden;
    font-family: 'Share Tech Mono', monospace;
    color: #c0ffc0;
    cursor: none;
    user-select: none;
}

#gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
}

/* ===== SCANLINES OVERLAY ===== */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 255, 0, 0.015) 2px,
            rgba(0, 255, 0, 0.015) 4px);
}

/* ===== PULSE FLASH ===== */
#pulseFlash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 8;
    background: radial-gradient(circle, rgba(0, 255, 100, 0.12) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

#pulseFlash.active {
    opacity: 1;
    transition: opacity 0.05s ease-in;
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 20px 30px;
    pointer-events: none;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.8s;
}

#hud.visible {
    opacity: 1;
}

#hudLeft,
#hudRight {
    width: 220px;
}

#hudCenter {
    flex: 1;
    text-align: center;
}

.hud-item {
    margin-bottom: 10px;
}

.hud-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: rgba(0, 255, 100, 0.5);
    display: block;
    margin-bottom: 4px;
}

/* Health pips */
.health-pips {
    display: flex;
    gap: 6px;
}

.pip {
    width: 20px;
    height: 8px;
    border: 1px solid rgba(0, 255, 100, 0.3);
    background: transparent;
    transition: all 0.3s;
}

.pip.active {
    background: #00ff64;
    box-shadow: 0 0 8px rgba(0, 255, 100, 0.6);
}

.pip.lost {
    background: rgba(255, 0, 0, 0.4);
    border-color: rgba(255, 0, 0, 0.5);
}

/* Bars */
.bar-container {
    width: 100%;
    height: 6px;
    background: rgba(0, 255, 100, 0.1);
    border: 1px solid rgba(0, 255, 100, 0.2);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00ff64, #00cc50);
    box-shadow: 0 0 6px rgba(0, 255, 100, 0.4);
    transition: width 0.3s linear;
}

.bar-fill.low {
    background: linear-gradient(90deg, #ff3333, #ff6600);
    box-shadow: 0 0 6px rgba(255, 50, 50, 0.4);
}

.pulse-fill {
    background: linear-gradient(90deg, #3366ff, #00ccff);
    box-shadow: 0 0 6px rgba(0, 150, 255, 0.4);
    transition: width 0.05s linear;
}

#directionHint {
    font-size: 11px;
    letter-spacing: 3px;
    color: rgba(0, 255, 100, 0.35);
}

#distLabel {
    text-align: right;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    background: rgba(0, 0, 12, 0.95);
}

.screen.active {
    display: flex;
}

.title-content,
.screen-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
}

/* Glitch title */
.glitch {
    font-family: 'Orbitron', sans-serif;
    font-size: 72px;
    font-weight: 900;
    color: #00d4ff;
    position: relative;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    animation: glitchAnim 3s infinite;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    color: #9333ea;
    animation: glitch1 2s infinite;
    clip-path: inset(0 0 60% 0);
}

.glitch::after {
    color: #00d4ff;
    animation: glitch2 2.5s infinite;
    clip-path: inset(50% 0 0 0);
}

@keyframes glitchAnim {

    0%,
    95%,
    100% {
        opacity: 1;
    }

    96% {
        opacity: 0.8;
        transform: translateX(-2px);
    }

    97% {
        opacity: 1;
        transform: translateX(2px);
    }
}

@keyframes glitch1 {

    0%,
    90%,
    100% {
        transform: translate(0);
    }

    91% {
        transform: translate(-3px, -1px);
    }

    93% {
        transform: translate(3px, 1px);
    }
}

@keyframes glitch2 {

    0%,
    88%,
    100% {
        transform: translate(0);
    }

    89% {
        transform: translate(2px, 2px);
    }

    92% {
        transform: translate(-2px, -1px);
    }
}

.static-glitch {
    color: #ff0040;
    text-shadow: 0 0 30px rgba(255, 0, 64, 0.7);
    animation: staticGlitch 0.15s infinite;
}

@keyframes staticGlitch {
    0% {
        transform: translate(0);
    }

    25% {
        transform: translate(-2px, 1px);
    }

    50% {
        transform: translate(1px, -2px);
    }

    75% {
        transform: translate(2px, 1px);
    }

    100% {
        transform: translate(-1px, -1px);
    }
}

.subtitle {
    font-size: 14px;
    letter-spacing: 4px;
    color: rgba(0, 212, 255, 0.5);
    margin: 30px 0 40px;
    animation: fadeInUp 1.5s ease-out 0.5s both;
}

.instructions {
    font-size: 12px;
    color: rgba(0, 212, 255, 0.35);
    line-height: 2.2;
    margin-bottom: 40px;
    animation: fadeInUp 1.5s ease-out 1s both;
}

.warning-text {
    color: rgba(255, 150, 0, 0.6) !important;
    margin-top: 10px;
    font-size: 11px;
}

.section-title {
    color: rgba(0, 212, 255, 0.6) !important;
    font-size: 11px;
    letter-spacing: 4px;
    margin-bottom: 4px;
}

.color-hint {
    font-size: 11px;
    text-align: left;
    display: block;
    padding-left: 40px;
    line-height: 1.8;
}

.color-hint.green {
    color: rgba(0, 255, 150, 0.7);
}

.color-hint.grey {
    color: rgba(170, 187, 204, 0.7);
}

.color-hint.red {
    color: rgba(255, 60, 60, 0.7);
}

.color-hint.blue {
    color: rgba(0, 200, 255, 0.7);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Buttons */
.glow-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    letter-spacing: 3px;
    color: #00d4ff;
    background: transparent;
    border: 1px solid rgba(0, 212, 255, 0.3);
    padding: 14px 36px;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s;
    animation: fadeInUp 1.5s ease-out 1.5s both;
    text-transform: uppercase;
}

.glow-btn:hover {
    background: rgba(0, 212, 255, 0.08);
    border-color: #00d4ff;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2), inset 0 0 20px rgba(0, 212, 255, 0.05);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.death-reason {
    font-size: 14px;
    color: rgba(255, 50, 50, 0.6);
    letter-spacing: 3px;
    margin: 30px 0 40px;
}

.win-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 48px;
    font-weight: 700;
    color: #00ff64;
    text-shadow: 0 0 30px rgba(0, 255, 100, 0.5);
    animation: winPulse 2s ease-in-out infinite;
}

@keyframes winPulse {

    0%,
    100% {
        text-shadow: 0 0 30px rgba(0, 255, 100, 0.5);
    }

    50% {
        text-shadow: 0 0 60px rgba(0, 255, 100, 0.8), 0 0 100px rgba(0, 255, 100, 0.3);
    }
}

.win-sub {
    font-size: 14px;
    color: rgba(0, 255, 100, 0.4);
    letter-spacing: 2px;
    margin: 20px 0 40px;
}

/* ===== DAMAGE FLASH ===== */
.damage-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 0, 0, 0.3) 0%, transparent 70%);
    pointer-events: none;
    z-index: 15;
    animation: damageAnim 0.4s ease-out forwards;
}

@keyframes damageAnim {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ===== HUD GLITCH (danger proximity) ===== */
#hud.glitch {
    animation: hudGlitch 0.12s infinite;
}

@keyframes hudGlitch {
    0%   { transform: translate(0); opacity: 1; filter: none; }
    15%  { transform: translate(-2px, 0); opacity: 0.85; filter: hue-rotate(40deg) brightness(1.3); }
    30%  { transform: translate(2px, -1px); opacity: 1; filter: none; }
    50%  { transform: translate(0, 1px); filter: hue-rotate(-25deg); }
    65%  { transform: translate(-1px, 0); opacity: 0.9; filter: brightness(0.8); }
    80%  { transform: translate(1px, 1px); opacity: 1; filter: none; }
    100% { transform: translate(0); opacity: 1; filter: none; }
}

/* ===== CURSOR: visible on screens, hidden in game ===== */
.screen.active {
    cursor: default;
}

.screen.active * {
    cursor: default;
}

.glow-btn {
    cursor: pointer !important;
}

/* ===== POINTER LOCK HINT ===== */
#lockHint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
    text-align: center;
    pointer-events: none;
    display: none;
    background: rgba(0, 0, 0, 0.75);
    padding: 18px 40px;
    border: 1px solid rgba(0, 255, 100, 0.15);
}

#lockHint.visible {
    display: block;
}

#lockHint p {
    font-size: 13px;
    letter-spacing: 4px;
    color: rgba(0, 255, 100, 0.75);
    animation: lockBlink 1.2s ease-in-out infinite;
}

@keyframes lockBlink {
    0%, 100% { opacity: 0.45; }
    50%       { opacity: 1; }
}

/* ===== VIGNETTE (ambient darkness) ===== */
#vignette {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 7;
    background: radial-gradient(ellipse at center,
        transparent 40%,
        rgba(0,0,0,0.55) 80%,
        rgba(0,0,0,0.85) 100%);
}

/* ===== JUMPSCARE ===== */
#jumpscareOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 90;
    pointer-events: none;
    display: none;
}

#jumpscareOverlay.active {
    display: block;
    background: rgba(255, 0, 0, 0.15);
    animation: jumpFlicker 0.1s infinite;
}

@keyframes jumpFlicker {
    0% {
        background: rgba(255, 0, 0, 0.15);
    }

    50% {
        background: rgba(255, 0, 0, 0.4);
    }

    100% {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* ===== PREFERS REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .glitch,
    .glitch::before,
    .glitch::after,
    .static-glitch,
    .win-title {
        animation: none !important;
    }

    #scanlines {
        display: none;
    }

    #pulseFlash {
        transition: none;
    }

    .damage-flash {
        animation-duration: 0.1s;
    }

    #hud.glitch {
        animation: none !important;
    }

    @keyframes lockBlink {
        0%, 100% { opacity: 1; }
    }
}

/* ===== SPACE THEME: Nebula Blobs (menu ambiance) ===== */
.nebula-blob {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(80px);
    opacity: 0.12;
    z-index: 99;
    animation: nebulaFloat 20s ease-in-out infinite alternate;
    transition: opacity 0.8s;
}
.nebula-blob.nb1 {
    width: 450px; height: 450px;
    background: radial-gradient(circle, #00d4ff 0%, transparent 70%);
    top: -10%; left: -5%;
}
.nebula-blob.nb2 {
    width: 350px; height: 350px;
    background: radial-gradient(circle, #9333ea 0%, transparent 70%);
    bottom: -10%; right: -5%;
    animation-delay: -10s;
}
.nebula-blob.hidden {
    opacity: 0 !important;
}
@keyframes nebulaFloat {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(30px, -20px) scale(1.1); }
    100% { transform: translate(-20px, 15px) scale(0.95); }
}