:root {
  --cyan: #53e6ff;          /* the single chromatic accent */
  --ice: #d8ecf8;           /* ice-highlight — headings, max emphasis */
  --frost: #d1e4fa;         /* frost-glow — primary luminous body */
  --mist: #c7d3ea;          /* moon-mist — muted body & labels */
  --fog: #9da7ba;           /* fog-veil — helper copy */
  --gold: #ffc061;
  --alert: #ff6a78;
  --edge: rgba(186, 215, 247, 0.12);   /* universal frosted hairline */
  --dim: rgba(199, 211, 234, 0.6);     /* mist, stepped back */
  --faint: rgba(199, 211, 234, 0.3);
  --bg: #02060a;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --disp: 'Space Grotesk', system-ui, sans-serif;
  --cune: 'Noto Sans Cuneiform', 'Space Grotesk', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ice);
  font-family: var(--disp);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  /* kill long-press selection / callout / tap highlight everywhere */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
a { -webkit-tap-highlight-color: transparent; }

#gl { position: fixed; top: 0; left: 0; z-index: 0; touch-action: none; display: block; }

/* ---------- boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 60%, #061019 0%, #01040a 70%, #000 100%);
}
.boot-inner { width: min(86vw, 460px); }
.boot-mark {
  font-family: var(--cune); font-size: 13px; letter-spacing: 0.34em; color: var(--cyan);
  text-shadow: 0 0 18px rgba(83, 230, 255, 0.55); margin-bottom: 22px;
}
#boot-log { font-family: var(--mono); font-size: 11.5px; color: var(--dim); min-height: 118px; line-height: 1.9; }
.boot-line::before { content: '› '; color: var(--cyan); }
.boot-track { margin-top: 18px; height: 1px; background: rgba(83, 230, 255, 0.16); overflow: hidden; }
#boot-bar { height: 100%; width: 0; background: linear-gradient(90deg, transparent, var(--cyan)); box-shadow: 0 0 12px var(--cyan); }

/* ---------- brand ---------- */
#brand {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(15px, 2.6vw, 26px) clamp(18px, 4vw, 46px);
  font-family: var(--mono); font-size: 17px; letter-spacing: 0.22em;
  pointer-events: none; opacity: 0; transition: opacity 1s ease 0.4s;
  /* hardly-perceptible letterhead backdrop, closed with a frosted glass-edge */
  background: linear-gradient(180deg, rgba(2, 6, 10, 0.42), rgba(2, 6, 10, 0.14) 55%, transparent);
  border-bottom: 1px solid var(--edge);
}
body.ready #brand { opacity: 1; }
.brand-mark { font-family: var(--cune); color: var(--ice); text-shadow: 0 0 14px rgba(83, 230, 255, 0.35); }
.brand-right { display: inline-flex; align-items: center; gap: clamp(12px, 2vw, 22px); pointer-events: auto; }
.brand-status { color: var(--dim); display: inline-flex; align-items: center; gap: 8px; }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }

/* ---------- HUD (leaders / rig / psi) ---------- */
#hud { position: fixed; inset: 0; z-index: 18; pointer-events: none; transition: opacity 0.5s ease; }
#leaders { position: fixed; inset: 0; pointer-events: none; overflow: visible; }
.leader { fill: none; stroke: rgba(83, 230, 255, 0.5); stroke-width: 1; }
.leader-dot { fill: var(--cyan); filter: drop-shadow(0 0 5px var(--cyan)); }

#rig {
  position: absolute; top: 0; left: 0; will-change: transform, opacity;
  padding: 12px 14px; border-left: 1px solid rgba(83, 230, 255, 0.35);
  background: linear-gradient(90deg, rgba(6, 20, 28, 0.55), rgba(6, 20, 28, 0));
  backdrop-filter: blur(2px);
}
#rig pre { font-family: var(--mono); font-size: 10.5px; line-height: 1.75; color: var(--cyan); white-space: pre; text-shadow: 0 0 10px rgba(83, 230, 255, 0.3); }
#rig .legend { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 320px; }
#rig .legend span { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em; color: var(--dim); border: 1px solid rgba(83, 230, 255, 0.25); padding: 2px 6px; border-radius: 2px; }

#psi-chip {
  position: absolute; top: 0; left: 0; will-change: transform, opacity;
  display: flex; align-items: baseline; gap: 6px; padding-left: 9px;
  border-left: 1px solid rgba(83, 230, 255, 0.4);
}
#psi-chip b { font-family: var(--disp); font-weight: 700; font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ice); text-shadow: 0 0 14px rgba(83, 230, 255, 0.45); }
#psi-chip i { font-style: normal; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--dim); }
#psi-chip em { font-style: normal; font-family: var(--mono); font-size: 9px; letter-spacing: 0.18em; color: var(--faint); margin-left: 6px; }

/* ---------- copy gallery ---------- */
#gallery { position: fixed; inset: 0; z-index: 20; pointer-events: none; transition: opacity 0.5s ease; }
/* cinema: the reel takes over — everything else recedes */
body.cinema #gallery, body.cinema #hud, body.cinema #dots, body.cinema #hint { opacity: 0 !important; pointer-events: none; }
.panel {
  position: absolute; inset: 0; display: flex; align-items: flex-start;
  padding: clamp(80px, 13vh, 122px) 0 0 clamp(24px, 5vw, 92px); will-change: opacity, filter;
}
.panel-in { position: relative; width: min(46vw, 480px); will-change: transform; }
/* soft feathered scrim so copy stays readable over the bright table */
.panel-in::before {
  content: ''; position: absolute; inset: -38px -52px; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 110% at 34% 50%, rgba(2,6,10,0.72), rgba(2,6,10,0.3) 46%, transparent 74%);
}

.p-eyebrow, .p-no { display: block; font-family: var(--mono); letter-spacing: 0.28em; color: var(--cyan); text-shadow: 0 0 12px rgba(83, 230, 255, 0.38); }
.p-eyebrow { font-size: 11px; margin-bottom: 18px; }
.p-no { font-size: 13px; margin-bottom: 14px; opacity: 0.85; }

.p-title { font-weight: 700; font-size: clamp(26px, 3.6vw, 44px); line-height: 1.04; letter-spacing: -0.015em; color: var(--ice); text-shadow: 0 0 34px rgba(83, 230, 255, 0.2); }
.p-body { margin-top: 16px; font-size: clamp(14px, 1.55vw, 17px); line-height: 1.58; color: var(--mist); max-width: 40ch; text-shadow: 0 1px 12px rgba(0, 8, 14, 0.75); }

.p-bullets { margin-top: 20px; list-style: none; display: flex; flex-direction: column; gap: 9px; }
.p-bullets li { font-family: var(--mono); font-size: 12px; letter-spacing: 0.02em; color: var(--ice); display: flex; align-items: center; gap: 10px; text-shadow: 0 1px 10px rgba(0, 8, 14, 0.7); }
.p-bullets li::before { content: ''; width: 12px; height: 1px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); flex: none; }

/* hero */
.panel-hero .p-headline span { display: block; font-weight: 700; font-size: clamp(42px, 7.4vw, 92px); line-height: 0.94; letter-spacing: -0.025em; color: var(--ice); text-shadow: 0 0 44px rgba(83, 230, 255, 0.25); }
.panel-hero .p-headline span:last-child { color: var(--cyan); }
.panel-hero .p-sub { margin-top: 24px; font-size: clamp(14px, 1.7vw, 18px); color: var(--mist); }
.panel-hero .p-sub .rotor { color: var(--cyan); display: inline-block; min-width: 3.4em; text-shadow: 0 0 14px rgba(83, 230, 255, 0.55); }
.panel-hero .p-foot { margin-top: 28px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.24em; color: var(--fog); text-transform: uppercase; padding-left: 10px; border-left: 1px solid rgba(83, 230, 255, 0.4); }

/* reel caption */
.panel-reel .p-caption { margin-top: 14px; font-size: clamp(14px, 1.7vw, 18px); color: var(--mist); max-width: 30ch; }

/* process steps */
.p-steps { margin-top: 22px; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.p-steps li { display: flex; align-items: baseline; gap: 14px; font-size: clamp(15px, 1.7vw, 19px); color: var(--ice); text-shadow: 0 1px 10px rgba(0, 8, 14, 0.7); }
.p-steps li b { font-family: var(--mono); font-size: 11px; color: var(--cyan); letter-spacing: 0.1em; }

/* ---------- dot index ---------- */
#dots {
  position: fixed; right: clamp(14px, 2.4vw, 32px); top: 50%; transform: translateY(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 11px; pointer-events: auto;
  opacity: 0; transition: opacity 1s ease 0.6s;
}
body.ready #dots { opacity: 1; }
.dot { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; background: rgba(83, 230, 255, 0.22); cursor: pointer; transition: background 0.3s, box-shadow 0.3s, transform 0.3s; }
.dot:hover { background: rgba(83, 230, 255, 0.5); }
.dot.on { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); transform: scale(1.25); }

#hint { position: fixed; bottom: clamp(66px, 9vh, 92px); left: 50%; transform: translateX(-50%); z-index: 40; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em; color: var(--dim); opacity: 0; pointer-events: none; text-align: center; transition: opacity 0.5s ease; }

/* ---------- pulsating orb buttons ---------- */
.orb {
  position: relative; width: 46px; height: 46px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(215, 236, 250, 0.16);   /* frosted glass-edge rim */
  display: grid; place-items: center; cursor: pointer; color: var(--ice);
  background: radial-gradient(circle at 42% 34%, rgba(83, 230, 255, 0.55), rgba(83, 230, 255, 0.05) 72%);
  box-shadow: 0 0 16px rgba(83, 230, 255, 0.35);
  animation: orbpulse 1.8s ease-in-out infinite;
  transition: transform 0.15s ease;
}
.orb:hover { filter: brightness(1.25); }
.orb:active { transform: scale(0.92); }
.orb svg { position: relative; filter: drop-shadow(0 0 3px rgba(0, 8, 14, 0.6)); }
@keyframes orbpulse {
  0%, 100% { transform: scale(0.94); box-shadow: 0 0 10px rgba(83, 230, 255, 0.28); }
  50% { transform: scale(1.06); box-shadow: 0 0 24px rgba(83, 230, 255, 0.55); }
}

/* normal-mode reel button (bottom centre), multi-coloured */
#controls { position: fixed; bottom: clamp(16px, 3vh, 30px); left: 50%; transform: translateX(-50%); z-index: 41; opacity: 0; transition: opacity 1s ease 0.8s; }
body.ready #controls { opacity: 1; }
body.cinema #controls { display: none; }
/* reel orb: idle is a slow colour churn + glow "brew", no scale pulse */
#cam-btn {
  opacity: 0.7;
  background: conic-gradient(from 0deg, #53e6ff, #b48bff, #ffc061, #64ffd0, #53e6ff);
  box-shadow: 0 0 22px rgba(140, 190, 255, 0.45);
  animation: orbhue 7s linear infinite, orbglow 3.4s ease-in-out infinite;
}
@keyframes orbhue { to { filter: hue-rotate(360deg); } }
@keyframes orbglow { 0%, 100% { box-shadow: 0 0 14px rgba(140, 190, 255, 0.34); } 50% { box-shadow: 0 0 28px rgba(140, 190, 255, 0.6); } }

/* reset orb: right quarter, same line as the reel button */
#reset-btn { position: fixed; bottom: clamp(16px, 3vh, 30px); left: 75%; transform: translateX(-50%); z-index: 41; width: 42px; height: 42px; opacity: 0; transition: opacity 1s ease 0.9s; }
body.ready #reset-btn { opacity: 1; }
body.cinema #reset-btn { display: none; }

/* email orb (top-right) — same orb philosophy as the reel button, but a
   cyan theme carrying a little bright (iOS-app, not neon) green. Pulses
   opposite the status dot. */
#email-btn {
  opacity: 0.7;
  width: 40px; height: 40px; text-decoration: none; animation-delay: -0.9s;
  background: conic-gradient(from 205deg, #53e6ff, #34c759, #b8fff0, #53e6ff);
  box-shadow: 0 0 16px rgba(52, 199, 89, 0.42);
}
body.cinema #email-btn { display: none; }

/* cinema: large audio button — horizontally centred, sitting below the reel */
#audio-wrap { position: fixed; inset: 0; z-index: 42; display: none; place-items: end center; padding-bottom: clamp(120px, 24vh, 220px); transform-origin: center bottom; pointer-events: none; }
body.cinema #audio-wrap { display: grid; }
#mute-btn { width: 84px; height: 84px; pointer-events: auto; }
#mute-btn .icon-sound { display: none; }
#mute-btn:not(.muted) .icon-muted { display: none; }
#mute-btn:not(.muted) .icon-sound { display: block; }

/* cinema: small exit, top-right third — red theme */
#exit-btn {
  position: fixed; top: clamp(66px, 11vh, 96px); right: clamp(20px, 4vw, 46px); z-index: 42;
  width: 38px; height: 38px; display: none; opacity: 0.7;
  background: radial-gradient(circle at 40% 34%, #ff8f8f, #e23b3b 74%);
  box-shadow: 0 0 16px rgba(255, 70, 70, 0.4);
}
body.cinema #exit-btn { display: grid; }

/* ---------- fallback ---------- */
#fallback { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; text-align: center; background: radial-gradient(120% 90% at 50% 40%, #061019, #000); }
#fallback h2 { font-size: 24px; margin: 12px 0; }
#fallback p { color: var(--dim); }
.ns { position: fixed; inset: 0; display: grid; place-items: center; color: var(--dim); font-family: var(--mono); }

/* ---------- portrait ---------- */
@media (max-width: 760px) {
  /* nav hugs the dynamic island — mere pixels below it */
  #brand { font-size: 15px; letter-spacing: 0.08em; padding: calc(env(safe-area-inset-top, 0px) + 6px) 18px 12px; }
  .brand-mark { font-size: 13px; }
  /* copy owns the top band, tucked just under the nav; the building sits below */
  .panel { align-items: flex-start; justify-content: flex-start; padding: calc(env(safe-area-inset-top, 0px) + 58px) 24px 0 24px; }
  .panel-in { width: min(92vw, 540px); }
  .panel-in::before { inset: -24px -26px -30px; background: radial-gradient(128% 108% at 42% 40%, rgba(2,6,10,0.82), rgba(2,6,10,0.36) 54%, transparent 82%); }
  .panel-hero .p-headline span { font-size: clamp(30px, 8.6vw, 52px); }
  .panel-hero .p-sub { margin-top: 16px; }
  .p-bullets, .p-steps { margin-top: 14px; }
  #rig { max-width: 82vw; }
  #rig pre { font-size: 9px; }
  /* bottom stack: dots ▸ reel orb, clearing the browser toolbar */
  #dots { right: 50%; top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 72px); transform: translateX(50%); flex-direction: row; gap: 9px; }
  #controls { bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); }
  #reset-btn { bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); }
  .brand-right { gap: 12px; }
  #email-btn { width: 36px; height: 36px; }
  #hint { display: none; }
}
