html, body.layers-page {
    height: 100%;
    overflow: hidden;
    background: #050510;
    color: #fff;
    --layer-nav: 56px;
    --layer-topbar: 52px;
    --layer-toolbar: 64px;
    --layer-cookie: 0px;
}
body.layers-page.has-cookie-banner { --layer-cookie: 92px; }

.layers-topbar {
    position: fixed;
    top: var(--layer-nav);
    left: 0;
    right: 0;
    z-index: 500;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(5,5,16,0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.layers-seo-head {
    padding: 0 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 10px;
}
.layers-seo-head h1 {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    margin: 0 0 6px;
    color: #fff;
}
.layers-seo-lead {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.45;
    color: rgba(255,255,255,0.62);
}

.layers-back {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.layers-back:hover { color: #fff; }
.mode-toggle {
    display: flex;
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 3px;
    border: 1px solid rgba(255,255,255,0.1);
}
.mode-btn {
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.55);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.mode-btn.active {
    background: rgba(72,219,108,0.28);
    color: #fff;
}
.topbar-actions { display: flex; gap: 6px; }
.tb-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.72rem;
    cursor: pointer;
}
.tb-btn.active { background: rgba(72,219,108,0.2); border-color: rgba(72,219,108,0.4); }
.tb-btn.muted { opacity: 0.45; }

.layers-main {
    position: fixed;
    top: calc(var(--layer-nav) + var(--layer-topbar));
    left: 0;
    right: 0;
    bottom: calc(var(--layer-toolbar) + var(--layer-cookie));
    display: grid;
    grid-template-columns: 1fr min(340px, 38vw);
}
@media (max-width: 900px) {
    .layers-main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr min(42vh, 380px);
    }
}

#layer-viz-wrap {
    position: relative;
    overflow: hidden;
    background: #050510;
    transition: background 0.8s ease;
    cursor: default;
}
#layer-viz-wrap.zoom-cursor-in { cursor: zoom-in; }
#layer-viz-wrap.zoom-cursor-out { cursor: zoom-out; }
#layer-viz-wrap { touch-action: none; }

#layer-zoom-stage {
    position: absolute;
    inset: 0;
    bottom: 48px;
}
.zoom-hint {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 7;
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.35s;
}
.zoom-hint.hidden { opacity: 0; pointer-events: none; }

/* ── Cinematic layer scene ─────────────────────────────────────────── */
#layer-scene {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}
#layer-bg {
    position: absolute;
    inset: 0;
    transition: background 0.9s ease, opacity 0.6s;
}
#layer-fx {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.layer-scene-caption,
#layer-scene-caption {
    position: absolute;
    bottom: 46px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(520px, calc(100% - 24px));
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.45;
    color: rgba(255,255,255,0.85);
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    z-index: 9;
    font-style: italic;
    margin: 0;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}
#layer-viz-wrap.scene-ready .layer-scene-caption,
#layer-viz-wrap.scene-ready #layer-scene-caption { opacity: 1; }
/* Keep caption visible above scale bar even on globe view */
#layer-viz-wrap.has-globe .layer-scene-caption,
#layer-viz-wrap.has-globe #layer-scene-caption { opacity: 1; bottom: 46px; }

#stars-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.8s;
    z-index: 1;
}
#depth-scale {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    z-index: 2;
}
#depth-scale .depth-marker {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: #48db6c;
    border-radius: 2px;
    transition: top 0.45s cubic-bezier(0.34,1.2,0.64,1);
    box-shadow: 0 0 10px #48db6c;
}
#tunnel-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    z-index: 4;
    padding: 20px 20px 20px 36px;
    pointer-events: none;
}
#layer-tunnel { pointer-events: auto; }
#layer-tunnel {
    width: min(200px, 28vw);
    max-height: 85%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: flex-direction 0.3s;
}
body[data-layer-mode="space"] #layer-tunnel { flex-direction: column-reverse; }
.tunnel-seg {
    flex: 1;
    min-height: 28px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.25s, opacity 0.25s, border-color 0.25s, box-shadow 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    text-align: center;
    padding: 4px;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    opacity: 0.55;
    background-size: cover !important;
    background-blend-mode: overlay;
    backdrop-filter: blur(2px);
}
.tunnel-seg.active {
    opacity: 1;
    transform: scaleX(1.08);
    border-color: rgba(255,255,255,0.5);
    box-shadow: 0 0 20px rgba(72,219,108,0.35);
    z-index: 2;
}
.tunnel-seg.earth-core {
    min-height: 36px;
    border-radius: 50%;
    flex: 0 0 48px;
    font-size: 0.7rem;
}

#layer-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.2;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.5s;
}
#layer-viz-wrap:not(.has-globe) #layer-svg { opacity: 0.35; }
#layer-svg .layer-ring { pointer-events: stroke; cursor: pointer; }

#journey-label {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 4;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.72rem;
    border: 1px solid rgba(255,255,255,0.1);
    text-align: right;
}
#journey-direction { display: block; color: rgba(255,255,255,0.5); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; }
#journey-depth { color: #48db6c; font-size: 0.9rem; }

#globe-mini-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 48px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
    z-index: 10;
}
#globe-mini-wrap.visible { opacity: 1; pointer-events: none; }
#globe-mini-wrap.visible #globe-mini { pointer-events: auto; }
#globe-mini { width: 100%; height: 100%; }
.globe-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.68rem;
    color: rgba(255,255,255,0.55);
    margin: 0;
    pointer-events: none;
    z-index: 11;
}

#layer-sidebar {
    background: rgba(8,8,28,0.97);
    border-left: 1px solid rgba(255,255,255,0.08);
    overflow-y: auto;
    padding: 12px 14px 28px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
@media (max-width: 900px) {
    #layer-sidebar {
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.08);
    }
}
.sidebar-progress { margin-bottom: 4px; }
#progress-text { font-size: 0.68rem; color: rgba(255,255,255,0.45); }
.progress-track {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}
#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #48db6c, #4cc9f0);
    width: 0%;
    transition: width 0.35s;
}

.layer-list-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
}
.layer-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    color: #fff;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.layer-item:hover { background: rgba(255,255,255,0.06); }
.layer-item.active {
    border-color: rgba(72,219,108,0.5);
    background: rgba(72,219,108,0.12);
    transform: translateX(3px);
}
.layer-item.visited { border-left: 3px solid rgba(72,219,108,0.6); }
.layer-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}
.layer-item-name { font-weight: 700; font-size: 0.82rem; display: block; }
.layer-item-range { font-size: 0.65rem; color: rgba(255,255,255,0.42); }

#layer-detail {
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}
.detail-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.detail-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(72,219,108,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
#layer-detail h3 { font-size: 1rem; font-weight: 800; margin: 0; line-height: 1.2; }
.detail-range { font-size: 0.68rem; color: rgba(255,255,255,0.45); }
.detail-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.detail-chip {
    font-size: 0.62rem;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
}
.detail-chip.temp { border-color: rgba(255,180,80,0.3); color: #ffd89b; }
.detail-chip.pressure { border-color: rgba(100,180,255,0.3); color: #a8d4ff; }
.detail-fact { font-size: 0.8rem; line-height: 1.55; color: rgba(255,255,255,0.78); margin: 0 0 10px; }
#detail-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-link {
    font-size: 0.72rem;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(72,219,108,0.15);
    border: 1px solid rgba(72,219,108,0.3);
    color: #a8f0b8;
    text-decoration: none;
}
.detail-link:hover { color: #fff; background: rgba(72,219,108,0.25); }

.layer-quiz-box {
    padding: 12px;
    background: rgba(76,201,240,0.08);
    border: 1px solid rgba(76,201,240,0.2);
    border-radius: 12px;
}
.layer-quiz-box.hidden { display: none; }
.layer-quiz-box.bonus {
    background: rgba(157,78,221,0.08);
    border-color: rgba(157,78,221,0.25);
}
.layer-quiz-box.bonus .quiz-box-title { color: #c77dff; }
.quiz-box-title { font-size: 0.75rem; font-weight: 700; margin-bottom: 8px; color: #4cc9f0; }
.quiz-q { font-size: 0.82rem; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.quiz-opt {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.2);
    color: #fff;
    font-size: 0.76rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.quiz-opt:hover:not(:disabled) { background: rgba(255,255,255,0.08); }
.quiz-opt.correct { border-color: #48db6c; background: rgba(72,219,108,0.2); }
.quiz-opt.wrong { border-color: #e74c3c; opacity: 0.65; }
.quiz-feedback { font-size: 0.75rem; margin: 8px 0 0; min-height: 1.2em; }
.quiz-feedback.ok { color: #48db6c; }
.quiz-feedback.bad { color: #ff8a80; }

.layers-bottom {
    position: fixed;
    bottom: var(--layer-cookie);
    left: 0;
    right: 0;
    height: var(--layer-toolbar);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    background: rgba(8,8,28,0.96);
    border-top: 1px solid rgba(255,255,255,0.08);
}
.bottom-mid {
    flex: 1;
    max-width: 320px;
    text-align: center;
}
#bottom-layer-name {
    display: block;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}
.nav-layer-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 44px;
}
.nav-layer-btn:disabled { opacity: 0.3; cursor: default; }
#layer-progress {
    height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}
#layer-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #48db6c, #9d4edd);
    width: 0%;
    transition: width 0.35s;
}

@media (prefers-reduced-motion: reduce) {
    .tunnel-seg, #depth-scale .depth-marker, #layer-progress-fill { transition: none; }
    .fx-cloud, .fx-meteor, .fx-aurora, .fx-magma, .fx-orbit, .fx-core-pulse,
    .fx-field-line, .fx-strata, .fx-horizon-glow { animation: none !important; }
}

/* ══ Per-layer cinematic backgrounds ═══════════════════════════════ */

/* Space - Earth surface (blue marble) */
#layer-viz-wrap[data-layer-key="space-surface"] #layer-bg {
    background:
        radial-gradient(ellipse 120% 80% at 50% 110%, rgba(45,106,79,0.9) 0%, transparent 45%),
        radial-gradient(ellipse 90% 60% at 30% 95%, rgba(30,80,140,0.85) 0%, transparent 50%),
        radial-gradient(ellipse 70% 50% at 70% 100%, rgba(20,60,100,0.8) 0%, transparent 45%),
        linear-gradient(180deg, #020818 0%, #0a2040 35%, #1a5080 60%, #3a90c0 80%, #87ceeb 100%);
}
#layer-viz-wrap[data-layer-key="space-surface"] .fx-horizon {
    position: absolute;
    bottom: 0;
    left: -10%;
    width: 120%;
    height: 45%;
    background: radial-gradient(ellipse 80% 100% at 50% 100%, #2d6a4f 0%, #1a5080 40%, transparent 70%);
    border-radius: 50% 50% 0 0 / 30% 30% 0 0;
}

/* Troposphere - clouds & weather */
#layer-viz-wrap[data-layer-key="space-troposphere"] #layer-bg {
    background: linear-gradient(180deg, #020818 0%, #1565c0 25%, #42a5f5 55%, #90caf9 85%, #e3f2fd 100%);
}
.fx-cloud {
    position: absolute;
    background: radial-gradient(ellipse, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.4) 50%, transparent 70%);
    border-radius: 50%;
    filter: blur(8px);
    animation: cloud-drift linear infinite;
}
@keyframes cloud-drift {
    from { transform: translateX(-120px); }
    to { transform: translateX(calc(100vw + 120px)); }
}

/* Stratosphere - deep blue + ozone shimmer */
#layer-viz-wrap[data-layer-key="space-stratosphere"] #layer-bg {
    background: linear-gradient(180deg, #020818 0%, #0d47a1 30%, #1565c0 60%, #42a5f5 100%);
}
.fx-ozone {
    position: absolute;
    left: 0;
    right: 0;
    top: 35%;
    height: 18%;
    background: linear-gradient(90deg,
        transparent 0%, rgba(156,39,176,0.15) 20%, rgba(103,58,183,0.35) 50%,
        rgba(63,81,181,0.25) 80%, transparent 100%);
    filter: blur(12px);
    animation: ozone-shimmer 6s ease-in-out infinite;
}
@keyframes ozone-shimmer {
    0%, 100% { opacity: 0.5; transform: scaleY(1); }
    50% { opacity: 0.9; transform: scaleY(1.15); }
}

/* Mesosphere - meteors */
#layer-viz-wrap[data-layer-key="space-mesosphere"] #layer-bg {
    background: linear-gradient(180deg, #020818 0%, #1a237e 40%, #3949ab 70%, #5c6bc0 100%);
}
.fx-meteor {
    position: absolute;
    width: 3px;
    height: 80px;
    background: linear-gradient(180deg, #fff 0%, rgba(255,200,100,0.8) 30%, transparent 100%);
    transform: rotate(-35deg);
    animation: meteor-fall linear infinite;
    filter: drop-shadow(0 0 6px #ffa726);
}
@keyframes meteor-fall {
    from { transform: rotate(-35deg) translate(0, -100px); opacity: 0; }
    10% { opacity: 1; }
    to { transform: rotate(-35deg) translate(400px, 500px); opacity: 0; }
}

/* Thermosphere - aurora + ISS */
#layer-viz-wrap[data-layer-key="space-thermosphere"] #layer-bg {
    background: linear-gradient(180deg, #020818 0%, #1a0030 50%, #0a0020 100%);
}
.fx-aurora {
    position: absolute;
    inset: 0;
    opacity: 0.75;
}
.fx-aurora-band {
    position: absolute;
    left: -20%;
    width: 140%;
    height: 35%;
    filter: blur(20px);
    animation: aurora-wave 8s ease-in-out infinite;
}
.fx-aurora-band:nth-child(1) {
    top: 15%;
    background: linear-gradient(90deg, transparent, rgba(0,255,136,0.5) 30%, rgba(0,200,255,0.4) 60%, transparent);
    animation-delay: 0s;
}
.fx-aurora-band:nth-child(2) {
    top: 30%;
    background: linear-gradient(90deg, transparent, rgba(180,80,255,0.45) 40%, rgba(100,200,255,0.35) 70%, transparent);
    animation-delay: -3s;
    animation-duration: 10s;
}
.fx-aurora-band:nth-child(3) {
    top: 45%;
    background: linear-gradient(90deg, transparent, rgba(0,255,100,0.35) 50%, rgba(150,50,255,0.3) 80%, transparent);
    animation-delay: -5s;
    animation-duration: 12s;
}
@keyframes aurora-wave {
    0%, 100% { transform: translateX(-5%) skewX(-5deg); opacity: 0.6; }
    50% { transform: translateX(5%) skewX(5deg); opacity: 1; }
}
.fx-satellite {
    position: absolute;
    top: 28%;
    right: 18%;
    width: 48px;
    height: 16px;
    background: linear-gradient(90deg, #888 0%, #ccc 40%, #888 100%);
    border-radius: 2px;
    box-shadow: -30px 0 0 -4px #666, 30px 0 0 -4px #666, 0 0 20px rgba(255,255,255,0.3);
    animation: sat-orbit 20s linear infinite;
}
@keyframes sat-orbit {
    from { transform: translate(0, 0) rotate(-5deg); }
    to { transform: translate(-80px, 40px) rotate(-5deg); }
}
.fx-earth-limb {
    position: absolute;
    bottom: -5%;
    left: 50%;
    transform: translateX(-50%);
    width: 140%;
    height: 35%;
    background: radial-gradient(ellipse 50% 100% at 50% 100%, rgba(30,80,140,0.9) 0%, rgba(10,30,60,0.6) 40%, transparent 70%);
    border-radius: 50% 50% 0 0;
}

/* Exosphere - thin atmosphere fade */
#layer-viz-wrap[data-layer-key="space-exosphere"] #layer-bg {
    background: radial-gradient(ellipse 80% 60% at 50% 100%, rgba(60,80,180,0.25) 0%, transparent 50%), #020818;
}
.fx-atmo-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: radial-gradient(ellipse 70% 100% at 50% 100%, rgba(100,140,255,0.2) 0%, transparent 60%);
    animation: atmo-pulse 5s ease-in-out infinite;
}
@keyframes atmo-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Outer space */
#layer-viz-wrap[data-layer-key="space-space"] #layer-bg {
    background: radial-gradient(ellipse at 30% 20%, rgba(30,20,60,0.4) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 70%, rgba(20,40,80,0.3) 0%, transparent 40%), #020208;
}
.fx-nebula {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.35;
    animation: nebula-drift 30s ease-in-out infinite;
}
@keyframes nebula-drift {
    0%, 100% { transform: scale(1) translate(0,0); }
    50% { transform: scale(1.1) translate(20px, -10px); }
}

/* Earth interior - crust */
#layer-viz-wrap[data-layer-key="earth-surface"] #layer-bg {
    background: linear-gradient(180deg, #87ceeb 0%, #8B6914 8%, #8B4513 25%, #654321 60%, #4a3728 100%);
}
.fx-strata {
    position: absolute;
    left: 0;
    right: 0;
    height: 12%;
    background: repeating-linear-gradient(0deg,
        rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 3px,
        transparent 3px, transparent 8px);
    border-top: 2px solid rgba(255,255,255,0.08);
    border-bottom: 2px solid rgba(0,0,0,0.3);
}

/* Upper mantle - magma */
#layer-viz-wrap[data-layer-key="earth-upper_mantle"] #layer-bg {
    background: radial-gradient(ellipse at 50% 80%, #ff4500 0%, #c1440e 40%, #8b2500 80%, #3d1000 100%);
}
.fx-magma {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,200,50,0.9) 0%, rgba(255,80,0,0.6) 40%, transparent 70%);
    filter: blur(6px);
    animation: magma-rise ease-in-out infinite;
}
@keyframes magma-rise {
    0% { transform: translateY(100px) scale(0.8); opacity: 0; }
    20% { opacity: 0.8; }
    80% { opacity: 0.6; }
    100% { transform: translateY(-120px) scale(1.2); opacity: 0; }
}

/* Lower mantle */
#layer-viz-wrap[data-layer-key="earth-lower_mantle"] #layer-bg {
    background: radial-gradient(ellipse at 50% 50%, #ff6b00 0%, #e85d04 30%, #b83200 60%, #4a1500 100%);
    animation: mantle-heat 8s ease-in-out infinite;
}
@keyframes mantle-heat {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}
.fx-pressure-wave {
    position: absolute;
    inset: 0;
    background: repeating-radial-gradient(circle at 50% 50%,
        transparent 0px, rgba(255,150,50,0.03) 40px, transparent 80px);
    animation: pressure-pulse 4s linear infinite;
}
@keyframes pressure-pulse {
    from { transform: scale(1); opacity: 0.5; }
    to { transform: scale(1.05); opacity: 0.8; }
}

/* Outer core - liquid metal + magnetic field */
#layer-viz-wrap[data-layer-key="earth-outer_core"] #layer-bg {
    background: radial-gradient(ellipse at 50% 50%, #ffe066 0%, #ffba08 25%, #e67e00 50%, #8b4500 80%, #2a1500 100%);
    animation: core-swirl 6s ease-in-out infinite;
}
@keyframes core-swirl {
    0%, 100% { filter: hue-rotate(0deg) brightness(1); }
    50% { filter: hue-rotate(8deg) brightness(1.1); }
}
.fx-metal-swirl {
    position: absolute;
    inset: 10%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(255,220,100,0.4), rgba(200,100,0,0.2), rgba(255,200,80,0.5), rgba(180,80,0,0.2), rgba(255,220,100,0.4));
    filter: blur(20px);
    animation: metal-spin 12s linear infinite;
}
@keyframes metal-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.fx-field-line {
    position: absolute;
    border: 2px solid rgba(100,200,255,0.35);
    border-radius: 50%;
    border-bottom-color: transparent;
    border-left-color: transparent;
    animation: field-pulse 3s ease-in-out infinite;
}
@keyframes field-pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

/* Inner core - blazing solid sphere */
#layer-viz-wrap[data-layer-key="earth-inner_core"] #layer-bg {
    background: radial-gradient(circle at 50% 50%, #ffffff 0%, #fff3b0 15%, #ffd700 35%, #ff8c00 55%, #cc4400 75%, #1a0800 100%);
}
.fx-core-sphere {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(280px, 45vw);
    height: min(280px, 45vw);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, #fff8dc 20%, #ffd700 45%, #ff6600 70%, #cc3300 100%);
    box-shadow: 0 0 80px #ffd700, 0 0 160px rgba(255,150,0,0.5), inset 0 0 60px rgba(255,255,200,0.8);
    animation: core-pulse 2.5s ease-in-out infinite;
}
@keyframes core-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 80px #ffd700, 0 0 160px rgba(255,150,0,0.5); }
    50% { transform: translate(-50%, -50%) scale(1.04); box-shadow: 0 0 120px #fff, 0 0 200px rgba(255,200,0,0.7); }
}
.fx-core-rays {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(400px, 70vw);
    height: min(400px, 70vw);
    transform: translate(-50%, -50%);
    background: conic-gradient(from 0deg, transparent 0deg, rgba(255,255,200,0.08) 10deg, transparent 20deg);
    animation: core-rays-spin 20s linear infinite;
    pointer-events: none;
}
@keyframes core-rays-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Stars visibility per layer */
#layer-viz-wrap[data-layer-key="space-surface"] #stars-bg { opacity: 0.15; }
#layer-viz-wrap[data-layer-key="space-troposphere"] #stars-bg { opacity: 0; }
#layer-viz-wrap[data-layer-key="space-stratosphere"] #stars-bg { opacity: 0.05; }
#layer-viz-wrap[data-layer-key="space-mesosphere"] #stars-bg { opacity: 0.35; }
#layer-viz-wrap[data-layer-key="space-thermosphere"] #stars-bg { opacity: 0.55; }
#layer-viz-wrap[data-layer-key="space-exosphere"] #stars-bg { opacity: 0.85; }
#layer-viz-wrap[data-layer-key="space-space"] #stars-bg { opacity: 1; }
#layer-viz-wrap[data-layer-key^="earth-"] #stars-bg { opacity: 0; }

/* Tunnel segment textures */
.tunnel-seg.seg-space-surface { background: linear-gradient(135deg, #2d6a4f, #1a5080) !important; }
.tunnel-seg.seg-space-troposphere { background: linear-gradient(135deg, #90caf9, #42a5f5) !important; }
.tunnel-seg.seg-space-stratosphere { background: linear-gradient(135deg, #42a5f5, #1565c0) !important; }
.tunnel-seg.seg-space-mesosphere { background: linear-gradient(135deg, #5c6bc0, #3949ab) !important; }
.tunnel-seg.seg-space-thermosphere { background: linear-gradient(135deg, #9d4edd, #1a0030) !important; }
.tunnel-seg.seg-space-exosphere { background: linear-gradient(135deg, #3a0ca3, #020818) !important; }
.tunnel-seg.seg-space-space { background: linear-gradient(135deg, #0a0a18, #000) !important; }
.tunnel-seg.seg-earth-surface { background: linear-gradient(135deg, #8B4513, #654321) !important; }
.tunnel-seg.seg-earth-upper_mantle { background: linear-gradient(135deg, #ff4500, #c1440e) !important; }
.tunnel-seg.seg-earth-lower_mantle { background: linear-gradient(135deg, #ff6b00, #b83200) !important; }
.tunnel-seg.seg-earth-outer_core { background: linear-gradient(135deg, #ffe066, #e67e00) !important; }
.tunnel-seg.seg-earth-inner_core { background: linear-gradient(135deg, #fff, #ffd700) !important; color: #333; text-shadow: none; }

/* ── Earth core → space scale bar ─────────────────────────────────── */
#earth-scale-bar {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 8px;
    z-index: 10;
    pointer-events: none;
}
#layer-viz-wrap.has-globe #earth-scale-bar { opacity: 1; }
.scale-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.45);
    margin-bottom: 4px;
    padding: 0 2px;
}
.scale-mid-label { color: rgba(72,219,108,0.85); font-weight: 700; }
.scale-track-wrap {
    position: relative;
    height: 28px;
    pointer-events: auto;
}
.scale-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg,
        #fff3b0 0%, #ffba08 12%, #e85d04 28%, #8B4513 38%,
        #2d6a4f 42%, #48cae4 52%, #4cc9f0 62%, #7b8cde 72%,
        #9d4edd 82%, #3a0ca3 92%, #0a0a18 100%);
    opacity: 0.85;
}
.scale-node {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    background: var(--node-color, #888);
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 2;
}
.scale-node:hover { transform: translate(-50%, -50%) scale(1.25); }
.scale-node.active {
    transform: translate(-50%, -50%) scale(1.45);
    box-shadow: 0 0 12px rgba(72,219,108,0.8);
    border-color: #fff;
    z-index: 3;
}
.scale-node.visited:not(.active) { border-color: rgba(72,219,108,0.7); }
.scale-node .scale-tip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.58rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.65);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
.scale-node:hover .scale-tip,
.scale-node.active .scale-tip { opacity: 1; }
.scale-marker {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 34px;
    background: #48db6c;
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 0 10px #48db6c;
    transition: left 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
    pointer-events: none;
    z-index: 4;
}
/* ── Journey progress & quiz CTA ──────────────────────────────────── */
.journey-progress-card {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}
.journey-progress-ring-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}
.progress-ring { width: 48px; height: 48px; }
.ring-bg { stroke: rgba(255,255,255,0.1); }
.ring-fill {
    stroke: #48db6c;
    stroke-dasharray: 97.4;
    stroke-dashoffset: 97.4;
    transition: stroke-dashoffset 0.5s ease;
}
.progress-ring-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 800;
    color: #fff;
}
.journey-progress-text { flex: 1; min-width: 0; }
#progress-text { font-size: 0.68rem; color: rgba(255,255,255,0.45); display: block; }
.progress-ring-sub { font-size: 0.62rem; color: rgba(255,255,255,0.35); display: block; margin-top: 2px; }
.total-journey-label { font-size: 0.6rem; color: rgba(72,219,108,0.75); display: block; margin-top: 4px; }
.journey-quiz-btn {
    width: 100%;
    border: 1px solid rgba(255,215,0,0.4);
    background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,150,0,0.1));
    color: #ffe066;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.15s;
}
.journey-quiz-btn:hover { background: rgba(255,215,0,0.22); color: #fff; transform: translateY(-1px); }
.journey-quiz-btn.hidden { display: none; }
.journey-quiz-btn.done {
    border-color: rgba(72,219,108,0.4);
    color: #a8f0b8;
    background: rgba(72,219,108,0.12);
    cursor: default;
}
.detail-link.btn-share { background: rgba(76,201,240,0.12); border-color: rgba(76,201,240,0.3); color: #a8e8ff; }
.share-toast {
    position: fixed;
    bottom: calc(var(--layer-toolbar) + var(--layer-cookie) + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(72,219,108,0.95);
    color: #050510;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 999px;
    z-index: 600;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Journey quiz modal ───────────────────────────────────────────── */
.layer-modal {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.layer-modal.hidden { display: none; }
.layer-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(6px);
}
.layer-modal-panel {
    position: relative;
    width: min(440px, 100%);
    max-height: 85vh;
    overflow-y: auto;
    background: rgba(12,12,32,0.98);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.layer-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.layer-modal-header h4 { margin: 0; font-size: 1rem; font-weight: 800; }
.modal-close-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
}
.layer-modal-body { padding: 16px; }
.layer-modal-body.hidden { display: none; }
.layer-modal-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}
.layer-modal-footer.hidden { display: none; }
.journey-quiz-intro { font-size: 0.8rem; color: rgba(255,255,255,0.65); margin-bottom: 10px; }
.journey-quiz-progress { font-size: 0.72rem; color: rgba(255,255,255,0.45); margin-bottom: 10px; }
.journey-score { font-size: 1.8rem; font-weight: 800; color: #48db6c; margin-bottom: 8px; }
.journey-quiz-msg { font-size: 0.82rem; color: rgba(255,255,255,0.75); margin-bottom: 12px; }
.layer-modal-footer .detail-link { display: inline-block; margin: 4px; }

/* Confetti */
#layer-confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 900;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    top: -10px;
    border-radius: 1px;
    animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
    to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* Wikipedia & curated facts */
.layer-wiki-wrap {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.layer-wiki-wrap.hidden { display: none; }
.layer-wiki-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.55);
    margin-bottom: 10px;
}
.layer-wiki-title i { color: #7b8cde; }
.layer-wiki-badge {
    font-size: 0.58rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: rgba(255,255,255,0.35);
    margin-left: auto;
}
.layer-more-facts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.layer-more-facts.hidden { display: none; }
.more-fact-row {
    font-size: 0.78rem;
    line-height: 1.45;
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    border-left: 3px solid rgba(123,140,222,0.6);
}
.more-fact-row strong {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.5);
    margin-bottom: 3px;
}
.more-fact-row span { color: rgba(255,255,255,0.82); }
.layer-wiki-body {
    font-size: 0.8rem;
    line-height: 1.55;
    color: rgba(255,255,255,0.78);
}
.layer-wiki-text { position: relative; }
.layer-wiki-text.is-collapsed {
    max-height: 7.5rem;
    overflow: hidden;
}
.layer-wiki-text.is-collapsed::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.5rem;
    background: linear-gradient(transparent, rgba(12,12,28,0.98));
    pointer-events: none;
}
.layer-wiki-text p { margin: 0 0 0.75em; }
.layer-wiki-text p:last-child { margin-bottom: 0; }
.layer-wiki-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 10px 0 4px;
    padding: 8px 12px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #a8b4ff;
    background: rgba(123,140,222,0.12);
    border: 1px solid rgba(123,140,222,0.35);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.layer-wiki-expand-btn:hover:not(:disabled) {
    background: rgba(123,140,222,0.22);
    color: #c8d0ff;
}
.layer-wiki-expand-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}
.layer-wiki-expand-btn.is-expanded {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.55);
}
.layer-wiki-thumb {
    float: right;
    max-width: 42%;
    margin: 0 0 10px 12px;
    text-align: center;
}
.layer-wiki-thumb img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}
.layer-wiki-thumb figcaption {
    font-size: 0.58rem;
    color: rgba(255,255,255,0.35);
    margin-top: 4px;
}
.layer-wiki-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
}
.layer-wiki-source {
    margin-top: 10px !important;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.4) !important;
}
.layer-wiki-source a {
    color: #7b8cde;
    text-decoration: none;
}
.layer-wiki-source a:hover { text-decoration: underline; }
.layer-wiki-fallback {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.5);
    margin: 0;
}

@media (max-width: 900px) {
    #earth-scale-bar { left: 8px; right: 8px; bottom: 6px; }
    .scale-node { width: 8px; height: 8px; }
    .scale-node .scale-tip { display: none; }
    .layer-wiki-thumb { float: none; max-width: 100%; margin: 0 0 10px; }
}
