/* =========================================================
   NRG · Aurora — full 3D Tron-corridor telemetry
   ========================================================= */

:root {
  --ink: #efefef;
  --ink-dim: #a8a8a8;
  --ink-mute: #6a6e74;
  --line: rgba(255,255,255,.10);
  --line-2: rgba(255,255,255,.20);
  --bg-0: #0a0c0f;
  --bg-1: #0f1115;
  --mx: 50%;
  --my: 30%;
  --cam-x: 0px;
  --cam-y: 0px;
  --cam-z: 0px;
  --flight: 0;
  --scroll-blur: 1; /* 1 at top, 0 once scrolled past first viewport */
  --grid-color-rgb: 96, 212, 255; /* cyan default; JS sweeps this per stage */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: auto; }
body {
  font-family: 'Share Tech Mono', monospace;
  background: linear-gradient(135deg, #1a1d21 0%, #0f1115 100%);
  color: var(--ink-dim);
  line-height: 1.5;
  min-height: 700vh; /* scroll spacer for flythrough */
  overflow-x: hidden;
  position: relative;
}
::selection { background: rgba(255,255,255,.18); color: #fff; }
a { color: inherit; text-decoration: none; }

/* =================== Background =================== */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
/* CSS fallback grid pattern — runs everywhere, sits under the WebGL canvas.
   Cyan-tinted with a scroll-driven glow that strengthens as you fly forward. */
.bg::before {
  content: "";
  position: absolute;
  inset: -10%;
  background-image:
    linear-gradient(rgba(var(--grid-color-rgb), .14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--grid-color-rgb), .14) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: 50% 50%;
  transform: perspective(700px) rotateX(58deg) translateY(20%) scale(1.6);
  filter:
    blur(calc(var(--scroll-blur, 0) * 22px))
    drop-shadow(0 0 calc(2px + var(--flight, 0) * 14px) rgba(var(--grid-color-rgb), .55))
    drop-shadow(0 0 calc(1px + var(--flight, 0) * 28px) rgba(var(--grid-color-rgb), .25));
  transition: filter .35s ease, background-image .8s ease;
  opacity: .55;
  mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
  pointer-events: none;
}
#grid3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  filter: blur(calc(var(--scroll-blur, 0) * 30px));
  transition: opacity 1.6s ease, filter .35s ease;
  will-change: filter;
}
#grid3d.ready { opacity: .9; }

.vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(140% 90% at 50% 100%, transparent 30%, rgba(0,0,0,.55) 80%, rgba(0,0,0,.95) 100%),
    radial-gradient(80% 60% at 50% 0%, rgba(255,255,255,.05), transparent 60%);
  pointer-events: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(255,255,255,0) 0px,
    rgba(255,255,255,0) 2px,
    rgba(255,255,255,.025) 3px,
    rgba(255,255,255,0) 4px
  );
  mix-blend-mode: overlay;
  pointer-events: none;
  animation: scanflicker 6s steps(60) infinite;
  filter: blur(calc(var(--scroll-blur, 0) * 4px));
  transition: filter .35s ease;
}
@keyframes scanflicker {
  0%, 100% { opacity: .9; }
  50% { opacity: .75; }
}

.grain {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    radial-gradient(rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 2px;
  mix-blend-mode: overlay;
  opacity: calc(.55 - var(--scroll-blur, 0) * .35);
  pointer-events: none;
  transition: opacity .35s ease;
}

.flashlight {
  position: absolute;
  inset: 0;
  background: radial-gradient(360px 360px at var(--mx) var(--my),
    rgba(255,255,255,.06),
    rgba(255,255,255,.02) 30%,
    transparent 60%);
  mix-blend-mode: overlay;
  transition: background .2s linear;
}

/* =================== HUD (fixed 2D) =================== */
.hud { position: relative; z-index: 9; pointer-events: none; }
.hud > * { pointer-events: auto; }

.marker-tape {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 9px 24px;
  background: rgba(0,0,0,.55);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--ink-mute);
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
}
.marker-tape .sep { color: rgba(255,255,255,.18); }
.marker-tape .blink {
  color: var(--ink);
  animation: blink 1.6s steps(2) infinite;
}
.marker-tape .blink::before { content: "● "; color: var(--ink); }
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: .35; }
}

.hud-top {
  position: fixed;
  top: 50px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  letter-spacing: .04em;
  font-size: 16px;
  will-change: transform;
  transition: transform .35s cubic-bezier(.2,.7,.2,1);
}
.brand-mark {
  position: relative;
  width: 26px;
  height: 26px;
  display: inline-block;
}
.brand-arc {
  position: absolute;
  inset: 0;
  border: 1px solid var(--ink);
  border-radius: 50%;
  border-bottom-color: transparent;
  border-right-color: transparent;
  animation: spin 8s linear infinite;
}
.brand-dot {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px;
  height: 6px;
  background: var(--ink);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(255,255,255,.55);
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(0,0,0,.55);
  border: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}
.status-dot.connected { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.status-dot.disconnected { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.hud-bottom {
  position: fixed;
  bottom: 18px;
  left: 24px;
  right: 24px;
  z-index: 10;
}
.hud-progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  background: rgba(0,0,0,.55);
  border: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ink-mute);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hud-progress-track {
  position: relative;
  height: 4px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
}
.hud-progress-fill {
  position: absolute;
  inset: 0 calc(100% - var(--flight) * 100%) 0 0;
  background: linear-gradient(90deg, #6f6f6f, #efefef);
  box-shadow: 0 0 12px rgba(255,255,255,.25);
  transition: inset .12s linear;
}

/* =================== Scene · 3D corridor =================== */
.scene {
  position: fixed;
  inset: 0;
  perspective: 1300px;
  perspective-origin: 50% 45%;
  pointer-events: none;
  z-index: 2;
}
.world {
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  transform-style: preserve-3d;
  /* --breath-y is written by effects.js during idle; defaults to 0 so the
     panels track the WebGL camera's idle bob and don't desync. */
  transform: translate3d(
    var(--cam-x, 0px),
    calc(var(--cam-y, 0px) + var(--breath-y, 0px)),
    var(--cam-z, 0px)
  );
  will-change: transform;
}
.stage {
  position: absolute;
  top: 0; left: 0;
  transform-style: preserve-3d;
  transform: translate3d(var(--stage-x, 0px), var(--stage-y, 0px), var(--stage-z, 0px));
}

.stage-marker {
  position: absolute;
  top: 0; left: 0;
  transform: translate(-50%, -50%) translate3d(0, -240px, 100px);
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
  pointer-events: none;
}
.stage-no {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  letter-spacing: .2em;
  color: var(--ink);
}
.stage-title {
  font-size: 22px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 14px rgba(255,255,255,.18);
}

/* =================== Panels =================== */
.panel {
  position: absolute;
  top: 0; left: 0;
  width: 240px;
  padding: 22px 22px 18px;
  background: rgba(8, 9, 12, 0.78);
  border: 1px solid var(--line-2);
  transform: translate(-50%, -50%) translate3d(var(--x, 0px), var(--y, 0px), var(--z, 0px));
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.02),
    0 30px 60px -30px rgba(0,0,0,.7),
    inset 0 0 30px rgba(255,255,255,.02);
  transition:
    transform .55s cubic-bezier(.2,.7,.2,1),
    border-color .25s ease,
    background .25s ease,
    box-shadow .35s ease,
    filter .35s ease,
    opacity .25s ease;
}
.panel:hover {
  border-color: rgba(255,255,255,.65);
  background: rgba(14, 16, 22, 0.92);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.18),
    0 0 50px rgba(255,255,255,.22),
    0 0 120px rgba(255,255,255,.10),
    0 40px 80px -30px rgba(0,0,0,.85),
    inset 0 0 40px rgba(255,255,255,.06);
}
.panel:hover .panel-corners { --c: rgba(255,255,255,1); }
.panel:hover .value {
  text-shadow: 0 0 26px rgba(255,255,255,.55), 0 0 8px rgba(255,255,255,.3);
}
.panel-corners { transition: background .25s ease; }

.panel-corners {
  position: absolute;
  inset: -1px;
  pointer-events: none;
  --c: rgba(255,255,255,.85);
  --t: 14px;
  background:
    linear-gradient(var(--c), var(--c)) top    left  / var(--t) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) top    left  / 1px var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) top    right / var(--t) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) top    right / 1px var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left  / var(--t) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left  / 1px var(--t) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--t) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 1px var(--t) no-repeat;
}

.panel h3 {
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--ink);
  margin-bottom: 18px;
  text-transform: uppercase;
}
.panel .value {
  font-size: 46px;
  color: #fff;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(255,255,255,.18);
}
.panel .unit {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: .2em;
  margin-top: 6px;
  text-transform: uppercase;
}
.panel .subtitle {
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: .22em;
  margin-top: 14px;
  text-transform: uppercase;
}
.panel .bar-chart {
  position: relative;
  width: 100%;
  height: 5px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line-2);
  margin-top: 16px;
  overflow: hidden;
}
.panel .bar-chart::after {
  content: "";
  position: absolute;
  inset: 0 calc(100% - var(--percentage, 0%)) 0 0;
  background: linear-gradient(90deg, #6f6f6f 0%, #efefef 100%);
  box-shadow: 0 0 10px rgba(255,255,255,.25);
  transition: inset 1s cubic-bezier(.22, 1, .36, 1);
}

/* Sparklines — 30-min rolling micro-chart pinned to panel bottom */
.panel .spark {
  display: block;
  width: 100%;
  height: 18px;
  margin-top: 12px;
  overflow: visible;
  opacity: .85;
}
.panel .spark-path {
  fill: none;
  stroke: rgba(var(--grid-color-rgb, 96, 212, 255), .9);
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(var(--grid-color-rgb, 96, 212, 255), .6));
  transition: stroke .8s ease;
}
.panel-feature .spark { height: 22px; }

/* Feature panel (center, slightly larger) */
.panel-feature {
  width: 280px;
  padding: 28px 26px 24px;
  background: rgba(6, 7, 10, .9);
}
.panel-feature h3 { font-size: 11px; margin-bottom: 22px; }
.panel-feature .value { font-size: 60px; }
.panel-feature::before {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid rgba(255,255,255,.12);
  pointer-events: none;
  outline: 1px solid rgba(255,255,255,.05);
  outline-offset: 6px;
}

/* Battery bank panel — wide horizontal */
.panel-bank {
  width: 720px;
  padding: 28px 32px 26px;
  text-align: center;
}
.panel-bank h3 { margin-bottom: 22px; font-size: 11px; }
.bank-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr;
  gap: 16px;
  align-items: end;
}
.bank-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.4);
}
.bank-cell .bank-label {
  font-size: 10px;
  letter-spacing: .25em;
  color: var(--ink-mute);
}
.bank-cell .value {
  font-size: 30px;
  color: #fff;
  letter-spacing: -.01em;
  text-shadow: 0 0 14px rgba(255,255,255,.18);
}
.bank-cell .bank-unit {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: .15em;
}
.bank-cell.bank-total {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.22);
}
.bank-cell.bank-total .value {
  font-size: 38px;
}

/* End panel */
.panel-end {
  width: 420px;
  padding: 36px 32px 32px;
  text-align: center;
}
.panel-end h3 {
  font-size: 14px;
  margin-bottom: 20px;
  letter-spacing: .3em;
}
.panel-end .end-line {
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 16px;
}
.panel-end .end-line span { color: #fff; }
.panel-end .end-meta {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: .15em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* =================== Hero stage =================== */
.stage-hero { }
.hero-block {
  position: absolute;
  top: 0; left: 0;
  transform: translate(-50%, -50%);
  width: 720px;
  text-align: left;
  pointer-events: auto;
}
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 11px;
  letter-spacing: .3em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.kicker-tick {
  width: 28px;
  height: 1px;
  background: var(--ink);
  display: inline-block;
}
.hero-title {
  font-size: clamp(70px, 11vw, 150px);
  line-height: .95;
  letter-spacing: -.01em;
  margin: 0 0 24px;
  color: var(--ink);
  text-shadow: 0 0 28px rgba(255,255,255,.10);
}
.hero-title .line {
  display: block;
  overflow: hidden;
}
.hero-title .line > span {
  display: block;
  transform: translateY(110%);
  animation: rise-in 1.1s cubic-bezier(.2,.7,.2,1) forwards;
}
.hero-title .line:nth-child(1) > span { animation-delay: .25s; }
.hero-title .line:nth-child(2) > span { animation-delay: .45s; padding-left: clamp(40px, 8vw, 130px); }
.hero-title i {
  font-style: normal;
  color: var(--ink-mute);
  animation: blink 1.2s steps(2) infinite;
}
@keyframes rise-in { to { transform: translateY(0); } }
.lede {
  max-width: 540px;
  font-size: 15px;
  color: var(--ink-dim);
  line-height: 1.6;
  margin-bottom: 28px;
  opacity: 0;
  animation: fade-up 1s ease .9s forwards;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.scroll-hint {
  font-size: 11px;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ink-mute);
  opacity: 0;
  animation: fade-up 1s ease 1.2s forwards;
}

/* =================== Click-to-focus =================== */
body.panel-focused { overflow: hidden; }
body.panel-focused #grid3d {
  filter: blur(28px) brightness(.45);
}
body.panel-focused .panel:not(.focused) {
  opacity: .12 !important;
  filter: blur(5px);
  pointer-events: none !important;
}
body.panel-focused .stage-marker { opacity: .25 !important; }
body.panel-focused .marker-tape,
body.panel-focused .hud-top,
body.panel-focused .hud-bottom { opacity: .35; pointer-events: none; }
body.panel-focused .scanlines, body.panel-focused .grain { opacity: .15; }

.panel.focused {
  z-index: 100;
  cursor: zoom-out;
  border-color: rgba(255,255,255,.7) !important;
  background: rgba(10, 12, 18, .96) !important;
  box-shadow:
    0 0 0 1px rgba(255,255,255,.4),
    0 0 80px rgba(255,255,255,.28),
    0 0 200px rgba(255,255,255,.14),
    inset 0 0 60px rgba(255,255,255,.07) !important;
}
.panel.focused .panel-corners { --c: rgba(255,255,255,1) !important; }
.panel.focused .value {
  text-shadow: 0 0 32px rgba(255,255,255,.7), 0 0 10px rgba(255,255,255,.4);
}

@media (min-width: 901px) {
  .panel.focused {
    transform: translate(-50%, -50%) translate3d(0, 0, 600px) !important;
  }
}

@media (max-width: 900px) {
  .panel.focused {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    width: 88vw;
    max-width: 380px;
    z-index: 100;
    animation: focus-in .35s cubic-bezier(.2,.7,.2,1);
  }
}
@keyframes focus-in {
  from { opacity: .3; }
  to { opacity: 1; }
}

body.panel-focused::after {
  content: "esc · or tap outside to close";
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: .28em;
  color: rgba(255,255,255,.6);
  text-transform: uppercase;
  z-index: 200;
  pointer-events: none;
  animation: focus-in .5s ease .15s both;
}

/* =================== Boot-up intro (~1.2s) =================== */
/* Black overlay reveals scene over the WebGL warmup; staggered keyframes
   sell a "console powering up" feel before the hero animation kicks in. */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  animation: boot-fade 1.2s ease forwards;
}
.boot-line {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
  opacity: 0;
  animation: boot-line 1.2s ease forwards;
}
.boot-bar {
  position: relative;
  width: 220px;
  height: 1px;
  background: rgba(255,255,255,.1);
  overflow: hidden;
  opacity: 0;
  animation: boot-line 1.2s ease forwards;
}
.boot-bar span {
  position: absolute;
  inset: 0 100% 0 0;
  background: linear-gradient(90deg, transparent, rgba(96,212,255,.9), transparent);
  animation: boot-sweep 1.1s cubic-bezier(.5,.05,.2,1) forwards;
}
@keyframes boot-fade {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}
@keyframes boot-line {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes boot-sweep {
  0%   { inset: 0 100% 0 0; }
  100% { inset: 0 -20% 0 100%; }
}

/* =================== Value flash on update =================== */
.value.flash {
  animation: flash 600ms ease;
}
@keyframes flash {
  0%   { color: #fff; text-shadow: 0 0 18px rgba(255,255,255,.45); }
  60%  { color: #fff; text-shadow: 0 0 28px rgba(255,255,255,.7), 0 0 6px rgba(255,255,255,.5); }
  100% { color: #fff; text-shadow: 0 0 18px rgba(255,255,255,.18); }
}

/* =================== Mobile · simplified flat layout =================== */
/* =================== Mobile · 3D Tron flythrough, scaled to fit =================== */
@media (max-width: 900px) {
  /* HUD compaction */
  .marker-tape {
    font-size: 9px;
    gap: 8px;
    padding: 7px 14px;
    letter-spacing: .18em;
  }
  .hud-top { top: 36px; left: 14px; right: 14px; }
  .brand-text { font-size: 13px; }
  .brand-mark { width: 22px; height: 22px; }
  .status-indicator { padding: 5px 10px; font-size: 9px; letter-spacing: .14em; }
  .hud-bottom { display: none; }

  /* Lighter overlays + stop the always-running animations on mobile (saves repaint) */
  .scanlines { opacity: .35; animation: none; }
  .grain { opacity: .25; }

  /* Mobile blur is much more expensive — tone the maxima down */
  #grid3d { filter: blur(calc(var(--scroll-blur, 0) * 18px)); }
  .bg::before {
    /* Skip the dual drop-shadow filter chain on mobile — too heavy. Just blur. */
    filter: blur(calc(var(--scroll-blur, 0) * 14px));
  }

  /* Tighter perspective so a small viewport feels deep */
  .scene { perspective: 800px; perspective-origin: 50% 48%; }

  /* Scale the camera/stage path to ~30% so panels fit on a phone but the
     up/down/left/right pan still reads. Path direction is identical to desktop. */
  .world {
    transform: translate3d(
      calc(var(--cam-x, 0px) * 0.30),
      calc((var(--cam-y, 0px) + var(--breath-y, 0px)) * 0.30),
      calc(var(--cam-z, 0px) * 0.30)
    );
  }
  .stage {
    transform: translate3d(
      calc(var(--stage-x, 0px) * 0.30),
      calc(var(--stage-y, 0px) * 0.30),
      calc(var(--stage-z, 0px) * 0.30)
    );
  }

  /* Trio panels (every stage with a center .panel-feature) — switch from
     left/center/right to top/center/bottom so they fit a portrait viewport.
     !important is required because each panel has the desktop --x/--y/--z
     baked into its inline style attribute (higher specificity by default). */
  .stage:has(.panel-feature) > .panel:nth-of-type(1) {
    --x: 0px !important; --y: -260px !important; --z: -50px !important;
  }
  .stage:has(.panel-feature) > .panel:nth-of-type(2) {
    --x: 0px !important; --y:    0px !important; --z:  90px !important;
  }
  .stage:has(.panel-feature) > .panel:nth-of-type(3) {
    --x: 0px !important; --y:  260px !important; --z: -50px !important;
  }

  /* Smaller panels */
  .panel {
    width: 180px;
    padding: 18px 16px 14px;
  }
  .panel h3 {
    font-size: 10px;
    margin-bottom: 14px;
    letter-spacing: .18em;
  }
  .panel .value { font-size: 36px; }
  .panel .unit { font-size: 10px; margin-top: 4px; }
  .panel .subtitle { font-size: 9px; margin-top: 10px; }
  .panel .bar-chart { margin-top: 12px; }

  .panel-feature {
    width: 200px;
    padding: 22px 18px 16px;
  }
  .panel-feature .value { font-size: 44px; }
  .panel-feature::before { outline-offset: 4px; }

  .panel-bank {
    width: 320px;
    padding: 22px 20px 18px;
  }
  .panel-bank h3 { font-size: 10px; margin-bottom: 16px; }
  .bank-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    align-items: stretch;
  }
  .bank-cell { padding: 10px 4px; gap: 4px; }
  .bank-cell .bank-label { font-size: 8px; letter-spacing: .15em; }
  .bank-cell .value { font-size: 18px; }
  .bank-cell.bank-total .value { font-size: 22px; }
  .bank-cell .bank-unit { font-size: 9px; }

  .panel-end {
    width: 280px;
    padding: 26px 22px 22px;
  }
  .panel-end h3 { font-size: 12px; }
  .panel-end .end-line { font-size: 14px; }
  .panel-end .end-meta { font-size: 9px; }

  /* Stage marker pushed up to clear the vertical panel stack */
  .stage-marker {
    transform: translate(-50%, -50%) translate3d(0, -380px, 100px);
  }
  .stage-no { font-size: 10px; padding: 2px 6px; }
  .stage-title { font-size: 14px; letter-spacing: .12em; }

  /* Hero block — kept inside the 3D scene (just at z=0,x=0,y=0 of stage 0) */
  .hero-block {
    width: min(90vw, 460px);
  }
  .hero-title {
    font-size: clamp(54px, 15vw, 88px);
    margin-bottom: 20px;
  }
  .hero-title .line:nth-child(2) > span { padding-left: clamp(28px, 7vw, 56px); }
  .lede { font-size: 14px; line-height: 1.55; margin-bottom: 22px; }
  .scroll-hint { font-size: 10px; }

  /* Click-to-focus → flat fixed modal (escapes the 3D context) */
  .panel.focused {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 88vw;
    max-width: 360px;
    padding: 26px 22px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot-overlay { display: none; }
  .scanlines, .grain, .marquee-track, .brand-arc { animation: none; }
  .hero-title .line > span { transform: none; animation: none; }
  .lede, .scroll-hint { opacity: 1; animation: none; }
  body { min-height: 100vh; }
  .scene { position: relative; perspective: none; }
  .world { position: relative; transform: none !important; display: flex; flex-direction: column; gap: 32px; padding: 90px 20px; }
  .stage { position: relative; transform: none !important; padding-top: 28px; }
  .stage-marker { position: relative; transform: none; margin-bottom: 14px; }
  .panel { position: relative; width: auto; transform: none !important; max-width: 720px; margin: 0 auto; }
  .hero-block { position: relative; transform: none; width: auto; }
  * { transition: none !important; }
}
