:root {
  --bg: #05060b;
  --bg-soft: #0c1019;
  --ink: #d8ffe4;
  --cyan: #00e5ff;
  --acid: #c9ff3e;
  --red: #ff395a;
  --line: rgba(0, 229, 255, 0.3);
  --panel: rgba(7, 12, 21, 0.72);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(201, 255, 62, 0.16), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(255, 57, 90, 0.2), transparent 45%),
    linear-gradient(135deg, var(--bg) 0%, #03040a 100%);
  color: var(--ink);
  font-family: 'Space Mono', monospace;
}

#scene-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#scene-canvas:active {
  cursor: grabbing;
}

.hud {
  position: fixed;
  top: clamp(12px, 3vw, 34px);
  left: clamp(14px, 3vw, 42px);
  z-index: 5;
  max-width: min(560px, 90vw);
  padding: clamp(14px, 2vw, 22px);
  background: var(--panel);
  border: 1px solid rgba(0, 229, 255, 0.28);
  box-shadow:
    0 0 0 1px rgba(201, 255, 62, 0.14) inset,
    0 0 40px rgba(0, 229, 255, 0.12);
  backdrop-filter: blur(6px);
}

.hud-kicker {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--acid);
  font-size: 0.66rem;
}

.hud h1 {
  margin: 10px 0 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.4rem, 4.2vw, 3.6rem);
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    0 0 8px rgba(0, 229, 255, 0.45),
    0 0 24px rgba(201, 255, 62, 0.25);
}

.hud-copy {
  margin: 0;
  font-size: clamp(0.84rem, 1.2vw, 1rem);
  line-height: 1.5;
  opacity: 0.9;
}

.node-panel {
  position: fixed;
  right: clamp(14px, 3vw, 42px);
  top: clamp(14px, 5vh, 72px);
  width: min(320px, calc(100vw - 28px));
  z-index: 5;
  padding: 16px;
  background: var(--panel);
  border: 1px solid rgba(255, 57, 90, 0.35);
  box-shadow: 0 0 35px rgba(255, 57, 90, 0.12);
}

.panel-label {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  color: var(--red);
}

.node-panel h2 {
  margin: 8px 0;
  font-family: 'Orbitron', sans-serif;
  text-transform: uppercase;
  font-size: 1.2rem;
}

.node-panel p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
}

.panel-tip {
  margin-top: 12px !important;
  color: rgba(201, 255, 62, 0.88);
}

.controls {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  z-index: 5;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: min(92vw, 560px);
}

.controls span, .controls button {
  border: 1px solid var(--line);
  background: rgba(6, 11, 20, 0.68);
  padding: 6px 10px;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

.crt-noise,
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.chroma-split,
.sigil-stream {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.chroma {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  opacity: 0;
}

.chroma.cyan {
  background: radial-gradient(circle at 40% 60%, rgba(0, 229, 255, 0.18), transparent 56%);
}

.chroma.red {
  background: radial-gradient(circle at 60% 40%, rgba(255, 57, 90, 0.16), transparent 58%);
}

.sigil-stream {
  display: grid;
  place-items: center;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.18em;
  font-size: clamp(0.9rem, 2vw, 1.5rem);
  color: rgba(255, 255, 255, 0.82);
  text-transform: uppercase;
  opacity: 1;
}

.crt-noise {
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.04) 0,
    rgba(255, 255, 255, 0.04) 1px,
    transparent 2px,
    transparent 4px
  );
  opacity: 0.12;
  mix-blend-mode: soft-light;
}

body.glitch .chroma.cyan {
  animation: channel-cyan 180ms steps(2) infinite;
  opacity: 0.42;
}

body.glitch .chroma.red {
  animation: channel-red 120ms steps(2) infinite;
  opacity: 0.36;
}

body.glitch .scanlines {
  opacity: 0.24;
}

body.glitch .hud,
body.glitch .node-panel,
body.glitch .controls {
  filter: contrast(1.12) saturate(1.2);
}

body.ritual .hud,
body.ritual .node-panel {
  border-color: rgba(201, 255, 62, 0.72);
  box-shadow: 0 0 44px rgba(201, 255, 62, 0.2);
}

body.burst .hud,
body.burst .node-panel,
body.burst .controls {
  transform: translateX(1px);
}

body.burst .chroma.cyan,
body.burst .chroma.red {
  opacity: 0.5;
}

body.entry-armed .hud,
body.entry-armed .node-panel,
body.entry-armed .controls {
  border-color: rgba(0, 229, 255, 0.6);
  box-shadow: 0 0 34px rgba(0, 229, 255, 0.2);
}

body.entry-armed .controls span,
body.entry-armed .controls button {
  border-color: rgba(0, 229, 255, 0.78);
  color: rgba(224, 255, 255, 0.98);
}

body.entry-armed .chroma.cyan {
  animation: channel-cyan 220ms steps(2) infinite;
  opacity: 0.34;
}

body.entry-armed .chroma.red {
  animation: channel-red 190ms steps(2) infinite;
  opacity: 0.22;
}

.secret {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 4, 8, 0.92);
}

.secret.active {
  display: flex;
}

.secret-box {
  width: min(480px, 100%);
  border: 1px solid rgba(201, 255, 62, 0.66);
  padding: 22px;
  background: linear-gradient(145deg, rgba(7, 12, 21, 0.95), rgba(5, 8, 15, 0.95));
  box-shadow: 0 0 46px rgba(201, 255, 62, 0.18);
}

.secret-label {
  margin: 0;
  font-size: 0.7rem;
  color: var(--acid);
  letter-spacing: 0.15em;
}

.secret-box h2 {
  margin: 8px 0;
  font-family: 'Orbitron', sans-serif;
}

.secret-box p {
  margin: 0 0 16px;
}

.secret-box button {
  border: 1px solid rgba(0, 229, 255, 0.5);
  background: rgba(0, 229, 255, 0.12);
  color: var(--ink);
  padding: 8px 12px;
  font-family: inherit;
}

body.glitch {
  animation: glitch-jump 0.2s steps(2) infinite;
}

@keyframes glitch-jump {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-1px, 1px);
  }
  50% {
    transform: translate(1px, -1px);
  }
  75% {
    transform: translate(-1px, -1px);
  }
  100% {
    transform: translate(0, 0);
  }
}

@keyframes channel-cyan {
  0% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(2px);
  }
  100% {
    transform: translateX(-1px);
  }
}

@keyframes channel-red {
  0% {
    transform: translateX(3px);
  }
  50% {
    transform: translateX(-2px);
  }
  100% {
    transform: translateX(1px);
  }
}

@media (max-width: 860px) {
  .hud,
  .node-panel {
    position: static;
    margin: 10px;
    width: auto;
  }

  .hud {
    margin-bottom: 0;
  }

  .node-panel {
    margin-top: 8px;
  }

  .controls {
    bottom: 8px;
    width: calc(100vw - 20px);
  }
}
