:root {
  --bg: #050806;
  --fg: #8dffa8;
  --dim: #4a9a5e;
  --ghost: #ff5c6c;
  --warn: #ffd166;
  --glow: 0 0 6px rgba(141, 255, 168, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font: 16px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* scanlines and vignette */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

body::before {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
}

body::after {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.65) 100%);
}

#screen {
  min-height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 18px 80px;
  text-shadow: var(--glow);
  transition: opacity 0.6s;
}

.line {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.5em;
}

.dim {
  color: var(--dim);
}

.warn {
  color: var(--warn);
}

/* ghost text */
.g {
  color: var(--ghost);
  text-shadow: 0 0 8px rgba(255, 92, 108, 0.55);
}

#row {
  display: none;
  gap: 0.6ch;
  align-items: baseline;
}

#prompt {
  white-space: pre;
  flex: none;
}

#in {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-shadow: inherit;
  caret-color: var(--fg);
  caret-shape: block;
}

@keyframes flicker {
  0%,
  91%,
  100% {
    opacity: 1;
  }
  92% {
    opacity: 0.8;
  }
  93% {
    opacity: 1;
  }
  96% {
    opacity: 0.9;
  }
  97% {
    opacity: 1;
  }
}

body.unease #screen {
  animation: flicker 7s infinite;
}

body.dread #screen {
  animation: flicker 3.5s infinite;
}

@keyframes glitch {
  0% {
    transform: translateX(-2px);
    text-shadow: 2px 0 #f0f, -2px 0 #0ff;
  }
  50% {
    transform: translateX(3px);
  }
  100% {
    transform: none;
  }
}

.glitch {
  animation: glitch 0.18s steps(2) 1;
}

body.blackout #screen {
  opacity: 0;
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  #screen {
    padding: 14px 12px 80px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.unease #screen,
  body.dread #screen,
  .glitch {
    animation: none;
  }

  #screen {
    transition: none;
  }
}
