@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Special+Elite&display=swap");

/* Story Line: full-screen visual-novel player shared by every part */
.sp {
    --sp-gold: #e6c36a;
    --sp-gold-hi: #ffe2a0;
    --sp-ratio: 1.7769;
    --sp-stage-w: min(100vw, calc(100vh * var(--sp-ratio)));
    --sp-stage-h: calc(var(--sp-stage-w) / var(--sp-ratio));
    position: fixed;
    inset: 0;
    z-index: 10100;
    overflow: hidden;
    background: #000;
    color: #f7f1e4;
    font-family: "Montserrat", "Segoe UI", Tahoma, sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.7s ease, visibility 0s linear 0.7s;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.sp.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.7s ease, visibility 0s;
}
/* Children with their own `visibility: visible` would otherwise stay clickable over the page */
.sp:not(.is-open),
.sp:not(.is-open) * {
    pointer-events: none !important;
}

/* Blurred copy of the scene that fills the space around the 16:9 stage */
.sp-backdrop {
    position: absolute;
    inset: -40px;
    pointer-events: none;
}
.sp-backdrop img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(34px) brightness(0.38) saturate(1.2);
    opacity: 0;
    transition: opacity 1.2s ease;
}
.sp-backdrop img.is-in { opacity: 1; }

.sp-stage {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--sp-stage-w);
    height: var(--sp-stage-h);
    transform: translate(-50%, -50%);
    overflow: hidden;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.85);
}
.sp-scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.07);
    filter: blur(10px) brightness(0.6);
    transition:
        opacity 1.1s cubic-bezier(0.22, 0.61, 0.36, 1),
        transform 1.6s cubic-bezier(0.16, 1, 0.3, 1),
        filter 1.1s ease;
}
.sp-scene.is-in {
    opacity: 1;
    transform: scale(1);
    filter: none;
}
.sp-scene.is-out {
    opacity: 0;
    transform: scale(0.985);
    filter: blur(6px) brightness(0.5);
    transition-duration: 0.8s;
}
.sp-stage.is-dim .sp-scene.is-in {
    filter: brightness(0.38) saturate(0.85) blur(2px);
    transform: scale(1.015);
}

/* Gold light sweep across the dialogue box when a line appears */
.sp-shine {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 2%;
    height: 34%;
    pointer-events: none;
}
/* overlay leaves the dark dialogue box as it is, so only the gold frame and text catch the light */
.sp-shine::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -30%;
    width: 26%;
    background: radial-gradient(ellipse 50% 50% at center, rgba(255, 236, 200, 0.75), rgba(255, 236, 200, 0.2) 45%, transparent 72%);
    mix-blend-mode: overlay;
    opacity: 0;
}
.sp-shine.is-run::before { animation: spShine 1.6s 0.75s ease-out forwards; }
@keyframes spShine {
    0% { left: -30%; opacity: 0; }
    15% { opacity: 1; }
    100% { left: 110%; opacity: 0; }
}

.sp-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.45) 100%);
}

/* Cinematic letterbox bars */
.sp-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: 11vh;
    background: #000;
    z-index: 6;
    pointer-events: none;
    transition: transform 1.1s cubic-bezier(0.65, 0, 0.35, 1);
}
.sp-bar--top { top: 0; transform: translateY(0); }
.sp-bar--bottom { bottom: 0; transform: translateY(0); }
.sp.is-playing .sp-bar--top { transform: translateY(-100%); }
.sp.is-playing .sp-bar--bottom { transform: translateY(100%); }

/* HUD */
.sp-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 8;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}
.sp-progress i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #a87b2c, var(--sp-gold-hi));
    box-shadow: 0 0 12px rgba(255, 210, 120, 0.8);
    transition: width 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.sp-hud {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 9;
    display: flex;
    gap: 8px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.5s ease 0.4s, transform 0.5s ease 0.4s;
}
.sp.is-open .sp-hud { opacity: 1; transform: none; }
.sp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid rgba(230, 195, 106, 0.55);
    border-radius: 6px;
    background: rgba(8, 6, 3, 0.72);
    color: #f7ecd2;
    font: 700 0.7rem/1 "Montserrat", "Segoe UI", Tahoma, sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.sp-btn svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
}
.sp-btn:hover {
    border-color: var(--sp-gold-hi);
    background: rgba(40, 28, 8, 0.85);
    color: #fff;
    box-shadow: 0 0 16px rgba(230, 195, 106, 0.35);
}
.sp-btn:focus-visible {
    outline: 2px solid var(--sp-gold-hi);
    outline-offset: 2px;
}

/* "Continue" prompt */
.sp-hint {
    position: absolute;
    left: 50%;
    bottom: max(14px, calc((100vh - var(--sp-stage-h)) / 2 + 1.2%));
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 236, 200, 0.92);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 6px);
    transition: opacity 0.45s ease, transform 0.45s ease;
}
.sp-hint.is-on { opacity: 1; transform: translate(-50%, 0); }
.sp-hint.is-top {
    top: max(58px, calc((100vh - var(--sp-stage-h)) / 2 + 2.5%));
    bottom: auto;
}
.sp-hint strong { color: var(--sp-gold-hi); }
.sp-hint.is-low { bottom: max(4px, calc((100vh - var(--sp-stage-h)) / 2 + 0.2%)); }

.sp-next {
    position: absolute;
    top: 58px;
    right: 14px;
    z-index: 9;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px 0 16px;
    border: 0;
    border-radius: 6px;
    background: linear-gradient(180deg, #f3d38a, #b8862f);
    color: #1b1206;
    font: 800 0.7rem/1 "Montserrat", "Segoe UI", Tahoma, sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 14px rgba(255, 200, 110, 0.45), 0 6px 16px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.2s ease, visibility 0s linear 0.4s;
}
.sp-next svg {
    width: 15px;
    height: 15px;
    transition: transform 0.2s ease;
}
.sp-next.is-on {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.2s ease, visibility 0s;
}
.sp-next:hover {
    background: linear-gradient(180deg, #ffe2a0, #c99636);
    box-shadow: 0 0 22px rgba(255, 200, 110, 0.75), 0 6px 16px rgba(0, 0, 0, 0.6);
}
.sp-next:hover svg { transform: translateX(3px); }
.sp-next:focus-visible {
    outline: 2px solid var(--sp-gold-hi);
    outline-offset: 2px;
}
@media (max-width: 640px) {
    .sp-hint {
        width: max-content;
        max-width: calc(100vw - 32px);
        white-space: normal;
        text-align: center;
        line-height: 1.5;
        border-radius: 14px;
    }
}
.sp-hint kbd {
    padding: 2px 6px;
    border: 1px solid rgba(230, 195, 106, 0.6);
    border-radius: 4px;
    font: inherit;
    font-size: 0.6rem;
}
.sp-hint-arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 7px solid var(--sp-gold);
    filter: drop-shadow(0 0 4px rgba(255, 210, 120, 0.9));
    animation: spBob 1.1s ease-in-out infinite;
}
@keyframes spBob {
    0%, 100% { transform: translateY(-2px); opacity: 0.7; }
    50% { transform: translateY(2px); opacity: 1; }
}

/* Choices */
.sp-choices {
    --sp-choice-h: clamp(54px, calc(var(--sp-stage-h) * 0.115), 82px);
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 7;
    width: calc(var(--sp-stage-w) * 0.5);
    min-width: 300px;
    max-width: 660px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: calc(var(--sp-choice-h) * 0.42);
    transform: translate(-50%, -58%);
    pointer-events: none;
    visibility: hidden;
    transition: visibility 0s linear 0.6s;
}
.sp-choices.is-on {
    pointer-events: auto;
    visibility: visible;
    transition: none;
}
.sp:focus { outline: none; }
.sp-choices-title,
.sp-choices-sub {
    margin: 0;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.sp-choices-title {
    color: var(--sp-gold-hi);
    font: 600 clamp(1rem, 1.8vw, 1.45rem)/1.2 Georgia, "Times New Roman", serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 0 0 18px rgba(255, 200, 110, 0.55), 0 2px 6px #000;
}
.sp-choices-sub {
    margin-top: calc(var(--sp-choice-h) * -0.3);
    color: rgba(247, 236, 210, 0.78);
    font: italic 400 clamp(0.78rem, 1.15vw, 0.95rem)/1.4 Georgia, "Times New Roman", serif;
    text-shadow: 0 2px 6px #000;
    transition-delay: 0.08s;
}
.sp-choices.is-on .sp-choices-title,
.sp-choices.is-on .sp-choices-sub { opacity: 1; transform: none; }

/* One shared ornate frame, so every choice is the same size and style */
.sp-choice {
    position: relative;
    display: flex;
    align-items: center;
    gap: calc(var(--sp-choice-h) * 0.26);
    width: 100%;
    height: var(--sp-choice-h);
    margin: 0;
    padding: 0 calc(var(--sp-choice-h) * 0.75) 0 calc(var(--sp-choice-h) * 0.6);
    border: 0;
    background: none;
    color: #f7ecd2;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    transform: translateY(26px) scale(0.96);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 6px rgba(255, 190, 80, 0.25));
    transition:
        opacity 0.55s ease,
        transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
        filter 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}
.sp-choices.is-on .sp-choice { opacity: 1; transform: none; }
.sp-choices.is-on .sp-choice:nth-of-type(1) { transition-delay: 0.15s, 0.15s, 0s; }
.sp-choices.is-on .sp-choice:nth-of-type(2) { transition-delay: 0.3s, 0.3s, 0s; }

.sp-choice-frame,
.sp-choice-frame::before,
.sp-choice-frame::after {
    position: absolute;
    clip-path: polygon(calc(var(--sp-choice-h) * 0.42) 0, calc(100% - var(--sp-choice-h) * 0.42) 0, 100% 50%, calc(100% - var(--sp-choice-h) * 0.42) 100%, calc(var(--sp-choice-h) * 0.42) 100%, 0 50%);
}
.sp-choice-frame {
    inset: 0;
    background: linear-gradient(180deg, #fff0c0 0%, #e6b64f 28%, #8a5a17 52%, #e8bc58 78%, #fff0c0 100%);
    background-size: 100% 200%;
    animation: spFrameGlow 3.6s ease-in-out infinite;
}
.sp-choice:nth-of-type(2) .sp-choice-frame { animation-delay: -1.8s; }
.sp-choice-frame::before {
    content: "";
    inset: 2px;
    background:
        radial-gradient(ellipse at 30% 0%, rgba(255, 200, 110, 0.16), transparent 60%),
        linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.035) 45%, transparent 50%),
        linear-gradient(180deg, #1d1712 0%, #0b0907 55%, #15100b 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 214, 140, 0.35);
}
/* Idle shimmer: runs on both buttons, staggered, so they both feel alive */
.sp-choice-frame::after {
    content: "";
    inset: 2px;
    background: linear-gradient(100deg, transparent 35%, rgba(255, 226, 160, 0.22) 50%, transparent 65%);
    background-size: 300% 100%;
    background-position: 150% 0;
    animation: spSweep 4.2s ease-in-out infinite;
}
.sp-choice:nth-of-type(2) .sp-choice-frame::after { animation-delay: 2.1s; }
@keyframes spSweep {
    0%, 55% { background-position: 150% 0; }
    100% { background-position: -50% 0; }
}
@keyframes spFrameGlow {
    0%, 100% { background-position: 0 0; }
    50% { background-position: 0 100%; }
}

.sp-choice-gem {
    position: absolute;
    left: 50%;
    width: calc(var(--sp-choice-h) * 0.2);
    height: calc(var(--sp-choice-h) * 0.2);
    background: linear-gradient(135deg, #fff3c8, #e2ad45 50%, #7d5214);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 0 0 10px rgba(255, 200, 100, 0.8);
}
.sp-choice-gem--top { top: calc(var(--sp-choice-h) * -0.1); }
.sp-choice-gem--bottom { bottom: calc(var(--sp-choice-h) * -0.1); }

.sp-choice-icon {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: calc(var(--sp-choice-h) * 0.6);
    height: calc(var(--sp-choice-h) * 0.6);
    border: 2px solid #e6b64f;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 196, 90, 0.18), rgba(0, 0, 0, 0.4));
    color: #f5c965;
    box-shadow: 0 0 12px rgba(255, 190, 80, 0.45), inset 0 0 8px rgba(255, 190, 80, 0.3);
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.sp-choice-icon svg {
    width: 55%;
    height: 55%;
    filter: drop-shadow(0 0 4px rgba(255, 200, 100, 0.7));
}
.sp-choice-text {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    color: #fbefd4;
    font: 500 calc(var(--sp-choice-h) * 0.3)/1.15 Georgia, "Times New Roman", serif;
    letter-spacing: 0.01em;
    text-shadow: 0 0 10px rgba(255, 210, 140, 0.35), 0 2px 4px #000;
}
.sp-choice-tag {
    position: absolute;
    right: calc(var(--sp-choice-h) * 0.62);
    top: 0;
    display: none;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font: 800 0.58rem/1 "Montserrat", sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    transform: translateY(-50%);
    white-space: nowrap;
}
.sp-choice-tag svg { width: 11px; height: 11px; }
.sp-choice.is-chosen .sp-choice-tag,
.sp-choice.is-locked .sp-choice-tag { display: inline-flex; }
.sp-choice.is-chosen .sp-choice-tag {
    background: linear-gradient(180deg, #f3d38a, #b8862f);
    color: #1b1206;
    box-shadow: 0 0 12px rgba(255, 200, 110, 0.7);
}
.sp-choice.is-locked .sp-choice-tag {
    background: rgba(20, 16, 12, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.75);
}

.sp-choices.is-on .sp-choice:not(.is-locked):hover,
.sp-choices.is-on .sp-choice:not(.is-locked):focus-visible {
    transform: translateY(-3px) scale(1.025);
    filter: drop-shadow(0 0 18px rgba(255, 196, 90, 0.8)) drop-shadow(0 10px 22px rgba(0, 0, 0, 0.8)) brightness(1.12);
    transition-delay: 0s;
    outline: none;
}
.sp-choice:not(.is-locked):hover .sp-choice-icon,
.sp-choice:not(.is-locked):focus-visible .sp-choice-icon {
    transform: scale(1.1) rotate(-6deg);
    box-shadow: 0 0 20px rgba(255, 200, 100, 0.85), inset 0 0 10px rgba(255, 200, 100, 0.45);
}
.sp-choice:not(.is-locked):hover .sp-choice-frame::after,
.sp-choice:not(.is-locked):focus-visible .sp-choice-frame::after {
    animation: spSweepFast 0.9s ease forwards;
}
@keyframes spSweepFast {
    from { background-position: 150% 0; }
    to { background-position: -50% 0; }
}

/* Saved path: the chosen option pulses, the other one is locked */
.sp-choices.is-on .sp-choice.is-chosen {
    animation: spChosenPulse 2.2s ease-in-out 0.9s infinite;
}
@keyframes spChosenPulse {
    0%, 100% { filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 8px rgba(255, 190, 80, 0.35)); }
    50% { filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 22px rgba(255, 200, 100, 0.85)); }
}
.sp-choice.is-locked {
    cursor: not-allowed;
}
.sp-choices.is-on .sp-choice.is-locked {
    opacity: 0.45;
    filter: grayscale(0.85) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.75));
}
.sp-choice.is-locked .sp-choice-frame,
.sp-choice.is-locked .sp-choice-frame::after { animation: none; }
.sp-choice.is-denied {
    animation: spDeny 0.45s ease;
}
@keyframes spDeny {
    0%, 100% { translate: 0 0; }
    20% { translate: -8px 0; }
    40% { translate: 7px 0; }
    60% { translate: -5px 0; }
    80% { translate: 3px 0; }
}

.sp-choice.is-picked {
    animation: spPick 0.65s ease forwards;
}
.sp-choices.is-leaving .sp-choice:not(.is-picked),
.sp-choices.is-leaving .sp-choices-title,
.sp-choices.is-leaving .sp-choices-sub {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    transition-delay: 0s;
    animation: none;
}
@keyframes spPick {
    0% { filter: drop-shadow(0 0 0 rgba(255, 196, 90, 0)) brightness(1); }
    35% { filter: drop-shadow(0 0 30px rgba(255, 210, 120, 1)) brightness(1.4); transform: scale(1.05); }
    100% { filter: drop-shadow(0 0 0 rgba(255, 196, 90, 0)) brightness(1); transform: scale(1); opacity: 0; }
}

/* Chapter title card and end card */
.sp-card {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background: radial-gradient(ellipse at center, rgba(40, 26, 6, 0.55), rgba(0, 0, 0, 0.94) 70%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}
.sp-card.is-on {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s ease, visibility 0s;
}
.sp-card-kicker {
    color: rgba(255, 236, 200, 0.7);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.42em;
    text-transform: uppercase;
}
.sp-card-title {
    margin: 0;
    color: var(--sp-gold-hi);
    font: 600 clamp(2.6rem, 7vw, 5.4rem)/1 Georgia, "Times New Roman", serif;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(255, 196, 90, 0.55), 0 3px 10px #000;
}
.sp-card-sub {
    margin: 0;
    color: #f2e6cc;
    font: italic 400 clamp(1rem, 2vw, 1.35rem)/1.4 Georgia, "Times New Roman", serif;
    letter-spacing: 0.04em;
}
.sp-card-line {
    position: relative;
    width: min(380px, 70vw);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--sp-gold), transparent);
}
.sp-card-line::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 9px;
    height: 9px;
    background: var(--sp-gold-hi);
    transform: translate(-50%, -50%) rotate(45deg);
    box-shadow: 0 0 12px rgba(255, 210, 120, 0.9);
}
.sp-card > * {
    opacity: 0;
    transform: translateY(14px);
}
.sp-card.is-on > * {
    animation: spRise 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
.sp-card.is-on > :nth-child(2) { animation-delay: 0.25s; }
.sp-card.is-on > :nth-child(3) { animation-delay: 0.45s; }
.sp-card.is-on > :nth-child(4) { animation-delay: 0.65s; }
.sp-card.is-on > :nth-child(5) { animation-delay: 0.85s; }
.sp-card.is-on .sp-card-line {
    animation-name: spLine;
}
@keyframes spRise {
    to { opacity: 1; transform: none; }
}
@keyframes spLine {
    from { opacity: 0; transform: scaleX(0); }
    to { opacity: 1; transform: scaleX(1); }
}
.sp-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}
.sp-card-actions .sp-btn { height: 42px; padding: 0 20px; }
.sp-btn--gold {
    border-color: transparent;
    background: linear-gradient(180deg, #f3d38a, #b8862f);
    color: #1b1206;
}
.sp-btn--gold:hover {
    background: linear-gradient(180deg, #ffe2a0, #c99636);
    color: #1b1206;
}

.sp-loader {
    width: 34px;
    height: 34px;
    border: 2px solid rgba(230, 195, 106, 0.2);
    border-top-color: var(--sp-gold-hi);
    border-radius: 50%;
    animation: spSpin 0.9s linear infinite;
}
.sp-card:not(.is-loading) .sp-loader { display: none; }
@keyframes spSpin { to { transform: rotate(360deg); } }

/* Clue cards baked into a scene: each one is hidden under a blur until picked */
.sp-clues {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}
.sp-clue {
    position: absolute;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    color: #f7ecd2;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}
/* Follows the inner gold line of the card drawn in the image (notched corners), minus the title row */
.sp-clue-veil {
    --title-left: 36%;
    position: absolute;
    inset: 0;
    clip-path: polygon(
        7.6% 9%, 92.4% 9%, 95.2% 19.5%, 95.2% 81%,
        92.4% 91.6%, 7.6% 91.6%, 4.8% 81%, 4.8% 19.5%);
    -webkit-mask:
        linear-gradient(90deg, #000 calc(var(--title-left) - 1.5%), transparent calc(var(--title-left) + 1.5%)),
        linear-gradient(180deg, transparent 35%, #000 41%);
    mask:
        linear-gradient(90deg, #000 calc(var(--title-left) - 1.5%), transparent calc(var(--title-left) + 1.5%)),
        linear-gradient(180deg, transparent 35%, #000 41%);
    transition: opacity 1.1s ease;
}
.sp-clue-blur {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    filter: blur(9px) saturate(0.85) brightness(0.9);
    transition: filter 1.1s ease;
}
.sp-clue-veil::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(100deg, transparent 35%, rgba(255, 226, 160, 0.16) 50%, transparent 65%);
    background-size: 300% 100%;
    background-position: 150% 0;
    animation: spSweep 4.2s ease-in-out infinite;
}
.sp-clue:nth-child(2) .sp-clue-veil::after { animation-delay: 2.1s; }
.sp-clue-label {
    position: absolute;
    inset: 38% 0 8.4%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.sp-clues.is-on .sp-clue:not(.is-revealed):not(.is-locked) .sp-clue-label {
    opacity: 1;
    transform: none;
}
.sp-clues.is-on .sp-clue:nth-child(2) .sp-clue-label { transition-delay: 0.15s; }
.sp-clue-icon {
    display: grid;
    place-items: center;
    width: clamp(30px, calc(var(--sp-stage-h) * 0.06), 48px);
    height: clamp(30px, calc(var(--sp-stage-h) * 0.06), 48px);
    border: 2px solid #e6b64f;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 196, 90, 0.2), rgba(0, 0, 0, 0.5));
    color: #f5c965;
    box-shadow: 0 0 14px rgba(255, 190, 80, 0.5);
    animation: spCluePulse 2.4s ease-in-out infinite;
}
.sp-clue-icon svg { width: 55%; height: 55%; }
@keyframes spCluePulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 190, 80, 0.4); transform: scale(1); }
    50% { box-shadow: 0 0 22px rgba(255, 200, 100, 0.85); transform: scale(1.06); }
}
.sp-clue-title {
    color: var(--sp-gold-hi);
    font: 600 clamp(0.85rem, calc(var(--sp-stage-h) * 0.032), 1.35rem)/1.15 Georgia, "Times New Roman", serif;
    letter-spacing: 0.03em;
    text-shadow: 0 0 14px rgba(255, 200, 110, 0.5), 0 2px 5px #000;
}
.sp-clue-cta {
    padding: 6px 12px;
    border: 1px solid rgba(230, 182, 79, 0.55);
    border-radius: 999px;
    background: rgba(10, 7, 4, 0.55);
    color: rgba(247, 236, 210, 0.9);
    font: 700 clamp(0.52rem, calc(var(--sp-stage-h) * 0.016), 0.68rem)/1 "Montserrat", sans-serif;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    text-shadow: 0 1px 4px #000;
}
.sp-clue-cta svg {
    width: 1.2em;
    height: 1.2em;
    margin-right: 4px;
    vertical-align: -0.25em;
}
.sp-clue-tag {
    position: absolute;
    left: 50%;
    top: 0;
    display: none;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font: 800 0.58rem/1 "Montserrat", sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
    transform: translate(-50%, -50%);
}
.sp-clue-tag svg { width: 11px; height: 11px; }

.sp-clue:not(.is-locked):not(.is-revealed):hover .sp-clue-blur,
.sp-clue:not(.is-locked):not(.is-revealed):focus-visible .sp-clue-blur {
    filter: blur(9px) saturate(0.9) brightness(1.05);
}
.sp-clue:not(.is-locked):not(.is-revealed):hover .sp-clue-label,
.sp-clue:not(.is-locked):not(.is-revealed):focus-visible .sp-clue-label {
    transform: translateY(-3px);
}
.sp-clue:focus-visible { outline: none; }

.sp-clue.is-revealed { cursor: default; }
.sp-clue.is-revealed .sp-clue-veil { opacity: 0; }
.sp-clue.is-revealed .sp-clue-blur { filter: blur(0) saturate(1) brightness(1); }
.sp-clue.is-revealed .sp-clue-label {
    opacity: 0;
    transform: scale(0.92);
}
.sp-clue.is-revealed::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 55% 60% at 50% 55%, rgba(255, 214, 140, 0.22), transparent 70%);
    opacity: 0;
    pointer-events: none;
    animation: spClueFlash 1.4s ease-out forwards;
}
@keyframes spClueFlash {
    30% { opacity: 1; }
    100% { opacity: 0; }
}
.sp-clue.is-revealed .sp-clue-tag {
    display: inline-flex;
    background: linear-gradient(180deg, #f3d38a, #b8862f);
    color: #1b1206;
    box-shadow: 0 0 12px rgba(255, 200, 110, 0.7);
}
.sp-clue.is-locked { cursor: not-allowed; }
.sp-clue.is-locked .sp-clue-blur { filter: blur(11px) grayscale(0.6) brightness(0.72); }
.sp-clue.is-locked .sp-clue-veil::after,
.sp-clue.is-locked .sp-clue-icon { animation: none; }
.sp-clues.is-on .sp-clue.is-locked .sp-clue-label { opacity: 0.55; transform: none; }
.sp-clue.is-locked .sp-clue-tag {
    display: inline-flex;
    background: rgba(20, 16, 12, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.75);
}
.sp-clue.is-denied { animation: spDeny 0.45s ease; }
.sp-clue.is-gone,
.sp-hot.is-gone {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
}
.sp-card-sub strong { color: var(--sp-gold-hi); font-style: normal; }

/* Buttons drawn inside a scene image: an invisible hit area with a gold glow */
.sp-hot {
    position: absolute;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: none;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}
.sp-hot:focus-visible { outline: none; }
.sp-hot-ring {
    position: absolute;
    inset: 4% 1.5%;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.4s ease, box-shadow 0.3s ease, background 0.3s ease;
}
.sp-clues.is-on .sp-hot-ring {
    opacity: 1;
    animation: spHotPulse 2.4s ease-in-out infinite;
}
.sp-clues.is-on .sp-hot:nth-child(2) .sp-hot-ring { animation-delay: 1.2s; }
@keyframes spHotPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 100, 0), inset 0 0 0 0 rgba(255, 214, 140, 0); }
    50% { box-shadow: 0 0 22px 2px rgba(255, 200, 100, 0.55), inset 0 0 14px rgba(255, 214, 140, 0.25); }
}
.sp-hot:not(.is-locked):hover .sp-hot-ring,
.sp-hot:not(.is-locked):focus-visible .sp-hot-ring {
    animation: none;
    background: rgba(255, 210, 130, 0.12);
    box-shadow: 0 0 28px 4px rgba(255, 200, 100, 0.8), inset 0 0 18px rgba(255, 220, 150, 0.4);
}
.sp-hot-tag {
    position: absolute;
    left: 50%;
    top: 0;
    display: none;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font: 800 0.58rem/1 "Montserrat", sans-serif;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
    transform: translate(-50%, -85%);
}
.sp-hot-tag svg { width: 11px; height: 11px; }
.sp-hot.is-chosen .sp-hot-tag,
.sp-hot.is-locked .sp-hot-tag { display: inline-flex; }
.sp-hot.is-chosen .sp-hot-tag {
    background: linear-gradient(180deg, #f3d38a, #b8862f);
    color: #1b1206;
    box-shadow: 0 0 12px rgba(255, 200, 110, 0.7);
}
.sp-hot.is-locked { cursor: not-allowed; }
.sp-hot.is-locked .sp-hot-ring {
    animation: none;
    background: rgba(4, 3, 2, 0.62);
    -webkit-backdrop-filter: grayscale(1) blur(2px);
    backdrop-filter: grayscale(1) blur(2px);
    box-shadow: none;
}
.sp-hot.is-locked .sp-hot-tag {
    background: rgba(20, 16, 12, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.75);
}
.sp-hot.is-picked .sp-hot-ring {
    animation: spHotPick 0.9s ease forwards;
}
@keyframes spHotPick {
    0% { background: rgba(255, 210, 130, 0.1); box-shadow: 0 0 20px 2px rgba(255, 200, 100, 0.6); }
    35% { background: rgba(255, 225, 160, 0.35); box-shadow: 0 0 48px 10px rgba(255, 210, 120, 1), inset 0 0 30px rgba(255, 230, 170, 0.7); }
    100% { background: rgba(255, 210, 130, 0); box-shadow: 0 0 24px 2px rgba(255, 200, 100, 0.4); }
}
.sp-hot.is-denied { animation: spDeny 0.45s ease; }

/* ---------- Notebook button in the HUD ---------- */
.sp-hud--left { right: auto; left: 14px; }
/* ---------- Music control (page + story) ---------- */
.sp-sound {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10150;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 6px;
    border: 1px solid rgba(230, 195, 106, 0.5);
    border-radius: 999px;
    background: linear-gradient(160deg, rgba(40, 26, 14, 0.88), rgba(12, 8, 5, 0.92));
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6), 0 0 22px rgba(255, 190, 90, 0.12);
    backdrop-filter: blur(8px);
    font-family: "Montserrat", "Segoe UI", Tahoma, sans-serif;
    transition: gap 0.3s ease, border-color 0.25s ease;
}
.sp-sound[hidden] { display: none; }
.sp-sound:hover,
.sp-sound:focus-within {
    gap: 10px;
    border-color: var(--sp-gold-hi, #ffe2a0);
}
.sp-sound-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, #f3d38a, #b8862f);
    color: #1b1206;
    cursor: pointer;
}
.sp-sound-btn svg { width: 19px; height: 19px; }
.sp-sound-btn:focus-visible { outline: 2px solid #ffe2a0; outline-offset: 2px; }
.sp-sound-range {
    --fill: 45%;
    width: 0;
    height: 4px;
    margin: 0;
    opacity: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, #e6c36a var(--fill), rgba(255, 236, 200, 0.18) var(--fill));
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: width 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
}
.sp-sound:hover .sp-sound-range,
.sp-sound:focus-within .sp-sound-range {
    width: 110px;
    margin-right: 8px;
    opacity: 1;
}
.sp-sound-range::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffe2a0;
    box-shadow: 0 0 8px rgba(255, 210, 120, 0.7);
    -webkit-appearance: none;
    appearance: none;
}
.sp-sound-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 50%;
    background: #ffe2a0;
}
@media (hover: none) {
    .sp-sound { gap: 10px; }
    .sp-sound-range { width: 90px; margin-right: 8px; opacity: 1; }
}
.sp-nb-btn { position: relative; padding-right: 10px; }
.sp-nb-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: linear-gradient(180deg, #f3d38a, #b8862f);
    color: #1b1206;
    font-size: 0.66rem;
    letter-spacing: 0;
}
.sp-nb-btn.has-new::after {
    content: "";
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e8463a;
    box-shadow: 0 0 0 2px #0b0806, 0 0 10px rgba(232, 70, 58, 0.9);
    animation: nbDot 1.6s ease-in-out infinite;
}
.sp-nb-btn.is-bump { animation: nbBump 0.7s cubic-bezier(0.34, 1.56, 0.64, 1); }
.sp-nb-btn.is-bump .sp-nb-badge { animation: nbBadge 0.7s ease; }
@keyframes nbBump {
    0% { transform: scale(1); }
    35% { transform: scale(1.14); box-shadow: 0 0 26px rgba(255, 200, 110, 0.9); border-color: var(--sp-gold-hi); }
    100% { transform: scale(1); }
}
@keyframes nbBadge {
    0%, 100% { transform: none; }
    40% { transform: scale(1.5) rotate(-8deg); }
}
@keyframes nbDot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ---------- "New clue" card: writes itself in, then flies into the notebook button ---------- */
.sp-note {
    --fly-x: 0px;
    --fly-y: 0px;
    position: absolute;
    left: 14px;
    top: 64px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: min(460px, calc(100vw - 32px));
    padding: 12px 22px 12px 14px;
    border-radius: 4px;
    background:
        repeating-linear-gradient(180deg, transparent 0 21px, rgba(70, 90, 130, 0.16) 21px 22px),
        linear-gradient(180deg, #f3e8cf, #e4d5b2);
    color: #2a1d12;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(120, 80, 30, 0.35), 0 0 30px rgba(255, 200, 110, 0.25);
    opacity: 0;
    transform: translateY(-18px) rotate(-3deg) scale(0.9);
    transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
.sp-note::before {
    content: "";
    position: absolute;
    left: 40px;
    top: -9px;
    width: 70px;
    height: 18px;
    background: rgba(240, 225, 180, 0.55);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transform: translateX(-50%) rotate(-4deg);
}
.sp-note.is-in { opacity: 1; transform: rotate(-1deg); }
.sp-note.is-fly {
    opacity: 0;
    transform: translate(var(--fly-x), var(--fly-y)) rotate(-12deg) scale(0.08);
    transition: opacity 0.7s ease-in 0.05s, transform 0.7s cubic-bezier(0.55, 0, 0.75, 0.4);
}
.sp-note-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 2px solid #8a2a1c;
    border-radius: 50%;
    color: #8a2a1c;
}
.sp-note-icon svg { width: 20px; height: 20px; }
.sp-note.is-in .sp-note-icon svg { animation: nbWrite 0.5s ease-in-out 0.5s 4; }
@keyframes nbWrite {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    50% { transform: translate(3px, 2px) rotate(8deg); }
}
.sp-note-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sp-note-kicker {
    color: #8a2a1c;
    font: 400 0.68rem/1.2 "Special Elite", "Courier New", monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.sp-note-title {
    font: 700 1.55rem/1.1 "Caveat", "Segoe Print", cursive;
    clip-path: inset(0 100% 0 0);
}
.sp-note.is-in .sp-note-title {
    animation: nbInk 1.6s cubic-bezier(0.45, 0, 0.55, 1) 0.45s forwards;
}
@keyframes nbInk { to { clip-path: inset(0 0 0 0); } }

/* ---------- Notebook ---------- */
.nb {
    position: fixed;
    inset: 0;
    z-index: 10300;
    display: grid;
    place-items: center;
    padding: 28px 16px 16px;
    visibility: hidden;
    transition: visibility 0s linear 0.6s;
    font-family: "Montserrat", "Segoe UI", Tahoma, sans-serif;
}
.nb.is-on { visibility: visible; transition: none; }
.nb-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(30, 18, 4, 0.55), rgba(0, 0, 0, 0.88) 75%);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.5s ease;
    cursor: pointer;
}
.nb.is-on .nb-backdrop { opacity: 1; }

/* Leather cover around the page; the page swings up into place */
.nb-book {
    position: relative;
    width: min(600px, 100%);
    max-height: min(86vh, 860px);
    display: flex;
    padding: 12px;
    border-radius: 10px;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(255, 210, 140, 0.12), transparent 60%),
        linear-gradient(160deg, #3a2414, #1c110a 60%, #2b1a0f);
    box-shadow:
        inset 0 0 0 1px rgba(230, 195, 106, 0.45),
        inset 0 0 0 5px #1a0f08,
        inset 0 0 0 6px rgba(230, 195, 106, 0.25),
        0 30px 80px rgba(0, 0, 0, 0.8),
        0 0 60px rgba(255, 190, 90, 0.12);
    opacity: 0;
    transform: perspective(1400px) translateY(60px) rotateX(18deg) scale(0.92);
    transform-origin: 50% 100%;
    transition: opacity 0.45s ease, transform 0.55s cubic-bezier(0.55, 0, 0.75, 0.4);
}
.nb.is-on .nb-book {
    opacity: 1;
    transform: none;
    transition: opacity 0.5s ease, transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.nb-rings {
    position: absolute;
    left: 9%;
    right: 9%;
    top: -14px;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}
.nb-rings i {
    position: relative;
    width: 12px;
    height: 30px;
    border-radius: 7px;
    background: linear-gradient(90deg, #6d5530, #fff0c0 40%, #b8862f 60%, #5a4322);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}
/* Punched hole in the page that the ring goes through */
.nb-rings i::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    z-index: -1;
    width: 16px;
    height: 14px;
    border-radius: 50%;
    background: #1c110a;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.4);
    transform: translateX(-50%);
}

.nb-page {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    overflow: hidden;
    color: #2a1d12;
    background-color: #ece0c3;
    background-image:
        radial-gradient(ellipse at 25% 15%, rgba(255, 255, 255, 0.45), transparent 55%),
        radial-gradient(ellipse at 85% 95%, rgba(140, 90, 30, 0.22), transparent 60%),
        radial-gradient(ellipse at 0% 60%, rgba(120, 80, 30, 0.12), transparent 40%);
    box-shadow: inset 0 0 40px rgba(110, 70, 20, 0.25);
}
.nb-head {
    position: relative;
    padding: 34px 56px 14px 64px;
    border-bottom: 1px solid rgba(138, 42, 28, 0.25);
}
.nb-kicker {
    display: block;
    color: #8a2a1c;
    font: 400 0.7rem/1 "Special Elite", "Courier New", monospace;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}
.nb-title {
    margin: 6px 0 10px;
    color: #24170d;
    font: 600 clamp(1.4rem, 3.4vw, 1.9rem)/1.1 Georgia, "Times New Roman", serif;
    letter-spacing: 0.04em;
}
.nb-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    font: 400 0.78rem/1 "Special Elite", "Courier New", monospace;
    color: #5a4330;
}
.nb-progress strong { color: #8a2a1c; font-size: 1rem; }
.nb-bar {
    position: relative;
    flex: 1 1 auto;
    height: 6px;
    border-radius: 999px;
    background: rgba(90, 60, 30, 0.18);
    overflow: hidden;
}
.nb-bar i {
    --fill: 0%;
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #8a2a1c, #c0442e);
}
.nb.is-on .nb-bar i {
    width: var(--fill);
    transition: width 1.2s cubic-bezier(0.22, 0.61, 0.36, 1) 0.5s;
}
.nb-close {
    position: absolute;
    top: 30px;
    right: 16px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(90, 60, 30, 0.35);
    border-radius: 50%;
    background: rgba(255, 250, 235, 0.5);
    color: #4a3322;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.25s ease;
}
.nb-close svg { width: 15px; height: 15px; }
.nb-close:hover { background: #8a2a1c; color: #fff4dc; transform: rotate(90deg); }
.nb-close:focus-visible { outline: 2px solid #8a2a1c; outline-offset: 2px; }

/* Ruled lines and a red margin that scroll with the writing */
.nb-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 22px 10px 64px;
    background-image:
        linear-gradient(90deg, transparent 46px, rgba(192, 58, 46, 0.45) 46px, rgba(192, 58, 46, 0.45) 48px, transparent 48px),
        repeating-linear-gradient(180deg, transparent 0 29px, rgba(60, 90, 140, 0.16) 29px 30px);
    background-attachment: local;
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 42, 28, 0.5) transparent;
}
.nb-part { padding: 14px 0 4px; }
.nb-part-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin: 0 0 8px;
    color: #5a4330;
    font: 400 0.74rem/1.3 "Special Elite", "Courier New", monospace;
    letter-spacing: 0.06em;
}
.nb-part-title span {
    padding: 3px 8px;
    border: 1.5px solid #8a2a1c;
    border-radius: 3px;
    color: #8a2a1c;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}
.nb-list { margin: 0; padding: 0; list-style: none; }

.nb-entry {
    position: relative;
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 12px;
    padding: 10px 0;
    opacity: 0;
    transform: translateX(-10px);
}
.nb-entry + .nb-entry { border-top: 1px dashed rgba(90, 60, 30, 0.25); }
.nb.is-on .nb-entry {
    animation: nbEntry 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
    animation-delay: calc(0.35s + var(--i) * 0.09s);
}
@keyframes nbEntry { to { opacity: 1; transform: none; } }
.nb-entry-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 2px solid #8a2a1c;
    border-radius: 50%;
    color: #8a2a1c;
    background: rgba(255, 248, 230, 0.5);
}
.nb-entry-icon svg { width: 17px; height: 17px; }
.nb-entry-body { min-width: 0; }
.nb-entry-title {
    margin: 0;
    color: #1f150c;
    font: 700 1.5rem/1.05 "Caveat", "Segoe Print", cursive;
}
.nb-entry-text {
    margin: 2px 0 0;
    color: #3a2a1c;
    font: 500 1.22rem/1.25 "Caveat", "Segoe Print", cursive;
}
.nb-entry-path {
    display: inline-block;
    margin-top: 6px;
    color: #8a2a1c;
    font: 400 0.66rem/1.3 "Special Elite", "Courier New", monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
/* Newly found clues are handwritten in as the notebook opens */
.nb.is-on .nb-entry.is-new .nb-entry-title,
.nb.is-on .nb-entry.is-new .nb-entry-text {
    clip-path: inset(0 100% 0 0);
    animation: nbInk 1.4s cubic-bezier(0.45, 0, 0.55, 1) forwards;
    animation-delay: calc(0.7s + var(--i) * 0.09s);
}
.nb.is-on .nb-entry.is-new .nb-entry-text { animation-delay: calc(1.3s + var(--i) * 0.09s); }
.nb-entry.is-new { background: linear-gradient(90deg, rgba(255, 214, 120, 0.28), transparent 80%); }
.nb-stamp {
    position: absolute;
    top: 8px;
    right: 4px;
    padding: 2px 8px;
    border: 2px solid #b0281e;
    border-radius: 3px;
    color: #b0281e;
    font: 400 0.72rem/1.2 "Special Elite", "Courier New", monospace;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0;
    transform: rotate(-14deg) scale(2.4);
}
.nb.is-on .nb-stamp {
    animation: nbStamp 0.45s cubic-bezier(0.5, 0, 0.75, 0) forwards;
    animation-delay: calc(1.6s + var(--i) * 0.09s);
}
@keyframes nbStamp {
    to { opacity: 0.85; transform: rotate(-14deg) scale(1); }
}

/* Clues that are still hidden: redacted lines */
.nb-entry.is-missing .nb-entry-icon {
    border-color: rgba(90, 60, 30, 0.4);
    color: rgba(90, 60, 30, 0.55);
    background: transparent;
}
.nb-redact {
    display: block;
    height: 12px;
    margin: 5px 0 7px;
    border-radius: 2px;
    background: #2a1d12;
    opacity: 0.78;
    clip-path: polygon(0 12%, 4% 0, 30% 8%, 60% 0, 96% 6%, 100% 30%, 99% 88%, 70% 100%, 35% 92%, 3% 100%);
}
.nb-redact:first-child { height: 15px; }
.nb-entry.is-missing .nb-entry-path { color: #6b5643; margin-top: 2px; }
.nb-entry.is-lost .nb-redact { opacity: 0.55; }

.nb-foot {
    margin: 0;
    padding: 12px 22px 16px 64px;
    border-top: 1px solid rgba(138, 42, 28, 0.25);
    color: #4a3322;
    font: 500 1.2rem/1.25 "Caveat", "Segoe Print", cursive;
    opacity: 0;
}
.nb.is-on .nb-foot { animation: nbEntry 0.6s ease 1s forwards; }

@media (max-width: 520px) {
    .nb-head { padding: 32px 50px 12px 22px; }
    .nb-body { padding: 4px 14px 8px 22px; background-image: repeating-linear-gradient(180deg, transparent 0 29px, rgba(60, 90, 140, 0.16) 29px 30px); }
    .nb-foot { padding: 10px 14px 14px 22px; }
    .sp-nb-btn { font-size: 0; gap: 6px; }
}

/* ---------- Notebook launcher on the Story Line intro ---------- */
.nb-launch {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px 10px 10px;
    border: 1px solid rgba(230, 195, 106, 0.5);
    border-radius: 12px;
    background: linear-gradient(160deg, rgba(40, 26, 14, 0.88), rgba(12, 8, 5, 0.92));
    color: #f7ecd2;
    font-family: "Montserrat", "Segoe UI", Tahoma, sans-serif;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6), 0 0 22px rgba(255, 190, 90, 0.12);
    backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateY(24px);
    pointer-events: none;
    transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease, box-shadow 0.25s ease;
}
.nb-launch.is-ready {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}
.nb-launch:hover,
.nb-launch:focus-visible {
    border-color: var(--sp-gold-hi, #ffe2a0);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.65), 0 0 28px rgba(255, 200, 110, 0.4);
    outline: none;
}
.nb-launch-book {
    position: relative;
    width: 46px;
    height: 56px;
    flex: 0 0 auto;
    border-radius: 3px 6px 6px 3px;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0 6px, transparent 6px),
        repeating-linear-gradient(180deg, transparent 0 9px, rgba(60, 90, 140, 0.2) 9px 10px),
        linear-gradient(180deg, #efe3c6, #ddcca6);
    box-shadow: 3px 3px 0 #8a6a3a, 4px 5px 10px rgba(0, 0, 0, 0.6);
    transform: rotate(-6deg);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.nb-launch-book::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: rgba(192, 58, 46, 0.6);
}
.nb-launch-book::after {
    content: "";
    position: absolute;
    left: -4px;
    top: 6px;
    bottom: 6px;
    width: 8px;
    background: radial-gradient(circle 3px at center, #b8862f 2.4px, transparent 3px) 0 0 / 8px 9px repeat-y;
}
.nb-launch:hover .nb-launch-book,
.nb-launch:focus-visible .nb-launch-book { transform: rotate(0deg) translateY(-4px) scale(1.06); }
.nb-launch-text { display: flex; flex-direction: column; gap: 3px; }
.nb-launch-kicker {
    color: rgba(255, 236, 200, 0.6);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}
.nb-launch-title {
    color: var(--sp-gold-hi, #ffe2a0);
    font: 600 1.05rem/1.1 Georgia, "Times New Roman", serif;
    letter-spacing: 0.06em;
}
.nb-launch-count {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(247, 236, 210, 0.82);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
}
.nb-launch-meter {
    position: relative;
    width: 70px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}
.nb-launch-meter i {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--fill, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, #a87b2c, #ffe2a0);
    box-shadow: 0 0 8px rgba(255, 210, 120, 0.8);
    transition: width 1s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.nb-launch-new {
    position: absolute;
    top: -9px;
    right: -9px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #c0392b;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    box-shadow: 0 0 12px rgba(232, 70, 58, 0.8);
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.nb-launch.has-new .nb-launch-new { opacity: 1; transform: none; }
.nb-launch.has-new { animation: nbLaunchGlow 2.4s ease-in-out infinite; }
@keyframes nbLaunchGlow {
    0%, 100% { box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6), 0 0 18px rgba(255, 190, 90, 0.15); }
    50% { box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6), 0 0 34px rgba(255, 200, 110, 0.55); }
}
@media (max-width: 640px) {
    .nb-launch { left: 12px; bottom: 12px; padding: 8px 14px 8px 8px; gap: 10px; }
    .sp-sound { right: 12px; bottom: 12px; }
    .nb-launch-book { width: 36px; height: 44px; }
}

/* Portrait screens: choices go under the stage so they stay readable */
@media (max-aspect-ratio: 1/1) {
    .sp-choices {
        top: calc(50% + var(--sp-stage-h) / 2 + 18px);
        width: min(92vw, 520px);
        transform: translateX(-50%);
    }
    .sp-hint { bottom: max(20px, calc((100vh - var(--sp-stage-h)) / 2 - 46px)); }
    .sp-bar { height: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
    .sp,
    .sp *,
    .sp *::before,
    .sp *::after,
    .nb *,
    .nb-launch {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        transition-duration: 0.2s !important;
        transition-delay: 0s !important;
    }
    .sp-scene,
    .sp-scene.is-in,
    .sp-scene.is-out { transform: none; }
}
