html, body { margin: 0; height: 100%; height: 100dvh; background: #000; overflow: hidden; }
body { display: flex; align-items: center; justify-content: center; }
/* 16:9 dentro de lo que se ve: dvh es la altura visible (en Chrome móvil, sin la barra de direcciones) */
/* --ar: proporción del juego (16:9 o más ancha en móviles alargados; la pone js/render.js) */
#screen { position: relative; width: min(100vw, calc(var(--ar, 1.7778) * 100vh)); height: min(calc(100vw / var(--ar, 1.7778)), 100vh); }
@supports (height: 100dvh) { #screen { width: min(100vw, calc(var(--ar, 1.7778) * 100dvh)); height: min(calc(100vw / var(--ar, 1.7778)), 100dvh); } }
#view {
  width: 100%; height: 100%; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated;
  display: block;
}
/* Filtro CRT (opciones): líneas de barrido alineadas con los 270 píxeles verticales, máscara de
   fósforo RGB, viñeta con esquinas redondeadas y un leve parpadeo. Solo CSS: no cuesta CPU. */
#crt { position: absolute; inset: 0; pointer-events: none; display: none; }
body.crt #crt { display: block; border-radius: 3% / 5%;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.32) 55%, rgba(0, 0, 0, 0.32) 100%);
  background-size: 100% calc(100% / 270);
  animation: crt-flicker 0.12s steps(2) infinite; }
body.crt #crt::before { content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(to right, rgba(255, 40, 40, 0.07) 0, rgba(255, 40, 40, 0.07) 33.3%, rgba(40, 255, 40, 0.06) 33.3%, rgba(40, 255, 40, 0.06) 66.6%, rgba(60, 80, 255, 0.07) 66.6%, rgba(60, 80, 255, 0.07) 100%);
  background-size: calc(100% / var(--vwpx, 480)) 100%; mix-blend-mode: screen; }
body.crt #crt::after { content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 58%, rgba(0, 0, 0, 0.45) 88%, rgba(0, 0, 0, 0.8) 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.75), inset 0 0 4px rgba(255, 255, 255, 0.08); }
body.crt #view { border-radius: 3% / 5%; filter: contrast(1.12) saturate(1.18) brightness(1.12) blur(0.35px); }
@keyframes crt-flicker { 0% { opacity: 0.94; } 100% { opacity: 1; } }
#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 4;
  color: #e8b850; background: #000; font: bold 18px/1.4 monospace; letter-spacing: 3px; text-align: center;
}
/* pantalla del estudio mientras carga: misma caja 16:9 que el juego, pixel art nítido */
#splashbox { width: min(100vw, 177.78vh); height: min(56.25vw, 100vh); }
@supports (height: 100dvh) { #splashbox { width: min(100vw, 177.78dvh); height: min(56.25vw, 100dvh); } }
#splashimg { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; image-rendering: pixelated; opacity: 0; }
/* aviso para móviles en vertical */
#rotate { display: none; position: fixed; inset: 0; z-index: 5; align-items: center; justify-content: center; text-align: center;
  background: #000; color: #e8b850; font: bold 18px/1.6 monospace; letter-spacing: 2px; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }
html, body { touch-action: none; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
/* botón de pantalla completa (esquina inferior izquierda) */
#fs { position: absolute; left: 0.8%; bottom: 1.2%; width: 4.2%; min-width: 26px; max-width: 44px; aspect-ratio: 1; padding: 5px;
  background: rgba(10, 6, 4, 0.45); border: 1px solid rgba(232, 184, 80, 0.55); border-radius: 3px; cursor: pointer; opacity: 0.7; z-index: 3; touch-action: manipulation; }
#fs:hover, #fs:active { opacity: 1; background: rgba(40, 24, 10, 0.7); }
#fs[hidden] { display: none; }
