:root {
  --bm-primary: #3b82f6;
  --bm-accent: #22d3ee;
  --bm-speed: 0.8;
  --bm-intensity: 0.42;
  --bm-softness: 0.72;
}

body {
  isolation: isolate;
}

#bridge-background {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
  background:
    radial-gradient(circle at 50% -15%, color-mix(in srgb, var(--bm-primary) 9%, transparent), transparent 52%),
    linear-gradient(145deg, #050916 0%, #081225 52%, #060a18 100%);
}

#bridge-background > span {
  position: absolute;
  display: none;
  will-change: transform, opacity;
}

#bridge-background[data-enabled="false"],
#bridge-background[data-reduced="true"] {
  display: none;
}

#bridge-background[data-paused="true"] *,
#bridge-background[data-paused="true"]::before,
#bridge-background[data-paused="true"]::after {
  animation-play-state: paused !important;
}

/* Aurora: Encore's five-fluid-current idea, broadened and softened for legibility. */
#bridge-background[data-animation="aurora"] .bm-orb {
  display: block;
  border-radius: 46% 54% 58% 42% / 52% 38% 62% 48%;
  filter: blur(calc(45px + var(--bm-softness) * 75px)) saturate(125%);
  opacity: calc(var(--bm-intensity) * 0.58);
}

.bm-orb-one {
  width: 58vmax;
  height: 48vmax;
  left: -23vmax;
  top: -24vmax;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--bm-primary) 78%, transparent), transparent 69%);
  animation: bm-aurora-one calc(15s / var(--bm-speed)) ease-in-out infinite;
}

.bm-orb-two {
  width: 56vmax;
  height: 52vmax;
  right: -24vmax;
  bottom: -27vmax;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--bm-accent) 75%, transparent), transparent 70%);
  animation: bm-aurora-two calc(18s / var(--bm-speed)) ease-in-out infinite;
}

.bm-orb-three {
  width: 48vmax;
  height: 43vmax;
  left: 23vw;
  top: 12vh;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--bm-primary) 42%, var(--bm-accent)), transparent 72%);
  animation: bm-aurora-three calc(22s / var(--bm-speed)) ease-in-out infinite;
}

.bm-orb-four {
  width: 70vmax;
  height: 38vmax;
  left: -16vmax;
  bottom: -27vmax;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--bm-primary) 55%, transparent), transparent 73%);
  animation: bm-aurora-four calc(27s / var(--bm-speed)) ease-in-out infinite;
}

.bm-orb-five {
  width: 64vmax;
  height: 52vmax;
  right: -31vmax;
  top: -14vmax;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--bm-accent) 51%, transparent), transparent 74%);
  animation: bm-aurora-five calc(31s / var(--bm-speed)) ease-in-out infinite;
}

@keyframes bm-aurora-one {
  0%, 100% { transform: translate3d(-7vw, -4vh, 0) rotate(-16deg) scale(1, 0.88); opacity: 0.35; }
  33% { transform: translate3d(45vw, 16vh, 0) rotate(31deg) scale(1.17, 0.78); opacity: 0.64; }
  66% { transform: translate3d(22vw, 52vh, 0) rotate(73deg) scale(0.86, 1.14); opacity: 0.46; }
}

@keyframes bm-aurora-two {
  0%, 100% { transform: translate3d(8vw, 7vh, 0) rotate(16deg) scale(1.08, 0.84); opacity: 0.39; }
  34% { transform: translate3d(-46vw, -16vh, 0) rotate(-38deg) scale(0.82, 1.18); opacity: 0.62; }
  68% { transform: translate3d(-18vw, -53vh, 0) rotate(-76deg) scale(1.16, 0.8); opacity: 0.44; }
}

@keyframes bm-aurora-three {
  0%, 100% { transform: translate3d(-18vw, 1vh, 0) rotate(0deg) scale(0.82, 1.12); opacity: 0.25; }
  32% { transform: translate3d(30vw, 28vh, 0) rotate(58deg) scale(1.2, 0.78); opacity: 0.50; }
  67% { transform: translate3d(-20vw, 44vh, 0) rotate(128deg) scale(0.93, 1.18); opacity: 0.34; }
}

@keyframes bm-aurora-four {
  0%, 100% { transform: translate3d(-12vw, 8vh, 0) rotate(-8deg) scale(1.08, 0.72); opacity: 0.23; }
  50% { transform: translate3d(51vw, -28vh, 0) rotate(51deg) scale(0.84, 1.1); opacity: 0.44; }
}

@keyframes bm-aurora-five {
  0%, 100% { transform: translate3d(6vw, -12vh, 0) rotate(12deg) scale(0.78, 1.12); opacity: 0.22; }
  50% { transform: translate3d(-52vw, 34vh, 0) rotate(-66deg) scale(1.13, 0.82); opacity: 0.42; }
}

/* Waves: translucent current bands sweeping across the lower dashboard. */
#bridge-background[data-animation="waves"] .bm-wave {
  display: block;
  left: -35%;
  width: 170%;
  height: 48%;
  bottom: -26%;
  border-radius: 43% 57% 0 0 / 70% 61% 0 0;
  opacity: calc(var(--bm-intensity) * 0.58);
  filter: blur(calc(14px + var(--bm-softness) * 34px));
}

.bm-wave-one {
  background: color-mix(in srgb, var(--bm-primary) 45%, transparent);
  animation: bm-wave-roll calc(19s / var(--bm-speed)) linear infinite;
}

.bm-wave-two {
  bottom: -32%;
  background: color-mix(in srgb, var(--bm-accent) 40%, transparent);
  animation: bm-wave-roll calc(27s / var(--bm-speed)) linear infinite reverse;
}

.bm-wave-three {
  bottom: -38%;
  background: color-mix(in srgb, var(--bm-primary) 24%, var(--bm-accent));
  animation: bm-wave-drift calc(23s / var(--bm-speed)) ease-in-out infinite;
}

@keyframes bm-wave-roll {
  from { transform: translate3d(-7%, 2%, 0) rotate(0deg); opacity: 0.31; }
  50% { transform: translate3d(7%, -12%, 0) rotate(180deg); opacity: 0.58; }
  to { transform: translate3d(-7%, 2%, 0) rotate(360deg); opacity: 0.31; }
}

@keyframes bm-wave-drift {
  0%, 100% { transform: translate3d(-9%, 0, 0) rotate(-2deg) scaleY(0.82); }
  50% { transform: translate3d(9%, -22%, 0) rotate(4deg) scaleY(1.14); }
}

/* Nebula: a slow rotating cloud with a quiet luminous core. */
#bridge-background[data-animation="nebula"] .bm-nebula {
  display: block;
  border-radius: 50%;
  opacity: calc(var(--bm-intensity) * 0.62);
  filter: blur(calc(34px + var(--bm-softness) * 78px)) saturate(135%);
}

.bm-nebula-one {
  width: 80vmax;
  height: 38vmax;
  left: 5vw;
  top: 18vh;
  background: conic-gradient(from 30deg, transparent, var(--bm-primary), transparent 42%, var(--bm-accent), transparent 78%);
  animation: bm-nebula-spin calc(34s / var(--bm-speed)) linear infinite;
}

.bm-nebula-two {
  width: 34vmax;
  height: 34vmax;
  right: -8vmax;
  top: -6vmax;
  background: radial-gradient(circle, var(--bm-accent), transparent 66%);
  animation: bm-nebula-orbit calc(18s / var(--bm-speed)) ease-in-out infinite;
}

.bm-nebula-three {
  width: 38vmax;
  height: 30vmax;
  left: -8vmax;
  bottom: -4vmax;
  background: radial-gradient(circle, var(--bm-primary), transparent 68%);
  animation: bm-nebula-orbit calc(22s / var(--bm-speed)) ease-in-out infinite reverse;
}

@keyframes bm-nebula-spin {
  from { transform: rotate(0deg) scale(0.92, 1.08); }
  50% { transform: rotate(180deg) scale(1.1, 0.88); }
  to { transform: rotate(360deg) scale(0.92, 1.08); }
}

@keyframes bm-nebula-orbit {
  0%, 100% { transform: translate3d(-8vw, -5vh, 0) scale(0.88); opacity: 0.28; }
  50% { transform: translate3d(18vw, 22vh, 0) scale(1.17); opacity: 0.64; }
}

/* Ribbons: clean diagonal links, like data paths crossing the bridge. */
#bridge-background[data-animation="ribbons"] .bm-ribbon {
  display: block;
  width: 130vw;
  height: 17vh;
  left: -18vw;
  border-radius: 50%;
  opacity: calc(var(--bm-intensity) * 0.48);
  filter: blur(calc(10px + var(--bm-softness) * 36px));
}

.bm-ribbon-one {
  top: 5vh;
  background: linear-gradient(90deg, transparent, var(--bm-primary), transparent 72%);
  animation: bm-ribbon-flow calc(15s / var(--bm-speed)) ease-in-out infinite;
}

.bm-ribbon-two {
  top: 40vh;
  background: linear-gradient(90deg, transparent 15%, var(--bm-accent), transparent 82%);
  animation: bm-ribbon-flow calc(20s / var(--bm-speed)) ease-in-out infinite reverse;
}

.bm-ribbon-three {
  top: 72vh;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bm-primary) 42%, var(--bm-accent)), transparent);
  animation: bm-ribbon-pulse calc(13s / var(--bm-speed)) ease-in-out infinite;
}

@keyframes bm-ribbon-flow {
  0%, 100% { transform: translate3d(-12vw, 4vh, 0) rotate(-12deg) scaleX(0.92); opacity: 0.25; }
  50% { transform: translate3d(12vw, -6vh, 0) rotate(8deg) scaleX(1.08); opacity: 0.64; }
}

@keyframes bm-ribbon-pulse {
  0%, 100% { transform: translate3d(9vw, 2vh, 0) rotate(5deg) scaleY(0.7); opacity: 0.22; }
  50% { transform: translate3d(-9vw, -11vh, 0) rotate(-8deg) scaleY(1.2); opacity: 0.57; }
}

/* Starfield: three CSS-only parallax fields, with no per-frame JavaScript. */
#bridge-background[data-animation="starfield"] .bm-stars {
  display: block;
  inset: -20%;
  width: 140%;
  height: 140%;
  opacity: calc(var(--bm-intensity) * 0.7);
  background-image:
    radial-gradient(circle, var(--bm-primary) 0 1px, transparent 1.8px),
    radial-gradient(circle, var(--bm-accent) 0 1px, transparent 1.8px);
  background-size: 71px 83px, 113px 127px;
  background-position: 13px 21px, 49px 72px;
}

.bm-stars-near {
  filter: drop-shadow(0 0 4px var(--bm-primary));
  animation: bm-stars-drift calc(20s / var(--bm-speed)) linear infinite;
}

.bm-stars-mid {
  transform: scale(0.75);
  opacity: calc(var(--bm-intensity) * 0.45) !important;
  animation: bm-stars-drift calc(31s / var(--bm-speed)) linear infinite reverse;
}

.bm-stars-far {
  transform: scale(0.55) rotate(22deg);
  opacity: calc(var(--bm-intensity) * 0.32) !important;
  animation: bm-stars-twinkle calc(7s / var(--bm-speed)) ease-in-out infinite;
}

@keyframes bm-stars-drift {
  from { transform: translate3d(-3%, -4%, 0) rotate(0deg); }
  to { transform: translate3d(5%, 6%, 0) rotate(4deg); }
}

@keyframes bm-stars-twinkle {
  0%, 100% { transform: scale(0.55) rotate(22deg); opacity: 0.18; }
  50% { transform: scale(0.61) rotate(25deg); opacity: 0.58; }
}

#bridge-background .bm-grain {
  display: block;
  inset: -25%;
  width: 150%;
  height: 150%;
  opacity: 0.035;
  background-image: repeating-radial-gradient(circle at 20% 30%, #fff 0 0.6px, transparent 0.8px 4px);
  background-size: 7px 9px;
  mix-blend-mode: soft-light;
  animation: bm-grain-shift 9s steps(6) infinite;
}

#bridge-background[data-grain="false"] .bm-grain {
  display: none;
}

@keyframes bm-grain-shift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  33% { transform: translate3d(3%, -2%, 0); }
  66% { transform: translate3d(-2%, 3%, 0); }
}

/* Launch splash */
#bridge-splash {
  position: fixed;
  z-index: 2147483646;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  color: #f8fbff;
  background:
    radial-gradient(circle at 50% 46%, color-mix(in srgb, var(--bm-primary) 20%, transparent), transparent 32%),
    linear-gradient(150deg, #030613 0%, #07142b 50%, #040817 100%);
  animation: bm-splash-arrive 360ms ease-out both;
}

#bridge-splash::before,
#bridge-splash::after {
  content: '';
  position: absolute;
  width: 55vmax;
  height: 55vmax;
  border: 1px solid color-mix(in srgb, var(--bm-accent) 17%, transparent);
  border-radius: 50%;
  animation: bm-splash-orbit 9s linear infinite;
}

#bridge-splash::after {
  width: 37vmax;
  height: 37vmax;
  border-color: color-mix(in srgb, var(--bm-primary) 20%, transparent);
  animation-duration: 6s;
  animation-direction: reverse;
}

.bm-splash-core {
  position: relative;
  width: min(540px, 88vw);
  text-align: center;
  animation: bm-splash-core 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.bm-splash-mark {
  width: 176px;
  max-width: 42vw;
  overflow: visible;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--bm-accent) 40%, transparent));
}

.bm-splash-mark path {
  fill: none;
  stroke: url(#bm-link-gradient);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: bm-splash-draw 800ms 130ms ease-out forwards;
}

.bm-splash-mark .bm-splash-deck {
  stroke-width: 3;
  animation-delay: 360ms;
}

.bm-splash-node {
  fill: #07142b;
  stroke: var(--bm-accent);
  stroke-width: 4;
  opacity: 0;
  transform-origin: 90px 62px;
  animation: bm-splash-node 460ms 670ms ease-out forwards;
}

.bm-splash-eyebrow {
  margin: 13px 0 7px;
  color: color-mix(in srgb, var(--bm-accent) 74%, #fff);
  font: 600 0.68rem/1.2 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.28em;
  opacity: 0;
  animation: bm-splash-copy 420ms 520ms ease-out forwards;
}

.bm-splash-core h1 {
  margin: 0;
  font: 700 clamp(2rem, 7vw, 4.4rem)/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.055em;
  opacity: 0;
  transform: translateY(13px);
  animation: bm-splash-copy 480ms 650ms ease-out forwards;
}

.bm-splash-core h1 span {
  color: color-mix(in srgb, var(--bm-accent) 72%, #fff);
  font-weight: 400;
}

.bm-splash-rule {
  width: 210px;
  max-width: 54vw;
  height: 1px;
  margin: 22px auto 14px;
  overflow: hidden;
  background: rgb(255 255 255 / 9%);
}

.bm-splash-rule i {
  display: block;
  width: 44%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--bm-accent), transparent);
  animation: bm-splash-scan 1.2s 700ms ease-in-out both;
}

.bm-splash-hint {
  margin: 0;
  color: rgb(199 215 237 / 55%);
  font: 500 0.72rem/1.2 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.06em;
  opacity: 0;
  animation: bm-splash-copy 360ms 1.1s ease-out forwards;
}

#bridge-splash.bm-splash-leave {
  pointer-events: none;
  animation: bm-splash-leave 330ms ease-in forwards;
}

@keyframes bm-splash-arrive {
  from { opacity: 0.08; }
  to { opacity: 1; }
}

@keyframes bm-splash-core {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes bm-splash-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes bm-splash-node {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes bm-splash-copy {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes bm-splash-scan {
  from { transform: translateX(-130%); }
  to { transform: translateX(260%); }
}

@keyframes bm-splash-orbit {
  from { transform: rotate(0deg) scale(0.96); }
  50% { transform: rotate(180deg) scale(1.04); }
  to { transform: rotate(360deg) scale(0.96); }
}

@keyframes bm-splash-leave {
  to { opacity: 0; transform: scale(1.025); }
}

/* Settings panel */
#bridge-motion-settings {
  position: fixed;
  z-index: 2147483645;
  top: 18px;
  right: 18px;
  display: none;
  width: min(390px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  box-sizing: border-box;
  padding: 20px;
  color: #e9f2ff;
  border: 1px solid rgb(125 178 255 / 22%);
  border-radius: 18px;
  background: rgb(6 14 31 / 94%);
  box-shadow: 0 24px 80px rgb(0 0 0 / 50%), inset 0 1px rgb(255 255 255 / 5%);
  backdrop-filter: blur(20px);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

#bridge-motion-settings[data-open="true"] {
  display: block;
  animation: bm-panel-in 180ms ease-out both;
}

.bm-settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.bm-settings-kicker {
  margin: 0 0 3px;
  color: #7dd3fc;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.bm-settings-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.bm-settings-close {
  width: 34px;
  height: 34px;
  padding: 0;
  color: #c8d8ee;
  border: 1px solid rgb(148 163 184 / 18%);
  border-radius: 10px;
  background: rgb(15 29 52 / 70%);
  cursor: pointer;
  font-size: 1.25rem;
}

.bm-settings-preview {
  position: relative;
  display: grid;
  place-items: center;
  height: 76px;
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid rgb(148 163 184 / 14%);
  border-radius: 13px;
  background:
    radial-gradient(circle at 18% 20%, color-mix(in srgb, var(--bm-primary) 70%, transparent), transparent 42%),
    radial-gradient(circle at 82% 78%, color-mix(in srgb, var(--bm-accent) 65%, transparent), transparent 42%),
    #071024;
}

.bm-settings-preview span {
  position: absolute;
  width: 180px;
  height: 55px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--bm-primary), var(--bm-accent));
  filter: blur(22px);
  opacity: 0.34;
  animation: bm-preview 5s ease-in-out infinite alternate;
}

.bm-settings-preview b {
  position: relative;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
}

.bm-settings-controls {
  display: grid;
  gap: 9px;
}

.bm-settings-row {
  display: grid;
  grid-template-columns: minmax(115px, 1fr) minmax(130px, 1.2fr);
  align-items: center;
  gap: 12px;
  min-height: 32px;
  font-size: 0.78rem;
}

.bm-settings-label {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: #c7d5e8;
}

.bm-settings-value {
  color: #7185a1;
  font-size: 0.67rem;
}

.bm-settings-row select,
.bm-settings-row input[type="color"] {
  width: 100%;
  height: 32px;
  box-sizing: border-box;
  color: #eef6ff;
  border: 1px solid rgb(148 163 184 / 20%);
  border-radius: 8px;
  background: #0b1930;
}

.bm-settings-row input[type="color"] {
  padding: 3px;
}

.bm-settings-row input[type="range"] {
  width: 100%;
  accent-color: var(--bm-accent);
}

.bm-toggle {
  justify-self: end;
  width: 34px;
  height: 18px;
  accent-color: var(--bm-accent);
}

.bm-settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgb(148 163 184 / 12%);
}

.bm-settings-footer button {
  padding: 8px 11px;
  color: #dceaff;
  border: 1px solid rgb(125 178 255 / 24%);
  border-radius: 9px;
  background: rgb(27 53 91 / 54%);
  cursor: pointer;
  font-size: 0.72rem;
}

.bm-settings-footer span {
  color: #7185a1;
  font-size: 0.65rem;
  text-align: right;
}

@keyframes bm-panel-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes bm-preview {
  from { transform: translateX(-36px) rotate(-8deg); }
  to { transform: translateX(36px) rotate(8deg); }
}

@media (prefers-reduced-motion: reduce) {
  #bridge-background {
    display: none !important;
  }

  #bridge-splash {
    display: none !important;
    animation: none !important;
  }

  #bridge-motion-settings *,
  #bridge-motion-settings *::before,
  #bridge-motion-settings *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 520px) {
  #bridge-motion-settings {
    top: 10px;
    right: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .bm-settings-row {
    grid-template-columns: 1fr 1.1fr;
  }
}
