/* Silkscreen (OFL) bundled locally so the game is fully self-contained: works
   offline as a PWA and inside Discord's sandboxed iframe with no external host
   to allow-list. Regular + Bold (headers/banners use the 700). Falls back to
   monospace if the files are missing. */
@font-face {
  font-family: 'Silkscreen';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/silkscreen.woff2') format('woff2');
}
@font-face {
  font-family: 'Silkscreen';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/silkscreen-bold.woff2') format('woff2');
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: 'Silkscreen', monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  /* Letterbox fill: a night-sky backdrop so the 4:3 canvas's side/top bars read as
     sky (with a gentle vignette to the edges) instead of dead black voids. */
  background:
    radial-gradient(ellipse 120% 90% at 50% 38%, rgba(40, 44, 96, 0.55), rgba(0, 0, 0, 0) 70%),
    radial-gradient(ellipse 140% 120% at 50% 50%, #14142c 0%, #0b0b1c 55%, #050510 100%);
  background-color: #050510;
  overflow: hidden;
  /* Mobile: never let a drag scroll/pan/zoom the page — the canvas owns all gestures. */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Responsive fill (mobile-first): the internal canvas resolution is now derived from the
   viewport's ASPECT RATIO at runtime (see computeStageWidth in script.js; HEIGHT stays 600,
   WIDTH is clamped to 800..1400). The script writes the live aspect into the `--ar` custom
   property, and we fit to THAT ratio — so on a wide phone in landscape the canvas fills the
   screen with no side bars. When the viewport is beyond the clamp (ultrawide desktop, or a
   portrait phone), min() keeps the aspect and the body letterboxes the residual as sky.
   Uses DYNAMIC viewport units (dvh/dvw) so mobile browser chrome / the gesture bar never
   clips the bottom control zone; 100vh/vw are the fallbacks. --ar defaults to 4:3. */
#gameCanvas {
  --ar: 1.3333;
  width: min(100vw, calc(100vh * var(--ar)));
  height: min(100vh, calc(100vw / var(--ar)));
  width: min(100dvw, calc(100dvh * var(--ar)));
  height: min(100dvh, calc(100dvw / var(--ar)));
  display: block;
  border: none;
  /* GPU-accelerated bilinear upscale of the capped backing store. `pixelated` forces a
     per-frame nearest-neighbour re-upscale that the Android WebView does on a SLOW path
     (Chrome GPU-accelerates it; WebView often doesn't) — the main on-device perf killer.
     Bilinear is slightly softer but composited on the GPU everywhere. */
  image-rendering: auto;
  touch-action: none;
}

/* Game-over name entry: a focusable-but-visually-hidden <input>. It exists only to raise the
   mobile soft keyboard and capture its value (mirrored to the on-canvas field). Kept in layout
   (not display:none / visibility:hidden, which suppress the keyboard) but ~invisible and
   non-interactive; the game calls .focus()/.blur() to show/dismiss the keyboard. 16px font
   stops iOS zoom-on-focus. Positioned mid-lower so the keyboard doesn't cover the score. */
#nameInput {
  position: fixed;
  left: 50%;
  top: 62%;
  transform: translateX(-50%);
  width: 60vw;
  max-width: 420px;
  height: 36px;
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  z-index: 5;
}

/* "Rotate to landscape" hint — shown only on touch devices held in portrait. */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(7, 7, 17, 0.94);
  color: #00e8dc;
  font-family: 'Silkscreen', monospace;
  font-size: 16px;
  line-height: 2.2;
  letter-spacing: 1px;
}
#rotate-hint > div { animation: rotatepulse 1.6s ease-in-out infinite; }
@keyframes rotatepulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

@media (orientation: portrait) {
  body.touch #rotate-hint { display: flex; }
}
