:root {
  color-scheme: dark;
  --bg: #000;
  --btn: #0000aa;
  --btn-fg: #ffff55;
  --btn-edge: #5555ff;
  --px: 1;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font: 16px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#wrap { position: relative; line-height: 0; }

canvas {
  display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  touch-action: none;
}

/* CRT: scanlines every other source row, a soft vignette and a faint glow. */
#crt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%),
    repeating-linear-gradient(to bottom,
      transparent 0, transparent calc(var(--px) * 1px),
      rgba(0, 0, 0, .35) calc(var(--px) * 1px), rgba(0, 0, 0, .35) calc(var(--px) * 2px));
}
body.crt #crt { display: block; }
body.crt canvas {
  filter: brightness(1.2) saturate(1.15);
  box-shadow: 0 0 60px rgba(85, 255, 255, .07);
  border-radius: 6px;
}

/* Touch controls */
#pad { display: none; flex-direction: column; align-items: center; gap: 10px; touch-action: none; }
@media (hover: none) and (pointer: coarse) {
  #pad { display: flex; }
}
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  body { flex-direction: row; }
}

.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-auto-rows: 56px; gap: 6px; }
.opts { display: flex; gap: 6px; }

#pad button {
  font: inherit;
  color: var(--btn-fg);
  background: var(--btn);
  border: 2px solid var(--btn-edge);
  border-radius: 0;
  padding: 0;
  touch-action: none;
}
.opts button { padding: 8px 14px; }
#pad button:active { background: var(--btn-edge); color: #fff; }
