body {
    background-color: #020105;
    color: #e5e7eb;
    margin: 0;
    overflow: hidden;
    height: 100vh;
}

/* --- BACKGROUND FX --- */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.6;
}

/* --- CRT OVERLAYS --- */
.scanlines {
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.4) 50%,
            rgba(0, 0, 0, 0.4));
    background-size: 100% 4px;
    animation: scan 1s linear infinite;
    pointer-events: none;
    z-index: 5;
}

.vignette {
    background: radial-gradient(circle, rgba(0, 0, 0, 0) 50%, rgba(5, 5, 16, 0.9) 100%);
    pointer-events: none;
    z-index: 51;
}

.crt-flicker {
    animation: flicker 0.15s infinite;
    pointer-events: none;
}

/* --- GLASS PANEL --- */
.glass-terminal {
    background: var(--cyber-glass);
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    border: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow:
        0 0 40px rgba(139, 92, 246, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

/* Glowing Border Animation */
.glass-terminal::before {
    content: '';
    position: absolute;
    inset: -1px;
    z-index: -1;
    background: linear-gradient(45deg, #00f3ff, transparent, #8b5cf6, transparent);
    border-radius: inherit;
    opacity: 0.5;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
}

/* --- SCROLLBAR --- */
.terminal-scroll::-webkit-scrollbar {
    width: 6px;
}

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

.terminal-scroll::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.terminal-scroll::-webkit-scrollbar-thumb:hover {
    background: #8b5cf6;
}

/* --- TEXT UTILS --- */
.text-glow {
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

.text-glow-purple {
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.cursor-blink {
    display: inline-block;
    width: 8px;
    height: 1.2em;
    background-color: #00f3ff;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* --- STATUS PILLS --- */
.status-pill {
    @apply px-2 py-0.5 rounded text-[10px] font-mono tracking-wider uppercase border border-white/10;
}

.pill-active {
    @apply bg-green-500/10 text-green-400 border-green-500/30;
}

.pill-warn {
    @apply bg-orange-500/10 text-orange-400 border-orange-500/30;
}

.pill-crit {
    @apply bg-red-500/10 text-red-400 border-red-500/30;
}

/* --- VIEW TRANSITIONS --- */
.view-section {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 42rem;
    padding: 1rem;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.view-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -45%);
}

.view-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}

/* --- NEW GLOW & RUNE STYLES --- */
.box-glow {
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.1), inset 0 0 20px rgba(0, 243, 255, 0.05);
}

.rune-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-start;
    opacity: 0;
    transition: opacity 1s ease;
    pointer-events: none;
    position: absolute;
    top: 0.8rem;
    left: 0.8rem;
    z-index: 20;
}

.rune-unit {
    position: relative;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rune-ring-outer {
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    border: 1px solid transparent;
    border-top-color: var(--rune-color);
    border-bottom-color: var(--rune-color);
    opacity: 0.8;
    animation: spin-slow 8s linear infinite;
    box-shadow: 0 0 8px var(--rune-color), inset 0 0 4px var(--rune-color);
}

.rune-ring-inner {
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    border: 1px dotted var(--rune-color);
    opacity: 0.9;
    animation: spin-reverse 6s linear infinite;
    box-shadow: 0 0 4px var(--rune-color);
}

.rune-icon {
    font-size: 0.9rem;
    color: var(--rune-color);
    filter: drop-shadow(0 0 8px var(--rune-color));
    z-index: 10;
}

@keyframes spin-slow {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes spin-reverse {
    100% {
        transform: rotate(-360deg);
    }
}

/* =========================================
   TERMINAL-ONLY GLITCH EFFECT
   Toggle by adding the 'glitch-terminal' class to the .glass-terminal container.
   - Slight jitter via transform with steps() timing
   - Chromatic aberration via text-shadow scoped to terminal content
   - Subtle scanline overlay using ::after
   - Performance: contain: paint; will-change: transform, filter
   - Respects prefers-reduced-motion
   ========================================= */

.glass-terminal.glitch-terminal {
    /* Contain effect to the terminal card bounds */
    position: relative;
    /* ensure ::after overlay anchors correctly */
    contain: paint;
    will-change: transform, filter;

    /* Glitch variables (base) */
    --jitter-amp: 4px;
    --tear-amp: 8px;
    --flicker-alpha: 0.15;

    /* Stronger stepwise jitter + subtle filter flicker */
    animation:
        terminal-jitter-intense 120ms steps(9, end) infinite,
        flicker-crt 1400ms steps(25, end) infinite alternate;
}

/* Spike mode: short, intense bursts increase amplitudes */
.glass-terminal.glitch-terminal.glitch-spike {
    --jitter-amp: 10px;
    --tear-amp: 16px;
    --flicker-alpha: 0.35;
}

/* Chromatic aberration: scoped to terminal content only */
.glass-terminal.glitch-terminal #terminal-body,
.glass-terminal.glitch-terminal #terminal-body * {
    /* Chromatic shift Animation for RGB tear */
    animation: chroma-shift-intense 240ms steps(5, end) infinite;
    text-shadow:
        -1px 0 rgba(0, 243, 255, 0.35),
        1px 0 rgba(139, 92, 246, 0.35);
}

/* Subtle scanline/slice overlay inside terminal only */
.glass-terminal.glitch-terminal::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 30;
    mix-blend-mode: screen;
    opacity: 0.35;
    will-change: transform, opacity, background-position, filter;

    /* Tear bands + scanlines + chroma micro-lines (terminal bounds only) */
    background:
        /* Scanline base */
        repeating-linear-gradient(to bottom,
            rgba(255, 255, 255, 0.03) 0 2px,
            transparent 2px 4px),
        /* Horizontal tear band highlight */
        repeating-linear-gradient(to bottom,
            transparent 0 5px,
            rgba(255, 255, 255, var(--flicker-alpha)) 5px 6px),
        /* Cyan micro-lines */
        repeating-linear-gradient(to bottom,
            rgba(0, 255, 255, 0.08) 0 1px,
            transparent 1px 5px),
        /* Magenta micro-lines */
        repeating-linear-gradient(to bottom,
            rgba(255, 0, 255, 0.08) 2px 3px,
            transparent 3px 7px);

    background-size: 100% 100%, 100% 6px, 100% 7px, 100% 9px;
    background-position: 0 0, 0 0, 0 0, 0 0;

    /* Horizontal tear step-shifts + overlay flicker + slight vertical nudge */
    animation:
        tear-shift-x 220ms steps(7, end) infinite,
        flicker-crt 1200ms steps(20, end) infinite,
        glitch-scan 800ms steps(10, end) infinite;
}

/* Slight jitter (sub-2px to ~1.5px) using short steps for performance */
@keyframes terminal-jitter {
    0% {
        transform: translate(0px, 0px);
    }

    10% {
        transform: translate(1px, -0.5px);
    }

    20% {
        transform: translate(-1.5px, 0.7px);
    }

    30% {
        transform: translate(0.8px, 1px);
    }

    40% {
        transform: translate(-0.6px, -0.8px);
    }

    50% {
        transform: translate(1.2px, 0.5px);
    }

    60% {
        transform: translate(-0.8px, 0.2px);
    }

    70% {
        transform: translate(0.6px, -1px);
    }

    80% {
        transform: translate(1px, 0.8px);
    }

    90% {
        transform: translate(-0.5px, -0.5px);
    }

    100% {
        transform: translate(0px, 0px);
    }
}

/* Gentle vertical nudge for scanline slice feel */
@keyframes glitch-scan {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-1px);
    }

    100% {
        transform: translateY(0);
    }
}

/* Intense terminal jitter using stepwise jumps gated by --jitter-amp */
@keyframes terminal-jitter-intense {
    0% {
        transform: translate(0, 0);
    }

    12% {
        transform: translate(calc(var(--jitter-amp) * 0.20), calc(var(--jitter-amp) * -0.20));
    }

    24% {
        transform: translate(calc(var(--jitter-amp) * -0.60), calc(var(--jitter-amp) * 0.30));
    }

    36% {
        transform: translate(calc(var(--jitter-amp) * 0.50), calc(var(--jitter-amp) * 0.50));
    }

    48% {
        transform: translate(calc(var(--jitter-amp) * -0.30), calc(var(--jitter-amp) * -0.60));
    }

    60% {
        transform: translate(calc(var(--jitter-amp) * 0.80), calc(var(--jitter-amp) * 0.10));
    }

    72% {
        transform: translate(calc(var(--jitter-amp) * -0.40), calc(var(--jitter-amp) * 0.20));
    }

    84% {
        transform: translate(calc(var(--jitter-amp) * 0.30), calc(var(--jitter-amp) * -0.70));
    }

    100% {
        transform: translate(0, 0);
    }
}

/* Chromatic text shadow misalignment with irregular pulses */
@keyframes chroma-shift-intense {
    0% {
        text-shadow:
            -1px 0 rgba(0, 243, 255, 0.30),
            1px 0 rgba(139, 92, 246, 0.30);
    }

    25% {
        text-shadow:
            -2px -1px rgba(0, 243, 255, 0.45),
            2px 1px rgba(139, 92, 246, 0.45);
    }

    50% {
        text-shadow:
            calc(var(--jitter-amp) * -0.30) -1px rgba(0, 243, 255, 0.55),
            calc(var(--jitter-amp) * 0.30) 1px rgba(139, 92, 246, 0.55);
    }

    75% {
        text-shadow:
            -1px 1px rgba(0, 243, 255, 0.35),
            1px -1px rgba(139, 92, 246, 0.35);
    }

    100% {
        text-shadow:
            0 0 rgba(0, 243, 255, 0.30),
            0 0 rgba(139, 92, 246, 0.30);
    }
}

/* Horizontal tear band sideways jump using background-position-x */
@keyframes tear-shift-x {
    0% {
        background-position:
            0 0,
            /* scanline base */
            0 0,
            /* tear band highlight */
            0 0,
            /* cyan lines */
            0 0;
        /* magenta lines */
        transform: translateY(0);
    }

    20% {
        background-position:
            0 0,
            calc(var(--tear-amp) * 0.25) 0,
            calc(var(--tear-amp) * -0.15) 0,
            0 0;
        transform: translateY(-0.5px);
    }

    40% {
        background-position:
            0 0,
            calc(var(--tear-amp) * -0.50) 0,
            calc(var(--tear-amp) * 0.35) 0,
            0 0;
        transform: translateY(0.5px);
    }

    60% {
        background-position:
            0 0,
            calc(var(--tear-amp) * 0.70) 0,
            calc(var(--tear-amp) * -0.25) 0,
            0 0;
        transform: translateY(-0.5px);
    }

    80% {
        background-position:
            0 0,
            calc(var(--tear-amp) * -0.30) 0,
            calc(var(--tear-amp) * 0.20) 0,
            0 0;
        transform: translateY(0.5px);
    }

    100% {
        background-position: 0 0, 0 0, 0 0, 0 0;
        transform: translateY(0);
    }
}

/* Opacity/brightness flicker for overlays and subtle container filter twitch */
@keyframes flicker-crt {
    0% {
        filter: none;
        opacity: 0.28;
    }

    12% {
        filter: brightness(1.03) contrast(1.02);
        opacity: 0.40;
    }

    14% {
        filter: brightness(0.96) contrast(1.05);
        opacity: 0.22;
    }

    50% {
        filter: none;
        opacity: 0.33;
    }

    62% {
        filter: brightness(1.06) contrast(1.03);
        opacity: 0.42;
    }

    64% {
        filter: brightness(0.94) contrast(1.06);
        opacity: 0.20;
    }

    100% {
        filter: none;
        opacity: 0.35;
    }
}

/* Accessibility: honor reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .glass-terminal.glitch-terminal {
        animation: none !important;
        filter: none !important;

        /* Collapse amplitudes for motion safety */
        --jitter-amp: 0px;
        --tear-amp: 0px;
        --flicker-alpha: 0.08;
    }

    .glass-terminal.glitch-terminal #terminal-body,
    .glass-terminal.glitch-terminal #terminal-body * {
        animation: none !important;
        text-shadow: none;
    }

    .glass-terminal.glitch-terminal::after {
        animation: none !important;
        opacity: 0.15;
        filter: none !important;
    }
}

/* =========================================
   DETONATION STATE + PAGE SHAKE (78%)
   ========================================= */

.glass-terminal.glitch-detonate {
    position: relative;
    contain: paint;
    will-change: transform, filter;
    --det-jitter: 18px;
    --det-rotate: 2.6deg;
    --det-skew: 6deg;
    --det-flash: 1;
    animation: detonate-jitter 900ms steps(24, end) both;
    filter: contrast(1.2) saturate(1.1);
    z-index: 40;
    /* keep window controls plausible above ::after overlay if needed */
}

/* Strong chroma split during detonation */
.glass-terminal.glitch-detonate #terminal-body,
.glass-terminal.glitch-detonate #terminal-body * {
    animation: detonate-chroma 900ms steps(24, end) both;
    text-shadow:
        -2px 0 rgba(0, 243, 255, 0.65),
        2px 0 rgba(139, 92, 246, 0.65);
}

.glass-terminal.glitch-detonate::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 55;
    mix-blend-mode: screen;
    opacity: 0.0;
    background:
        radial-gradient(ellipse at center, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.05) 60%, transparent 70%),
        repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 4px);
    animation: detonate-flash 900ms steps(24, end) both;
}

/* Hidden state to remove from layout after detonation */
.glass-terminal.is-hidden {
    display: none !important;
}

/* Full-page violent shake */
body.page-shake {
    animation: page-shake 1100ms steps(22, end) both;
    will-change: transform;
}

/* Keyframes: detonation jitter */
@keyframes detonate-jitter {
    0% {
        transform: translate(0, 0) rotate(0) skew(0, 0);
        opacity: 1;
        filter: none;
    }

    10% {
        transform: translate(var(--det-jitter), calc(var(--det-jitter) * -0.6)) rotate(calc(var(--det-rotate) * -0.8)) skew(var(--det-skew), calc(var(--det-skew) * -0.6));
    }

    20% {
        transform: translate(calc(var(--det-jitter) * -0.9), calc(var(--det-jitter) * 0.5)) rotate(var(--det-rotate)) skew(calc(var(--det-skew) * -0.6), var(--det-skew));
        filter: saturate(1.2) contrast(1.2);
    }

    35% {
        transform: translate(calc(var(--det-jitter) * 0.8), calc(var(--det-jitter) * -1.0)) rotate(calc(var(--det-rotate) * 0.9)) skew(calc(var(--det-skew) * 0.9), calc(var(--det-skew) * -0.8));
    }

    50% {
        transform: translate(calc(var(--det-jitter) * -1.0), calc(var(--det-jitter) * 0.8)) rotate(calc(var(--det-rotate) * -1.0)) skew(calc(var(--det-skew) * -0.8), calc(var(--det-skew) * 0.8));
        opacity: 0.5;
    }

    70% {
        transform: translate(calc(var(--det-jitter) * 0.6), calc(var(--det-jitter) * -0.6)) rotate(calc(var(--det-rotate) * 0.6)) skew(calc(var(--det-skew) * 0.6), calc(var(--det-skew) * -0.6));
    }

    85% {
        transform: translate(calc(var(--det-jitter) * -0.4), calc(var(--det-jitter) * 0.4)) rotate(calc(var(--det-rotate) * -0.4)) skew(calc(var(--det-skew) * -0.4), calc(var(--det-skew) * 0.4));
        opacity: 0.25;
    }

    100% {
        transform: translate(0, 0) rotate(0) skew(0, 0);
        opacity: 0.12;
        filter: blur(0.6px) contrast(1.4) brightness(0.9);
    }
}

/* Keyframes: strong chroma split */
@keyframes detonate-chroma {
    0% {
        text-shadow: -1px 0 rgba(0, 243, 255, 0.5), 1px 0 rgba(139, 92, 246, 0.5);
    }

    30% {
        text-shadow: -3px -1px rgba(0, 243, 255, 0.8), 3px 1px rgba(139, 92, 246, 0.8);
    }

    60% {
        text-shadow: -5px 2px rgba(0, 243, 255, 0.9), 5px -2px rgba(139, 92, 246, 0.9);
    }

    100% {
        text-shadow: 0 0 rgba(0, 243, 255, 0.4), 0 0 rgba(139, 92, 246, 0.4);
    }
}

/* Keyframes: detonation overlay flash */
@keyframes detonate-flash {
    0% {
        opacity: 0.0;
        filter: none;
    }

    20% {
        opacity: 0.5;
    }

    40% {
        opacity: 0.9;
        filter: brightness(1.9) contrast(1.3);
    }

    60% {
        opacity: 0.7;
        filter: brightness(1.2) contrast(1.1);
    }

    80% {
        opacity: 0.48;
    }

    100% {
        opacity: 0.25;
        filter: none;
    }
}

/* Keyframes: page shake */
@keyframes page-shake {
    0% {
        transform: translate(0, 0) rotate(0);
    }

    5% {
        transform: translate(4px, -3px) rotate(-0.6deg);
    }

    10% {
        transform: translate(-5px, 3px) rotate(0.7deg);
    }

    15% {
        transform: translate(6px, -4px) rotate(-0.8deg);
    }

    20% {
        transform: translate(-7px, 4px) rotate(0.8deg);
    }

    25% {
        transform: translate(7px, -5px) rotate(-0.9deg);
    }

    30% {
        transform: translate(-8px, 5px) rotate(0.9deg);
    }

    35% {
        transform: translate(8px, -6px) rotate(-0.8deg);
    }

    40% {
        transform: translate(-7px, 6px) rotate(0.7deg);
    }

    45% {
        transform: translate(6px, -5px) rotate(-0.6deg);
    }

    50% {
        transform: translate(-5px, 4px) rotate(0.5deg);
    }

    60% {
        transform: translate(4px, -3px) rotate(-0.4deg);
    }

    70% {
        transform: translate(-3px, 3px) rotate(0.3deg);
    }

    80% {
        transform: translate(2px, -2px) rotate(-0.2deg);
    }

    90% {
        transform: translate(-1px, 1px) rotate(0.1deg);
    }

    100% {
        transform: translate(0, 0) rotate(0);
    }
}

/* Reduced motion tweaks for detonation + shake */
@media (prefers-reduced-motion: reduce) {

    .glass-terminal.glitch-detonate,
    .glass-terminal.glitch-detonate::after,
    body.page-shake {
        animation: none !important;
        transform: none !important;
        filter: none !important;
        opacity: 1 !important;
    }
}

/* =========================================
   RED ERROR WINDOW & TRANSITION FX
   ========================================= */

/* Pulsing background overlay (replaces body::before from snippet) */
.red-pulse-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(139, 0, 0, 0.2) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
    /* Behind terminal/error window but above canvas */
    animation: pulseBackground 2s ease-in-out infinite;
    opacity: 0;
    transition: opacity 1s ease;
}

.red-pulse-overlay.active {
    opacity: 1;
}

@keyframes pulseBackground {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.6;
    }
}

/* Error Window Container */
.error-window {
    width: 400px;
    height: 175px;
    background: linear-gradient(135deg, #0a0000 0%, #1a0000 50%, #0a0000 100%);
    border: 2px solid #ff0000;
    box-shadow:
        0 0 20px rgba(255, 0, 0, 0.8),
        0 0 40px rgba(255, 0, 0, 0.6),
        inset 0 0 30px rgba(255, 0, 0, 0.1),
        0 8px 32px rgba(0, 0, 0, 0.9);
    border-radius: 4px;
    padding: 0;
    z-index: 1000;
    animation: windowAppear 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), criticalFlash 1.5s infinite;
    backdrop-filter: blur(10px);
    transform-origin: center;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    counter-reset: error-box-counter;
    /* Initialize counter here since we only have one */
}

/* Counter increment */
.error-window {
    counter-increment: error-box-counter;
}

/* External index number */
.error-window::before {
    content: "0" counter(error-box-counter);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 2px 8px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
    z-index: 5;
}

@keyframes windowAppear {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes criticalFlash {

    0%,
    100% {
        border-color: #ff0000;
    }

    50% {
        border-color: #ff6666;
    }
}

.error-header {
    background: linear-gradient(180deg, #8b0000 0%, #ff0000 100%);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.7);
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid #ff0000;
}

/* Header scanline effect */
.error-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: scanline 3s linear infinite;
}

@keyframes scanline {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.error-title {
    color: #ffffff;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hazard-bar {
    height: 10px;
    width: 100%;
    border-top: 1px solid #ffcc00;
    border-bottom: 1px solid #ffcc00;
    box-shadow: 0 0 8px rgba(255, 204, 0, 0.5);
    overflow: hidden;
    background: repeating-linear-gradient(45deg,
            #000000 0,
            #000000 10px,
            #ffcc00 10px,
            #ffcc00 20px);
    animation: moveStripes 0.5s linear infinite;
    position: relative;
    z-index: 2;
}

@keyframes moveStripes {
    to {
        background-position: 20px 0;
    }
}

.error-body {
    flex-grow: 1;
    padding: 10px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
    background: linear-gradient(180deg, #8b0000 0%, #ff0000 100%);
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.7);
    color: #ffffff;
}

.error-content-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    justify-content: center;
}

.error-code {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 5px;
    color: #ffff00;
    text-shadow: 0 0 8px rgba(255, 255, 0, 0.5);
}

.error-message {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    line-height: 1.4;
    text-align: center;
    color: #ffffff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.7);
}

.close-button {
    margin-top: 0;
    background: #fff;
    color: #8b0000;
    border: 1px solid #ffcc00;
    width: 120px;
    height: 25px;
    line-height: 23px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    border-radius: 2px;
    transition: background 0.1s, box-shadow 0.3s;
    box-shadow: 0 0 5px rgba(255, 204, 0, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.close-button:hover {
    background: #ffcc00;
    color: #000;
    box-shadow: 0 0 10px rgba(255, 0, 0, 1);
}

@keyframes glitchText {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-1px, 1px);
    }

    50% {
        transform: translate(1px, -1px);
    }

    75% {
        transform: translate(0, 1px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* --- Black Red Theme (Box 1 Style) --- */
.error-window.error-theme-black {
    border-color: #ff0000;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8), 0 0 40px rgba(255, 0, 0, 0.6);
}

.error-window.error-theme-black .error-header {
    background: linear-gradient(180deg, #8b0000 0%, #ff0000 100%);
    border-bottom: 1px solid #ff0000;
}

.error-window.error-theme-black .error-header::before {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.error-window.error-theme-black .error-title {
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.error-window.error-theme-black .error-body {
    background: linear-gradient(135deg, #0a0000 0%, #1a0000 50%, #0a0000 100%);
    color: #ff0000;
}

.error-window.error-theme-black .error-code {
    color: #ff0000;
    text-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
    animation: glitchText 0.3s infinite;
}

.error-window.error-theme-black .error-message {
    color: #ff6666;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.7);
}

.error-window.error-theme-black .close-button {
    background: #000;
    color: #ff0000;
    border: 1px solid #ff0000;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.7);
}

.error-window.error-theme-black .close-button:hover {
    background: #ff0000;
    color: #000;
    box-shadow: 0 0 10px rgba(255, 0, 0, 1);
}

/* =========================================
   LAGGY TRANSITION FX
   ========================================= */
@keyframes laggy-dissolve {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
        filter: none;
    }

    20% {
        opacity: 1;
        transform: translate(4px, -4px) scale(1.01);
        filter: contrast(2) hue-rotate(45deg);
    }

    40% {
        opacity: 0.8;
        transform: translate(-4px, 4px) scale(1.02);
        filter: invert(0.3);
    }

    60% {
        opacity: 0.5;
        transform: translate(2px, 2px) scale(1.05);
        filter: blur(2px);
    }

    80% {
        opacity: 0.2;
        transform: translate(-2px, -2px) scale(1.1);
        filter: blur(4px) grayscale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.2);
        filter: blur(8px);
    }
}

.lag-spike-active {
    /* Use steps() to simulate low framerate/lag */
    animation: laggy-dissolve 1.2s steps(4, end) forwards !important;
    pointer-events: none;
}