/* MONTSERRAT, SELF-HOSTED, NOT FROM A CDN.
 *
 * One variable file per subset covering weight 100-900, so 700 and 900 are real
 * Bold and Black cut from the same family rather than the browser smearing one
 * face. Two subsets are served: `latin` (U+0000-00FF plus a short extras list)
 * and `latin-ext`. See _chromakey/glyphscan.js — it reports every non-ASCII
 * character the UI actually draws and which subset holds it, because a glyph
 * outside both falls back to a system face MID-STRING.
 *
 * SELF-HOSTED because a Google Fonts fetch that fails does not error: the text
 * silently renders in the fallback, and a screenshot cannot tell the two apart.
 * This project has already shipped that exact failure once with the logo (see
 * the SVG-MIME note in frontend.js). Files live in frontend/fonts/ and travel
 * with the build. Montserrat is SIL OFL 1.1 — see frontend/fonts/OFL.txt.
 *
 * `font-display: block` rather than `swap`: CANVAS TEXT DOES NOT REFLOW. A
 * swapped-in font repaints DOM text for free, but every string in this game is
 * drawn once into a bitmap, so anything drawn before the face arrives keeps the
 * fallback's metrics until that screen is drawn again. boot() awaits
 * document.fonts.load() for this reason — block is only the second line. */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('frontend/fonts/montserrat-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('frontend/fonts/montserrat-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  font-family: Montserrat, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  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(16px, 2vw, 30px);
}

.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: 12px; max-width: 80vw; word-break: break-all; }
.loading .load-fail button {
  font: inherit; font-size: 14px; 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: 700 18px/1.6 Montserrat, "Segoe UI", Roboto, sans-serif;
  letter-spacing: .14em;
}
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint { display: grid; }
}
