:root {
  /* DESIGN typography tokens retained: IBM Plex Mono* Mono** only for short system codes; Space Grotesk* Grotesk** for larger system declarations and elegant retro labels. */
  --obsidian: #05060D;
  --violet-black: #121024;
  --ultraviolet: #8A5CFF;
  --cyan: #24F7FF;
  --gold: #E7C66A;
  --rose: #FF6FD8;
  --mint: #B8FFE8;
  --pearl: #F4F0FF;
  --rail-x: 50vw;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--pearl);
  font-family: "Nunito Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% 14%, rgba(138, 92, 255, 0.22), transparent 28rem),
    radial-gradient(circle at 20% 55%, rgba(255, 111, 216, 0.08), transparent 24rem),
    linear-gradient(180deg, #05060D 0%, #090814 35%, #121024 62%, #05060D 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    repeating-linear-gradient(90deg, transparent 0 72px, rgba(36, 247, 255, 0.025) 72px 73px),
    repeating-linear-gradient(0deg, transparent 0 96px, rgba(231, 198, 106, 0.018) 96px 97px);
  mix-blend-mode: screen;
}

.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.aperture {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(36, 247, 255, 0.18);
  box-shadow: inset 0 0 60px rgba(138, 92, 255, 0.18), 0 0 80px rgba(36, 247, 255, 0.08);
  opacity: 0.8;
}

.aperture-one { width: 46rem; height: 46rem; top: -16rem; left: calc(50% - 23rem); animation: apertureSpin 36s linear infinite; }
.aperture-two { width: 32rem; height: 32rem; bottom: 4rem; right: -10rem; animation: apertureSpin 48s linear infinite reverse; }

.lens {
  position: absolute;
  height: 2px;
  width: 68vw;
  left: -70vw;
  background: linear-gradient(90deg, transparent, rgba(36, 247, 255, 0.0), var(--cyan), var(--pearl), var(--rose), transparent);
  filter: blur(1px);
  box-shadow: 0 0 24px rgba(36, 247, 255, 0.9), 0 0 54px rgba(255, 111, 216, 0.45);
  opacity: 0.7;
}

.lens-a { top: 30vh; animation: lensSweep 8s ease-in-out infinite; }
.lens-b { top: 72vh; animation: lensSweep 12s ease-in-out infinite 2s; opacity: 0.38; }

.viewport-border {
  position: fixed;
  inset: 1.1rem;
  border-radius: 2.1rem;
  pointer-events: none;
  z-index: 9;
  border: 1px solid rgba(36, 247, 255, 0.72);
  box-shadow: inset 0 0 26px rgba(138, 92, 255, 0.25), 0 0 38px rgba(36, 247, 255, 0.16), 0 0 0 1px rgba(138, 92, 255, 0.18);
  animation: drawPerimeter 2.2s cubic-bezier(.2,.7,.1,1) both, borderPulse 5s ease-in-out infinite 2.4s;
}

.viewport-border::before,
.viewport-border::after {
  content: "";
  position: absolute;
  width: 5rem;
  height: 5rem;
  border-radius: 1.4rem;
  opacity: 0.95;
}

.viewport-border::before { top: -1px; left: -1px; border-top: 2px solid var(--gold); border-left: 2px solid var(--gold); }
.viewport-border::after { right: -1px; bottom: -1px; border-right: 2px solid var(--rose); border-bottom: 2px solid var(--rose); }

.bus-rail {
  position: fixed;
  top: 0;
  left: calc(var(--rail-x) - 1px);
  width: 2px;
  height: 100vh;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(36, 247, 255, 0.55), rgba(138, 92, 255, 0.95), rgba(231, 198, 106, 0.45), transparent);
  box-shadow: 0 0 20px rgba(36, 247, 255, 0.55);
}

.bus-rail::before,
.bus-rail::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 22vh;
  border-radius: 99rem;
  background: rgba(36, 247, 255, 0.12);
}

.bus-rail::before { top: 12vh; }
.bus-rail::after { bottom: 12vh; background: rgba(255, 111, 216, 0.1); }

.bus-node {
  position: absolute;
  left: 50%;
  top: 7vh;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--pearl), var(--cyan) 32%, var(--ultraviolet) 62%, transparent 68%);
  box-shadow: 0 0 18px var(--cyan), 0 0 44px var(--ultraviolet), 0 0 76px rgba(255, 111, 216, 0.5);
}

.system-cabinet { position: relative; z-index: 3; }

.scene {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 8rem 1.4rem;
  position: relative;
}

.scene::before {
  content: attr(data-chapter);
  position: absolute;
  top: 12vh;
  left: calc(50% + min(31vw, 28rem));
  writing-mode: vertical-rl;
  font: 500 0.68rem/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.22em;
  color: rgba(184, 255, 232, 0.46);
  text-transform: uppercase;
}

.module {
  position: relative;
  width: min(78vw, 760px);
  min-height: 54vh;
  border-radius: 2.25rem;
  padding: clamp(2rem, 5vw, 4.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  background:
    radial-gradient(circle at 70% 20%, rgba(36, 247, 255, 0.12), transparent 17rem),
    radial-gradient(circle at 16% 82%, rgba(255, 111, 216, 0.08), transparent 16rem),
    linear-gradient(145deg, rgba(18, 16, 36, 0.92), rgba(5, 6, 13, 0.88));
  border: 1px solid rgba(36, 247, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(244, 240, 255, 0.05), inset 0 0 80px rgba(138, 92, 255, 0.14), 0 1.4rem 5rem rgba(0, 0, 0, 0.52), 0 0 70px rgba(36, 247, 255, 0.08);
  overflow: hidden;
  transform: translateY(30px) scale(0.985);
  opacity: 0.62;
  transition: transform 900ms cubic-bezier(.2,.7,.1,1), opacity 900ms ease, border-color 450ms ease, box-shadow 450ms ease;
}

.scene-active .module,
.module:hover {
  transform: translateY(0) scale(1);
  opacity: 1;
  border-color: rgba(36, 247, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(231, 198, 106, 0.14), inset 0 0 90px rgba(138, 92, 255, 0.18), 0 1.4rem 5rem rgba(0, 0, 0, 0.62), 0 0 90px rgba(36, 247, 255, 0.17);
}

.module::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0 32%, rgba(244, 240, 255, 0.12), transparent 48% 100%);
  transform: translateX(-130%);
  transition: transform 1.2s ease;
}

.scene-active .module::before,
.module:hover::before { transform: translateX(130%); }

.module-rim {
  position: absolute;
  inset: 0.65rem;
  border-radius: 1.75rem;
  border: 1px solid rgba(138, 92, 255, 0.38);
  pointer-events: none;
}

.module-rim::before,
.module-rim::after {
  content: "";
  position: absolute;
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
}

.module-rim::before { top: -1px; right: -1px; border-top: 1px solid var(--gold); border-right: 1px solid var(--gold); }
.module-rim::after { left: -1px; bottom: -1px; border-left: 1px solid var(--cyan); border-bottom: 1px solid var(--cyan); }

.narrow-module { width: min(68vw, 640px); }
.wide-module { width: min(84vw, 860px); }
.chamber-module { min-height: 72vh; }
.console-module { width: min(74vw, 720px); }
.final-module { align-items: center; text-align: center; }

.mono-tag,
.caption,
.edge-note {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--mint);
}

.mono-tag { margin: 0 0 1.1rem; font-size: 0.72rem; opacity: 0.82; }
.caption { margin: 1.4rem 0 0; font-size: 0.66rem; opacity: 0.55; }

h1, h2, p { position: relative; z-index: 1; }

h1 {
  margin: 0;
  font-size: clamp(3.4rem, 10vw, 8.9rem);
  line-height: 0.88;
  letter-spacing: -0.075em;
  font-weight: 900;
  color: var(--pearl);
  text-shadow: 0 0 22px rgba(36, 247, 255, 0.38), 0 0 54px rgba(138, 92, 255, 0.25);
}

h2 {
  margin: 0;
  max-width: 11ch;
  font-family: "Space Grotesk", "Nunito Sans", system-ui, sans-serif;
  font-size: clamp(2.2rem, 6vw, 5.75rem);
  line-height: 0.93;
  letter-spacing: -0.055em;
  color: var(--pearl);
}

p {
  max-width: 37rem;
  font-size: clamp(1.02rem, 1.6vw, 1.24rem);
  line-height: 1.72;
  color: rgba(244, 240, 255, 0.75);
}

.declaration {
  font-family: "Space Grotesk", "Nunito Sans", sans-serif;
  font-size: clamp(1.2rem, 2.3vw, 2rem);
  line-height: 1.2;
  color: rgba(244, 240, 255, 0.86);
}

.opening-glyph {
  position: relative;
  z-index: 1;
  width: min(34rem, 100%);
  height: 5.5rem;
  margin-top: 2rem;
  border-radius: 999rem;
  border: 1px solid rgba(36, 247, 255, 0.4);
  background: rgba(5, 6, 13, 0.42);
  overflow: hidden;
}

.opening-glyph::before {
  content: "";
  position: absolute;
  inset: 50% 1rem auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--gold), transparent);
  box-shadow: 0 0 20px var(--cyan);
}

.opening-glyph span {
  position: absolute;
  top: 50%;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  background: rgba(36, 247, 255, 0.12);
  transform: translateY(-50%);
  animation: beadTravel 4.8s ease-in-out infinite;
}

.opening-glyph span:nth-child(1) { left: 16%; }
.opening-glyph span:nth-child(2) { left: 48%; animation-delay: .4s; border-color: var(--rose); }
.opening-glyph span:nth-child(3) { left: 78%; animation-delay: .8s; border-color: var(--gold); }

.corner-screw {
  position: absolute;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 1px solid rgba(231, 198, 106, 0.65);
  box-shadow: 0 0 12px rgba(231, 198, 106, 0.38);
}
.screw-a { top: 1.9rem; right: 2rem; }
.screw-b { bottom: 1.9rem; left: 2rem; }

.signal-slit {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 9rem;
  margin-top: 2rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(231, 198, 106, 0.28);
  background: linear-gradient(90deg, rgba(5,6,13,.2), rgba(36,247,255,.08), rgba(5,6,13,.2));
  overflow: hidden;
}

.signal-slit i {
  position: absolute;
  top: 50%;
  left: 8%;
  height: 2px;
  width: 18%;
  background: var(--cyan);
  box-shadow: 0 0 20px var(--cyan);
  animation: signalPass 3s ease-in-out infinite;
}
.signal-slit i:nth-child(2) { animation-delay: .3s; top: 34%; background: var(--rose); }
.signal-slit i:nth-child(3) { animation-delay: .65s; top: 66%; background: var(--gold); }
.signal-slit i:nth-child(4) { animation-delay: 1s; top: 44%; }
.signal-slit i:nth-child(5) { animation-delay: 1.35s; top: 57%; background: var(--mint); }

.edge-note { position: absolute; top: 50%; font-size: 0.62rem; opacity: 0.45; }
.edge-left { left: -6.5rem; transform: rotate(-90deg); }
.edge-right { right: -6.5rem; transform: rotate(90deg); }

.calibration-rings {
  position: relative;
  z-index: 1;
  align-self: center;
  width: min(28rem, 82vw);
  aspect-ratio: 1;
  margin-top: 2.5rem;
  border-radius: 50%;
}

.ring, .bright-node { position: absolute; inset: 50%; transform: translate(-50%, -50%); border-radius: 50%; }
.ring { border: 1px solid rgba(36, 247, 255, 0.4); animation: ringPulse 5s ease-in-out infinite; }
.ring-one { width: 82%; height: 82%; }
.ring-two { width: 56%; height: 56%; border-color: rgba(138, 92, 255, 0.58); animation-delay: .5s; }
.ring-three { width: 30%; height: 30%; border-color: rgba(231, 198, 106, 0.54); animation-delay: 1s; }
.bright-node { width: 1.6rem; height: 1.6rem; background: var(--pearl); box-shadow: 0 0 24px var(--cyan), 0 0 70px var(--ultraviolet); }

.bubble-field {
  position: relative;
  z-index: 1;
  align-self: stretch;
  min-height: 22rem;
  margin-top: 2rem;
  border-radius: 2rem;
  border: 1px solid rgba(36, 247, 255, 0.22);
  background: radial-gradient(circle at 50% 50%, rgba(36, 247, 255, 0.12), transparent 11rem), rgba(5, 6, 13, 0.26);
  overflow: hidden;
}

.bubble {
  position: absolute;
  width: clamp(3.5rem, 7vw, 5.6rem);
  height: clamp(3.5rem, 7vw, 5.6rem);
  border-radius: 50%;
  border: 1px solid rgba(244, 240, 255, 0.28);
  background: radial-gradient(circle at 30% 24%, rgba(244, 240, 255, 0.76), rgba(184, 255, 232, 0.13) 28%, rgba(138, 92, 255, 0.13) 58%, rgba(5, 6, 13, 0.22));
  color: var(--pearl);
  box-shadow: inset -14px -16px 26px rgba(138, 92, 255, 0.18), 0 0 24px rgba(36, 247, 255, 0.18);
  cursor: pointer;
  transition: transform 350ms cubic-bezier(.2,.8,.2,1), border-color 350ms ease, box-shadow 350ms ease;
  animation: bubbleFloat 7s ease-in-out infinite;
}

.bubble:hover, .bubble.is-pulled {
  border-color: rgba(255, 111, 216, 0.82);
  box-shadow: inset -14px -16px 26px rgba(255, 111, 216, 0.2), 0 0 36px rgba(255, 111, 216, 0.36), 0 0 64px rgba(36, 247, 255, 0.2);
}

.bubble span { font-family: "IBM Plex Mono", monospace; font-size: 1.1rem; opacity: 0.75; }
.b1 { left: 10%; top: 20%; }
.b2 { left: 28%; top: 58%; animation-delay: -1s; }
.b3 { left: 54%; top: 13%; animation-delay: -2s; }
.b4 { right: 9%; top: 42%; animation-delay: -3s; }
.b5 { left: 67%; bottom: 9%; animation-delay: -1.6s; }
.b6 { left: 42%; top: 36%; animation-delay: -4s; }

.monopole-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #F4F0FF 0 18%, #24F7FF 34%, #8A5CFF 62%, transparent 68%);
  box-shadow: 0 0 28px #24F7FF, 0 0 80px #8A5CFF, 0 0 124px rgba(255, 111, 216, 0.38);
  animation: coreBreath 3.8s ease-in-out infinite;
}

.routing-console {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: 2.4rem;
  display: grid;
  gap: 1rem;
}

.route-pill {
  height: 4.8rem;
  border-radius: 99rem;
  border: 1px solid rgba(36, 247, 255, 0.26);
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 0 1.3rem;
  background: linear-gradient(90deg, rgba(5,6,13,.54), rgba(18,16,36,.78));
}
.route-pill span { width: 1rem; height: 1rem; border-radius: 50%; background: var(--ultraviolet); box-shadow: 0 0 18px var(--ultraviolet); }
.route-pill.active { border-color: rgba(231, 198, 106, 0.5); }
.route-pill.active span { background: var(--gold); box-shadow: 0 0 18px var(--gold), 0 0 34px var(--cyan); }
.route-pill em { font-family: "Space Grotesk", sans-serif; font-style: normal; letter-spacing: 0.15em; font-size: .78rem; color: rgba(244, 240, 255, 0.74); }

.seal-orb {
  position: relative;
  z-index: 1;
  width: min(23rem, 78vw);
  aspect-ratio: 1;
  margin-top: 2rem;
  border-radius: 50%;
  border: 1px solid rgba(231, 198, 106, 0.36);
  box-shadow: inset 0 0 90px rgba(36, 247, 255, 0.1), 0 0 80px rgba(138, 92, 255, 0.18);
}
.seal-orb div, .seal-orb span { position: absolute; inset: 50%; transform: translate(-50%, -50%); border-radius: 50%; }
.seal-orb div { width: 42%; height: 42%; border: 1px solid rgba(36,247,255,.48); }
.seal-orb span { width: 1.7rem; height: 1.7rem; background: var(--pearl); box-shadow: 0 0 26px var(--cyan), 0 0 70px var(--ultraviolet); }

@keyframes drawPerimeter { from { clip-path: inset(0 50% 100% 50% round 2rem); opacity: .15; } to { clip-path: inset(0 round 2rem); opacity: 1; } }
@keyframes borderPulse { 50% { border-color: rgba(138, 92, 255, 0.75); box-shadow: inset 0 0 34px rgba(36,247,255,.18), 0 0 48px rgba(138,92,255,.24); } }
@keyframes lensSweep { 0%, 18% { transform: translateX(0) scaleX(.5); opacity: 0; } 34%, 54% { opacity: .72; } 72%, 100% { transform: translateX(180vw) scaleX(1.2); opacity: 0; } }
@keyframes apertureSpin { to { transform: rotate(360deg); } }
@keyframes beadTravel { 50% { transform: translate(1.8rem, -50%) scale(1.35); box-shadow: 0 0 20px currentColor; } }
@keyframes signalPass { 0% { transform: translateX(-120%); opacity: 0; } 35%, 65% { opacity: 1; } 100% { transform: translateX(560%); opacity: 0; } }
@keyframes ringPulse { 50% { transform: translate(-50%, -50%) scale(1.06); box-shadow: 0 0 34px rgba(36,247,255,.24); } }
@keyframes bubbleFloat { 50% { translate: 0 -1.15rem; } }
@keyframes coreBreath { 50% { transform: translate(-50%, -50%) scale(1.16); filter: saturate(1.25); } }

@media (max-width: 760px) {
  .viewport-border { inset: .65rem; border-radius: 1.4rem; }
  .scene { padding: 6rem 1rem; }
  .scene::before, .edge-note { display: none; }
  .module, .narrow-module, .wide-module, .console-module { width: min(92vw, 720px); border-radius: 1.6rem; }
  .chamber-module { min-height: 82vh; }
  h1 { font-size: clamp(3rem, 15vw, 5.5rem); }
  h2 { max-width: 9.5ch; }
}
