:root {
    /* Design typography tokens: Space Grotesk** for large headings; IBM Plex Mono** for coordinates. */
    --mint: #B8E6D1;
    --ink: #101318;
    --parchment: #E8E1D4;
    --sage: #8FA99B;
    --void: #06080B;
    --slate: #29313A;
    --violet: #8D86B8;
    --clay: #B98573;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--parchment);
    background:
        radial-gradient(circle at 16% 16%, rgba(141, 134, 184, 0.25), transparent 28rem),
        radial-gradient(circle at 82% 8%, rgba(184, 230, 209, 0.16), transparent 24rem),
        linear-gradient(140deg, var(--void), var(--ink) 54%, #15191f);
    font-family: Inter, system-ui, sans-serif;
    overflow-x: hidden;
}

.habitat {
    position: relative;
    isolation: isolate;
}

.grain,
.scanline {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.grain {
    opacity: 0.18;
    background-image: radial-gradient(circle, rgba(232, 225, 212, 0.7) 0 1px, transparent 1px);
    background-size: 13px 17px;
    mix-blend-mode: soft-light;
}

.scanline {
    opacity: 0.09;
    background: repeating-linear-gradient(180deg, transparent 0 7px, rgba(184, 230, 209, 0.6) 8px);
}

.chamber {
    position: relative;
    min-height: 100vh;
    padding: 32px;
    overflow: hidden;
}

.chamber::before,
.chamber::after {
    content: "";
    position: absolute;
    border-radius: 42% 58% 64% 36% / 42% 38% 62% 58%;
    filter: blur(2px);
    opacity: 0.38;
    z-index: -1;
}

.chamber::before {
    width: 45vw;
    height: 38vw;
    left: -12vw;
    bottom: -9vw;
    background: rgba(143, 169, 155, 0.24);
    animation: morph 16s ease-in-out infinite;
}

.chamber::after {
    width: 34vw;
    height: 30vw;
    right: -8vw;
    top: 12vh;
    background: rgba(185, 133, 115, 0.18);
    animation: morph 19s ease-in-out infinite reverse;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    position: relative;
    z-index: 3;
}

h1,
h2,
h3 {
    font-family: "Space Grotesk", Inter, sans-serif;
    margin: 0;
    letter-spacing: -0.055em;
}

h1 {
    position: relative;
    font-size: clamp(3rem, 8vw, 8.8rem);
    line-height: 0.86;
    color: var(--parchment);
    text-shadow: 0 0 32px rgba(184, 230, 209, 0.18);
}

h1::before,
h1::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.38;
}

h1::before {
    color: var(--mint);
    transform: translate(2px, -2px);
    clip-path: inset(0 0 58% 0);
}

h1::after {
    color: var(--clay);
    transform: translate(-3px, 2px);
    clip-path: inset(60% 0 0 0);
}

.mono,
.checksum,
.diagnostics,
.terminal-line {
    font-family: "IBM Plex Mono", monospace;
}

.mono {
    margin: 0 0 10px;
    color: var(--mint);
    font-size: 0.74rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.checksum {
    min-width: 145px;
    padding: 14px 16px;
    border: 1px solid rgba(184, 230, 209, 0.26);
    background: rgba(16, 19, 24, 0.58);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.checksum span,
.diagnostics span {
    display: block;
    color: var(--sage);
    font-size: 0.68rem;
}

.checksum strong {
    font-family: Oxanium, "Space Grotesk", sans-serif;
    font-size: 1.65rem;
    color: var(--mint);
}

.routes {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.route {
    fill: none;
    stroke: var(--mint);
    stroke-width: 1.4;
    stroke-dasharray: 12 10;
    stroke-linecap: round;
    opacity: 0.58;
    filter: drop-shadow(0 0 8px rgba(184, 230, 209, 0.28));
}

.route.is-drawn {
    animation: dashDrift 8s linear infinite;
}

.core-wrap {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 2;
    pointer-events: none;
}

.core-blob {
    position: relative;
    width: min(520px, 72vw);
    min-height: 390px;
    padding: 82px 66px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid rgba(184, 230, 209, 0.25);
    border-radius: 48% 52% 61% 39% / 48% 40% 60% 52%;
    background:
        radial-gradient(circle at 34% 28%, rgba(184, 230, 209, 0.32), transparent 30%),
        linear-gradient(145deg, rgba(41, 49, 58, 0.86), rgba(16, 19, 24, 0.86));
    box-shadow: inset 0 0 65px rgba(184, 230, 209, 0.09), 0 50px 120px rgba(0, 0, 0, 0.45);
    animation: corePulse 8s ease-in-out infinite;
    pointer-events: auto;
}

.core-rings {
    position: absolute;
    inset: -42px;
    border: 1px dashed rgba(141, 134, 184, 0.5);
    border-radius: inherit;
    animation: spin 28s linear infinite;
}

.core-rings::after {
    content: "";
    position: absolute;
    inset: 24px;
    border: 1px solid rgba(185, 133, 115, 0.28);
    border-radius: 38% 62% 50% 50% / 50% 48% 52% 50%;
}

.core-blob h2 {
    max-width: 430px;
    font-size: clamp(2rem, 4vw, 4.25rem);
    line-height: 0.92;
}

.human {
    max-width: 410px;
    font-family: Fraunces, Georgia, serif;
    color: rgba(232, 225, 212, 0.78);
    font-size: 1.06rem;
    line-height: 1.55;
}

.pulse-button {
    align-self: flex-start;
    border: 1px solid rgba(184, 230, 209, 0.34);
    color: var(--ink);
    background: var(--mint);
    padding: 12px 16px;
    font: 700 0.78rem Oxanium, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    cursor: pointer;
    box-shadow: 8px 8px 0 rgba(141, 134, 184, 0.38);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.pulse-button:hover {
    transform: translate(4px, 4px);
    box-shadow: 2px 2px 0 rgba(141, 134, 184, 0.55);
}

.pulse-button.is-active {
    background: var(--clay);
    color: var(--void);
}

.panel {
    position: absolute;
    width: min(270px, 28vw);
    min-height: 230px;
    padding: 18px;
    border: 1px solid rgba(232, 225, 212, 0.14);
    background: rgba(41, 49, 58, 0.72);
    backdrop-filter: blur(18px);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
    z-index: 2;
}

.panel h3,
.narrative-card h3 {
    font-size: 1.35rem;
}

.panel p:not(.mono),
.narrative-card p:not(.mono) {
    color: rgba(232, 225, 212, 0.7);
    line-height: 1.55;
}

.panel-left-top { left: 6vw; top: 22vh; }
.panel-right-top { right: 6vw; top: 18vh; }
.panel-left-bottom { left: 8vw; bottom: 9vh; }
.panel-right-bottom { right: 7vw; bottom: 8vh; }

.drift { animation: floatDrift 7s ease-in-out infinite; }
.slow { animation-duration: 9s; }
.slower { animation-duration: 11s; }

.iso {
    position: relative;
    width: 86px;
    height: 76px;
    margin: 10px 0 22px 16px;
    transform: rotateX(58deg) rotateZ(45deg);
    transform-style: preserve-3d;
}

.iso span {
    position: absolute;
    display: block;
    border: 1px solid rgba(184, 230, 209, 0.45);
    background: rgba(141, 134, 184, 0.34);
    box-shadow: 0 0 22px rgba(184, 230, 209, 0.12);
}

.icon-pylon span:nth-child(1) { width: 42px; height: 42px; left: 18px; top: 24px; }
.icon-pylon span:nth-child(2) { width: 24px; height: 72px; left: 27px; top: -18px; background: rgba(185, 133, 115, 0.42); }
.icon-pylon span:nth-child(3) { width: 62px; height: 16px; left: 8px; top: 56px; background: rgba(184, 230, 209, 0.24); }
.icon-map span:nth-child(1) { width: 54px; height: 42px; left: 0; top: 18px; background: rgba(143, 169, 155, 0.36); }
.icon-map span:nth-child(2) { width: 54px; height: 42px; left: 32px; top: 5px; }
.icon-map span:nth-child(3) { width: 36px; height: 36px; left: 24px; top: 32px; background: rgba(185, 133, 115, 0.34); }
.icon-capsule span:nth-child(1) { width: 76px; height: 32px; border-radius: 30px; left: 0; top: 18px; background: rgba(184, 230, 209, 0.25); }
.icon-capsule span:nth-child(2) { width: 26px; height: 26px; left: 14px; top: 21px; background: rgba(141, 134, 184, 0.44); }
.icon-capsule span:nth-child(3) { width: 26px; height: 26px; left: 44px; top: 21px; background: rgba(185, 133, 115, 0.38); }
.icon-crystal span:nth-child(1) { width: 54px; height: 54px; left: 14px; top: 8px; transform: rotate(45deg); background: rgba(184, 230, 209, 0.25); }
.icon-crystal span:nth-child(2) { width: 34px; height: 34px; left: 25px; top: 19px; transform: rotate(45deg); background: rgba(141, 134, 184, 0.44); }
.icon-crystal span:nth-child(3) { width: 70px; height: 14px; left: 8px; top: 62px; background: rgba(143, 169, 155, 0.34); }

.diagnostics {
    position: absolute;
    right: 32px;
    top: 48%;
    display: grid;
    gap: 10px;
    z-index: 3;
}

.diagnostics div {
    width: 168px;
    padding: 11px 13px;
    border-left: 2px solid var(--violet);
    background: rgba(6, 8, 11, 0.62);
}

.diagnostics strong {
    color: var(--parchment);
    font-size: 0.82rem;
}

.font-sentinel {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.lower-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.8fr 0.9fr;
    gap: 18px;
    padding: 28px 32px 60px;
    background: linear-gradient(180deg, transparent, rgba(6, 8, 11, 0.74));
}

.narrative-card {
    position: relative;
    min-height: 220px;
    padding: 26px;
    overflow: hidden;
    border: 1px solid rgba(232, 225, 212, 0.12);
    background: rgba(16, 19, 24, 0.76);
}

.narrative-card.wide {
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    justify-content: end;
}

.narrative-card.wide h2 {
    max-width: 690px;
    font-size: clamp(2.4rem, 5vw, 5.8rem);
    line-height: 0.9;
}

.mini-blob {
    display: block;
    width: 120px;
    height: 92px;
    margin-bottom: 22px;
    border-radius: 54% 46% 61% 39% / 44% 52% 48% 56%;
    background: radial-gradient(circle at 30% 25%, var(--mint), var(--sage));
    opacity: 0.72;
    animation: morph 9s ease-in-out infinite;
}

.glitch-card::before {
    content: "OFFSET_00X";
    position: absolute;
    right: -18px;
    top: 22px;
    color: rgba(185, 133, 115, 0.3);
    font: 700 2.2rem Oxanium, sans-serif;
    transform: rotate(90deg);
}

.terminal-card {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(41, 49, 58, 0.86), rgba(6, 8, 11, 0.9));
}

.terminal-line {
    color: var(--mint);
}

@keyframes corePulse {
    0%, 100% { transform: scale(1); border-radius: 48% 52% 61% 39% / 48% 40% 60% 52%; }
    50% { transform: scale(1.025); border-radius: 41% 59% 48% 52% / 57% 37% 63% 43%; }
}

@keyframes morph {
    0%, 100% { border-radius: 42% 58% 64% 36% / 42% 38% 62% 58%; transform: translate(0, 0) rotate(0deg); }
    50% { border-radius: 62% 38% 44% 56% / 55% 61% 39% 45%; transform: translate(14px, -18px) rotate(4deg); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes floatDrift {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(0, -14px, 0); }
}

@keyframes dashDrift {
    to { stroke-dashoffset: -120; }
}

@media (max-width: 980px) {
    .chamber {
        min-height: auto;
        padding: 22px;
    }

    .topbar,
    .lower-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    .core-wrap,
    .panel,
    .diagnostics {
        position: relative;
        inset: auto;
    }

    .core-wrap {
        margin: 40px 0;
    }

    .panel {
        width: 100%;
        margin: 14px 0;
    }

    .diagnostics {
        margin-top: 18px;
    }

    .routes {
        opacity: 0.25;
    }

    .terminal-card {
        grid-column: auto;
    }
}

@media (max-width: 620px) {
    .core-blob {
        width: 100%;
        min-height: 340px;
        padding: 58px 32px;
    }

    .lower-grid {
        padding: 18px;
    }
}
