/* ==========================================================================
   AI GHOST STORY GENERATOR - HAUNTED GOTHIC DESIGN SYSTEM & ANIMATIONS
   ========================================================================== */

/* --- 1. CSS CUSTOM PROPERTIES (DESIGN TOKENS) --- */
:root {
    /* Color Palette */
    --color-bg-pitch: #07060c;
    --color-bg-dark: #0c0916;
    --color-bg-midnight: #130d24;
    --color-bg-surface: rgba(19, 13, 36, 0.72);
    --color-bg-surface-hover: rgba(29, 19, 56, 0.85);
    --color-bg-input: rgba(10, 7, 20, 0.85);

    --color-ghost-white: #f8fafc;
    --color-ghost-glow: #e0e7ff;
    --color-violet-glow: #c084fc;
    --color-violet-core: #a855f7;
    --color-violet-dark: #6b21a8;
    --color-spirit-cyan: #38bdf8;
    --color-crimson-accent: #dc2626;
    --color-amber-candle: #fbbf24;

    --color-text-primary: #f8fafc;
    --color-text-secondary: #cbd5e1;
    --color-text-muted: #94a3b8;

    --border-subtle: rgba(168, 85, 247, 0.22);
    --border-glow: rgba(192, 132, 252, 0.55);
    --border-focus: #c084fc;

    /* Shadow & Glow Effects */
    --glow-violet-sm: 0 0 10px rgba(168, 85, 247, 0.4);
    --glow-violet-md: 0 0 22px rgba(168, 85, 247, 0.55);
    --glow-violet-lg: 0 0 45px rgba(168, 85, 247, 0.4);
    --shadow-card: 0 12px 40px -10px rgba(0, 0, 0, 0.8), 0 0 20px rgba(168, 85, 247, 0.15);

    /* Typography */
    --font-heading: 'Cinzel Decorative', 'Creepster', Georgia, serif;
    --font-horror-accent: 'Creepster', cursive;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Layout & Transitions */
    --nav-height: 72px;
    --max-width: 1200px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- 2. BASE & RESET --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    background-color: var(--color-bg-pitch);
    color: var(--color-text-primary);
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    line-height: 1.65;
    background: radial-gradient(circle at 50% 0%, #170e30 0%, #0c0817 50%, #050308 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Accessible hidden utility */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.text-center {
    text-align: center;
}

.text-glow-violet {
    color: var(--color-violet-glow);
    text-shadow: 0 0 18px rgba(192, 132, 252, 0.7);
}

/* --- 3. ATMOSPHERIC SKY & BACKGROUND (Layer 0) --- */
.sky-background {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Subtle, Infrequent Lightning Flash (Non-intense, accessible) */
.lightning-flash {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 65% 20%, rgba(192, 132, 252, 0.12), transparent 70%);
    opacity: 0;
    animation: lightningGlow 22s ease-in-out infinite;
}

@keyframes lightningGlow {
    0%, 94%, 96%, 100% { opacity: 0; }
    94.5% { opacity: 0.35; }
    95.2% { opacity: 0.15; }
    95.8% { opacity: 0.45; }
}

/* Distant stars twinkling */
.stars-cluster {
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(1.5px 1.5px at 15% 12%, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(1px 1px at 35% 25%, rgba(200, 220, 255, 0.6), transparent),
        radial-gradient(2px 2px at 75% 18%, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(1px 1px at 85% 32%, rgba(192, 132, 252, 0.6), transparent),
        radial-gradient(1.5px 1.5px at 50% 10%, rgba(255, 255, 255, 0.7), transparent);
    background-repeat: repeat;
    background-size: 550px 550px;
    opacity: 0.65;
}

/* Glowing Full Moon */
.full-moon {
    position: absolute;
    top: 40px;
    right: 8%;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f1f5f9 45%, #e2e8f0 75%, #cbd5e1 100%);
    box-shadow: 
        0 0 30px 5px rgba(255, 255, 255, 0.5),
        0 0 70px 20px rgba(192, 132, 252, 0.4),
        0 0 120px 40px rgba(124, 58, 237, 0.25);
    animation: moonGlow 7s ease-in-out infinite alternate;
}

@keyframes moonGlow {
    0% {
        box-shadow: 
            0 0 30px 5px rgba(255, 255, 255, 0.45),
            0 0 65px 18px rgba(192, 132, 252, 0.35),
            0 0 110px 35px rgba(124, 58, 237, 0.2);
        transform: translateY(0);
    }
    100% {
        box-shadow: 
            0 0 40px 8px rgba(255, 255, 255, 0.65),
            0 0 85px 25px rgba(192, 132, 252, 0.55),
            0 0 140px 50px rgba(124, 58, 237, 0.35);
        transform: translateY(-4px);
    }
}

.moon-halo {
    position: absolute;
    inset: -25px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.2) 0%, transparent 70%);
}

.moon-crater {
    position: absolute;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.35);
}
.crater-1 { width: 22px; height: 18px; top: 35px; left: 30px; }
.crater-2 { width: 14px; height: 14px; top: 70px; left: 55px; }
.crater-3 { width: 18px; height: 12px; top: 45px; left: 75px; }

.moon-cloud {
    position: absolute;
    background: rgba(19, 13, 36, 0.55);
    border-radius: 20px;
    filter: blur(4px);
}
.cloud-1 { width: 140px; height: 18px; top: 60px; left: -25px; transform: rotate(-5deg); }
.cloud-2 { width: 100px; height: 14px; top: 90px; left: 40px; transform: rotate(3deg); }

/* Gothic Haunted Mansion Silhouette */
.mansion-silhouette {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 380px;
    z-index: 1;
    pointer-events: none;
    opacity: 0.85;
}

.mansion-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Flickering candlelight in mansion windows */
.flicker-window-1 { fill: var(--color-amber-candle); animation: candleFlicker1 3s infinite; }
.flicker-window-2 { fill: var(--color-amber-candle); animation: candleFlicker2 4.2s infinite; }
.flicker-window-3 { fill: var(--color-amber-candle); animation: candleFlicker3 2.7s infinite; }

@keyframes candleFlicker1 {
    0%, 100% { opacity: 0.9; }
    25% { opacity: 0.3; }
    50% { opacity: 0.85; }
    70% { opacity: 0.2; }
    85% { opacity: 1; }
}

@keyframes candleFlicker2 {
    0%, 100% { opacity: 0.75; }
    30% { opacity: 0.1; }
    55% { opacity: 0.9; }
    80% { opacity: 0.4; }
}

@keyframes candleFlicker3 {
    0%, 100% { opacity: 0.8; }
    40% { opacity: 0.15; }
    60% { opacity: 0.7; }
    90% { opacity: 0.95; }
}

/* Drifting Atmospheric Fog Waves */
.fog-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 220px;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

.fog-wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 250%;
    height: 100%;
    background-repeat: repeat-x;
}

.fog-wave-1 {
    background: linear-gradient(0deg, rgba(19, 13, 36, 0.95) 0%, rgba(168, 85, 247, 0.25) 45%, transparent 100%);
    opacity: 0.7;
    animation: fogDrift 28s linear infinite alternate;
}

.fog-wave-2 {
    background: linear-gradient(0deg, rgba(12, 9, 22, 0.85) 0%, rgba(56, 189, 248, 0.18) 50%, transparent 100%);
    opacity: 0.55;
    animation: fogDrift 38s linear infinite alternate-reverse;
}

.fog-wave-3 {
    background: linear-gradient(0deg, rgba(7, 6, 12, 0.9) 0%, rgba(192, 132, 252, 0.15) 60%, transparent 100%);
    opacity: 0.6;
    animation: fogDrift 48s linear infinite alternate;
}

@keyframes fogDrift {
    0% { transform: translateX(0); }
    100% { transform: translateX(-40%); }
}

/* Floating Supernatural Dust Particles */
.spirit-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    bottom: -20px;
    border-radius: 50%;
    background: var(--color-violet-glow);
    filter: blur(1px);
    box-shadow: 0 0 8px var(--color-violet-core);
    opacity: 0.6;
    animation: particleDriftUp 12s infinite linear;
}

.p-1 { left: 10%; width: 5px; height: 5px; animation-duration: 9s; animation-delay: 0s; }
.p-2 { left: 22%; width: 4px; height: 4px; animation-duration: 14s; animation-delay: 2s; background: var(--color-spirit-cyan); }
.p-3 { left: 38%; width: 6px; height: 6px; animation-duration: 11s; animation-delay: 4s; }
.p-4 { left: 52%; width: 3px; height: 3px; animation-duration: 16s; animation-delay: 1s; }
.p-5 { left: 67%; width: 5px; height: 5px; animation-duration: 10s; animation-delay: 5s; background: #ffffff; }
.p-6 { left: 81%; width: 4px; height: 4px; animation-duration: 13s; animation-delay: 3s; }
.p-7 { left: 92%; width: 6px; height: 6px; animation-duration: 15s; animation-delay: 6s; background: var(--color-spirit-cyan); }
.p-8 { left: 45%; width: 5px; height: 5px; animation-duration: 12s; animation-delay: 7s; }

@keyframes particleDriftUp {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    15% { opacity: 0.7; }
    80% { opacity: 0.6; }
    100% { transform: translateY(-110vh) translateX(30px); opacity: 0; }
}


/* --- 4. GHOST CHARACTERS & ANIMATIONS (Layer 5) --- */
.ghost-decorations {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

/* Ghost SVGs general properties */
.ghost-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

/* ==========================================================================
   B. WALKING GHOST — ESSENTIAL (Section 5.B)
   - Travels horizontally from outside left (-160px) to outside right (100vw + 160px)
   - Separate nested bobber simulates vertical walking steps without keyframe conflict
   - Swaying tail, responsive across screens, pointer-events none
   ========================================================================== */
.walking-ghost-track {
    position: fixed;
    bottom: 24px;
    left: 0;
    width: 120px;
    height: 140px;
    z-index: 15;
    pointer-events: none;
    /* Horizontal movement across the entire viewport */
    animation: walkingGhostJourney 20s linear infinite;
    will-change: transform;
}

@keyframes walkingGhostJourney {
    0% {
        transform: translateX(-160px);
    }
    100% {
        transform: translateX(calc(100vw + 160px));
    }
}

/* Nested bobber: Simulates rhythmic up-and-down walking steps */
.walking-ghost-bobber {
    width: 100%;
    height: 100%;
    animation: walkingGhostStep 0.65s ease-in-out infinite alternate;
    will-change: transform;
    position: relative;
}

@keyframes walkingGhostStep {
    0% {
        transform: translateY(0) rotate(1deg);
    }
    100% {
        transform: translateY(-18px) rotate(-2deg);
    }
}

.walking-ghost-svg {
    filter: drop-shadow(0 0 12px rgba(168, 85, 247, 0.8));
    animation: walkingGhostTailSway 1.3s ease-in-out infinite alternate;
}

@keyframes walkingGhostTailSway {
    0% {
        transform: skewX(-3deg);
    }
    100% {
        transform: skewX(3deg);
    }
}

/* Subtle ground shadow that stretches as ghost bobs */
.walking-ghost-shadow {
    position: absolute;
    bottom: -6px;
    left: 20%;
    width: 60%;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    filter: blur(4px);
    animation: walkingShadowScale 0.65s ease-in-out infinite alternate;
}

@keyframes walkingShadowScale {
    0% {
        transform: scale(1);
        opacity: 0.55;
    }
    100% {
        transform: scale(0.65);
        opacity: 0.25;
    }
}

/* ==========================================================================
   C. FLYING GHOST (Section 5.C)
   - Flies diagonally through hero section
   - Soft glowing violet appearance, gentle floating
   ========================================================================== */
.flying-ghost-container {
    position: absolute;
    top: 15%;
    left: -100px;
    width: 75px;
    height: 85px;
    pointer-events: none;
    animation: flyingGhostDiagonal 18s ease-in-out infinite;
}

@keyframes flyingGhostDiagonal {
    0% {
        transform: translate(-100px, 0) scale(0.85);
        opacity: 0;
    }
    10% {
        opacity: 0.85;
    }
    50% {
        transform: translate(calc(50vw), 120px) scale(1) rotate(6deg);
        opacity: 0.9;
    }
    90% {
        opacity: 0.85;
    }
    100% {
        transform: translate(calc(100vw + 120px), 40px) scale(0.85) rotate(-4deg);
        opacity: 0;
    }
}

/* ==========================================================================
   D. BACKGROUND GHOSTS (Section 5.D)
   - Translucent ghosts placed across different sections
   ========================================================================== */
.bg-ghost {
    position: absolute;
    pointer-events: none;
    z-index: 4;
}

.bg-ghost-1 {
    top: 42%;
    left: 5%;
    width: 70px;
    height: 80px;
    animation: bgGhostFloat1 8s ease-in-out infinite alternate;
}

@keyframes bgGhostFloat1 {
    0% { transform: translateY(0) rotate(-4deg); }
    100% { transform: translateY(-30px) rotate(4deg); }
}

.bg-ghost-2 {
    top: 68%;
    right: 6%;
    width: 90px;
    height: 100px;
    animation: bgGhostFloat2 12s ease-in-out infinite alternate;
}

@keyframes bgGhostFloat2 {
    0% { transform: translateY(0) translateX(0) rotate(5deg); }
    50% { transform: translateY(-25px) translateX(-15px) rotate(-2deg); }
    100% { transform: translateY(-45px) translateX(10px) rotate(6deg); }
}

.bg-ghost-3 {
    top: 85%;
    left: 12%;
    width: 60px;
    height: 70px;
    animation: bgGhostFloat3 10s ease-in-out infinite alternate;
}

@keyframes bgGhostFloat3 {
    0% { transform: translateY(0) rotate(-6deg); }
    100% { transform: translateY(-35px) rotate(6deg); }
}


/* --- 5. MAIN CONTENT WRAPPER & GLASSMORPHISM (Layer 10) --- */
.content-wrapper {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Reusable Glassmorphism Panel */
.glass-panel {
    background: var(--color-bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-panel:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-card), var(--glow-violet-sm);
}

/* Section Common Headers */
.section-header {
    margin-bottom: 3.5rem;
}

.section-tag {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-violet-glow);
    background: rgba(168, 85, 247, 0.15);
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(168, 85, 247, 0.3);
    margin-bottom: 0.9rem;
}

.section-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #ffffff;
    margin-bottom: 0.8rem;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.section-subtitle {
    font-size: 1.15rem;
    color: var(--color-text-secondary);
    max-width: 650px;
    margin: 0 auto;
}


/* --- 6. NAVIGATION BAR --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background: rgba(7, 6, 12, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #ffffff;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    transition: transform var(--transition-fast);
}

.brand-logo:hover {
    transform: translateY(-2px);
}

.logo-ghost-icon {
    width: 32px;
    height: 35px;
    filter: drop-shadow(0 0 8px var(--color-violet-core));
    animation: logoGhostHover 3s ease-in-out infinite alternate;
}

@keyframes logoGhostHover {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

.brand-text {
    letter-spacing: 0.02em;
}

.nav-links {
    display: flex;
    align-items: center;
    list-style: none;
    gap: 1.8rem;
}

.nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.4rem 0.2rem;
    position: relative;
    transition: color var(--transition-fast);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-violet-glow);
    box-shadow: 0 0 8px var(--color-violet-glow);
    transition: width var(--transition-fast);
}

.nav-link:hover {
    color: #ffffff;
}

.nav-link:hover::after {
    width: 100%;
}

.nav-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-violet-core), var(--color-violet-dark));
    color: #ffffff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.nav-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
}

/* Mobile Hamburger Menu */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    z-index: 110;
}

.hamburger-line {
    width: 22px;
    height: 2px;
    background: #ffffff;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.mobile-menu-btn.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.mobile-menu-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}
.mobile-menu-btn.active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}


/* --- 7. HERO SECTION --- */
.hero-section {
    min-height: calc(100vh - var(--nav-height));
    display: flex;
    align-items: center;
    padding: 4rem 0 6rem;
    position: relative;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
    gap: 3.5rem;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-violet-glow);
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.3);
    padding: 0.45rem 1rem;
    border-radius: var(--radius-full);
    margin-bottom: 1.4rem;
}

.pulse-spirit-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-spirit-cyan);
    box-shadow: 0 0 10px var(--color-spirit-cyan);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

.hero-title {
    font-family: var(--font-heading);
    font-size: clamp(2.6rem, 5.5vw, 4.2rem);
    font-weight: 900;
    line-height: 1.12;
    letter-spacing: -0.02em;
    color: #ffffff;
    margin-bottom: 1.2rem;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
}

.hero-subtitle {
    font-size: clamp(1.2rem, 2.2vw, 1.55rem);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.hero-description {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    max-width: 560px;
    margin-bottom: 2.2rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.9rem 1.8rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--transition-normal);
}

.btn-primary {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 50%, #4c1d95 100%);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(124, 58, 237, 0.65), 0 0 20px rgba(192, 132, 252, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-primary);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--border-glow);
    color: #ffffff;
    transform: translateY(-3px);
}

.btn-glow {
    position: relative;
    overflow: hidden;
}

.btn-glow::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transform: rotate(45deg);
    animation: btnGlowShine 4s infinite;
}

@keyframes btnGlowShine {
    0% { transform: translateX(-150%) rotate(45deg); }
    30%, 100% { transform: translateX(150%) rotate(45deg); }
}

.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   A. HERO FLOATING GHOST (Section 5.A)
   - Large cute-spooky ghost
   - Continuous float, gentle side-to-side, rotation, soft glowing aura
   ========================================================================== */
.hero-ghost-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    height: 380px;
}

.hero-floating-ghost {
    position: relative;
    width: 250px;
    height: 300px;
    animation: heroGhostFloat 4.5s ease-in-out infinite alternate;
}

@keyframes heroGhostFloat {
    0% {
        transform: translateY(0) rotate(-4deg) translateX(-8px);
    }
    50% {
        transform: translateY(-24px) rotate(2deg) translateX(6px);
    }
    100% {
        transform: translateY(-36px) rotate(4deg) translateX(-4px);
    }
}

.hero-ghost-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Eye pupil animation */
.ghost-pupil {
    animation: pupilTrack 4s ease-in-out infinite alternate;
}

@keyframes pupilTrack {
    0%, 100% { transform: translate(0, 0); }
    30% { transform: translate(-2px, -1px); }
    70% { transform: translate(2px, 1px); }
}

.ghost-eyes-group {
    animation: eyesBlink 5s infinite;
    transform-origin: center;
}

@keyframes eyesBlink {
    0%, 94%, 98%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(0.1); }
}

.hero-ghost-ground-shadow {
    position: absolute;
    bottom: -15px;
    left: 20%;
    width: 60%;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.6) 0%, transparent 75%);
    filter: blur(6px);
    animation: heroGhostShadow 4.5s ease-in-out infinite alternate;
}

@keyframes heroGhostShadow {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(0.65); opacity: 0.25; }
}


/* --- 8. STORY GENERATOR SECTION --- */
.generator-section {
    padding: 6rem 0;
    position: relative;
}

.generator-card-wrapper {
    position: relative;
    max-width: 820px;
    margin: 0 auto;
}

/* ==========================================================================
   E. INTERACTIVE GHOST (Section 5.E)
   - Placed near the story generator
   - Bounces on hover, changes expression, shows speech bubble
   - Click populates idea textarea with random spooky prompt
   ========================================================================== */
.interactive-ghost-container {
    position: absolute;
    top: -55px;
    right: 25px;
    z-index: 20;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform var(--transition-fast);
}

.ghost-speech-bubble {
    background: rgba(19, 13, 36, 0.95);
    color: var(--color-violet-glow);
    border: 1px solid var(--border-glow);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    margin-bottom: 6px;
    white-space: nowrap;
    position: relative;
    animation: speechBounce 3s ease-in-out infinite alternate;
    pointer-events: none;
}

.ghost-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: rgba(19, 13, 36, 0.95) transparent;
    display: block;
    width: 0;
}

@keyframes speechBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

.interactive-ghost-body {
    width: 65px;
    height: 75px;
    animation: miniGhostFloat 3.5s ease-in-out infinite alternate;
    transition: transform var(--transition-fast);
}

@keyframes miniGhostFloat {
    0% { transform: translateY(0) rotate(-3deg); }
    100% { transform: translateY(-10px) rotate(3deg); }
}

.interactive-ghost-container:hover .interactive-ghost-body {
    animation: interactiveBounce 0.4s ease-in-out infinite alternate;
}

@keyframes interactiveBounce {
    0% { transform: translateY(0) scale(1.05); }
    100% { transform: translateY(-14px) scale(1.12); }
}

.interactive-ghost-container:hover .ghost-speech-bubble {
    color: #ffffff;
    background: var(--color-violet-dark);
    border-color: #ffffff;
}

.interactive-ghost-container:active {
    transform: scale(0.92);
}

/* Generator Main Form Card */
.generator-card {
    padding: 2.8rem;
    position: relative;
}

.story-form {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.required-indicator {
    color: var(--color-violet-glow);
    margin-left: 2px;
}

.btn-surprise {
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: var(--color-violet-glow);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-surprise:hover {
    background: rgba(168, 85, 247, 0.3);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

.form-control {
    width: 100%;
    background: var(--color-bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.9rem 1.1rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.25), var(--glow-violet-sm);
    background: rgba(15, 10, 30, 0.95);
}

.story-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.story-textarea.glow-flash {
    animation: textareaGlowFlash 0.8s ease-out;
}

@keyframes textareaGlowFlash {
    0% { border-color: #38bdf8; box-shadow: 0 0 25px rgba(56, 189, 248, 0.8); }
    100% { border-color: var(--border-subtle); box-shadow: none; }
}

.form-helper-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.input-error-msg {
    font-size: 0.85rem;
    color: #f87171;
    min-height: 1.2rem;
}

/* Category Grid & Pills */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
}

.category-pill {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.9rem;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
}

.category-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.category-pill:hover {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.4);
    transform: translateY(-2px);
}

.category-pill.active {
    background: rgba(168, 85, 247, 0.25);
    border-color: var(--color-violet-glow);
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}

.pill-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.category-pill.active .pill-label {
    color: #ffffff;
}

/* Dual Column Form Row */
.form-row-dual {
    display: flex;
    gap: 1.5rem;
}

.flex-1 {
    flex: 1;
}

/* Length Options */
.length-selector {
    display: flex;
    gap: 0.6rem;
}

.length-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.length-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.length-option:hover {
    background: rgba(168, 85, 247, 0.12);
    transform: translateY(-2px);
}

.length-option.active {
    background: rgba(168, 85, 247, 0.25);
    border-color: var(--color-violet-glow);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.3);
}

.length-badge {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.length-desc {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

/* Generate Button */
.btn-block {
    width: 100%;
    padding: 1.15rem;
    font-size: 1.15rem;
}

.btn-generate {
    letter-spacing: 0.06em;
}

.btn-ghost-icon {
    font-size: 1.35rem;
    animation: btnGhostFloat 2s ease-in-out infinite alternate;
}

@keyframes btnGhostFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}


/* --- 9. MAGICAL LOADING STATE (Section 10) --- */
.loading-panel {
    padding: 3.5rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-color: var(--border-glow);
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading-arcane-circle {
    position: relative;
    width: 150px;
    height: 150px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.runes-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px dashed rgba(192, 132, 252, 0.4);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

.ring-outer {
    animation: rotateClockwise 12s linear infinite;
    border-color: rgba(168, 85, 247, 0.6);
}

.ring-inner {
    inset: 18px;
    border: 1px dotted rgba(56, 189, 248, 0.5);
    animation: rotateCounter 8s linear infinite;
}

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

@keyframes rotateCounter {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

.summoning-ghost {
    width: 65px;
    height: 75px;
    position: relative;
    z-index: 2;
    animation: summoningGhostFloat 2s ease-in-out infinite alternate;
}

@keyframes summoningGhostFloat {
    0% { transform: translateY(0) scale(0.95); }
    100% { transform: translateY(-10px) scale(1.05); }
}

.loading-title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.loading-dots {
    animation: blinkDots 1.5s infinite;
}

@keyframes blinkDots {
    0%, 20% { opacity: 0; }
    40% { opacity: 0.5; }
    60%, 100% { opacity: 1; }
}

.loading-subtitle {
    font-size: 0.95rem;
    color: var(--color-violet-glow);
    margin-bottom: 1.8rem;
}

.loading-progress-bar {
    width: 240px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-glow-track {
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--color-violet-glow), transparent);
    animation: progressSlide 1.6s ease-in-out infinite;
}

@keyframes progressSlide {
    0% { left: -50%; }
    100% { left: 150%; }
}


/* --- 10. ERROR BANNER --- */
.error-banner {
    display: flex;
    align-items: flex-start;
    gap: 1.2rem;
    padding: 1.5rem 1.8rem;
    background: rgba(45, 12, 20, 0.85);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

.error-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.error-body {
    flex: 1;
}

.error-title {
    color: #fca5a5;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.error-message {
    color: #fee2e2;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.error-troubleshooting {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-family: monospace;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.error-troubleshooting ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.btn-close-error {
    background: transparent;
    border: none;
    color: #f87171;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem;
}


/* --- 11. GENERATED STORY RESULT CARD (Section 11) --- */
.story-result-card {
    padding: 3rem;
    margin-top: 2rem;
    border-color: var(--border-glow);
    box-shadow: var(--shadow-card), var(--glow-violet-md);
    animation: resultCardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes resultCardEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.result-badge {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.3rem 0.85rem;
    border-radius: var(--radius-full);
}

.category-badge {
    background: rgba(168, 85, 247, 0.2);
    color: var(--color-violet-glow);
    border: 1px solid rgba(168, 85, 247, 0.4);
}

.length-badge {
    background: rgba(56, 189, 248, 0.15);
    color: var(--color-spirit-cyan);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.model-badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-muted);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.result-ghost-icon {
    width: 36px;
    height: 42px;
    filter: drop-shadow(0 0 8px var(--color-violet-core));
}

.result-story-title {
    font-family: var(--font-heading);
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    font-weight: 900;
    color: #ffffff;
    line-height: 1.25;
    margin-bottom: 1.2rem;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.6);
}

/* --- Language Grid & Pills in Form --- */
.language-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.language-pill {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.1rem;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
}

.language-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.language-pill:hover {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.4);
    transform: translateY(-2px);
}

.language-pill.active {
    background: rgba(168, 85, 247, 0.25);
    border-color: var(--color-violet-glow);
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}

.pill-flag {
    font-size: 1.2rem;
}

/* ==========================================================================
   VOICE NARRATION PLAYER & HORROR AUDIO CONTROLS
   ========================================================================== */
.voice-narration-player {
    background: rgba(13, 9, 26, 0.75);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: var(--radius-md);
    padding: 1.4rem 1.6rem;
    margin: 1.4rem 0 2rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.voice-narration-player:hover {
    border-color: rgba(192, 132, 252, 0.5);
}

/* Active narrating glowing state */
.voice-narration-player.narrating-active {
    border-color: var(--color-violet-glow);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.4), inset 0 0 20px rgba(56, 189, 248, 0.15);
    animation: playerPulseAura 3s ease-in-out infinite alternate;
}

@keyframes playerPulseAura {
    0% {
        box-shadow: 0 0 20px rgba(168, 85, 247, 0.35), inset 0 0 15px rgba(56, 189, 248, 0.1);
    }
    100% {
        box-shadow: 0 0 35px rgba(168, 85, 247, 0.6), inset 0 0 25px rgba(56, 189, 248, 0.25);
    }
}

.narration-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
}

.narrator-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.narrator-ghost-icon {
    width: 32px;
    height: 36px;
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.8));
    animation: narratorGhostHover 2.5s ease-in-out infinite alternate;
}

@keyframes narratorGhostHover {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px) rotate(4deg); }
}

.narrator-mini-ghost {
    width: 100%;
    height: 100%;
}

.narrator-info {
    display: flex;
    flex-direction: column;
}

.narrator-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.narrator-status {
    font-size: 0.8rem;
    color: var(--color-violet-glow);
    font-weight: 500;
}

/* Sound-Wave Visualizer Bars */
.sound-wave-bars {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
}

.sound-wave-bars .bar {
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--color-spirit-cyan), var(--color-violet-glow));
    border-radius: var(--radius-full);
    transform: scaleY(0.2);
    transform-origin: bottom;
    transition: transform 0.2s ease;
}

/* Pulsing audio wave animation when active */
.voice-narration-player.narrating-active .sound-wave-bars .bar {
    animation: soundWavePulse 1.1s ease-in-out infinite alternate;
}

.sound-wave-bars .bar-1 { animation-delay: 0.0s !important; }
.sound-wave-bars .bar-2 { animation-delay: 0.2s !important; }
.sound-wave-bars .bar-3 { animation-delay: 0.4s !important; }
.sound-wave-bars .bar-4 { animation-delay: 0.1s !important; }
.sound-wave-bars .bar-5 { animation-delay: 0.3s !important; }
.sound-wave-bars .bar-6 { animation-delay: 0.5s !important; }
.sound-wave-bars .bar-7 { animation-delay: 0.2s !important; }

@keyframes soundWavePulse {
    0% { transform: scaleY(0.25); opacity: 0.6; }
    50% { transform: scaleY(0.85); opacity: 1; }
    100% { transform: scaleY(0.4); opacity: 0.7; }
}

/* Paused state freezes sound waves */
.voice-narration-player.narrating-paused .sound-wave-bars .bar {
    animation-play-state: paused !important;
}

/* Narration Progress Track */
.narration-progress-track {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 1.1rem;
}

.narration-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--color-violet-core), var(--color-spirit-cyan));
    box-shadow: 0 0 8px var(--color-spirit-cyan);
    transition: width 0.3s ease;
}

/* Main Controls Row */
.narration-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.playback-buttons-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-voice {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1.15rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.btn-voice-play, .btn-voice-resume, .btn-voice-replay {
    background: linear-gradient(135deg, var(--color-violet-core), #6b21a8);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.35);
}

.btn-voice-play:hover, .btn-voice-resume:hover, .btn-voice-replay:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.55), 0 0 14px rgba(192, 132, 252, 0.6);
}

.btn-voice-pause {
    background: rgba(245, 158, 11, 0.18);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.btn-voice-pause:hover {
    background: rgba(245, 158, 11, 0.3);
    transform: translateY(-2px);
}

.btn-voice-stop {
    background: rgba(239, 68, 68, 0.16);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-voice-stop:hover {
    background: rgba(239, 68, 68, 0.28);
    transform: translateY(-2px);
}

/* Atmosphere Audio Control Group */
.atmosphere-control-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.btn-atmosphere {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-atmosphere:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
    color: #ffffff;
}

.btn-atmosphere.active {
    background: rgba(56, 189, 248, 0.18);
    border-color: var(--color-spirit-cyan);
    color: #e0f2fe;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.35);
}

.atmosphere-volume-wrapper {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.vol-icon {
    font-size: 0.85rem;
}

.volume-slider {
    width: 75px;
    accent-color: var(--color-spirit-cyan);
    cursor: pointer;
    height: 4px;
}

.vol-percent {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: monospace;
    min-width: 28px;
}

/* Auto-Play & Settings Toggle Bar */
.narration-settings-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.autoplay-setting-label {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    user-select: none;
}

.ghost-checkbox {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.ghost-checkbox:checked + .checkbox-custom {
    background: var(--color-violet-core);
    border-color: var(--color-violet-glow);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.ghost-checkbox:checked + .checkbox-custom::after {
    content: '✓';
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 900;
}

.btn-toggle-settings {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-toggle-settings:hover {
    color: var(--color-violet-glow);
}

.settings-chevron {
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
}

.btn-toggle-settings[aria-expanded="true"] .settings-chevron {
    transform: rotate(180deg);
}

/* Collapsible Scary Voice Settings Panel */
.voice-settings-panel {
    margin-top: 1.2rem;
    padding: 1.4rem;
    background: rgba(7, 5, 14, 0.85);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    animation: fadeIn 0.3s ease-out;
}

.voice-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.1rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.setting-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text-secondary);
}

.select-ghost {
    font-size: 0.88rem;
    padding: 0.55rem 0.8rem;
    border-radius: var(--radius-sm);
    background: rgba(18, 12, 34, 0.95);
    color: #ffffff;
}

.select-ghost option {
    background: #0f0b1c;
    color: #ffffff;
}

.setting-subtext {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

.voice-pills-row {
    display: flex;
    gap: 0.4rem;
}

.voice-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.45rem 0.4rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.voice-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.voice-pill:hover {
    background: rgba(168, 85, 247, 0.12);
    color: #ffffff;
}

.voice-pill.active {
    background: rgba(168, 85, 247, 0.25);
    border-color: var(--color-violet-glow);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

.voice-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.76rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
}

.story-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(168, 85, 247, 0.4), transparent);
}

.divider-rune {
    color: var(--color-violet-glow);
    font-size: 1.1rem;
}

.result-story-content {
    font-size: 1.1rem;
    line-height: 1.85;
    color: #e2e8f0;
    margin-bottom: 2.5rem;
    white-space: pre-line;
}

.result-story-content p {
    margin-bottom: 1.4rem;
}

.result-footer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--border-subtle);
    padding-top: 1.8rem;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.btn-action {
    padding: 0.75rem 1.4rem;
    font-size: 0.95rem;
}

.copy-toast {
    display: inline-block;
    align-self: flex-start;
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #86efac;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    animation: fadeIn 0.2s ease-out;
}


/* --- 12. HOW IT WORKS SECTION (Section 12) --- */
.how-it-works-section {
    padding: 6rem 0;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.step-card {
    padding: 2.5rem 2rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-normal), border-color var(--transition-normal);
}

.step-card:hover {
    transform: translateY(-8px);
    border-color: var(--border-glow);
}

.step-number {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 900;
    color: rgba(168, 85, 247, 0.15);
    line-height: 1;
}

.step-icon-wrap {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.step-emoji {
    font-size: 1.8rem;
}

.step-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.8rem;
}

.step-desc {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.step-card-ghost {
    position: absolute;
    bottom: -15px;
    right: -10px;
    font-size: 3.5rem;
    opacity: 0.08;
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.step-card:hover .step-card-ghost {
    opacity: 0.18;
    transform: translateY(-6px);
}


/* --- 13. OPEN-SOURCE AI SECTION (Section 13) --- */
.open-source-section {
    padding: 6rem 0;
}

.benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.8rem;
    margin-bottom: 3rem;
}

.benefit-card {
    padding: 2.2rem 2rem;
    transition: transform var(--transition-normal);
}

.benefit-card:hover {
    transform: translateY(-5px);
}

.benefit-icon {
    font-size: 2.2rem;
    margin-bottom: 1.2rem;
}

.benefit-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.6rem;
}

.benefit-desc {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.65;
}

.benefit-desc code {
    background: rgba(0, 0, 0, 0.4);
    color: var(--color-spirit-cyan);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
}

.prerequisite-box {
    max-width: 780px;
    margin: 0 auto;
    padding: 1.8rem 2.2rem;
    border-color: rgba(56, 189, 248, 0.35);
}

.prereq-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-spirit-cyan);
    background: rgba(56, 189, 248, 0.15);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    margin-bottom: 0.6rem;
}

.prereq-text {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.prereq-text code {
    background: rgba(0, 0, 0, 0.4);
    color: var(--color-violet-glow);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}


/* --- 14. ABOUT SECTION (Section 14) --- */
.about-section {
    padding: 6rem 0 8rem;
}

.about-card {
    padding: 3.5rem;
}

.about-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 3.5rem;
    align-items: center;
}

.about-desc {
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    line-height: 1.75;
    margin-bottom: 1.2rem;
}

.about-contribute-box {
    margin-top: 1.8rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 1.5rem 1.8rem;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--color-violet-glow);
}

.contribute-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.8rem;
}

.contribute-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.contribute-list code {
    color: var(--color-spirit-cyan);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
}

.about-visual-col {
    display: flex;
    justify-content: center;
    align-items: center;
}

.about-ghost-circle {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.about-ghost-svg {
    width: 160px;
    height: 180px;
    animation: aboutGhostSway 4s ease-in-out infinite alternate;
}

@keyframes aboutGhostSway {
    0% { transform: translateY(0) rotate(-4deg); }
    100% { transform: translateY(-16px) rotate(4deg); }
}

.spell-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px dashed rgba(168, 85, 247, 0.4);
    animation: rotateClockwise 16s linear infinite;
}


/* --- 15. FOOTER & FOOTER GHOST (Section 15) --- */
.site-footer {
    background: #050308;
    border-top: 1px solid var(--border-subtle);
    position: relative;
    overflow: hidden;
    padding-top: 4rem;
}

/* F. GHOST FOOTER ANIMATION (Section 5.F) */
.footer-ghost-track {
    position: absolute;
    top: 12px;
    left: 0;
    width: 100%;
    height: 60px;
    pointer-events: none;
    overflow: hidden;
}

.footer-drifting-ghost {
    width: 50px;
    height: 60px;
    animation: footerGhostJourney 25s ease-in-out infinite alternate;
}

@keyframes footerGhostJourney {
    0% {
        transform: translateX(10vw) translateY(0);
    }
    50% {
        transform: translateX(50vw) translateY(-10px);
    }
    100% {
        transform: translateX(85vw) translateY(4px);
    }
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 3rem;
    padding-bottom: 3.5rem;
}

.footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    margin-bottom: 0.8rem;
}

.footer-tagline {
    font-style: italic;
    color: var(--color-violet-glow);
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
}

.footer-open-source-note {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    max-width: 380px;
}

.footer-col-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.2rem;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.footer-links a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-fast), transform var(--transition-fast);
    display: inline-block;
}

.footer-links a:hover {
    color: var(--color-violet-glow);
    transform: translateX(3px);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 1.8rem 0;
}

.footer-bottom-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}


/* --- 16. RESPONSIVE MEDIA QUERIES --- */
@media (max-width: 1024px) {
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2.5rem;
    }

    .hero-description {
        margin: 0 auto 2.2rem;
    }

    .hero-actions, .hero-stats {
        justify-content: center;
    }

    .hero-ghost-stage {
        height: 280px;
    }

    .hero-floating-ghost {
        width: 190px;
        height: 230px;
    }

    .about-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .about-contribute-box {
        text-align: left;
    }

    .footer-content {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        width: 100%;
        background: rgba(10, 7, 20, 0.97);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 2rem 1.5rem;
        gap: 1.5rem;
        border-bottom: 1px solid var(--border-subtle);
    }

    .nav-links.active {
        display: flex;
        animation: fadeIn 0.3s ease-out;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .form-row-dual {
        flex-direction: column;
        gap: 1.5rem;
    }

    .generator-card {
        padding: 1.8rem 1.2rem;
    }

    .story-result-card {
        padding: 1.8rem 1.2rem;
    }

    .interactive-ghost-container {
        right: 10px;
        top: -65px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    .footer-bottom-flex {
        flex-direction: column;
        text-align: center;
    }

    .walking-ghost-track {
        width: 90px;
        height: 105px;
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    .category-grid {
        grid-template-columns: 1fr;
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }
}


/* --- 17. ACCESSIBILITY: PREFERS-REDUCED-MOTION (Section 18) --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Pause infinite horizontal journeys */
    .walking-ghost-track {
        animation: none !important;
        display: none !important;
    }

    .flying-ghost-container,
    .bg-ghost,
    .footer-drifting-ghost {
        animation: none !important;
        opacity: 0.25;
    }

    .lightning-flash {
        display: none !important;
    }

    .runes-ring,
    .fog-wave,
    .particle {
        animation: none !important;
    }
}
