/* Nunito 800 shipped with the page (../fonts, shared with Cloud Hop), so the car app needs no network. */
@font-face {
  font-family: "Nunito";
  font-weight: 800;
  font-display: swap;
  src: url(../fonts/nunito-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito";
  font-weight: 800;
  font-display: swap;
  src: url(../fonts/nunito-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;
}

* { box-sizing: border-box; margin: 0; }

/* Page colours follow the game's theme (engine.js sets data-theme); the media query covers the first paint. */
:root {
  --bg: #f7f2ec; --fg: #423e52; --card: #ffffff; --field: #f6f1eb; --line: #ebe4dc; --accent: #8e9bff; --on-accent: #ffffff;
  --b1: #ffdcd2; --b2: #d6e7ff; --b3: #dcf2e3;
}
:root[data-theme="dark"] {
  --bg: #1e1c29; --fg: #f2eef8; --card: #2c2a3a; --field: #201e2b; --line: #3a3850; --accent: #a3adff; --on-accent: #1e1c29;
  --b1: #352b48; --b2: #232f45; --b3: #243832;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1e1c29; --fg: #f2eef8; --card: #2c2a3a; --field: #201e2b; --line: #3a3850; --accent: #a3adff; --on-accent: #1e1c29;
    --b1: #352b48; --b2: #232f45; --b3: #243832;
  }
}

/* Large soft circles drifting behind the whole page (the game canvas is transparent). */
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blobs i { position: absolute; border-radius: 50%; animation: drift 22s ease-in-out infinite alternate; }
.blobs i:nth-child(1) { left: -12vmin; top: 4vh; width: 46vmin; height: 46vmin; background: var(--b1); }
.blobs i:nth-child(2) { right: -18vmin; top: 38vh; width: 58vmin; height: 58vmin; background: var(--b2); animation-duration: 27s; }
.blobs i:nth-child(3) { left: 14vw; bottom: -26vmin; width: 52vmin; height: 52vmin; background: var(--b3); animation-duration: 32s; }
@keyframes drift { to { transform: translate(4vmin, -3vmin); } }

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: "Nunito", system-ui, sans-serif;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  min-height: 0;
}

canvas {
  display: block;
  border-radius: 18px;
  touch-action: none;
  cursor: pointer;
}

/* Player name entry, shown over the game. */
.name-dialog {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 28, 41, 0.45);
}

.name-dialog[hidden] { display: none; }

.name-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 320px);
  padding: 20px;
  border-radius: 18px;
  background: var(--card);
}

.name-box label { font-size: 20px; }

.name-box input {
  min-height: 64px;   /* car touch targets: at least 64 dp */
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 20px;
  user-select: text;
}

.name-box input:focus { outline: none; border-color: var(--accent); }

.name-actions { display: flex; gap: 10px; justify-content: flex-end; }

.name-actions button {
  min-width: 96px;
  min-height: 64px;
  padding: 10px 24px;
  border: 0;
  border-radius: 32px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}

.name-actions button[type="submit"] { background: var(--accent); color: var(--on-accent); }

/* Short landscape screens: car displays, tablets, laptops. */
@media (orientation: landscape) and (max-height: 820px) {
  body {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  canvas { border-radius: 12px; }
}
