:root {
    --orange-fire: #FF6B2B;
    --orange-warm: #FF9A3C;
    --green-leaf: #2D9B5A;
    --green-mint: #A8E6CF;
    --cream: #FFF8F0;
    --dark-earth: #1C1207;
    --gold: #F4C842;
    --ff-display: 'Fraunces', serif;
    --ff-body: 'DM Sans', sans-serif;
    --ff-mono: 'Courier Prime', monospace
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden
}

body {
    font-family: var(--ff-body);
    background: var(--cream);
    color: var(--dark-earth);
    overflow-x: hidden
}

/* Scroll Progress */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--orange-fire), var(--gold));
    width: 0;
    z-index: 9999;
    transition: width .15s
}

/* Grain */
#grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    opacity: .035;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")
}

/* Navigation */
#story-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    background: rgba(28, 18, 7, 0.05);
    backdrop-filter: blur(12px);
    transition: background 0.3s;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-emoji {
    font-size: 1.5rem;
}

.logo-text {
    font: 900 1.2rem var(--ff-display);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    color: inherit;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-link {
    font: 700 0.8rem var(--ff-mono);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-decoration: none;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.nav-link:hover {
    opacity: 1;
}

.nav-cta {
    background: var(--orange-fire);
    color: #fff;
    font: 700 0.8rem var(--ff-body);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 28px;
    border-radius: 40px;
    text-decoration: none;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 15px rgba(255, 107, 43, 0.2);
}

.nav-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 43, 0.3);
}

body[data-mood="cream"] #story-nav,
body[data-mood="warm"] #story-nav {
    color: var(--dark-earth);
}

body[data-mood="dark"] #story-nav,
body[data-mood="green"] #story-nav,
body[data-mood="fire"] #story-nav {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

/* Chapter base */
.chapter {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    overflow: hidden;
    transition: background .8s
}

.ch-inner {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    text-align: center
}

/* Moods */
[data-mood="dark"] {
    background: var(--dark-earth);
    color: #fff
}

[data-mood="cream"] {
    background: var(--cream);
    color: var(--dark-earth)
}

[data-mood="warm"] {
    background: var(--orange-warm);
    color: var(--dark-earth)
}

[data-mood="green"] {
    background: var(--green-leaf);
    color: #fff
}

[data-mood="fire"] {
    background: var(--orange-fire);
    color: #fff
}

/* ── CH0 Hero ── */
.ch0-eyebrow {
    font: 700 .75rem/1 var(--ff-mono);
    letter-spacing: .3em;
    text-transform: uppercase;
    color: var(--orange-warm);
    margin-bottom: 32px
}

.ch0-title {
    font: 900 clamp(2.4rem, 7vw, 5.5rem)/1 var(--ff-display);
    letter-spacing: -.03em;
    margin-bottom: 28px
}

.ch0-title em {
    color: var(--orange-fire);
    font-style: italic
}

.ch0-sub {
    font: 500 clamp(1rem, 2.5vw, 1.4rem)/1.5 var(--ff-body);
    color: rgba(255, 255, 255, .55);
    max-width: 500px;
    margin: 0 auto
}

.scroll-cue {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    font: 700 .7rem var(--ff-mono);
    letter-spacing: .2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .35);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: pulse-cue 2s infinite
}

.scroll-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange-fire);
    animation: bounce-dot 2s infinite
}

@keyframes bounce-dot {

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

    50% {
        transform: translateY(10px)
    }
}

@keyframes pulse-cue {

    0%,
    100% {
        opacity: .35
    }

    50% {
        opacity: .7
    }
}

/* Food Emojis */
#food-emojis {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1
}

.food-emoji {
    position: absolute;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    animation: float-up linear infinite;
    opacity: .25;
    will-change: transform
}

@keyframes float-up {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0
    }

    10% {
        opacity: .25
    }

    90% {
        opacity: .25
    }

    100% {
        transform: translateY(-10vh) rotate(30deg);
        opacity: 0
    }
}

/* ── CH1 Counters ── */
.ch-heading {
    font: 900 clamp(2rem, 5vw, 3.8rem)/1.05 var(--ff-display);
    letter-spacing: -.02em;
    margin-bottom: 56px
}

.ch-heading em {
    color: var(--orange-fire);
    font-style: italic
}

[data-mood="green"] .ch-heading em,
[data-mood="fire"] .ch-heading em {
    color: var(--gold)
}

[data-mood="warm"] .ch-heading em {
    color: var(--dark-earth)
}

.counters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 32px;
    max-width: 900px;
    margin: 0 auto
}

.counter-card {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(12px);
    border-radius: 28px;
    padding: 40px 28px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .06);
    border: 1px solid rgba(0, 0, 0, .04)
}

.counter-icon {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 12px
}

.counter-num {
    font: 900 3.2rem var(--ff-display);
    color: var(--orange-fire);
    display: inline
}

.counter-suf {
    font: 900 1.6rem var(--ff-display);
    color: var(--orange-fire)
}

.counter-card p {
    font: 500 .95rem/1.5 var(--ff-body);
    color: #666;
    margin-top: 10px
}

/* ── CH2 Players ── */
.players {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 28px;
    max-width: 900px;
    margin: 0 auto
}

.player-card {
    background: var(--cream);
    border-radius: 28px;
    padding: 44px 28px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .1);
    transition: transform .4s;
    transform-style: preserve-3d;
    perspective: 600px;
    cursor: default
}

.player-card:hover {
    transform: rotateY(4deg) rotateX(-2deg) translateY(-6px)
}

.player-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px
}

.player-card h3 {
    font: 900 1.4rem var(--ff-display);
    margin-bottom: 8px
}

.player-card p {
    font: 400 .95rem/1.5 var(--ff-body);
    color: #555
}

/* ── CH3 Timeline ── */
.timeline {
    max-width: 560px;
    margin: 0 auto;
    text-align: left;
    position: relative;
    padding-left: 56px
}

.timeline::before {
    content: '';
    position: absolute;
    left: 22px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, .25)
}

.tl-step {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 36px;
    position: relative
}

.tl-num {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--dark-earth);
    font: 900 1.1rem var(--ff-display);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: absolute;
    left: -56px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .2)
}

.tl-content h4 {
    font: 700 1.15rem var(--ff-display);
    color: #fff;
    margin-bottom: 4px
}

.tl-content p {
    font: 400 .9rem/1.5 var(--ff-body);
    color: rgba(255, 255, 255, .7)
}

/* ── CH4 Impact ── */
.impact-nums {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 32px;
    max-width: 800px;
    margin: 0 auto 48px
}

.impact-card {
    text-align: center
}

.impact-icon {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 8px
}

.impact-val {
    font: 900 clamp(2.2rem, 5vw, 3.6rem) var(--ff-display);
    color: var(--gold);
    display: block
}

.impact-card p {
    font: 500 .9rem var(--ff-body);
    color: rgba(255, 255, 255, .55);
    margin-top: 6px
}

#mesh-canvas {
    width: 100%;
    height: 280px;
    display: block;
    margin: 0 auto;
    max-width: 900px
}

/* ── CH5 Manifesto ── */
.manifesto-wrap {
    max-width: 720px;
    text-align: center
}

.manifesto-line {
    font: 400 clamp(1.2rem, 3vw, 2rem)/1.5 var(--ff-display);
    color: var(--dark-earth);
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .8s, transform .8s
}

.manifesto-line.visible {
    opacity: 1;
    transform: translateY(0)
}

.manifesto-line em {
    color: var(--orange-fire)
}

.manifesto-line strong {
    color: var(--green-leaf)
}

.manifesto-break {
    height: 24px
}

#manifesto-bg-food {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: .07;
    overflow: hidden
}

/* ── CH6 CTA ── */
.cta-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px
}

.cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--cream);
    color: var(--dark-earth);
    text-decoration: none;
    font: 700 1rem var(--ff-body);
    padding: 18px 32px;
    border-radius: 60px;
    transition: transform .3s, box-shadow .3s;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .15)
}

.cta-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, .25)
}

.cta-btn span {
    font-size: 1.4rem
}

.cta-footer {
    font: 400 .85rem/1.6 var(--ff-body);
    color: rgba(255, 255, 255, .55);
    margin-top: 8px
}

.cta-footer strong {
    color: #fff
}

/* ── STITCH AI ── */
#stitch {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px
}

#stitch-label {
    font: 700 .6rem var(--ff-mono);
    letter-spacing: .15em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
    background: rgba(0, 0, 0, .5);
    padding: 4px 10px;
    border-radius: 20px;
    backdrop-filter: blur(8px)
}

#stitch-orb {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange-fire), var(--green-leaf));
    cursor: pointer;
    box-shadow: 0 0 24px rgba(255, 107, 43, .4), 0 0 60px rgba(45, 155, 90, .2);
    animation: orb-pulse 3s ease-in-out infinite;
    transition: transform .3s
}

#stitch-orb:hover {
    transform: scale(1.15)
}

@keyframes orb-pulse {

    0%,
    100% {
        box-shadow: 0 0 24px rgba(255, 107, 43, .4), 0 0 60px rgba(45, 155, 90, .2)
    }

    50% {
        box-shadow: 0 0 36px rgba(255, 107, 43, .6), 0 0 80px rgba(45, 155, 90, .35)
    }
}

#stitch-bubble {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 300px;
    background: rgba(28, 18, 7, .92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 20px 20px 4px 20px;
    padding: 20px;
    opacity: 0;
    transform: translateY(10px) scale(.95);
    transition: opacity .3s, transform .3s;
    pointer-events: none
}

#stitch-bubble.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto
}

#stitch-text {
    font: 400 .85rem/1.6 var(--ff-mono);
    color: rgba(255, 255, 255, .85);
    min-height: 40px
}

#stitch-text .cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background: var(--orange-fire);
    animation: blink .6s step-end infinite;
    margin-left: 2px;
    vertical-align: text-bottom
}

@keyframes blink {
    50% {
        opacity: 0
    }
}

.stitch-bounce {
    animation: orb-bounce .5s ease !important
}

@keyframes orb-bounce {

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

    40% {
        transform: translateY(-12px)
    }

    60% {
        transform: translateY(-4px)
    }
}

/* ── Anim-in (scroll reveal) ── */
.anim-in {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity .7s ease, transform .7s ease
}

.anim-in.visible {
    opacity: 1;
    transform: translateY(0)
}

/* ── Responsive ── */
@media(max-width:768px) {
    .chapter {
        padding: 60px 20px
    }

    .counters,
    .players {
        grid-template-columns: 1fr
    }

    .cta-buttons {
        flex-direction: column;
        align-items: center
    }

    #stitch {
        bottom: 16px;
        right: 16px
    }

    #stitch-bubble {
        width: 260px
    }

    #stitch-orb {
        width: 44px;
        height: 44px
    }

    .timeline {
        padding-left: 48px
    }

    .tl-num {
        left: -48px;
        width: 36px;
        height: 36px;
        font-size: .9rem
    }
}

@media(max-width:480px) {
    #stitch {
        right: 50%;
        transform: translateX(50%);
        bottom: 12px;
        flex-direction: row;
        align-items: center;
        gap: 10px
    }

    #stitch-bubble {
        right: -40px;
        width: calc(100vw - 40px);
        bottom: 60px
    }
}