:root {
  --page: #0c0b0a;
  --bezel: #1d1b18;
  --bezel-edge: #34312b;
  --caption: #8c8a84;
  --scanline: rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--page);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--caption);
  font: 13px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* The EGA 640x350 picture filled a 4:3 tube, so pixels are taller than wide. */
.monitor {
  width: min(calc(100% - 30px), calc((100vh - 110px) * 4 / 3));
  min-width: 280px;
}

/* Glass with a black overscan border around the picture. */
.crt {
  padding: 3.5%;
  overflow: hidden;
  background: #030303;
  border-radius: 22px / 18px;
  box-shadow:
    0 0 0 14px var(--bezel),
    0 0 0 15px var(--bezel-edge),
    0 24px 60px rgba(0, 0, 0, 0.75);
}

.tube {
  position: relative;
}

.crt canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  outline: none;
  image-rendering: pixelated;
  filter: blur(0.35px) saturate(1.15) brightness(1.12);
}

/* Horizontal scanlines: one dark gap per EGA pixel row. */
.tube::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 50%, var(--scanline) 50%);
  background-size: 100% calc(100% / 350);
}

/* Tube vignette, faint glass sheen and flicker. */
.tube::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.05), transparent 45%),
    radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.5) 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
  animation: flicker 0.12s steps(2) infinite;
}

@keyframes flicker {
  from { opacity: 0.94; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tube::after { animation: none; }
}

.caption {
  margin: 30px 0 0;
  text-align: center;
  letter-spacing: 0.04em;
}
