@font-face {
  font-family: "Quaver";
  src: url("../res/fonts/quaver/quaver.ttf") format("truetype");
  font-display: block;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Host letterbox — palette dark purple (PIXEL_ART.md). */
  background: #0e1020;
  font-family: "Quaver", monospace;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0e1020;
}

/*
  Size/position are owned by PixelScreen in JS (integer CSS px only).
  Never set percentage width/height here — that breaks pixel-perfect scale.
*/
/*
  Presentation-only scrolling map under the transparent menu buffer.
  Sized/painted by MenuMapBackdrop to match the game canvas CSS box.
*/
#menu-map-backdrop {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  margin: 0;
  padding: 0;
  border: 0;
  pointer-events: none;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* Match #game-canvas CRT punch so the seam is invisible. */
  filter: contrast(1.08) saturate(1.1) brightness(1.02);
}

#game-canvas {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
  border: 0;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* Slight CRT phosphor punch — no blur (keeps integer upscale crisp). */
  filter: contrast(1.08) saturate(1.1) brightness(1.02);
}

/*
  Presentation-only CRT glass. Position/size synced to the canvas by PixelScreen.
  Must not receive input; must not touch the logical 480×270 buffer.
  Minor look: scanlines + aperture tint + vignette + faint phosphor flicker.
*/
#crt-overlay {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  pointer-events: none;
  overflow: hidden;
  /* Faint vertical aperture grille (palette yellow / white / purple). */
  background: repeating-linear-gradient(
    to right,
    rgba(255, 226, 80, 0.018) 0, /* yellow */
    rgba(227, 232, 197, 0.014) 1px, /* white */
    rgba(51, 39, 69, 0.03) 2px, /* purple */
    rgba(51, 39, 69, 0.03) 3px
  );
  box-shadow:
    inset 0 0 0 1px rgba(227, 232, 197, 0.1), /* white */
    inset 0 0 32px rgba(51, 39, 69, 0.5); /* purple */
}

/* Scanlines + rare micro phosphor flicker */
#crt-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(14, 16, 32, 0.28) 0, /* dark purple */
    rgba(14, 16, 32, 0.28) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.45;
  mix-blend-mode: multiply;
  animation: crt-phosphor 5.5s linear infinite;
}

@keyframes crt-phosphor {
  0%,
  96%,
  100% {
    opacity: 0.45;
  }
  97% {
    opacity: 0.32;
  }
}

/* Soft vignette (palette dark purple / purple — no yellow wash) */
#crt-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse at center,
      transparent 48%,
      rgba(14, 16, 32, 0.5) 100% /* dark purple */
    );
  box-shadow: inset 0 0 56px rgba(14, 16, 32, 0.4);
}

#ui-root {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

#ui-root > * {
  pointer-events: auto;
}
