/* THE PIXEL FACES, SELF-HOSTED (request 553: the reference video's font, throughout the game).
 *
 *   'RR Pixel'      Tiny5 — every label, row, paragraph and number (thin square pixel caps
 *                   with real lowercase, the reference HUD's RAZE / SCORE look)
 *   'RR Pixel Bold' Silkscreen Bold — headlines, display numbers and the hit counter (the
 *                   reference's chunky 5 HIT)
 *
 * Each file is ONE cut, declared for the whole 100-900 weight range on purpose: the game asks
 * for 600/700/900 all over, and a single-weight face asked for bold is SMEARED by the browser
 * (synthetic bold) — the one thing a pixel font cannot survive. Weight is chosen by family
 * (frontend.js setFont), never by synthesis.
 *
 * SELF-HOSTED, not a CDN fetch that fails silently into a fallback. Both SIL OFL 1.1 — see
 * frontend/fonts/OFL-Tiny5.txt and OFL-Silkscreen.txt. Montserrat's files stay in the folder,
 * unused.
 *
 * font-display: block rather than swap: CANVAS TEXT DOES NOT REFLOW — every string is drawn
 * once into a bitmap, so boot() awaits document.fonts.load() before the first frame. */
@font-face {
  font-family: 'RR Pixel';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('frontend/fonts/tiny5-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'RR Pixel Bold';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('frontend/fonts/silkscreen-bold-latin.woff2') format('woff2');
}

:root {
  color-scheme: dark;
  font-family: 'RR Pixel', monospace;
  background: #05070b;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, #1c2438 0%, #080b12 48%, #030407 100%);
}

/* A GAME PAGE, NOT A DOCUMENT: no scrolling, rubber-band or pull-to-refresh,
   no pinch-zoom, no text selection or long-press callout anywhere on it (the
   canvas already had these; the touch HUD sits outside it). */
html, body {
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: grid;
  place-items: center;
}

.game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  box-shadow: 0 0 80px #000, 0 0 0 2px #2e3952;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* The front end resizes the backing store to the display, so the browser is
     no longer upscaling it — nearest-neighbour only added stair-stepping to
     UI text and hairlines. The game art is high-resolution sprite work, not
     pixel art, so smooth sampling suits it too. */
  image-rendering: auto;
  touch-action: none;
  outline: none;
  background: #0a0e18;
  /* THE BROWSER'S OWN TOUCH HIGHLIGHT. Mobile WebKit/Blink paint a translucent
     grey wash over whatever was tapped, and on a full-bleed canvas that is a
     soft slab across the whole game for the length of the tap — nothing in the
     page draws it, so it cannot be removed from JS. The press is answered by
     the control's compression and by the haptic instead (see hapticTick).
     `user-select` goes with it: a long press on a canvas otherwise raises the
     selection/callout UI, which is the same interruption by another route. */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffe45e;
  background: #080b12;
  letter-spacing: .16em;
  text-align: center;
  font-size: clamp(20px, 2.4vw, 32px);
}

.loading.hidden { display: none; }

/* A failed load (game.js showLoadFailure): the message and a reload button. */
.loading .load-fail { display: grid; gap: 14px; justify-items: center; padding: 24px; }
.loading .load-fail small { color: #9fb2d8; letter-spacing: .04em; font-size: 16px; max-width: 80vw; word-break: break-all; }
.loading .load-fail button {
  font: inherit; font-size: 18px; letter-spacing: .14em; color: #080b12; background: #ffe45e;
  border: 0; border-radius: 6px; padding: 10px 22px; cursor: pointer;
}

/* MOBILE BROWSERS: 100vh is the viewport WITHOUT the address bar, so a shell
   sized off it runs under the bar. The dynamic unit is the visible height. */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
  .game-shell { width: min(100vw, calc(100dvh * 16 / 9)); }
}

/* Held upright, a phone gets a prompt instead of a postage-stamp game. (The
   Android app is locked to landscape and never shows it.) */
.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: #ffe45e;
  background: #080b12;
  font: 400 20px/1.6 'RR Pixel', monospace;
  letter-spacing: .14em;
}
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint { display: grid; }
}

/* A RETRY THAT CAME BACK UPRIGHT (request 572, webshell.js): the reload dropped the landscape
   lock, so the page is drawn turned a quarter, the way the phone is still held, until the first
   tap brings fullscreen + landscape back. No ROTATE PHONE card in between. */
html.rr-rot .rotate-hint { display: none !important; }
html.rr-rot body {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vh;
  height: 100vw;
  transform-origin: 0 0;
  transform: translateX(100vw) rotate(90deg);
}
html.rr-rot.rr-rot-ccw body { transform: translateY(100vh) rotate(-90deg); }
html.rr-rot .game-shell { width: min(100vh, calc(100vw * 16 / 9)); }
html.rr-rot #ror-touch, html.rr-rot #ror-gest { visibility: hidden; }
@supports (height: 100dvh) {
  html.rr-rot body { width: 100dvh; }
  html.rr-rot.rr-rot-ccw body { transform: translateY(100dvh) rotate(-90deg); }
  html.rr-rot .game-shell { width: min(100dvh, calc(100vw * 16 / 9)); }
}
