:root {
  --fg: #5ad7ff;
  --fg-dim: #3aa6cc;
  --glow1: #2ea8ff;
  --glow2: #1a78c8;
  --bg: #000;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: 'VT323', 'Courier New', monospace;
}

body {
  /* tap anywhere refocuses the hidden input */
  cursor: text;
}

#crt {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #020610 0%, #000 70%, #000 100%);
  padding: clamp(12px, 3vw, 32px);
  overflow: hidden;
}

#crt::before {
  /* scanlines */
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 2px,
    rgba(0, 0, 0, 0.28) 3px
  );
  pointer-events: none;
  z-index: 2;
}

#crt::after {
  /* vignette */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.75) 100%);
  pointer-events: none;
  z-index: 3;
}

#screen {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  color: var(--fg);
  font-size: clamp(16px, 2.4vw, 24px);
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-shadow:
    0 0 2px var(--fg),
    0 0 6px var(--glow1),
    0 0 14px var(--glow2);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  padding-right: 4px;
  animation: flicker 4s infinite;
}

#screen::-webkit-scrollbar { width: 0; }

/* hidden input that receives keystrokes */
#kbd {
  position: absolute;
  left: -9999px;
  top: 0;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.cursor {
  display: inline-block;
  width: 0.55em;
  background: var(--fg);
  color: var(--fg);
  text-shadow: 0 0 6px var(--glow1), 0 0 14px var(--glow2);
  animation: blink 1s steps(1) infinite;
  vertical-align: baseline;
}

.cursor.solid {
  animation: none;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  48% { opacity: 1; }
  49% { opacity: 0.92; }
  50% { opacity: 1; }
  72% { opacity: 1; }
  73% { opacity: 0.96; }
  74% { opacity: 1; }
}

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