@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,300;0,700;1,400&family=Teko:wght@500;700&family=Nosifer&display=swap');

:root {
    /* The Carnage Palette - Enhanced for Maximum Depth & Legibility */
    --pitch-black: #000000;
    --void-black: #050303;
    --coagulated-blood: #170000;
    --dried-blood: #3a0000;
    --fresh-blood: #8a0000;
    --pulsing-red: #c70000;
    --arterial-spray: #ff0505;

    /* Text Colors - High Contrast for Readability */
    --flesh-pale: #e8d0d0;
    --bone-white: #ffffff;
    --muted-bone: #b8a5a5;

    /* Typography */
    --font-title: 'Nosifer', display;
    --font-head: 'Teko', sans-serif;
    --font-body: 'Crimson Pro', serif;
    /* Fallback for --font-ui if missing */
    --font-ui: 'Courier New', Courier, monospace;

    /* Premium Easing & UI Base */
    --smooth-curve: cubic-bezier(0.25, 1, 0.3, 1);
    --panel-bg: rgba(10, 2, 2, 0.85);
}

/* ==========================================================================
   GLOBAL RESET & THE VOID (ONE-FRAME LOCK)
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    cursor: crosshair;
}

::selection {
    background: var(--arterial-spray);
    color: var(--pitch-black);
    text-shadow: none;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--pitch-black);
}
::-webkit-scrollbar-thumb {
    background: var(--dried-blood);
    border-radius: 3px;
    transition: background 0.3s ease;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--pulsing-red);
}

body, html {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for flawless mobile display */
    overflow: hidden; /* Prevent full-page scroll */
    background-color: transparent;
    color: var(--bone-white);
    font-family: var(--font-body);
}

body {
    display: flex;
    flex-direction: column;
    /* Padding removed: The sticky navbar automatically pushes content down now! */
}

/* Background Animation */
.bg-gif {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    object-fit: cover;
    z-index: -3;
    pointer-events: none;
}

/* Ambient Deep Breathing Vignette */
body::before {
    content: "";
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 150vw; height: 150vh;
    background: radial-gradient(ellipse at center, transparent 15%, var(--void-black) 60%, var(--pitch-black) 100%);
    pointer-events: none;
    z-index: -1;
    box-shadow: inset 0 0 150px rgba(138, 0, 0, 0.15);
    animation: ambientVignettePulse 8s infinite ease-in-out;
}

/* Premium Asylum Wall Texture */
body::after {
    content: "";
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-image: repeating-linear-gradient(45deg, rgba(58, 0, 0, 0.03) 0px, transparent 1px, transparent 4px);
    opacity: 0.6;
    pointer-events: none;
    z-index: -2;
}

/* ==========================================================================
   NAVIGATION - STICKY FIX
   ========================================================================== */
.navbar {
    /* THE FIX: Sticky keeps it at the top but inside document flow */
    position: sticky; 
    top: 0;
    left: 0;
    width: 100%;
    min-height: 70px;
    height: auto;
    padding: 10px 15px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.98) 0%, rgba(30, 5, 5, 0.92) 100%);
    border-bottom: 2px solid var(--dried-blood);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: organicHeartbeatBorderBottom 4s infinite var(--smooth-curve);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.nav-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(10px, 3vw, 42px);
    flex-wrap: wrap; /* Wraps cleanly on mobile */
    margin: 0;
    padding: 5px 0;
    list-style: none;
}

.navbar li a {
    font-family: var(--font-head);
    font-size: clamp(0.85rem, 2.5vw, 1.15rem);
    font-weight: 700;
    letter-spacing: clamp(1px, 1vw, 3px);
    color: var(--muted-bone);
    text-decoration: none;
    text-transform: uppercase;
    position: relative;
    padding: clamp(5px, 1.5vw, 8px) clamp(10px, 2vw, 16px);
    transition: all 0.3s var(--smooth-curve);
    white-space: nowrap;
}

.navbar li a::before {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 2px;
    background: var(--arterial-spray);
    transform: translate(-50%, -50%) rotate(-3deg);
    transition: width 0.4s var(--smooth-curve);
    box-shadow: 0 0 10px var(--arterial-spray);
    z-index: 2;
    opacity: 0;
}

.navbar li a:hover,
.navbar li a.active {
    color: var(--bone-white);
    text-shadow: 0 0 15px rgba(255, 5, 5, 0.7);
}

.navbar li a:hover::before,
.navbar li a.active::before {
    width: 100%;
    opacity: 1;
}

/* ==========================================================================
   MAIN LAYOUT & CONTROLS (FIT TO FRAME - FULLY RESPONSIVE)
   ========================================================================== */
.app-container {
    display: flex;
    flex-direction: column;
    /* Flex 1 tells it to fill exact remaining space under the navbar perfectly */
    flex: 1; 
    min-height: 0; 
    padding: clamp(10px, 2vw, 1.5rem) clamp(10px, 3vw, 2rem);
    gap: clamp(10px, 2vw, 1.5rem);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden; /* Crucial for one-frame layout */
    box-sizing: border-box;
}

.controls-header {
    display: flex;
    flex-direction: column;
    gap: clamp(0.5rem, 2vw, 1rem);
    background: var(--panel-bg);
    padding: clamp(0.5rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
    border-radius: 4px;
    border: 1px solid var(--dried-blood);
    backdrop-filter: blur(10px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8);
    animation: organicHeartbeatBorderFull 4s infinite var(--smooth-curve);
    flex-shrink: 0;
}

.controls-top {
    display: flex;
    flex-wrap: wrap; /* Allows stacking on mobile */
    justify-content: space-between;
    align-items: center;
    gap: clamp(10px, 2vw, 1.5rem);
}

/* Faction Toggles */
.faction-toggle {
    display: flex;
    flex: 1 1 200px; /* Stretches on mobile */
    background: rgba(0, 0, 0, 0.8);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid var(--dried-blood);
}

.faction-btn {
    flex: 1;
    background: transparent;
    color: var(--muted-bone);
    border: none;
    padding: clamp(0.4rem, 1vw, 0.6rem) clamp(0.5rem, 2vw, 1.5rem);
    font-family: var(--font-head);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 700;
    letter-spacing: clamp(1px, 1vw, 2px);
    transition: all 0.3s;
    text-transform: uppercase;
}

.faction-btn.active {
    background: linear-gradient(to bottom, var(--fresh-blood), var(--dried-blood));
    color: var(--bone-white);
    text-shadow: 0 2px 4px var(--pitch-black);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Search & Sort */
.search-container {
    flex: 2 1 250px; /* Adapts size seamlessly */
}

.search-bar {
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--dried-blood);
    color: var(--bone-white);
    padding: 0.6rem 1.2rem;
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    border-radius: 2px;
    outline: none;
    transition: all 0.3s var(--smooth-curve);
}

.search-bar:focus {
    border-color: var(--arterial-spray);
    box-shadow: 0 0 15px rgba(200, 0, 0, 0.3), inset 0 0 10px rgba(200, 0, 0, 0.1);
}

.search-bar::placeholder { color: var(--muted-bone); opacity: 0.5; font-style: italic; }

.sort-dropdown {
    flex: 1 1 120px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--bone-white);
    border: 1px solid var(--dried-blood);
    padding: 0.6rem clamp(0.5rem, 2vw, 1.2rem);
    font-family: var(--font-head);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    letter-spacing: 1px;
    border-radius: 2px;
    outline: none;
}
.sort-dropdown option { background: var(--pitch-black); color: var(--bone-white); }

/* Category Tabs */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(5px, 2vw, 1rem);
    padding-bottom: 0.2rem;
}

.cat-tab {
    background: transparent;
    border: 1px solid var(--dried-blood);
    color: var(--muted-bone);
    padding: clamp(0.2rem, 1vw, 0.3rem) clamp(0.8rem, 2vw, 1.2rem);
    border-radius: 20px;
    font-family: var(--font-head);
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.3s;
}

.cat-tab:hover, .cat-tab.active {
    border-color: var(--arterial-spray);
    color: var(--bone-white);
    background: rgba(138, 0, 0, 0.15);
    box-shadow: 0 0 10px rgba(255, 5, 5, 0.2);
}

/* ==========================================================================
   CONTENT AREA - AUTO-SCROLLING SPLIT VIEW (RESPONSIVE STACKING)
   ========================================================================== */
.content-area {
    display: flex;
    flex-direction: column; /* Mobile: Stacks vertically */
    gap: clamp(10px, 2vw, 1.5rem);
    flex: 1;
    min-height: 0; /* Important for preventing flexbox from overflowing */
    overflow: hidden;
}

/* Desktop Split */
@media (min-width: 900px) {
    .content-area { flex-direction: row; }
}

/* Left: Archive List */
.perk-list-container {
    width: 100%;
    height: 40%; /* Mobile allocation */
    background: var(--panel-bg);
    border: 1px solid var(--dried-blood);
    border-radius: 4px;
    overflow-y: auto; /* Scrolls only internally */
    backdrop-filter: blur(10px);
    animation: organicHeartbeatBorderFull 4s infinite var(--smooth-curve);
    animation-delay: 0.5s;
}

@media (min-width: 900px) {
    .perk-list-container { width: 35%; height: 100%; }
}

.perk-card {
    display: flex;
    align-items: center;
    gap: clamp(0.8rem, 2vw, 1.2rem);
    padding: clamp(0.8rem, 2vw, 1rem);
    border-bottom: 1px solid rgba(58, 0, 0, 0.4);
    transition: all 0.2s var(--smooth-curve);
    position: relative;
}

.perk-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0px;
    background: var(--arterial-spray);
    transition: width 0.3s var(--smooth-curve);
}

.perk-card:hover, .perk-card.active { background: linear-gradient(90deg, rgba(58, 0, 0, 0.3) 0%, transparent 100%); }
.perk-card.active::before, .perk-card:hover::before { width: 4px; box-shadow: 0 0 15px var(--arterial-spray); }

.perk-card-icon {
    width: clamp(35px, 8vw, 50px);
    height: clamp(35px, 8vw, 50px);
    object-fit: contain;
    filter: grayscale(100%) brightness(0.5);
    transition: all 0.4s;
}

.perk-card.active .perk-card-icon, .perk-card:hover .perk-card-icon {
    filter: drop-shadow(0 0 8px rgba(255, 5, 5, 0.6)) grayscale(0%) brightness(1);
}

.perk-card-info h3 {
    font-family: var(--font-head);
    font-size: clamp(1rem, 3vw, 1.3rem);
    letter-spacing: 1px;
    color: var(--bone-white);
}

.perk-card-info span { font-size: clamp(0.8rem, 2vw, 0.9rem); color: var(--pulsing-red); font-style: italic; }

/* Right: Display Panel */
.perk-display-container {
    width: 100%;
    height: 60%; /* Mobile allocation */
    background: var(--panel-bg);
    border: 1px solid var(--dried-blood);
    border-radius: 4px;
    padding: clamp(1rem, 3vw, 2rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    backdrop-filter: blur(10px);
    overflow-y: auto;
    animation: organicHeartbeatBorderFull 4s infinite var(--smooth-curve);
}

@media (min-width: 900px) {
    .perk-display-container { width: 65%; height: 100%; }
}

.display-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
    border-bottom: 1px dashed var(--dried-blood);
    padding-bottom: clamp(1rem, 3vw, 1.5rem);
    width: 100%;
}

.display-icon-wrapper {
    position: relative;
    width: clamp(100px, 20vw, 140px);
    height: clamp(100px, 20vw, 140px);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Visceral Rotating Blood Ring */
.display-icon-wrapper::after {
    content: '';
    position: absolute;
    width: 100%; height: 100%;
    border: 2px dashed var(--dried-blood);
    border-top-color: var(--arterial-spray);
    border-bottom-color: var(--pulsing-red);
    border-radius: 50%;
    animation: rotateDash 8s linear infinite;
    box-shadow: inset 0 0 20px rgba(138, 0, 0, 0.2), 0 0 20px rgba(138, 0, 0, 0.2);
}

@keyframes rotateDash { 100% { transform: rotate(360deg); } }

#display-icon {
    width: clamp(60px, 12vw, 100px);
    height: clamp(60px, 12vw, 100px);
    object-fit: contain;
    filter: drop-shadow(0 10px 25px rgba(255, 5, 5, 0.4));
}

.display-title-group { display: flex; flex-direction: column; align-items: center; }

.display-title-group h1 {
    font-family: var(--font-head);
    font-size: clamp(1.8rem, 6vw, 3rem);
    text-transform: uppercase;
    color: var(--arterial-spray);
    letter-spacing: clamp(1px, 1vw, 3px);
    text-shadow: 0 5px 15px rgba(138, 0, 0, 0.6);
    margin-bottom: 0.5rem;
    line-height: 1;
}

.meta-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(0.4rem, 1vw, 0.8rem); }

.meta-tag {
    background: rgba(23, 0, 0, 0.6);
    border: 1px solid var(--dried-blood);
    padding: 0.3rem clamp(0.5rem, 2vw, 1rem);
    border-radius: 2px;
    font-family: var(--font-head);
    font-size: clamp(0.75rem, 2.5vw, 1rem);
    letter-spacing: 1px;
    color: var(--flesh-pale);
    text-transform: uppercase;
}

.display-desc {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    line-height: 1.6;
    color: var(--bone-white);
    max-width: 800px;
    margin-bottom: clamp(1rem, 3vw, 2rem);
}

/* Automated Scenario Module - Horror Version */
.scenario-box {
    background: linear-gradient(135deg, rgba(15, 0, 0, 0.9), rgba(5, 0, 0, 0.95));
    border: 1px solid var(--dried-blood);
    border-left: 4px solid var(--fresh-blood);
    padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 4vw, 2rem);
    width: 100%;
    max-width: 800px;
    position: relative;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 10px 20px rgba(0, 0, 0, 0.5);
}

.scenario-box::before {
    content: '>> ENTITY SIMULATION';
    display: block;
    font-family: var(--font-head);
    color: var(--pulsing-red);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    margin-bottom: 0.8rem;
    letter-spacing: clamp(1px, 1vw, 3px);
    text-shadow: 0 0 8px rgba(200, 0, 0, 0.4);
}

#display-scenario {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: var(--muted-bone);
    font-style: italic;
    line-height: 1.5;
}

/* ==========================================================================
   VISCERAL ANIMATIONS (UNTOUCHED)
   ========================================================================== */
@keyframes organicHeartbeatBorderFull {
    0%, 100% { border-color: var(--dried-blood); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8); }
    10% { border-color: var(--arterial-spray); box-shadow: 0 15px 40px rgba(200, 0, 0, 0.25), inset 0 0 10px rgba(200, 0, 0, 0.05); }
    20% { border-color: var(--dried-blood); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8); }
    30% { border-color: var(--pulsing-red); box-shadow: 0 15px 38px rgba(150, 0, 0, 0.15); }
    40%, 95% { border-color: var(--dried-blood); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8); }
}

@keyframes organicHeartbeatBorderBottom {
    0%, 100% { border-bottom-color: var(--dried-blood); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5); }
    10% { border-bottom-color: var(--arterial-spray); box-shadow: 0 8px 30px rgba(255, 5, 5, 0.3); }
    20% { border-bottom-color: var(--dried-blood); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5); }
    30% { border-bottom-color: var(--pulsing-red); box-shadow: 0 8px 28px rgba(200, 0, 0, 0.2); }
    40%, 95% { border-bottom-color: var(--dried-blood); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5); }
}

@keyframes ambientVignettePulse {
    0%, 100% { box-shadow: inset 0 0 100px rgba(30, 0, 0, 0.8); }
    50% { box-shadow: inset 0 0 180px rgba(100, 0, 0, 0.3); }
}

.glitch-text { animation: bloodGlitch 0.4s cubic-bezier(0.25, 1, 0.3, 1) both; color: var(--arterial-spray); }

@keyframes bloodGlitch {
    0% { transform: translate(0) }
    20% { transform: translate(-3px, 2px); text-shadow: -2px 0 red, 2px 0 black; }
    40% { transform: translate(-1px, -3px) }
    60% { transform: translate(3px, 1px); text-shadow: 2px 0 red, -2px 0 black; }
    80% { transform: translate(1px, -2px) }
    100% { transform: translate(0) }
}