:root {
  --room-light: 0;
  --haunt: 0;
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #030608;
  color: #182723;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  min-height: 100svh;
  overflow-x: hidden;
  background: radial-gradient(ellipse at 43% 25%, #080d11 0%, #04080b 52%, #020406 100%);
  isolation: isolate;
}
/* The room's lights change every frame of the reveal and of a transmission. Registered as not inherited and written
   onto the few elements that read them (lighting.js), a change restyles those elements, not the ~4,000 elements of the
   machine and of the screen's reflected copies (that was ~45 ms a frame). */
@property --room-light { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --haunt { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --camera-reveal { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --case-light { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --key-light { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --control-light { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --screen-emission { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --screen-shine { syntax: '<number>'; inherits: false; initial-value: 0; }
body::before, main::after { --room-light: inherit; --haunt: inherit; }
/* The room follows the screen (app.js): its colour washes the wall behind the machine and pulses with the music; before
   MUSIC MODE drops the room goes dark. Written on main only, read by its pseudo-elements. */
@property --room-tint { syntax: '<color>'; inherits: false; initial-value: #7fb4d2; }
@property --room-pulse { syntax: '<number>'; inherits: false; initial-value: 0; }
@property --room-dim { syntax: '<number>'; inherits: false; initial-value: 0; }
main::before, main::after { --room-tint: inherit; --room-pulse: inherit; --room-dim: inherit; }
main::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 62% 30%, var(--room-tint) 0%, transparent 62%);
  mix-blend-mode: screen;
  opacity: calc(var(--room-pulse) * .55);
  will-change: opacity;   /* it pulses with the kick: composited, not repainted */
}
.equipment::before { --screen-emission: inherit; }
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 30% 15%, #64737d 0%, #4d5c69 31%, #364652 66%, #243440 100%);
  opacity: var(--room-light);
}
main {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
}
main::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(ellipse at 55% 48%, transparent 30%, #0105077a 74%, #010304bd 100%);
  opacity: calc(.75 - var(--room-light) * .75 + var(--haunt) * .3 + var(--room-dim) * .9);
  transition: --room-dim .8s ease;
}
.equipment {
  --case-light: 0;
  --key-light: 0;
  --control-light: 0;
  --screen-emission: 0;
  --screen-shine: 0;
  --camera-reveal: 0;
  position: relative;
  width: min(94vw, calc((100svh - 112px) * 1456 / 816));
  aspect-ratio: 1456 / 816;
  flex: none;
  user-select: none;
  -webkit-user-select: none;
}
.equipment[data-cinematic="true"] {
  transform: scale(calc(1.024 - var(--camera-reveal) * .024));
  transform-origin: 50% 50%;
}
#console { display: block; width: 100%; height: 100%; overflow: visible; }
#chassis {
  filter: brightness(calc(.038 + var(--case-light) * .962)) saturate(calc(.25 + var(--case-light) * .75));
}
.fera-keyboard {
  filter: brightness(calc(.052 + var(--key-light) * .948)) saturate(calc(.45 + var(--key-light) * .55));
}
.key-legend { opacity: calc(.055 + var(--key-light) * .945); }
[data-section="signal"], [data-section="receiver"], [data-section="stereo"], [data-section="status"], [data-section="jog"], .fera-receiver-status, .fera-decor-meter {
  filter: brightness(calc(.044 + var(--control-light) * .956)) saturate(calc(.3 + var(--control-light) * .7));
}
.fera-trigger-frame { filter: brightness(calc(.05 + var(--case-light) * .95)); }
.fera-trigger-glass { filter: brightness(calc(.72 + var(--case-light) * .28)); }
/* Until the machine is on, the SOUND key sits dark with the case: in the dark room only the POWER rocker glows. */
[data-control="trigger"][data-sound="off"] .fera-trigger-glass { filter: brightness(calc(.05 + var(--case-light) * .95)); }
/* The POWER rocker's frame sits in the dark with the case until the room lights rise; its paddle glows through, like the SOUND key's glass. */
[data-control="power"] .rocker-frame { filter: brightness(calc(.05 + var(--case-light) * .95)); }
[data-control="power"] .rocker-paddle { filter: brightness(calc(.72 + var(--case-light) * .28)); }
[data-control="trigger"][data-sound="on"] .fera-trigger-glass { filter: brightness(calc(.72 + var(--case-light) * .28)) drop-shadow(0 0 6px rgba(255, 138, 30, .6)); }
.night-light { opacity: calc(1 - var(--room-light) * .97); }
.screen-reflected-surface { opacity: calc(var(--screen-emission) * (.68 - var(--room-light) * .60)); }
.screen-atmosphere { opacity: calc(var(--screen-emission) * (1 - var(--room-light) * .4)); }
.screen-bezel-light { opacity: calc(var(--screen-emission) * (1.05 - var(--room-light) * .23)); }
.screen-bezel-shine { opacity: var(--screen-shine); }
.screen-reflected-surface, .screen-reflected-surface * { pointer-events: none !important; }
/* In the dark room the POWER rocker's ember and its halo pulse together until it is pressed. */
.equipment[data-cinematic="true"][data-phase="off"] .rocker-standby {
  animation: standby-button-pulse 3s ease-in-out infinite !important;
}
.equipment[data-cinematic="true"][data-phase="off"] .night-power-glow,
.equipment[data-cinematic="true"][data-phase="off"] .night-spill > g,
.equipment[data-cinematic="true"][data-phase="off"] .night-floor > g {
  animation: standby-halo-pulse 3s ease-in-out infinite !important;
}
@keyframes standby-button-pulse {
  0%, 100% { opacity: .28; }
  42%, 58% { opacity: 1; }
}
@keyframes standby-halo-pulse {
  0%, 100% { opacity: .12; }
  42%, 58% { opacity: 1; }
}
.compact-lighting { display: none; }
.is-compact .desktop-lighting { display: none; }
.is-compact .compact-lighting { display: inline; }
.equipment[data-phase="off"] #screen { visibility: hidden; }
.compact-case { display: none; }
.equipment:focus { outline: none; }
/* chassis.js SCREEN (655.32, 70, 625.68 x 294.36) on the 1456 x 816 case. */
#screen, .equipment::before {
  position: absolute;
  left: 45.0082417582%;
  top: 8.5784313725%;
  width: 42.9725274725%;
  height: 36.0735294118%;
  border-radius: 1.5% / 3%;
}
#screen {
  overflow: clip;
  isolation: isolate;
}
/* Phosphor bloom: one compositor drop-shadow. SVG blur and displacement filters here re-ran on every animated frame
   and cost most of the frame budget. */
#screen[data-optics] { filter: drop-shadow(0 0 2px #8bd6ff66); }
/* A YouTube video is a separate compositor surface: keep filters off its ancestors. */
#screen[data-film-view]:not([data-film-source="native"]) { filter: none; }
/* Outer halation sits outside the screen's optical filter so it can spill onto the bezel.
   The green flanks continue the tube's outward green fringe. The blurred halo is rasterized
   once; only its opacity follows the tube's emission, so the music's glow never repaints it. */
.equipment::before {
  content: '';
  pointer-events: none;
  box-shadow:
    0 0 2px 1px rgb(214 240 255 / .82),
    -4px 0 13px 1px rgb(112 255 208 / .2),
    4px 0 13px 1px rgb(112 255 208 / .2),
    0 0 9px 3px rgb(150 207 250 / .56),
    0 1px 26px 8px rgb(105 185 246 / .42),
    0 8px 64px 19px rgb(67 147 227 / .26);
  opacity: var(--screen-emission);
  will-change: opacity;
}
button, input { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid #fb7059; outline-offset: 4px; }
.help-toggle {
  position: fixed;
  z-index: 5;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #30494630;
  border-radius: 50%;
  background: #dce7e529;
  color: #2f454d;
  font-size: 14px;
  opacity: 0.35;
  transition: opacity 180ms, background 180ms;
  cursor: pointer;
}
.help-toggle:hover, .help-toggle:focus-visible { opacity: 1; background: #dce7e5a0; }
body:not([data-phase="on"]) .help-toggle { opacity: .12; color: #849596; border-color: #78909224; background: none; }
body:not([data-phase="on"]) .help-toggle:focus-visible { opacity: .75; }
dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100svh - 40px);
  padding: 38px;
  border: 1px solid #f7f7ed;
  border-radius: 8px;
  background: #ddded4;
  color: #1c2b27;
  box-shadow: 0 30px 100px #122c3c66, inset 0 0 0 4px #ccd0c6;
}
dialog::backdrop { background: #10292470; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.dialog-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  background: none;
  color: #30453f;
  font-size: 26px;
  cursor: pointer;
}
.eyebrow { margin: 0 0 20px; font: 700 11px 'Courier New', monospace; letter-spacing: 0.15em; }
h1 { margin: 0 0 12px; font-size: 26px; font-weight: 500; letter-spacing: -0.6px; }
.help-intro { color: #54625c; font-size: 14px; line-height: 1.6; }
dl { margin: 22px 0 24px; font-size: 13px; line-height: 1.5; }
dl div { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid #b4beb4; }
dt { font-weight: 700; }
dd { margin: 0; color: #485750; }
.sound-option { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; }
.sound-option + .sound-option { margin-top: 14px; }
.sound-option input { accent-color: #3d564a; width: 16px; height: 16px; }
.help-note { color: #606b65; font-size: 11px; line-height: 1.6; margin: 20px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.audio-cable { position:absolute; inset:0; width:100%; height:100%; overflow:visible; z-index:5; pointer-events:none; opacity:calc(.055 + var(--room-light) * .945); }
/* The cable is a rubber tube: a soft cast shadow, a dark body, a lit upper flank and a narrow gleam. */
.patch-wire-shadow { stroke:#01070b; stroke-width:8; opacity:.42; transform:translate(4px,7px); }
.patch-wire-body { stroke:#0e171e; stroke-width:6; }
.patch-wire-mid { stroke:#26323a; stroke-width:3.6; transform:translate(-.6px,-.7px); }
.patch-wire-edge { stroke:#6f8591; stroke-width:1.1; opacity:.38; transform:translate(-1.3px,-1.5px); }
.patch-wire-gleam { stroke:#d8e6ee; stroke-width:.5; opacity:.35; transform:translate(-1.5px,-1.7px); }
.plug-signal { opacity:.25; transition:opacity .3s; }
.audio-cable[data-live="true"] .plug-signal { opacity:1; filter:drop-shadow(0 0 4px #72c4ff); }
.noscript { position: fixed; inset: auto 0 10px; text-align: center; font-size: 14px; }
.noscript a { color: inherit; }
.is-compact.equipment { width: min(94vw, 760px, calc((100svh - 116px) * 760 / 1490)); aspect-ratio: 760 / 1490; }
.is-compact .desktop-case, .is-compact .desktop-only, .is-compact [data-part="status-frame"] { display: none; }
.is-compact .compact-case { display: inline; }
.is-compact #screen, .is-compact.equipment::before {
  left: 11.6842105263%;
  top: 7.4362416107%;
  width: 74.8421052632%;
  height: 17.9597315436%;
}
/* Safari does not apply CSS filter functions to SVG groups, so without these the case stays lit in the dark room. */
.is-safari #chassis { filter:none; opacity:calc(.028 + var(--case-light) * .972); }
.is-safari .fera-keyboard { filter:none; opacity:calc(.04 + var(--key-light) * .96); }
.is-safari :is([data-section="signal"], [data-section="receiver"], [data-section="stereo"], [data-section="status"], [data-section="jog"], .fera-receiver-status, .fera-decor-meter) { filter:none; opacity:calc(.032 + var(--control-light) * .968); }
/* Opacity keeps the dark opening consistent on mobile SVG compositors and avoids repainting five filtered material copies during relight. */
@media (max-width:800px), (pointer:coarse) {
  #chassis { filter:none; opacity:calc(.028 + var(--case-light) * .972); }
  .fera-keyboard { filter:none; opacity:calc(.04 + var(--key-light) * .96); }
  [data-section="signal"], [data-section="receiver"], [data-section="stereo"], [data-section="status"], [data-section="jog"], .fera-receiver-status, .fera-decor-meter { filter:none; opacity:calc(.032 + var(--control-light) * .968); }
  .screen-reflected-surface { display:none; }
  [fill="url(#cap-grain)"] { display:none; }
  .equipment[data-cinematic="true"] { transform:none; }
  /* Phones draw the same halo without the green flanks. */
  .equipment::before {
    box-shadow:0 0 2px 1px #d6f0ffd1, 0 0 9px 3px #96cffa8f, 0 1px 26px 8px #69b9f66b, 0 8px 64px 19px #4393e342;
  }
}
.is-compact .dial-label { font-size: 14px; }
/* EXTRAPOLATION would run into its neighbours at 14px. */
.is-compact .dial-label.is-long { font-size: 8.5px; letter-spacing: .4px; }
.is-compact text.menu-label { font-size: 11px; }
.is-compact text.menu-kanji { display: none; }
.is-compact .signal-label { font-size: 13px; }
/* A phone held sideways (about 850 by 340): the HUD shrinks to thin top and bottom lines, so the machine takes the height. */
@media (pointer:coarse) and (max-height:500px) and (min-width:801px) {
  .equipment { width: min(98vw, calc((100svh - 44px) * 1456 / 816)); }
}
@media (max-width: 800px) {
  main { min-height: 100svh; padding-top: 12px; padding-bottom: 12px; }
  dialog { padding: 28px; }
  .help-toggle { width: 44px; height: 44px; }
}
/* Calm mode, chosen in the guide, stills every CSS animation and transition. */
:root[data-motion="calm"] *, :root[data-motion="calm"] *::before, :root[data-motion="calm"] *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }

/* Cool CRT spill on the cap edges that face the screen. */
.cap-screen-spill { opacity: calc(var(--screen-emission) * var(--spill) * (1 - var(--room-light) * .45)); }

/* A pressed cap sits lower, so its shadow tucks in under it and softens. */
.cap-cast { transition: transform 60ms ease, opacity 60ms ease; transform-box: fill-box; transform-origin: center; }
.is-held .cap-cast { transform: translate(-1px, -1.2px) scale(.98); opacity: .75; }
.is-pressed .cap-cast { transform: translate(-1.8px, -2.2px) scale(.96); opacity: .5; }

/* The receiver's INTERCEPT monitor: a live camera placed exactly on the SVG glass. Nothing is drawn over the player. */
.live-feed { position:absolute; z-index:2; overflow:hidden; border-radius:2px; background:#000; pointer-events:none; }
.live-feed[hidden], .equipment[data-phase="off"] .live-feed { display:none; }
.live-feed .monitor-live { position:absolute; inset:0; opacity:0; transition:opacity .3s linear; }
/* A live camera is graded toward the tube's phosphor; the tube canvas above it draws the glass. */
.live-feed .monitor-live iframe { filter:saturate(1.15) contrast(1.1) brightness(1.04); }
.live-feed .monitor-tube { z-index:1; }
.live-feed .monitor-offline { position:absolute; inset:0; z-index:2; display:none; flex-direction:column; align-items:center; justify-content:center; font-family:var(--terminal-font); color:#bfeaff; text-shadow:0 0 4px #6fcfff; pointer-events:none; }
.live-feed[data-offline="true"] .monitor-offline { display:flex; }
.live-feed .monitor-offline b { font-weight:400; font-size:1em; letter-spacing:.18em; animation:monitor-offline 1.8s ease-in-out infinite; }
.live-feed .monitor-offline small { font-size:.42em; letter-spacing:.2em; color:#86aec7; margin-top:.3em; }
@keyframes monitor-offline { 0%, 100% { opacity:.35; } 50% { opacity:1; } }
:root[data-motion="calm"] .live-feed .monitor-offline b { animation:none; }
.live-feed iframe, .live-feed video, .live-feed canvas { position:absolute; inset:0; width:100%; height:100%; border:0; object-fit:cover; display:block; }
.signal-note { font-size:6.4px; }
.is-compact .signal-note { font-size:9px; }

/* Retro-futurist labels: numbered modules, small spaced capitals, a coral index in the terminal font. Unscoped, so the
   screen's reflected copies of the case (lighting.js) print them the same. */
.module-label { font:600 6.6px 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing:1.6px; fill:#2a2c2e; }
.module-num { font-family:var(--terminal-font); font-weight:400; fill:#ff5b36; letter-spacing:.5px; }
.serial-label { font:500 4.6px 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing:1.5px; fill:#8f8d85; }
.brand-word { font:800 13px 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing:2px; fill:#1f2123; }
.plate-mk { font-family:var(--terminal-font); font-size:10px; letter-spacing:1px; fill:#ff5b36; }
.brand-sub { font:600 5px 'Helvetica Neue', Helvetica, Arial, sans-serif; letter-spacing:1.6px; fill:#6f6d67; }
.is-compact #chassis .module-label { font-size:9.5px; }
.band-scope { position:absolute; z-index:2; border-radius:4px; pointer-events:none; }
.band-scope[hidden], .equipment[data-phase="off"] .band-scope { display:none; }
/* The eyes over the small screens while the vault's cap is lifted (eyes.js): pixel art, kept square. */
.screen-eyes { position:absolute; z-index:3; border-radius:3px; pointer-events:none; image-rendering:pixelated; }
.screen-eyes[hidden], .equipment[data-phase="off"] .screen-eyes { display:none; }
/* The print slit's light: a slow soft blink while the machine stands by, steady while it prints, dark when off. */
.slot-led { opacity: .2; animation: slot-standby 2.6s ease-in-out infinite; }
.equipment[data-printing] .slot-led { animation: none; opacity: 1; }
.equipment[data-phase="off"] .slot-led { animation: none; opacity: .05; }
@keyframes slot-standby { 0%, 100% { opacity: .14; } 50% { opacity: .75; } }
:root[data-motion="calm"] .slot-led { animation: none; opacity: .45; }
/* MUSIC MODE (app.js sets data-music): a running loop anywhere in the machine repaints all of its SVG every frame, and
   the joystick and the knobs wait behind that paint. The idle loops hold still; the screens carry the show. */
.slot-led[data-still] { animation: none; opacity: .45; }
:root[data-music] .fera-deck .lever-lamp { animation: none; }
:root[data-music] :is(.rp-roll, .egg-tick, .egg-sweep, .hud-eggs b, .hud-live i, .hud-alert) { animation-play-state: paused; }
