:root {
  color-scheme: dark;
  background: #000;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(
      to bottom,
      rgb(91 255 117 / 0.025) 0,
      rgb(91 255 117 / 0.025) 1px,
      transparent 1px,
      transparent 8px
    ),
    #000;
}

body::after {
  position: fixed;
  z-index: 1;
  inset: 0;
  content: "";
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgb(91 255 117 / 0.025) 0,
    rgb(91 255 117 / 0.025) 1px,
    transparent 1px,
    transparent 8px
  );
  animation: page-crt-flicker 4s steps(1) infinite;
}

#rain {
  position: fixed;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1s ease, filter 200ms ease;
}

body.rain-over-boot #rain {
  opacity: 1;
}

body.matrix-overdrive #rain {
  filter: brightness(1.6) saturate(1.4) drop-shadow(0 0 8px hsl(108 90% 70% / 0.9));
}

.boot-screen {
  position: fixed;
  z-index: 4;
  inset: 0;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 0.45rem;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.45) 100%),
    repeating-linear-gradient(
      to bottom,
      rgb(91 255 117 / 0.025) 0,
      rgb(91 255 117 / 0.025) 1px,
      transparent 1px,
      transparent 8px
    ),
    #000;
  color: hsl(108 90% 70%);
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.9rem, 2vw, 1.25rem);
  letter-spacing: 0.12em;
  text-shadow: 0 0 4px hsl(108 90% 70% / 0.7);
  isolation: isolate;
  overflow: hidden;
  transition: opacity 1.5s ease, visibility 1.5s step-end;
}

.boot-screen::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  content: "";
  pointer-events: none;
}

.boot-screen::before {
  background: rgb(180 255 190 / 0.08);
  mix-blend-mode: screen;
  opacity: 0;
  animation: crt-flicker 4s steps(1) infinite;
}

body.rain-over-boot .boot-screen,
body.boot-fading .boot-screen {
  background:
    radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / 0.45) 100%),
    repeating-linear-gradient(
      to bottom,
      rgb(91 255 117 / 0.025) 0,
      rgb(91 255 117 / 0.025) 1px,
      transparent 1px,
      transparent 8px
    ),
    rgb(0 0 0 / 0.45);
}

.boot-line {
  position: relative;
  z-index: 1;
  width: fit-content;
  min-height: 1.2em;
  margin: 0;
}

.boot-line.is-active::after {
  content: "_";
  animation: cursor-blink 750ms steps(1) infinite;
}

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

@keyframes crt-flicker {
  0%,
  93%,
  100% {
    opacity: 0;
  }

  94% {
    opacity: 0.4;
  }

  95% {
    opacity: 0.12;
  }
}

@keyframes page-crt-flicker {
  0%,
  93%,
  100% {
    opacity: 1;
  }

  94% {
    opacity: 0.82;
  }

  95% {
    opacity: 0.95;
  }
}

main {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 100vh;
  place-content: center;
  gap: 0.5rem;
  padding: 1rem;
  text-align: center;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 1s ease, transform 1s ease;
}

video {
  width: min(91.666vw, 1100px);
  max-height: calc(100vh - 4rem);
  background: #000;
}

.legal-disclaimer {
  position: fixed;
  z-index: 3;
  right: 0.5rem;
  bottom: 0.5rem;
  left: 0.5rem;
  margin: 0;
  color: #fff;
  font-size: clamp(0.5rem, 0.9vw, 0.6rem);
  line-height: 1.35;
  text-align: left;
  text-shadow: 1px 1px 1px #000, -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000;
  opacity: 0;
  transition: opacity 1s ease;
}

body.boot-fading #rain,
body.boot-complete #rain,
body.boot-complete main,
body.boot-complete .legal-disclaimer {
  opacity: 1;
}

body.boot-complete main {
  transform: none;
}

body.boot-fading .boot-screen,
body.boot-complete .boot-screen {
  visibility: hidden;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  #rain,
  main,
  .legal-disclaimer,
  .boot-screen {
    transition-duration: 1ms;
  }

  .boot-line.is-active::after {
    animation: none;
  }

  .boot-screen::before {
    animation: none;
  }

  body::after {
    animation: none;
  }
}
