:root {
    --ink: #faecd6;
    --ink-dim: rgba(250, 236, 214, .82);
    --line: rgba(255, 255, 255, .22);
    --glass: rgba(10, 10, 10, .45);
    --glow: rgba(255, 232, 170, .9);

    /* Visuals (still used for some elements, but 3D is primary now) */
    --bg: url('https://static.wixstatic.com/media/bdbe03_319b1699aa174f8bbf73f5aa4842ac39~mv2.png');
    --mid: url('https://static.wixstatic.com/media/bdbe03_0d4f05b9d38b4155a2c3ff76a44ae317~mv2.png');
    --fg: url('https://static.wixstatic.com/media/bdbe03_7f4c3c9e5b3f4f1bbfbd3e0e27b3d7b5~mv2.png');
    --arch: 'https://static.wixstatic.com/media/bdbe03_3ff9252ab6a3430fac691a0ce2767e42~mv2.png';

    /* Theme bed (plays only when no song is close) */
    --src-theme: 'https://static.wixstatic.com/mp3/bdbe03_090a944b42cc46d9ac7ff052ed8a775a.m4a';
}

html,
body {
    margin: 0;
    height: 100%;
    background: #0b0b0b;
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif
}

* {
    box-sizing: border-box
}

body {
    overflow: hidden
}

/* Scene container — 3D canvas is injected inside this */
#scene {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #050505
}

.layer.bg {
    position: absolute;
    inset: 0;
    background-image: var(--bg);
    background-size: cover;
    background-position: center;
    will-change: transform, filter;
    transition: filter 1.2s ease, opacity .8s;
    z-index: 0
}

.layer.mid {
    position: absolute;
    inset: -8% -8%;
    background-image: var(--mid);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    opacity: .96;
    will-change: transform;
    z-index: 1
}

.layer.fg {
    position: absolute;
    inset: -10% -10%;
    background-image: var(--fg);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
    will-change: transform;
    z-index: 2
}

.orb-focus .layer.bg {
    filter: blur(2px) brightness(.85)
}

/* Character (2D) – hidden in 3D mode but kept in DOM */
#character {
    position: absolute;
    left: 50%;
    bottom: 7%;
    width: min(32vw, 380px);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 3;
    filter: contrast(1.06) saturate(1.06) brightness(.98);
    --archAnim: none;
    animation: breathe 8s ease-in-out infinite, var(--archAnim);
}

#character img {
    width: 100%;
    height: auto;
    display: block;
    -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, .99), rgba(0, 0, 0, .3) 70%, transparent 100%);
    mask-image: linear-gradient(to top, rgba(0, 0, 0, .99), rgba(0, 0, 0, .3) 70%, transparent 100%)
}

@keyframes breathe {

    0%,
    100% {
        transform: translate(-50%, 0) scale(1)
    }

    50% {
        transform: translate(-50%, -1.6%) scale(1.01)
    }
}

@keyframes archMidair {
    0% {
        transform: translate(-50%, 0) rotate(0) scale(1)
    }

    30% {
        transform: translate(-50%, -2.6%) rotate(-1.5deg) scale(1.03)
    }

    55% {
        transform: translate(-50%, -4.2%) rotate(-2deg) scale(1.06)
    }

    100% {
        transform: translate(-50%, 0) rotate(0) scale(1)
    }
}

.arching {
    --archAnim: archMidair 1.15s cubic-bezier(.2, .8, .2, 1) 1;
}

/* Fireflies (2D overlay, still used for vibe) */
#fireflies {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2
}

.fly {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 240, 200, 1) 0%, rgba(255, 240, 200, .25) 70%, transparent 100%);
    opacity: .85;
    filter: drop-shadow(0 0 6px rgba(255, 240, 200, .9))
}

/* HUD */
#hud {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 20
}

button.icon {
    cursor: pointer;
    border-radius: 999px;
    border: 1px solid var(--line);
    padding: 8px 10px;
    background: var(--glass);
    color: var(--ink)
}

button.icon:hover {
    background: rgba(255, 255, 255, .08)
}

/* Intro overlay */
#enter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 30
}

#enter .card {
    max-width: 860px;
    margin: 6vw 4vw;
    padding: 28px;
    border-radius: 20px;
    background: rgba(0, 0, 0, .32);
    border: 1.5px solid rgba(255, 255, 255, .22);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
    text-align: center
}

#enter h1 {
    margin: 0 0 10px;
    font-size: 28px;
    letter-spacing: .02em
}

#enter .sub {
    opacity: .9;
    font-size: 15px;
    margin-bottom: 16px
}

#enter .btn {
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .08);
    color: var(--ink);
    font-size: 14px;
    cursor: pointer
}

#enter .meta {
    color: var(--ink-dim);
    font-size: 12.5px;
    margin-top: 10px
}

/* Story Panel */
#overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .25);
    /* a bit lighter so the garden is still visible */
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    display: none;
    z-index: 28;
}

#panel {
    position: absolute;
    left: 50%;
    bottom: 0;
    /* start just off-screen and slide up */
    transform: translate(-50%, 115%);
    transition: transform .45s cubic-bezier(.2, .8, .2, 1);

    width: min(760px, 90vw);
    max-height: 34vh;
    /* ≈ bottom third of the screen */
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 16px;
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    color: var(--ink);
    z-index: 29;

    display: flex;
    flex-direction: column;
    overflow: hidden;

    font-size: 13px;
    /* slightly smaller text overall */
}

#panel.on {
    transform: translate(-50%, 0);
}

#panel .top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* no X button anymore */
    padding: 8px 14px;
    border-bottom: 1px solid var(--line);
}

#panel .title {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: .02em;
}

#panel .body {
    padding: 10px 14px;
    line-height: 1.5;
    overflow: auto;
    font-size: 13px;
    /* smaller body text too */
}

#panel blockquote {
    margin: 8px 0 12px;
    padding: 6px 10px;
    border-left: 2px solid #ffe2a6;
    background: rgba(255, 255, 255, .05);
}

#panel details {
    margin: 12px 0;
    border: 1px dashed rgba(255, 255, 255, .18);
    border-radius: 12px;
    padding: 8px 10px;
}

#panel summary {
    cursor: pointer;
    opacity: .92;
}

#panel pre {
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.55;
}

#toast {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 10px;
    font-size: 12px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: none;
    z-index: 32
}

@media (max-width:768px) {
    #character {
        bottom: 4%;
        width: min(46vw, 360px)
    }

    #panel {
        max-height: 66vh
    }
}

/* ===================== CAPTIONS ===================== */
#captionRail {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 3vh;
    z-index: 25;
    pointer-events: none;
    display: flex;
    justify-content: center;
    padding: 0 5vw;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
}

#captionRail .caption {
    font-size: clamp(11px, 1.9vw, 15px);
    letter-spacing: .02em;
    line-height: 1.4;
    color: var(--ink);

    max-width: min(1000px, 88vw);
    min-height: 34px;
    padding: 4px 10px 6px;

    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(12, 12, 12, .65), rgba(12, 12, 12, .34));
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 16px 50px rgba(0, 0, 0, .38), inset 0 0 0 1px rgba(255, 255, 255, .06);
    position: relative;
    overflow: hidden;
    text-align: center;
}

#captionRail .caption:before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .2), transparent);
}

#captionRail .glint {
    position: absolute;
    top: 50%;
    width: 72px;
    height: 1.5px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, rgba(240, 210, 140, .9), transparent);
    animation: glint 5.2s linear infinite;
    opacity: .3;
}

@keyframes glint {
    0% {
        left: -10%
    }

    100% {
        left: 110%
    }
}

#captionRail .text {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .45s ease, transform .45s ease
}

/* =================================================== */