:root {
  color-scheme: dark;
  font-family: 'Courier New', monospace;
  background: #000;
  color: #92ffb2;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  height: 100dvh;
}
canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
  color: #9bbca6;
  background: transparent;
  border: 1px solid #325b4055;
  padding: 12px 14px;
  font-size: 10px;
  letter-spacing: 1.5px;
  min-height: 44px;
}
button:hover,
button:focus-visible {
  color: #caffdb;
  border-color: #6aff91;
}
button:focus-visible,
a:focus-visible {
  outline: 1px solid #9effb9;
  outline-offset: 5px;
}
header,
footer {
  position: fixed;
  z-index: 5;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  font-size: 12px;
  letter-spacing: 2px;
  color: #6fa080;
}
header {
  top: max(14px, env(safe-area-inset-top));
}
footer {
  bottom: max(20px, env(safe-area-inset-bottom));
  font-size: 12px;
}
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(0deg, #0000 0px, #0000 2px, #0003 3px);
  opacity: 0.55;
}
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 28%, #0009 100%);
}
[hidden] {
  display: none !important;
}
/* Curved phosphor glass and a large, legible interruption. */
#error {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  width: min(520px, 86vw);
  background: radial-gradient(ellipse, #12321b 0%, #031007 75%, #000 100%);
  border: 1px solid #8bffa8;
  box-shadow:
    inset 0 0 45px #000,
    0 0 2px 3px #294b32,
    0 0 75px #24ff5440;
  letter-spacing: 1px;
  padding: 32px 20px;
  text-align: center;
  overflow: hidden;
  border-radius: 22px / 16px;
}
#ending,
#fallback {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
#ending p,
#fallback > p:first-child {
  font-size: 12px;
  letter-spacing: 3px;
  color: #386c47;
}
#ending h1 {
  font-size: clamp(21px, 4vw, 52px);
  font-weight: 400;
  letter-spacing: -1px;
  text-shadow:
    0 0 12px #23ff68,
    0 0 48px #00ff5144;
  margin: 24px 0 38px;
  animation: reveal 2s both;
}
#ending button {
  animation: reveal 2s 1s both;
}
#fallback {
  background: #010704;
}
#fallback h1 {
  font-weight: 400;
  font-size: 25px;
}
#fallback p {
  max-width: 420px;
  font-size: 13px;
  line-height: 1.8;
  color: #7b9a84;
}
#fallback a {
  text-decoration: none;
  font-size: 12px;
  color: #8deca6;
  margin-top: 28px;
}
#progress {
  height: 2px;
  width: 60px;
  background: #285035;
  transform-origin: left;
}
@keyframes reveal {
  from {
    opacity: 0;
    filter: blur(6px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}
@media (max-width: 500px) {
  header,
  footer {
    left: 16px;
    right: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
  }
  .scanlines {
    opacity: 0.2;
  }
}

#error h1 {
  margin: 0;
  font-size: clamp(48px, 12vw, 86px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 4px;
  color: #b8ffbc;
  text-shadow:
    -1px 0 #62ff8c,
    1px 0 #dcffcf,
    0 0 8px #5cff7e,
    0 0 24px #32ff60;
  transform: perspective(600px) rotateX(3deg);
}

#ending p {
  color: #80b991;
}

/* Scanlines and a slow rolling CRT refresh band. */
#error::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, #0005 0 1px, transparent 1px 3px);
  box-shadow: inset 0 0 55px 14px #000b;
}
#error::before {
  content: '';
  position: absolute;
  inset: -100% 0;
  background: linear-gradient(transparent 42%, #8effa015 49%, transparent 54%);
  animation: crt-refresh 2s linear infinite;
}
@keyframes crt-refresh {
  from {
    transform: translateY(-25%);
  }
  to {
    transform: translateY(25%);
  }
}

#chapter {
  font-size: clamp(13px, 3.4vw, 15px);
  line-height: 1.5;
  letter-spacing: 1px;
  font-weight: 700;
  color: #a8d9b5;
}
