:root {
  color-scheme: dark;
  --bg: oklch(8% 0.006 160);
  --panel: oklch(10.5% 0.008 160 / 0.92);
  --panel-2: oklch(14% 0.007 160 / 0.72);
  --fg: oklch(86% 0.012 150);
  --muted: oklch(71% 0.01 150 / 0.68);
  --faint: oklch(80% 0.009 150 / 0.18);
  --line: oklch(82% 0.01 150 / 0.24);
  --line-hard: oklch(86% 0.012 150 / 0.56);
  --glow: oklch(84% 0.016 150 / 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 46%, oklch(58% 0.018 150 / 0.13), transparent 15rem),
    radial-gradient(circle at 80% 20%, oklch(74% 0.012 150 / 0.06), transparent 24rem),
    linear-gradient(180deg, oklch(9% 0.006 160), var(--bg) 52%, oklch(6.5% 0.006 160));
  color: var(--fg);
  font-family:
    "Courier Prime",
    "JetBrains Mono",
    "SFMono-Regular",
    Consolas,
    monospace;
}

body::before {
  content: "";
  position: fixed;
  inset: -12%;
  pointer-events: none;
  background:
    repeating-radial-gradient(circle at 16% 48%, transparent 0 6px, oklch(85% 0.01 150 / 0.05) 7px, transparent 8px),
    linear-gradient(90deg, transparent, oklch(85% 0.01 150 / 0.035), transparent);
  filter: blur(0.1px);
}

.stage {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: clamp(0.75rem, 2.2vw, 2rem);
  isolation: isolate;
}

.matrix,
.noise,
.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.matrix {
  z-index: 1;
  opacity: 0.24;
  background-image:
    linear-gradient(90deg, transparent 0 11px, oklch(86% 0.012 150 / 0.22) 12px, transparent 13px),
    linear-gradient(180deg, transparent 0 11px, oklch(86% 0.012 150 / 0.18) 12px, transparent 13px),
    repeating-linear-gradient(90deg, transparent 0 38px, oklch(86% 0.012 150 / 0.1) 38px 39px),
    repeating-linear-gradient(180deg, transparent 0 38px, oklch(86% 0.012 150 / 0.1) 38px 39px);
  background-size: 13px 13px, 13px 13px, 39px 39px, 39px 39px;
  mask-image: radial-gradient(circle at 50% 46%, black, transparent 78%);
}

.noise {
  z-index: 4;
  opacity: 0.22;
  background-image:
    repeating-radial-gradient(circle at 13% 31%, oklch(92% 0.008 150 / 0.2) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, transparent 0 6px, oklch(88% 0.01 150 / 0.07) 6px 7px);
  mix-blend-mode: screen;
}

.scanline {
  z-index: 5;
  opacity: 0.75;
  background: repeating-linear-gradient(
    180deg,
    transparent 0,
    transparent 6px,
    oklch(90% 0.01 150 / 0.052) 7px,
    transparent 8px
  );
}

.console {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(1160px, 100%);
  min-height: min(720px, calc(100dvh - clamp(1.5rem, 4.4vw, 4rem)));
  border: 1px solid var(--line-hard);
  background:
    linear-gradient(90deg, transparent 0 6%, var(--panel-2) 48%, transparent 94%),
    linear-gradient(180deg, oklch(20% 0.01 160 / 0.18), transparent 32%, oklch(24% 0.01 160 / 0.12)),
    var(--panel);
  box-shadow:
    inset 0 0 0 1px oklch(90% 0.01 150 / 0.045),
    inset 0 0 95px oklch(86% 0.012 150 / 0.036),
    0 0 110px oklch(84% 0.014 150 / 0.075);
}

.console::before,
.console::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.console::before {
  inset: 1.4rem;
  border: 1px solid var(--faint);
  opacity: 0.82;
}

.console::after {
  right: clamp(1rem, 3vw, 2rem);
  top: clamp(1rem, 3vw, 2rem);
  width: clamp(3rem, 8vw, 6rem);
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 8px);
  box-shadow:
    0 13px 0 oklch(86% 0.012 150 / 0.16),
    0 26px 0 oklch(86% 0.012 150 / 0.1);
}

.console-top,
.console-bottom {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  padding: clamp(1.1rem, 2.1vw, 1.8rem) clamp(1.25rem, 4vw, 3.7rem);
  color: var(--muted);
  font-size: clamp(0.68rem, 1vw, 0.86rem);
  letter-spacing: 0.055em;
}

.console-top {
  align-items: start;
}

.console-top samp,
.console-bottom samp {
  font: inherit;
  text-transform: lowercase;
}

.console-top samp:nth-child(2),
.console-bottom samp:nth-child(2) {
  text-align: center;
}

.console-top samp:nth-child(3),
.console-bottom samp:nth-child(3) {
  text-align: right;
}

.console-core {
  position: relative;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(1.1rem, 2.8vw, 2.1rem);
  padding: clamp(1.1rem, 3vw, 2.3rem) clamp(1rem, 3.6vw, 3.3rem);
}

.console-core::before,
.console-core::after {
  content: "+";
  position: absolute;
  color: oklch(88% 0.01 150 / 0.38);
  font-size: clamp(0.7rem, 1.2vw, 1rem);
}

.console-core::before {
  left: clamp(1.2rem, 3.6vw, 3.5rem);
  top: 50%;
}

.console-core::after {
  right: clamp(1.2rem, 3.6vw, 3.5rem);
  top: 50%;
}

.ascii-mark {
  margin: 0;
  overflow: hidden;
  max-width: 100%;
  color: oklch(82% 0.012 150 / 0.72);
  font-size: clamp(0.34rem, 0.88vw, 0.74rem);
  line-height: 1;
  text-align: center;
  text-shadow:
    0 0 1px oklch(92% 0.01 150 / 0.8),
    0 0 20px var(--glow);
  user-select: none;
}

.watch {
  display: grid;
  grid-template-columns: 3ch auto 2ch auto 2ch auto 2ch auto 3ch;
  justify-content: center;
  align-items: start;
  width: 100%;
  color: var(--fg);
  font-size: clamp(2.7rem, 7.15vw, 6.4rem);
  font-weight: 900;
  line-height: 0.84;
  letter-spacing: 0;
  text-align: center;
  text-shadow:
    0 0 1px oklch(98% 0.005 150 / 0.92),
    0 0 34px oklch(86% 0.012 150 / 0.2);
  white-space: nowrap;
}

.unit {
  display: grid;
  justify-items: center;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.digits {
  display: block;
}

.separator {
  align-self: start;
  padding-inline: 0.08em;
  color: oklch(83% 0.01 150 / 0.66);
  transform: translateY(-0.025em);
}

.label {
  display: block;
  margin-top: clamp(0.42rem, 0.8vw, 0.6rem);
  color: var(--muted);
  font-size: clamp(0.44rem, 0.85vw, 0.72rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
}

.unit-ms .digits {
  color: oklch(78% 0.01 150 / 0.78);
}

.trace {
  display: grid;
  gap: 0.2rem;
  justify-items: center;
  max-width: 100%;
  color: oklch(80% 0.012 150 / 0.66);
  font-size: clamp(0.54rem, 1.05vw, 0.86rem);
  font-weight: 700;
  letter-spacing: 0.035em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0 16px oklch(86% 0.012 150 / 0.14);
}

.trace output {
  font: inherit;
}

.watch.glitch {
  animation: glitch-step 0.16s steps(2, end);
}

@keyframes glitch-step {
  0% {
    opacity: 1;
    transform: translateX(0);
    filter: none;
  }
  35% {
    opacity: 0.82;
    transform: translateX(-0.018em);
    filter: blur(0.5px);
  }
  70% {
    opacity: 0.94;
    transform: translateX(0.012em);
    filter: contrast(1.65);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
    filter: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .console {
    animation: panel-rise 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  .matrix {
    animation: matrix-drift 12s linear infinite;
  }

  .noise {
    animation: static-shift 740ms steps(2, end) infinite;
  }

  .scanline {
    animation: scan-drift 6s linear infinite;
  }
}

@keyframes panel-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes matrix-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-39px, 39px, 0);
  }
}

@keyframes static-shift {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-1%, 1%, 0);
  }
}

@keyframes scan-drift {
  from {
    transform: translateY(-20px);
  }
  to {
    transform: translateY(20px);
  }
}

@media (max-width: 760px) {
  .stage {
    padding: 0.8rem;
  }

  .console {
    align-content: center;
    grid-template-rows: auto auto auto;
    gap: clamp(1.2rem, 5vh, 2.4rem);
    min-height: calc(100dvh - 1.6rem);
  }

  .console::before {
    inset: 0.72rem;
  }

  .console::after,
  .console-core::before,
  .console-core::after {
    display: none;
  }

  .console-top,
  .console-bottom {
    grid-template-columns: 1fr;
    gap: 0.42rem;
    padding: 0 1.3rem;
    font-size: 0.64rem;
  }

  .console-top samp,
  .console-top samp:nth-child(2),
  .console-top samp:nth-child(3),
  .console-bottom samp,
  .console-bottom samp:nth-child(2),
  .console-bottom samp:nth-child(3) {
    text-align: left;
  }

  .console-core {
    align-content: center;
    justify-items: center;
    gap: clamp(0.95rem, 4vw, 1.6rem);
    padding: 0.7rem 1.05rem;
  }

  .ascii-mark {
    justify-self: center;
    font-size: clamp(0.23rem, 1.68vw, 0.41rem);
  }

  .watch {
    font-size: clamp(1.12rem, 8.1vw, 2.05rem);
  }

  .separator {
    padding-inline: 0.04em;
  }

  .label {
    margin-top: 0.34rem;
    font-size: clamp(0.34rem, 2.1vw, 0.48rem);
    letter-spacing: 0.08em;
  }

  .trace {
    justify-items: start;
    width: 100%;
    overflow: hidden;
    font-size: clamp(0.35rem, 2.25vw, 0.55rem);
    text-align: left;
  }
}

@media (max-width: 420px) {
  .watch {
    font-size: clamp(1rem, 7.55vw, 1.86rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
