@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 */
    --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 */
    --flesh-pale: #e8d0d0;
    --bone-white: #ffffff;
    --muted-bone: #b8a5a5;

    /* Typography */
    --font-title: 'Nosifer', display;
    --font-head: 'Teko', sans-serif;
    --font-body: 'Crimson Pro', serif;

    /* Glass & Overlay Variables */
    --glass-panel: rgba(10, 2, 2, 0.85);
    --perk-blur-bg: rgba(20, 0, 0, 0.4);
    --smooth-curve: cubic-bezier(0.25, 1, 0.3, 1);

    /* Subtle Horror Noise Overlay */
    --fog-overlay: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)" opacity="0.04"/></svg>');
}

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

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

/* Hides the hardcoded <br> tags in your HTML so CSS can perfectly control the spacing */
body > br {
    display: none;
}

/* ==========================================================================
   FLUID LAYOUT & THE VOID
   ========================================================================== */
html, body {
    width: 100%;
    max-width: 100vw;
    min-height: 100dvh; /* Allows scrolling on mobile if content overflows */
    overflow-x: hidden;
    background-color: #0a0a0a;
    color: var(--bone-white);
    font-family: var(--font-body);
}

/* On Desktop: Engage the One-Frame Lock. On Mobile: Allows scrolling. */
@media (min-width: 1000px) {
    html, body { 
        height: 100vh;
        overflow: hidden; 
    }
}

body {
    display: flex;
    flex-direction: column;
    /* No padding-top needed; sticky navbar pushes content down naturally */
    background-image: radial-gradient(circle at 50% 0%, var(--coagulated-blood) 0%, var(--pitch-black) 80%), var(--fog-overlay);
    position: relative;
    z-index: 1;
}

body::before {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 150vw; height: 150vh;
    background: radial-gradient(ellipse at center, transparent 20%, var(--pitch-black) 80%);
    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;
}

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

/* ==========================================================================
   PREMIUM MAIN NAVBAR - STICKY FIX
   ========================================================================== */
.navbar {
    /* STICKY FIX: Keeps it at the top, but dynamically pushes content underneath it */
    position: sticky; 
    top: 0;
    left: 0;
    width: 100%;
    min-height: 70px;
    height: auto;
    padding: clamp(5px, 1.5vw, 10px) 15px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.98) 0%, rgba(15, 0, 0, 0.90) 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: organicHeartbeatBorder 4s infinite var(--smooth-curve);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.nav-links {
    display: flex;
    gap: clamp(15px, 3vw, 40px);
    flex-wrap: wrap; /* Prevents overflow if screen is super narrow */
    list-style: none;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 5px 0;
}

.navbar li a {
    font-family: var(--font-head);
    font-size: clamp(0.9rem, 2.5vw, 1.5rem);
    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, 15px);
    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;
}

/* ==========================================================================
   DIFFICULTY SELECTOR (FLUID & POSITIONED CORRECTLY)
   ========================================================================== */
.difficulty-container {
    /* Changed from absolute to relative to keep it in the flow under the navbar */
    position: relative; 
    align-self: flex-end; /* Aligns to the right side of the screen */
    margin-top: clamp(10px, 2vw, 20px);
    margin-right: clamp(15px, 4vw, 30px);
    z-index: 500;
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 12px);
    background: var(--glass-panel);
    border: 1px solid var(--dried-blood);
    padding: clamp(4px, 1vw, 8px) clamp(8px, 2vw, 16px);
    border-radius: 3px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    animation: organicHeartbeatBorderFull 4s infinite var(--smooth-curve);
}

.difficulty-label {
    font-family: var(--font-head);
    color: var(--pulsing-red);
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(255, 5, 5, 0.3);
}

.difficulty-select {
    background: rgba(15, 0, 0, 0.8);
    color: var(--bone-white);
    border: 1px solid var(--arterial-spray);
    padding: clamp(4px, 1vw, 6px) clamp(8px, 2vw, 12px);
    font-family: var(--font-head);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    text-transform: uppercase;
    letter-spacing: 1px;
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 0 8px rgba(255, 5, 5, 0.15);
    transition: all 0.3s ease;
}

.difficulty-select:hover {
    border-color: var(--pulsing-red);
    box-shadow: inset 0 0 12px rgba(255, 5, 5, 0.3);
}
.difficulty-select option { background: var(--pitch-black); color: var(--bone-white); font-family: var(--font-head); }

/* ==========================================================================
   MAIN DASHBOARD - RESPONSIVE SPLIT
   ========================================================================== */
.dashboard {
    flex: 1; /* Fills remaining space */
    min-height: 0; /* Allows internal elements to scroll correctly on desktop */
    display: flex;
    flex-direction: column; /* Stacks vertically on mobile */
    padding: clamp(1rem, 2vw, 1.5rem) clamp(1rem, 4vw, 3rem);
    gap: clamp(1.5rem, 4vw, 2.5rem);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 1000px) {
    .dashboard {
        display: grid;
        grid-template-columns: 1fr 1fr;
        height: 100%;
        overflow: hidden; /* Locks frame on desktop */
    }
}

/* --- LEFT COLUMN: INFO PANEL --- */
.info-panel {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    animation: slideInLeft 0.7s var(--smooth-curve) forwards;
    min-height: 0; /* Important for flex-scrolling */
    height: 100%;
}

.build-header {
    border-left: 4px solid var(--arterial-spray);
    padding-left: clamp(10px, 3vw, 20px);
    background: linear-gradient(90deg, rgba(138, 0, 0, 0.15) 0%, transparent 100%);
    padding-top: 10px;
    padding-bottom: 10px;
    position: relative;
    flex-shrink: 0;
}

.build-title {
    font-family: var(--font-head);
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: clamp(1px, 1vw, 3px);
    line-height: 1;
    color: var(--bone-white);
    text-shadow: 0 0 15px rgba(255, 5, 5, 0.5);
}

.build-subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: var(--pulsing-red);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: clamp(2px, 1vw, 4px);
    margin-top: 5px;
    font-style: italic;
}

.meta-tags { display: flex; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }

.tag {
    background: rgba(23, 0, 0, 0.8);
    border: 1px solid var(--dried-blood);
    padding: clamp(4px, 1vw, 6px) clamp(10px, 2vw, 14px);
    border-radius: 2px;
    font-family: var(--font-head);
    font-size: clamp(0.85rem, 2vw, 1rem);
    letter-spacing: 2px;
    color: var(--flesh-pale);
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
.tag span { color: var(--pulsing-red); margin-right: 6px; }

/* Strategy Container (Where the Game Tips live) */
.strategy-container {
    background: var(--glass-panel);
    border: 1px solid var(--dried-blood);
    border-radius: 4px;
    padding: clamp(12px, 3vw, 20px);
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 10px 30px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    flex: 1;
    min-height: 200px; /* Safe minimum height before scrolling triggers */
    
    /* THE FIX: Adds an internal scrollbar on desktop so text NEVER cuts off */
    overflow-y: auto; 
    
    animation: organicHeartbeatBorderFull 4s infinite var(--smooth-curve);
    animation-delay: 0.5s;
}

.strategy-container::-webkit-scrollbar { width: 6px; }
.strategy-container::-webkit-scrollbar-track { background: var(--pitch-black); border-radius: 3px; }
.strategy-container::-webkit-scrollbar-thumb { background: var(--dried-blood); border-radius: 3px; }
.strategy-container::-webkit-scrollbar-thumb:hover { background: var(--pulsing-red); }

.phase h4 {
    font-family: var(--font-head);
    color: var(--arterial-spray);
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px dashed var(--dried-blood);
    padding-bottom: 6px;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(255, 5, 5, 0.3);
}
.phase p { font-size: clamp(0.95rem, 2.5vw, 1.05rem); line-height: 1.6; color: var(--muted-bone); }

.pro-tip {
    background: rgba(138, 0, 0, 0.1);
    border-left: 3px solid var(--arterial-spray);
    padding: 12px 15px;
    font-weight: 700;
    font-size: clamp(0.9rem, 2vw, 1rem);
    color: var(--bone-white);
    box-shadow: inset 20px 0 30px -20px rgba(255, 5, 5, 0.2);
}

/* --- RIGHT COLUMN: VISUAL PANEL (THE ALTAR) --- */
.visual-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: slideInRight 0.7s var(--smooth-curve) forwards;
    padding-bottom: 30px;
}

/* The Rhombus Layout - Fully Percentage/Clamp Based to prevent overlap */
.perk-diamond {
    position: relative;
    width: clamp(250px, 75vw, 400px);
    height: clamp(250px, 75vw, 400px);
    margin-bottom: clamp(10px, 3vw, 20px);
}

.perk-wrapper {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(140px, 40vw, 200px);
    height: clamp(80px, 25vw, 120px);
    z-index: 5;
}

/* Percentage offsets ensure the diamond scales flawlessly without hardcoded pixels breaking it */
.pos-top { top: -10%; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }
.pos-bottom { bottom: -10%; left: 50%; transform: translateX(-50%); flex-direction: column; }
.pos-left { top: 50%; left: -15%; transform: translateY(-50%); flex-direction: row-reverse; }
.pos-right { top: 50%; right: -15%; transform: translateY(-50%); flex-direction: row; }

.perk-slot {
    width: clamp(55px, 15vw, 85px);
    height: clamp(55px, 15vw, 85px);
    background: var(--perk-blur-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--dried-blood);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.8);
    transform: rotate(45deg);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    transition: all 0.3s var(--smooth-curve);
    z-index: 2;
    animation: organicHeartbeatBorderFull 4s infinite var(--smooth-curve);
}

.perk-slot:hover {
    transform: rotate(45deg) scale(1.05);
    z-index: 10;
    animation: none;
    border-color: var(--arterial-spray);
    box-shadow: 0 0 25px rgba(255, 5, 5, 0.5), inset 0 0 15px rgba(255, 5, 5, 0.2);
}

.perk-slot img {
    width: clamp(35px, 10vw, 60px);
    height: clamp(35px, 10vw, 60px);
    transform: rotate(-45deg);
    filter: drop-shadow(0px 5px 8px rgba(0, 0, 0, 0.9)) brightness(0.9);
    transition: all 0.3s ease;
}

.perk-slot:hover img { filter: drop-shadow(0px 0px 10px rgba(255, 5, 5, 0.8)) brightness(1.1); }

.perk-name-label {
    font-family: var(--font-head);
    font-size: clamp(0.85rem, 2.5vw, 1.15rem);
    font-weight: 700;
    color: var(--bone-white);
    text-transform: uppercase;
    text-shadow: 0 3px 5px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 1);
    letter-spacing: 1px;
    text-align: center;
    padding: clamp(4px, 1vw, 8px);
    z-index: 3;
}

.pos-top .perk-name-label { margin-bottom: 5px; }
.pos-bottom .perk-name-label { margin-top: 5px; }
.pos-left .perk-name-label { margin-right: clamp(10px, 3vw, 20px); text-align: right; }
.pos-right .perk-name-label { margin-left: clamp(10px, 3vw, 20px); text-align: left; }

.randomize-btn {
    background: linear-gradient(135deg, var(--coagulated-blood), var(--dried-blood));
    color: var(--bone-white);
    border: 1px solid var(--pulsing-red);
    padding: clamp(10px, 3vw, 12px) clamp(30px, 8vw, 50px);
    font-family: var(--font-head);
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 4px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8), inset 0 2px 5px rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    transition: all 0.3s var(--smooth-curve);
    position: relative;
    overflow: hidden;
    margin-top: 5px;
    white-space: nowrap;
}

.randomize-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(255, 5, 5, 0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.randomize-btn::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: skewX(-20deg);
    transition: 0.6s var(--smooth-curve);
}

.randomize-btn:hover {
    transform: translateY(-3px);
    border-color: var(--arterial-spray);
    box-shadow: 0 15px 30px rgba(200, 0, 0, 0.4), inset 0 0 15px rgba(200, 0, 0, 0.2);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}
.randomize-btn:hover::before { opacity: 1; }
.randomize-btn:hover::after { left: 150%; }
.randomize-btn:active { transform: translateY(1px); }

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

@keyframes organicHeartbeatBorder {
    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); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.glitch-flash { animation: bloodFlash 0.35s var(--smooth-curve); }

@keyframes bloodFlash {
    0% { opacity: 1; filter: brightness(1) drop-shadow(0 0 0 red); }
    30% { opacity: 0.5; filter: brightness(1.5) contrast(1.5) drop-shadow(0 0 20px var(--arterial-spray)); transform: scale(0.98); }
    70% { opacity: 0.8; filter: brightness(0.8) drop-shadow(0 0 10px var(--pulsing-red)); transform: scale(1.02); }
    100% { opacity: 1; filter: brightness(1) drop-shadow(0 0 0 red); transform: scale(1); }
}