/* ========================================
   STAGE MODE - Level Select: Neon District map
   Scoped to #level-select-overlay so the shared
   .overlay / .overlay-panel styles stay untouched.
   ======================================== */

#level-select-overlay {
    --ls-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --ls-cyan: #5ef3ff;
    --ls-magenta: #ff4fd8;
    --ls-violet: #a46bff;
    --ls-mint: #3dffc6;
    --ls-gold: #ffcf4a;
    --ls-bronze-rim: linear-gradient(160deg, #e2b679 0%, #8a5e33 40%, #c39056 65%, #5a3b1f 100%);
    --ls-gutter: 14px;
    padding: 0;
    background: #07041a;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#level-select-overlay .level-select-panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    height: 100%;
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #0b0722;
    box-shadow: none;
    overflow: hidden;
    isolation: isolate;
    font-family: var(--ls-font);
}

/* Desktop / tablet: present the map as a tall framed card */
@media (min-width: 769px) and (min-height: 700px) {
    #level-select-overlay {
        padding: 24px;
        background:
            radial-gradient(ellipse at 50% 30%, rgba(140, 60, 255, 0.18), transparent 60%),
            #07041a;
    }

    #level-select-overlay .level-select-panel {
        height: min(100%, 960px);
        border-radius: 28px;
        border: 1px solid rgba(164, 107, 255, 0.28);
        box-shadow: 0 0 80px rgba(120, 60, 255, 0.25), 0 30px 80px rgba(0, 0, 0, 0.6);
    }
}

/* ---------- Far layer: sky + skyline ---------- */

.ls-sky {
    position: absolute;
    inset: 0 0 -40% 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 30% at 50% 6%, rgba(255, 79, 216, 0.22), transparent 70%),
        radial-gradient(ellipse 50% 22% at 85% 14%, rgba(94, 243, 255, 0.14), transparent 70%),
        linear-gradient(180deg, #0a0628 0%, #1a0b3e 22%, #120830 45%, #0b0722 100%);
    will-change: transform;
}

.ls-sky-skyline {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--safe-area-inset-top) + 40px);
    height: 190px;
    opacity: 0.9;
}

.ls-sky-skyline svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------- Scrollable map ---------- */

#level-select-overlay .stage-path {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-width: none;
}

#level-select-overlay .stage-path::-webkit-scrollbar {
    display: none;
}

.ls-world {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.ls-env {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    pointer-events: none;
}

.ls-env .nd-flicker {
    animation: ls-neon-flicker 7s steps(1, end) infinite;
}

.ls-env .nd-flicker--slow {
    animation-duration: 11s;
    animation-delay: -4s;
}

/* ---------- Ambient props ---------- */

.ls-lantern {
    --s: 1;
    position: absolute;
    width: calc(13px * var(--s));
    height: calc(19px * var(--s));
    margin-left: calc(-6.5px * var(--s));
    border-radius: 45% / 35%;
    background:
        repeating-linear-gradient(180deg, transparent 0 3px, rgba(120, 20, 10, 0.35) 3px 4px),
        radial-gradient(ellipse at 40% 40%, #ffd27a 0%, #ff7a2a 45%, #c2241c 100%);
    box-shadow:
        0 0 10px 2px rgba(255, 120, 40, 0.65),
        0 0 28px 8px rgba(255, 90, 30, 0.28);
    transform-origin: 50% -10px;
    animation: ls-lantern-sway 4.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

.ls-lantern::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -10px;
    width: 1px;
    height: 10px;
    background: rgba(40, 20, 30, 0.9);
}

.ls-lantern::after {
    content: '';
    position: absolute;
    left: 20%;
    right: 20%;
    top: -2px;
    bottom: -2px;
    border-top: 2px solid #2a1414;
    border-bottom: 2px solid #2a1414;
    border-radius: 2px;
}

.ls-spark {
    position: absolute;
    left: 0;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffffff 0%, #c9fbff 35%, rgba(94, 243, 255, 0) 70%);
    box-shadow: 0 0 10px 3px rgba(94, 243, 255, 0.75), 0 0 22px 8px rgba(164, 107, 255, 0.4);
    offset-rotate: 0deg;
    offset-anchor: center;
    animation: ls-spark-travel 4s linear infinite;
    pointer-events: none;
    z-index: 1;
}

/* ---------- Stage nodes ---------- */

#level-select-overlay .stage-node {
    position: absolute;
    z-index: 2;
    width: var(--n);
    height: var(--n);
    margin: calc(var(--n) / -2) 0 0 calc(var(--n) / -2);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: #fff;
    font-family: var(--ls-font);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: filter 0.2s ease;
}

/* Generous invisible hit area */
#level-select-overlay .stage-node::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
}

#level-select-overlay .stage-node:focus-visible {
    outline: none;
}

#level-select-overlay .stage-node:focus-visible .node-face {
    outline: 3px solid #fff;
    outline-offset: 4px;
}

.stage-node .node-plinth {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    transform: translateY(calc(var(--n) * 0.1));
    background: linear-gradient(180deg, #3a2a20, #1a120c);
    box-shadow: 0 calc(var(--n) * 0.08) calc(var(--n) * 0.16) rgba(0, 0, 0, 0.65);
}

.stage-node .node-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: calc(var(--n) * 0.075) solid transparent;
    transition: transform 0.14s cubic-bezier(0.3, 0.7, 0.4, 1.4), box-shadow 0.2s ease;
}

/* Concave dish inside the rim */
.stage-node .node-face::before {
    content: '';
    position: absolute;
    inset: 9%;
    border-radius: 50%;
    box-shadow:
        inset 0 calc(var(--n) * 0.05) calc(var(--n) * 0.08) rgba(0, 0, 0, 0.45),
        inset 0 calc(var(--n) * -0.03) calc(var(--n) * 0.05) rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.stage-node:active .node-face,
.stage-node.is-pressed .node-face {
    transform: translateY(calc(var(--n) * 0.06)) scale(0.97);
}

/* Locked: charcoal dish, bronze rim, gold lock */
.stage-node.locked .node-face {
    background:
        radial-gradient(circle at 50% 32%, #4a4248 0%, #2c262c 55%, #19151b 100%) padding-box,
        var(--ls-bronze-rim) border-box;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.7),
        inset 0 1px 0 rgba(255, 230, 190, 0.18);
}

.stage-node.locked .node-plinth {
    background: linear-gradient(180deg, #5a3e24, #23170e);
}

.stage-node .node-lock {
    display: block;
    width: 46%;
    height: 46%;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 6px rgba(255, 190, 80, 0.25));
}

.stage-node .node-lock svg {
    display: block;
    width: 100%;
    height: 100%;
}

.stage-node.locked.is-denied .node-face {
    animation: ls-deny 0.36s ease;
}

/* Unlocked (playable): teal dish, mint neon ring */
.stage-node.unlocked .node-face {
    background:
        radial-gradient(circle at 50% 30%, #1fb393 0%, #0c6f5e 48%, #053b33 100%) padding-box,
        linear-gradient(180deg, #b8fff0 0%, #34f5be 45%, #10b98a 100%) border-box;
    box-shadow:
        0 0 0 1px rgba(0, 40, 30, 0.8),
        0 0 calc(var(--n) * 0.16) rgba(61, 255, 198, 0.7),
        0 0 calc(var(--n) * 0.42) rgba(61, 255, 198, 0.3);
}

.stage-node.unlocked .node-plinth {
    background: linear-gradient(180deg, #0f6b55, #032820);
}

.stage-node .node-number {
    position: relative;
    font-size: calc(var(--n) * 0.44);
    font-weight: 800;
    line-height: 1;
    color: #fff;
    letter-spacing: -0.02em;
    text-shadow:
        0 2px 0 rgba(0, 40, 30, 0.55),
        0 0 10px rgba(160, 255, 230, 0.75);
}

/* Completed: cool cyan→violet ring, calmer glow */
.stage-node.completed .node-face {
    background:
        radial-gradient(circle at 50% 30%, #2a7fa8 0%, #164a78 50%, #0c2246 100%) padding-box,
        linear-gradient(180deg, #a8fbff 0%, #5ef3ff 40%, #a46bff 100%) border-box;
    box-shadow:
        0 0 0 1px rgba(0, 10, 40, 0.8),
        0 0 calc(var(--n) * 0.14) rgba(94, 243, 255, 0.5),
        0 0 calc(var(--n) * 0.36) rgba(164, 107, 255, 0.25);
}

.stage-node.completed .node-plinth {
    background: linear-gradient(180deg, #24407a, #0b1430);
}

.stage-node.completed .node-number {
    text-shadow: 0 2px 0 rgba(0, 10, 40, 0.55), 0 0 10px rgba(140, 220, 255, 0.7);
}

/* Current (frontier) stage: brightest, breathing */
.stage-node.current {
    z-index: 3;
}

.stage-node.current .node-face {
    box-shadow:
        0 0 0 1px rgba(0, 40, 30, 0.8),
        0 0 calc(var(--n) * 0.2) rgba(61, 255, 198, 0.9),
        0 0 calc(var(--n) * 0.55) rgba(61, 255, 198, 0.45);
}

.stage-node .node-aura {
    position: absolute;
    inset: -60%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(61, 255, 198, 0.42) 0%, rgba(61, 255, 198, 0.14) 38%, rgba(61, 255, 198, 0) 68%);
    animation: ls-breathe 2.8s ease-in-out infinite;
    pointer-events: none;
}

.stage-node.current::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid rgba(61, 255, 198, 0.75);
    animation: ls-ripple 2.8s ease-out infinite;
    pointer-events: none;
}

/* Star slots under played stages */
.stage-node .node-stars {
    position: absolute;
    left: 50%;
    top: calc(100% + var(--n) * 0.06);
    display: flex;
    gap: 1px;
    padding: 2px 5px;
    border-radius: 999px;
    background: rgba(10, 6, 24, 0.82);
    border: 1px solid rgba(255, 207, 74, 0.35);
    transform: translateX(-50%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.stage-node .node-star {
    width: calc(var(--n) * 0.19);
    height: calc(var(--n) * 0.19);
    min-width: 11px;
    min-height: 11px;
    fill: #4a3d5c;
}

.stage-node .node-star.is-earned {
    fill: var(--ls-gold);
    filter: drop-shadow(0 0 3px rgba(255, 200, 60, 0.7));
}

/* ---------- FX overlay ---------- */

.ls-fx {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(7, 4, 22, 0.88) 0%, rgba(7, 4, 22, 0.55) calc(var(--safe-area-inset-top) + 70px), rgba(7, 4, 22, 0) calc(var(--safe-area-inset-top) + 150px)),
        linear-gradient(0deg, rgba(5, 3, 16, 0.75) 0%, rgba(5, 3, 16, 0) calc(var(--safe-area-inset-bottom) + 130px)),
        radial-gradient(ellipse 120% 85% at 50% 50%, transparent 58%, rgba(3, 1, 12, 0.6) 100%);
}

.ls-petal {
    position: absolute;
    top: -12px;
    width: 7px;
    height: 5px;
    border-radius: 70% 0 70% 0;
    background: linear-gradient(135deg, #ffd0e8, #ff7fc0);
    opacity: 0;
    animation: ls-petal-fall 13s linear infinite;
}

.ls-petal:nth-child(1) { left: 8%;  animation-delay: 0s;   animation-duration: 14s; }
.ls-petal:nth-child(2) { left: 26%; animation-delay: -5s;  animation-duration: 17s; }
.ls-petal:nth-child(3) { left: 47%; animation-delay: -9s;  animation-duration: 13s; }
.ls-petal:nth-child(4) { left: 66%; animation-delay: -2s;  animation-duration: 16s; }
.ls-petal:nth-child(5) { left: 82%; animation-delay: -11s; animation-duration: 15s; }
.ls-petal:nth-child(6) { left: 93%; animation-delay: -7s;  animation-duration: 18s; }

/* ---------- Header ---------- */

.ls-header {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    z-index: 5;
    padding:
        calc(var(--safe-area-inset-top) + 10px)
        calc(var(--safe-area-inset-right) + var(--ls-gutter))
        0
        calc(var(--safe-area-inset-left) + var(--ls-gutter));
    pointer-events: none;
}

.ls-header > * {
    pointer-events: auto;
}

.ls-header::before {
    /* Ambient bloom behind the title sign */
    content: '';
    position: absolute;
    left: 15%;
    right: 15%;
    top: calc(var(--safe-area-inset-top) - 10px);
    height: 110px;
    background: radial-gradient(ellipse at 50% 50%, rgba(200, 80, 255, 0.35), rgba(94, 243, 255, 0.08) 45%, transparent 70%);
    pointer-events: none;
    animation: ls-breathe-soft 5s ease-in-out infinite;
}

.ls-header-row {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.ls-header-sub {
    position: relative;
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    min-height: 0;
}

.ls-back-btn {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 14px;
    border: 2px solid transparent;
    background:
        linear-gradient(180deg, #2c2034 0%, #140d1b 100%) padding-box,
        var(--ls-bronze-rim) border-box;
    color: #fff;
    cursor: pointer;
    box-shadow:
        0 4px 0 #0b070f,
        0 8px 16px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ls-back-btn svg {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.ls-back-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #0b070f, 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ls-title {
    position: relative;
    justify-self: center;
    max-width: 100%;
    margin: 0;
    padding: 7px clamp(8px, 2.6vw, 18px) 8px;
    border-radius: 12px;
    border: 2px solid transparent;
    background:
        linear-gradient(180deg, #1c1036 0%, #0d0720 100%) padding-box,
        var(--ls-bronze-rim) border-box;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.7),
        0 8px 20px rgba(0, 0, 0, 0.55),
        0 0 26px rgba(180, 80, 255, 0.4),
        inset 0 0 16px rgba(140, 60, 255, 0.35);
    font-family: var(--ls-font);
    font-size: clamp(14px, 4.3vw, 26px);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0.03em;
    white-space: nowrap;
    text-align: center;
}

/* Gem ornaments on the sign frame */
.ls-title::before,
.ls-title::after {
    content: '';
    position: absolute;
    left: 50%;
    width: 9px;
    height: 9px;
    margin-left: -4.5px;
    transform: rotate(45deg);
    background: linear-gradient(135deg, #f3c9ff, #a046ff);
    border: 1.5px solid #b98a52;
    box-shadow: 0 0 8px rgba(200, 100, 255, 0.8);
}

.ls-title::before { top: -6px; }
.ls-title::after { bottom: -6px; }

.ls-title-neon {
    color: #d4fcff;
    text-shadow:
        0 0 2px #fff,
        0 0 6px var(--ls-cyan),
        0 0 14px #00d9ff,
        0 0 26px rgba(0, 217, 255, 0.6);
    animation: ls-neon-flicker 9s steps(1, end) infinite;
}

.ls-title-district {
    color: #ffd6fb;
    text-shadow:
        0 0 2px #fff,
        0 0 6px var(--ls-magenta),
        0 0 14px #c94bff,
        0 0 26px rgba(201, 75, 255, 0.6);
}

.ls-stars {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 46px;
    padding: 0 14px 0 9px;
    border-radius: 999px;
    border: 2px solid transparent;
    background:
        linear-gradient(180deg, #24182c 0%, #100a16 100%) padding-box,
        linear-gradient(180deg, #ffe08a 0%, #b47a1e 50%, #ffd36a 100%) border-box;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.7),
        0 6px 14px rgba(0, 0, 0, 0.5),
        0 0 16px rgba(255, 190, 60, 0.3);
    white-space: nowrap;
}

.ls-star-icon {
    flex-shrink: 0;
    filter: drop-shadow(0 0 5px rgba(255, 200, 60, 0.7));
}

.ls-stars-text {
    font-family: var(--ls-font);
    font-size: 19px;
    font-weight: 800;
    color: var(--ls-gold);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 0 #5a3500, 0 0 10px rgba(255, 190, 60, 0.55);
}

/* QA debug badge (dev tooling, functionality unchanged) */
#level-select-overlay .ls-qa-btn {
    min-height: 32px;
    padding: 7px 11px;
    border-radius: 9px;
    border: 1.5px solid var(--ls-magenta);
    background: rgba(22, 8, 40, 0.82);
    color: #f6ecff;
    font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 79, 216, 0.45), inset 0 0 10px rgba(255, 79, 216, 0.18);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#level-select-overlay .ls-qa-btn.is-active {
    background: rgba(200, 0, 170, 0.45);
    border-color: #fff;
    box-shadow: 0 0 14px rgba(255, 79, 216, 0.8), inset 0 0 12px rgba(255, 255, 255, 0.2);
}

/* ---------- Bottom info bar ---------- */

#level-select-overlay .stage-info-bar {
    position: absolute;
    z-index: 5;
    left: calc(var(--safe-area-inset-left) + var(--ls-gutter));
    right: calc(var(--safe-area-inset-right) + var(--ls-gutter));
    bottom: calc(var(--safe-area-inset-bottom) + 12px);
    min-height: 58px;
    margin: 0;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 18px;
    border: 1px solid rgba(140, 255, 230, 0.2);
    background: linear-gradient(180deg, rgba(14, 42, 52, 0.55) 0%, rgba(8, 20, 32, 0.7) 100%);
    backdrop-filter: blur(10px) saturate(1.2);
    -webkit-backdrop-filter: blur(10px) saturate(1.2);
    box-shadow:
        inset 0 1px 0 rgba(200, 255, 245, 0.12),
        0 10px 30px rgba(0, 0, 0, 0.45),
        0 0 20px rgba(61, 255, 198, 0.06);
    color: rgba(230, 255, 250, 0.92);
    font-family: var(--ls-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0.01em;
}

/* ---------- Stage-to-stage transition ----------
   JS adds .ls-advancing (blocks taps, tap = skip) then .ls-advance-run (starts the
   timeline). Delays here mirror ADVANCE_* in level-select.js. */

.ls-skip {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 6;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#level-select-overlay.ls-advancing .ls-skip {
    display: block;
}

/* Path segment draws in behind the spark */
.nd-adv-reveal {
    stroke-dashoffset: 1;
}

#level-select-overlay.ls-advance-run .nd-adv-reveal {
    animation: ls-adv-reveal 0.9s 0.5s linear both;
}

.ls-spark--advance {
    animation: ls-spark-travel 0.9s 0.5s linear 1 both;
    animation-play-state: paused;
}

#level-select-overlay.ls-advance-run .ls-spark--advance {
    animation-play-state: running;
}

/* The finished stage gives a little "done" pulse as the spark leaves it */
#level-select-overlay.ls-advance-run .stage-node.completed:has(+ .stage-node.is-arriving) .node-face {
    animation: ls-done-pulse 0.5s 0.15s ease-out both;
}

/* The next stage starts locked, then the lid breaks and the ring ignites */
.stage-node.is-arriving .node-face {
    opacity: 0;
}

.stage-node.is-arriving .node-plinth {
    background: linear-gradient(180deg, #5a3e24, #23170e);
}

.stage-node.is-arriving .node-plinth::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, #0f6b55, #032820);
    opacity: 0;
}

.stage-node.is-arriving .node-aura,
.stage-node.is-arriving.current::after {
    opacity: 0;
}

.stage-node .node-ghost {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: calc(var(--n) * 0.075) solid transparent;
    background:
        radial-gradient(circle at 50% 32%, #4a4248 0%, #2c262c 55%, #19151b 100%) padding-box,
        var(--ls-bronze-rim) border-box;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 230, 190, 0.18);
    pointer-events: none;
}

/* Before the run starts the ghost is plain locked art; afterwards (finish) it is gone with the re-render */
#level-select-overlay.ls-advance-run .stage-node.is-arriving .node-ghost {
    animation: ls-lock-break 0.55s 1.35s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

#level-select-overlay.ls-advance-run .stage-node.is-arriving .node-face {
    animation: ls-ignite 0.55s 1.7s cubic-bezier(0.2, 0.9, 0.3, 1.3) forwards;
}

#level-select-overlay.ls-advance-run .stage-node.is-arriving .node-plinth::after {
    animation: ls-fade 0.4s 1.7s ease-out forwards;
}

#level-select-overlay.ls-advance-run .stage-node.is-arriving .node-aura {
    animation: ls-aura-in 0.6s 1.8s ease-out both, ls-breathe 2.8s 2.4s ease-in-out infinite;
}

#level-select-overlay.ls-advance-run .stage-node.is-arriving.current::after {
    animation: ls-ripple 1s 1.7s ease-out 1 both;
}

/* Burst ring when the lock gives way */
.stage-node.is-arriving::before {
    border: 3px solid rgba(61, 255, 198, 0.9);
    opacity: 0;
}

#level-select-overlay.ls-advance-run .stage-node.is-arriving::before {
    animation: ls-burst 0.7s 1.35s ease-out both;
}

/* ---------- Entrance ---------- */

#level-select-overlay.ls-entering .ls-header-row {
    animation: ls-drop-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

#level-select-overlay.ls-entering .ls-header-sub,
#level-select-overlay.ls-entering .stage-info-bar {
    animation: ls-fade-up 0.5s 0.15s ease-out both;
}

#level-select-overlay.ls-entering .ls-env {
    animation: ls-fade 0.6s ease-out both;
}

#level-select-overlay.ls-entering .stage-node {
    animation: ls-node-pop 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
    animation-delay: calc(120ms + var(--i) * 32ms);
}

/* ---------- Keyframes ---------- */

@keyframes ls-breathe {
    0%, 100% { opacity: 0.6; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1.04); }
}

@keyframes ls-breathe-soft {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
}

@keyframes ls-ripple {
    0% { opacity: 0.8; transform: scale(1); }
    70%, 100% { opacity: 0; transform: scale(1.5); }
}

@keyframes ls-neon-flicker {
    0%, 100% { opacity: 1; }
    91% { opacity: 1; }
    92% { opacity: 0.55; }
    93% { opacity: 1; }
    95% { opacity: 0.7; }
    96% { opacity: 1; }
}

@keyframes ls-lantern-sway {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: rotate(4deg); }
}

@keyframes ls-spark-travel {
    0% { offset-distance: 0%; opacity: 0; }
    10% { opacity: 1; }
    88% { opacity: 1; }
    100% { offset-distance: 100%; opacity: 0; }
}

@keyframes ls-petal-fall {
    0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0deg); }
    8% { opacity: 0.85; }
    85% { opacity: 0.7; }
    100% { opacity: 0; transform: translate3d(-60px, 105vh, 0) rotate(540deg); }
}

@keyframes ls-adv-reveal {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

@keyframes ls-done-pulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes ls-lock-break {
    0% { transform: translateX(0) scale(1); opacity: 1; }
    15% { transform: translateX(-3px) scale(1); }
    30% { transform: translateX(3px) scale(1); }
    45% { transform: translateX(-2px) scale(1.02); opacity: 1; }
    100% { transform: translateY(-6px) scale(1.35); opacity: 0; filter: brightness(2) blur(2px); }
}

@keyframes ls-ignite {
    0% { opacity: 0; transform: scale(0.7); filter: brightness(2.2); }
    60% { opacity: 1; transform: scale(1.14); filter: brightness(1.4); }
    100% { opacity: 1; transform: scale(1); filter: none; }
}

@keyframes ls-aura-in {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 0.6; transform: scale(0.92); }
}

@keyframes ls-burst {
    0% { opacity: 0.9; transform: scale(0.85); }
    100% { opacity: 0; transform: scale(1.9); }
}

@keyframes ls-deny {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes ls-node-pop {
    0% { opacity: 0; transform: translateY(14px) scale(0.6); }
    100% { opacity: 1; transform: none; }
}

@keyframes ls-drop-in {
    0% { opacity: 0; transform: translateY(-18px); }
    100% { opacity: 1; transform: none; }
}

@keyframes ls-fade-up {
    0% { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: none; }
}

@keyframes ls-fade {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* ---------- Small / short screens ---------- */

@media (max-width: 360px) {
    #level-select-overlay {
        --ls-gutter: 10px;
    }

    .ls-back-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .ls-stars {
        height: 42px;
        padding: 0 10px 0 7px;
        gap: 3px;
    }

    .ls-star-icon {
        width: 22px;
        height: 22px;
    }

    .ls-stars-text {
        font-size: 16px;
    }

    .ls-header-row {
        gap: 6px;
    }
}

@media (max-height: 600px) {
    #level-select-overlay .stage-info-bar {
        min-height: 44px;
        padding: 8px 14px;
        font-size: 13px;
    }

    .ls-header-sub {
        margin-top: 4px;
    }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    #level-select-overlay *,
    #level-select-overlay *::before,
    #level-select-overlay *::after {
        animation: none !important;
        transition: none !important;
    }

    .ls-petal,
    .ls-spark {
        display: none;
    }
}
