:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: rgba(8, 12, 22, 0.78);
  --line: rgba(87, 255, 196, 0.22);
  --text: #e7fff8;
  --muted: #86a7a0;
  --green: #57ffc4;
  --violet: #9f7cff;
  --red: #ff4d6d;
  --chaos: 0;
  --phase: 0;
  --meter: 0%;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(87, 255, 196, 0.12), transparent 28rem),
    radial-gradient(circle at 84% 76%, rgba(159, 124, 255, 0.14), transparent 26rem),
    linear-gradient(135deg, #03040a 0%, var(--bg) 58%, #090414 100%);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  filter: saturate(calc(1 + var(--chaos) * 0.12)) contrast(calc(1 + var(--chaos) * 0.04));
}

body.meltdown {
  animation: hue-panic calc(2200ms - var(--chaos) * 70ms) linear infinite;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(87, 255, 196, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 255, 196, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black, transparent 74%);
  transform: skew(calc(var(--chaos) * -0.12deg));
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035) 0,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: overlay;
  opacity: 0.32;
  transform: translateY(calc(var(--chaos) * -1px));
}

.terminal {
  position: relative;
  z-index: 2;
  width: min(860px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow:
    0 0 calc(70px + var(--chaos) * 14px) rgba(87, 255, 196, 0.12),
    inset 0 0 calc(38px + var(--chaos) * 7px) rgba(87, 255, 196, 0.05);
  backdrop-filter: blur(18px);
  transform: rotate(calc(var(--chaos) * -0.1deg));
}

.terminal::after {
  content: attr(data-phase);
  position: absolute;
  right: -3vw;
  bottom: -2vw;
  z-index: -1;
  color: rgba(255, 77, 109, 0);
  font-size: clamp(4rem, 13vw, 12rem);
  font-weight: 800;
  line-height: 0.8;
  text-transform: uppercase;
  text-shadow: 0 0 0 rgba(255, 77, 109, 0);
  transform: rotate(-8deg) skew(-7deg);
  pointer-events: none;
  transition: color 220ms ease, text-shadow 220ms ease;
}

body.meltdown .terminal::after {
  color: rgba(255, 77, 109, 0.1);
  text-shadow: 0 0 38px rgba(255, 77, 109, 0.42);
}

.chrome {
  display: flex;
  gap: 9px;
  align-items: center;
  height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.chrome span {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 16px currentColor;
}

.chrome span:nth-child(2) {
  background: #ffd166;
}

.chrome span:nth-child(3) {
  background: var(--green);
}

.panel {
  position: relative;
  z-index: 1;
  padding: clamp(30px, 6vw, 68px);
}

.eyebrow,
.status {
  color: var(--muted);
  font-size: 0.83rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  position: relative;
  margin: 18px 0 14px;
  max-width: 100%;
  font-size: clamp(3rem, 8.5vw, 6.7rem);
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-wrap: balance;
  text-shadow:
    0 0 24px rgba(87, 255, 196, 0.52),
    0 0 72px rgba(159, 124, 255, 0.24);
  transition: transform 160ms ease;
}

h1::before,
h1::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

h1::before {
  color: var(--red);
  transform: translate(-3px, 1px);
}

h1::after {
  color: var(--green);
  transform: translate(3px, -1px);
}

body.glitch h1::before,
body.glitch h1::after {
  animation: glitch calc(480ms - var(--chaos) * 28ms) steps(2, end) infinite;
  opacity: 0.72;
}

body.abyss h1 {
  font-size: clamp(2.6rem, 7.1vw, 5.35rem);
  transform: translateX(calc(var(--phase) * 1.5px)) scale(calc(1 + var(--phase) * 0.006));
  text-shadow:
    0 0 18px rgba(87, 255, 196, 0.86),
    0 0 52px rgba(159, 124, 255, 0.72),
    0 0 90px rgba(255, 77, 109, 0.42);
}

.subtitle {
  max-width: 42rem;
  margin: 0 0 28px;
  color: #b9d7d1;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
}

body.meltdown .subtitle {
  animation: subtitle-slip 920ms steps(2, end) infinite;
}

button {
  border: 1px solid rgba(87, 255, 196, 0.55);
  border-radius: 6px;
  padding: 13px 18px;
  background: rgba(87, 255, 196, 0.08);
  color: var(--green);
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(87, 255, 196, 0.1);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:hover,
button:focus-visible {
  background: rgba(87, 255, 196, 0.16);
  box-shadow: 0 0 34px rgba(87, 255, 196, 0.25);
  transform: translateY(-2px);
  outline: none;
}

.signal-meter {
  width: min(390px, 100%);
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signal-meter span {
  display: block;
  margin-bottom: 8px;
}

.signal-meter i {
  display: block;
  height: 8px;
  border: 1px solid rgba(87, 255, 196, 0.32);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(87, 255, 196, 0.08);
  box-shadow: inset 0 0 14px rgba(87, 255, 196, 0.12);
}

.signal-meter i::before {
  content: "";
  display: block;
  width: var(--meter);
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--violet), var(--red));
  box-shadow: 0 0 18px rgba(87, 255, 196, 0.56);
  transition: width 220ms ease;
}

.status {
  min-height: 1.4em;
  max-width: 46rem;
  margin: 24px 0 0;
  overflow-wrap: anywhere;
}

.author {
  margin-top: 24px;
  color: rgba(185, 215, 209, 0.72);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.author a {
  color: var(--green);
  text-decoration: none;
  text-shadow: 0 0 14px rgba(87, 255, 196, 0.42);
}

.author a:hover,
.author a:focus-visible {
  color: #fff;
  outline: none;
}

.cursor {
  animation: blink 800ms steps(2, end) infinite;
}

.matrix {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(32, 1fr);
  gap: 8px;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

body.revealed .matrix {
  opacity: calc(0.4 + var(--chaos) * 0.08);
}

body.meltdown .matrix {
  filter: hue-rotate(calc(var(--phase) * 18deg)) drop-shadow(0 0 8px var(--green));
  transform: scale(calc(1 + var(--phase) * 0.008));
}

.rune {
  color: rgba(87, 255, 196, 0.5);
  font-size: calc(0.82rem + var(--chaos) * 0.025rem);
  text-shadow: 0 0 14px rgba(87, 255, 196, 0.45);
  animation: fall var(--speed) linear infinite;
  animation-delay: var(--delay);
}

.burst {
  position: fixed;
  inset: 50%;
  z-index: 3;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
  animation: spark 700ms ease-out forwards;
  transform: rotate(var(--angle)) translateX(0);
}

body.overload {
  animation: overload 180ms steps(2, end) 4;
}

.containment {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 4;
  width: min(560px, calc(100vw - 32px));
  border: 1px solid rgba(255, 77, 109, 0.56);
  border-radius: 6px;
  padding: 12px 16px;
  background: rgba(16, 4, 12, 0.82);
  color: #ffdce4;
  box-shadow: 0 0 42px rgba(255, 77, 109, 0.24);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -120%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.containment strong,
.containment span {
  display: block;
}

.containment strong {
  color: var(--red);
  font-size: 0.9rem;
  letter-spacing: 0.16em;
}

.containment span {
  margin-top: 4px;
  color: #f6b8c6;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

body.breach .containment {
  opacity: 1;
  transform: translate(-50%, 0);
  animation: warning-blink 780ms steps(2, end) infinite;
}

.ham {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(90deg, rgba(255, 77, 109, 0.18) 0 2px, transparent 2px 18px),
    radial-gradient(circle, rgba(87, 255, 196, 0.32), rgba(5, 7, 13, 0.92) 52%);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-transform: uppercase;
  transform: scale(1.08);
  transition: opacity 180ms ease, transform 180ms ease;
}

.ham strong,
.ham span {
  display: block;
}

.ham strong {
  font-size: clamp(3.4rem, 13vw, 12rem);
  line-height: 0.85;
  text-shadow:
    0 0 22px var(--green),
    0 0 70px var(--red);
}

.ham span {
  margin-top: 24px;
  color: var(--green);
  font-size: clamp(1rem, 3vw, 1.8rem);
  letter-spacing: 0.2em;
  text-shadow: 0 0 20px rgba(87, 255, 196, 0.9);
}

body.ham-mode {
  animation: ham-quake 90ms steps(2, end) infinite;
}

body.ham-mode .ham {
  opacity: 1;
  transform: scale(1);
  animation: ham-flash 320ms steps(2, end) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes overload {
  0% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(calc(var(--chaos) * 0.7px), calc(var(--chaos) * -0.5px));
  }
  100% {
    transform: translate(calc(var(--chaos) * -0.4px), calc(var(--chaos) * 0.6px));
  }
}

@keyframes hue-panic {
  to {
    filter: hue-rotate(360deg) saturate(calc(1.35 + var(--chaos) * 0.07));
  }
}

@keyframes subtitle-slip {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(calc(var(--chaos) * -0.7px));
  }
  100% {
    transform: translateX(calc(var(--chaos) * 0.5px));
  }
}

@keyframes warning-blink {
  50% {
    border-color: rgba(87, 255, 196, 0.68);
    box-shadow: 0 0 54px rgba(87, 255, 196, 0.28);
  }
}

@keyframes ham-quake {
  0% {
    transform: translate(-2px, 1px) rotate(-0.25deg);
  }
  50% {
    transform: translate(2px, -1px) rotate(0.25deg);
  }
  100% {
    transform: translate(-1px, 2px) rotate(-0.15deg);
  }
}

@keyframes ham-flash {
  50% {
    filter: invert(1) hue-rotate(180deg);
  }
}

@keyframes glitch {
  0% {
    clip-path: inset(0 0 74% 0);
  }
  33% {
    clip-path: inset(44% 0 28% 0);
  }
  66% {
    clip-path: inset(14% 0 58% 0);
  }
  100% {
    clip-path: inset(68% 0 6% 0);
  }
}

@keyframes spark {
  from {
    opacity: 1;
    transform: rotate(var(--angle)) translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(var(--distance)) scale(0.2);
  }
}

@keyframes fall {
  from {
    transform: translateY(-24vh);
  }
  to {
    transform: translateY(112vh);
  }
}

@media (max-width: 560px) {
  body {
    padding: 12px;
  }

  .panel {
    padding: 24px;
  }

  h1,
  body.abyss h1 {
    font-size: clamp(2.35rem, 15vw, 4.15rem);
  }

  .subtitle {
    margin-bottom: 22px;
  }

  .matrix {
    grid-template-columns: repeat(18, 1fr);
  }
}
