:root { --bg: #04050a; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  font-family: "Courier New", monospace;
  color: #9aa3bd;
}

/* 16:9 frame that always fits the window */
#frame {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 90px rgba(60, 80, 160, .18), 0 0 0 1px #11162a;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  outline: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* CRT overlay: scanlines + curved-ish vignette + faint flicker. Press C in-game to toggle. */
#frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.20) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,.5) 100%);
  mix-blend-mode: multiply;
  animation: crt-flicker 7s infinite steps(1);
}

body.crt-off #frame::after { display: none; }

@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  41%      { opacity: .93; }
  42%      { opacity: 1; }
  77%      { opacity: .95; }
  78%      { opacity: 1; }
}
