:root {
  --bg: #020804;
  --green: #7cff8a;
  --green-soft: #48d86a;
  --green-dark: #0f5f2d;
  --glow:
    0 0 6px rgba(124, 255, 138, 0.85), 0 0 18px rgba(72, 216, 106, 0.45),
    0 0 38px rgba(72, 216, 106, 0.22);
  --font: "Courier New", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: #000;
  overflow: hidden;
  font-family: var(--font);
  color: var(--green);
}

body {
  display: grid;
  place-items: center;
}

.crt {
  position: relative;
  width: min(100vw, 1200px);
  height: min(100vh, 760px);
  padding: clamp(24px, 5vw, 64px);
  background:
    radial-gradient(
      circle at center,
      rgba(30, 130, 56, 0.12),
      rgba(0, 0, 0, 0.7) 58%,
      #000 100%
    ),
    linear-gradient(180deg, rgba(0, 20, 8, 0.96), rgba(0, 7, 3, 0.98));
  border-radius: 32px;
  box-shadow:
    inset 0 0 70px rgba(0, 0, 0, 0.95),
    inset 0 0 18px rgba(124, 255, 138, 0.18),
    0 0 80px rgba(0, 0, 0, 0.9);
  transform: perspective(900px) rotateX(0.8deg);
  isolation: isolate;
}

.crt::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.045) 0,
    rgba(255, 255, 255, 0.045) 1px,
    rgba(0, 0, 0, 0.25) 2px,
    rgba(0, 0, 0, 0.25) 4px
  );
  mix-blend-mode: overlay;
  opacity: 0.55;
  z-index: 20;
}

.crt::after {
  content: "";
  position: absolute;
  inset: -10%;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 45%,
    rgba(0, 0, 0, 0.55) 76%,
    rgba(0, 0, 0, 0.95) 100%
  );
  z-index: 21;
}

.noise {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.12;
  background-image:
    linear-gradient(90deg, transparent 0 97%, rgba(124, 255, 138, 0.45) 98%),
    linear-gradient(0deg, transparent 0 96%, rgba(124, 255, 138, 0.25) 98%);
  background-size:
    37px 23px,
    29px 31px;
  animation: jitter 220ms steps(2, end) infinite;
  z-index: 4;
  pointer-events: none;
}

.screen {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  align-items: center;
  z-index: 10;
  filter: blur(0.25px);
}

.boot-lines {
  text-align: center;
  align-self: end;
  margin-bottom: clamp(18px, 3vh, 34px);
  font-size: clamp(18px, 3vw, 35px);
  line-height: 1.25;
  letter-spacing: 0.08em;
  text-transform: none;
  text-shadow: var(--glow);
  animation: textPulse 2.8s ease-in-out infinite;
}

.line {
  text-align: center;
  display: block;
  opacity: 0;
  transform: translateX(-8px);
  animation: typeIn 0.55s steps(20, end) forwards;
  white-space: pre;
}

.line:nth-child(1) {
  animation-delay: 0.4s;
}
.line:nth-child(2) {
  animation-delay: 1.2s;
}
.line:nth-child(3) {
  animation-delay: 1.9s;
}
.line:nth-child(4) {
  animation-delay: 2.8s;
}

.mark-wrap {
  position: relative;
  width: min(56vw, 430px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  opacity: 0;
  animation:
    markAppear 0.8s ease-out 3.5s forwards,
    markFloat 6s ease-in-out 4.2s infinite;
  filter: drop-shadow(0 0 8px rgba(124, 255, 138, 0.9))
    drop-shadow(0 0 28px rgba(72, 216, 106, 0.35));
}

.mark-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.wire {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.88;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: drawWire 2.4s ease-out forwards;
}

.w1 {
  animation-delay: 3.7s;
}
.w2 {
  animation-delay: 4s;
  opacity: 0.74;
}
.w3 {
  animation-delay: 4.3s;
  opacity: 0.6;
}
.w4 {
  animation-delay: 4.6s;
  opacity: 0.5;
}

.spin-slow {
  transform-origin: 100px 100px;
  animation: spin 20s linear infinite;
}

.spin-rev {
  transform-origin: 100px 100px;
  animation: spinReverse 14s linear infinite;
}

.node {
  fill: var(--green);
  opacity: 0.9;
  filter: drop-shadow(0 0 5px rgba(124, 255, 138, 0.9));
  animation: nodeBlink 1.8s ease-in-out infinite;
}

.footer {
  text-align: center;
  align-self: start;
  margin-top: clamp(18px, 3vh, 34px);
  font-size: clamp(15px, 2vw, 24px);
  line-height: 1.35;
  letter-spacing: 0.07em;
  text-shadow: var(--glow);
  opacity: 0;
  animation:
    footerIn 0.8s ease-out 5.5s forwards,
    textPulse 3.5s ease-in-out 6s infinite;
}

.cursor {
  display: inline-block;
  width: 0.65em;
  height: 1em;
  margin-left: 0.15em;
  background: var(--green);
  box-shadow: var(--glow);
  transform: translateY(0.15em);
  animation: blink 0.85s steps(1, end) infinite;
}

.sweep {
  position: absolute;
  left: 0;
  right: 0;
  top: -25%;
  height: 20%;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(124, 255, 138, 0.08),
    transparent
  );
  animation: sweep 5.5s linear infinite;
  z-index: 19;
  pointer-events: none;
}

.crt.exiting .mark-wrap {
  animation: exitMark 0.75s ease-in forwards;
}

.crt.exiting .boot-lines {
  animation: exitText 0.75s ease-in 0.45s forwards;
}

.crt.exiting .footer {
  animation: exitText 0.75s ease-in 0.85s forwards;
}

.next-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(22px, 4vw, 46px);
  letter-spacing: 0.12em;
  text-shadow: var(--glow);
  opacity: 0;
  transform: scale(0.96);
  z-index: 12;
  pointer-events: none;
}

.next-screen-subtitle {
  font-size: 0.45em;
  margin-top: 1em;
  letter-spacing: 0.08em;
}

.crt.transition-complete .screen {
  visibility: hidden;
}

.crt.transition-complete .next-screen {
  animation: nextIn 0.9s ease-out forwards;
}

@keyframes typeIn {
  from {
    opacity: 0;
    transform: translateX(-8px);
    clip-path: inset(0 100% 0 0);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    clip-path: inset(0 0 0 0);
  }
}

@keyframes drawWire {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes markAppear {
  to {
    opacity: 1;
  }
}

@keyframes footerIn {
  to {
    opacity: 1;
  }
}

@keyframes textPulse {
  0%,
  100% {
    filter: brightness(0.95) blur(0.12px);
  }
  50% {
    filter: brightness(1.28) blur(0.45px);
  }
}

@keyframes markFloat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-8px) scale(1.015);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinReverse {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes nodeBlink {
  0%,
  100% {
    opacity: 0.35;
  }
  45% {
    opacity: 1;
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes sweep {
  to {
    transform: translateY(720%);
  }
}

@keyframes jitter {
  0% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(1px, -1px);
  }
  100% {
    transform: translate(-1px, 1px);
  }
}

@keyframes exitMark {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  40% {
    opacity: 1;
    transform: translateY(-6px) scale(1.08);
    filter: brightness(1.8);
  }
  100% {
    opacity: 0;
    transform: translateY(32px) scale(0.82);
    filter: brightness(0.25) blur(5px);
  }
}

@keyframes exitText {
  0% {
    opacity: 1;
    transform: translateY(0);
    filter: brightness(1);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
    filter: brightness(1.8);
  }
  100% {
    opacity: 0;
    transform: translateY(24px);
    filter: brightness(0.2) blur(4px);
  }
}

@keyframes nextIn {
  0% {
    opacity: 0;
    transform: scale(0.96);
    filter: blur(8px);
  }
  65% {
    opacity: 1;
    transform: scale(1.02);
    filter: blur(0.5px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0.15px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 640px) {
  .crt {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .boot-lines {
    font-size: clamp(16px, 5vw, 26px);
  }

  .footer {
    font-size: clamp(13px, 4vw, 20px);
  }

  .mark-wrap {
    width: min(72vw, 330px);
  }
}
