:root {
    --bg: #FAF4E8;
    --text: #2E2A23;
    --text-secondary: #7A6F5D;
    --accent-green: #5B8C5A;
    --accent-wine: #8B4557;
    --quest-line: #C9B99A;
    --chapter-band: #F0E8D8;
    --inventory-bg: #3D3225;
    --lantern-amber: #E8B84B;
}

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

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.75;
    overflow-x: hidden;
    padding-bottom: 48px;
}

/* Quest line SVG running down the left margin */
.quest-line-svg {
    position: fixed;
    left: 38px;
    top: 0;
    width: 4px;
    height: 100vh;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.6s ease;
}

body.quest-started .quest-line-svg {
    opacity: 1;
}

.quest-line-path {
    stroke-dasharray: 6, 4;
}

/* Sections */
.section {
    position: relative;
    z-index: 2;
}

/* The Cover */
.section-cover {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.cover-title {
    font-family: 'Silkscreen', cursive;
    font-weight: 400;
    font-size: 24px;
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    min-height: 1.4em;
    margin-bottom: 16px;
}

.cover-title .cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: var(--accent-green);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.cover-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 18px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 1s ease;
}

.cover-subtitle.visible {
    opacity: 1;
}

/* Chapter Bands */
.chapter-band {
    width: 100%;
    height: 40px;
    background-color: var(--chapter-band);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chapter-label {
    font-family: 'Silkscreen', cursive;
    font-weight: 400;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

/* Chapter Sections */
.section-chapter {
    padding: 60px 20px 60px 0;
}

.section-chapter-1 {
    min-height: 150vh;
}

.section-chapter-2 {
    min-height: 150vh;
}

.section-chapter-3 {
    min-height: 150vh;
}

/* Quest entries column */
.quest-entries {
    max-width: 620px;
    margin-left: 60px;
    position: relative;
}

/* Quest line in the margin */
.quest-entries::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-image: repeating-linear-gradient(
        to bottom,
        var(--quest-line) 0px,
        var(--quest-line) 6px,
        transparent 6px,
        transparent 10px
    );
}

/* Quest icon markers on the line */
.quest-icon-marker {
    position: relative;
    width: 28px;
    height: 28px;
    margin-left: -44px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg);
    border-radius: 50%;
    z-index: 3;
}

.quest-icon {
    width: 16px;
    height: 16px;
}

.quest-icon-end {
    margin-top: 30px;
}

/* Journal entries */
.entry {
    margin-bottom: 40px;
    padding: 24px 28px;
    background-color: var(--bg);
    position: relative;
}

/* Torn paper edges via clip-path */
.torn-paper {
    clip-path: polygon(
        0% 3px, 3% 0px, 6% 4px, 9% 1px, 12% 3px, 15% 0px, 18% 2px, 21% 0px,
        24% 4px, 27% 1px, 30% 3px, 33% 0px, 36% 2px, 39% 0px, 42% 3px, 45% 1px,
        48% 4px, 51% 0px, 54% 2px, 57% 0px, 60% 3px, 63% 1px, 66% 4px, 69% 0px,
        72% 3px, 75% 1px, 78% 0px, 81% 3px, 84% 0px, 87% 2px, 90% 0px, 93% 4px,
        96% 1px, 100% 3px,
        100% calc(100% - 3px), 97% 100%, 94% calc(100% - 4px), 91% 100%,
        88% calc(100% - 2px), 85% 100%, 82% calc(100% - 3px), 79% 100%,
        76% calc(100% - 4px), 73% 100%, 70% calc(100% - 2px), 67% 100%,
        64% calc(100% - 3px), 61% 100%, 58% calc(100% - 4px), 55% 100%,
        52% calc(100% - 2px), 49% 100%, 46% calc(100% - 3px), 43% 100%,
        40% calc(100% - 4px), 37% 100%, 34% calc(100% - 2px), 31% 100%,
        28% calc(100% - 3px), 25% 100%, 22% calc(100% - 4px), 19% 100%,
        16% calc(100% - 2px), 13% 100%, 10% calc(100% - 3px), 7% 100%,
        4% calc(100% - 4px), 1% 100%, 0% calc(100% - 2px)
    );
    border-left: 3px solid var(--quest-line);
}

.entry-date {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.entry-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text);
}

/* Fade-in elements */
[data-fade] {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 1s ease, transform 1s ease;
}

[data-fade].visible {
    opacity: 1;
    transform: translateY(0);
}

/* Hand-drawn map */
.map-container {
    margin: 60px -20px 60px -30px;
    padding: 30px 20px;
    background-color: var(--chapter-band);
    border-radius: 2px;
}

.hand-drawn-map {
    width: 100%;
    max-width: 800px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.map-label {
    font-family: 'Caveat', cursive;
    font-size: 13px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

.map-title {
    font-family: 'Caveat', cursive;
    font-size: 16px;
    fill: var(--text-secondary);
    text-anchor: middle;
}

/* Back Cover */
.section-back-cover {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-cover-content {
    text-align: center;
}

.quest-complete {
    font-family: 'Silkscreen', cursive;
    font-weight: 400;
    font-size: 16px;
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
}

.quest-motto {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 16px;
    color: var(--text-secondary);
}

/* Inventory Bar */
.inventory-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background-color: var(--inventory-bg);
    opacity: 0.95;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.6s ease;
}

.inventory-bar.visible {
    transform: translateY(0);
}

.inventory-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.2;
    transition: opacity 0.4s ease, filter 0.4s ease;
}

.inventory-item.collected {
    opacity: 1;
    filter: drop-shadow(0 0 6px var(--lantern-amber));
}

.inventory-item.bounce {
    animation: bounce-in 0.5s ease;
}

@keyframes bounce-in {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.inventory-icon {
    width: 20px;
    height: 20px;
}

/* Mobile */
@media (max-width: 768px) {
    .quest-entries {
        margin-left: 40px;
        max-width: calc(100% - 20px);
    }

    .quest-entries::before {
        left: -20px;
    }

    .quest-icon-marker {
        margin-left: -34px;
    }

    .quest-line-svg {
        left: 18px;
    }

    .map-container {
        margin-left: -20px;
        margin-right: -10px;
    }

    .section-chapter {
        padding: 40px 16px 40px 0;
    }

    .inventory-bar {
        gap: 16px;
    }
}
