@font-face {
  font-family: "Geist Sans";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Variable.woff2") format("woff2");
  font-weight: 100 800; font-style: normal; font-display: swap;
}

:root {
  /* Palette: two condiments on a neutral base. Borrowed from FFV as an idea
     (ketchup + mustard), but true condiment colors — FFV's are muted for an archive.
     mustard — the everyday reward: count, +1, CLEAN, prompts, clean ripple
     ketchup — action: the Play again button
     white   — the rare one: rank-ups, and the ripple on a 5+ clean streak */
  /* Background: a cool slate, lighter behind the burger. Cool against the warm
     food, so the stack pops without the background asking for attention. */
  --bg-center: #56616e;
  --bg-edge: #3a434e;
  --text: rgb(232 228 220);
  --ink: #141414;
  --panel: rgb(232 228 220);
  --mustard: #ffcf33;
  --ketchup: #e0282e;
  --ketchup-dark: #a51c21;
  /* Type system: sans for words with meaning (title, ranks, lines, button),
     mono for numbers and system labels (counts, CLEAN, prompts) — a register receipt.
     Same faces as fastfoodvisors.xyz, served from ./fonts. */
  --font-sans: "Geist Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* On-screen text sits on a mid-tone slate: a faint dark lift keeps edges crisp in daylight. */
  --lift: 0 1px 3px rgb(0 0 0 / .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse 90% 70% at 50% 55%, var(--bg-center), var(--bg-edge)) fixed, var(--bg-edge);
  color: var(--text);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* no iOS long-press menu */
  touch-action: manipulation;  /* no double-tap zoom */
}

body > canvas { position: fixed; inset: 0; display: block; z-index: 0; }
#game {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100dvh; max-width: 440px; margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  gap: 12px;
}

/* HUD: one centered column. Title before play, then the count.
   Fixed height so the stage never resizes when things appear. */
.hud {
  height: 92px; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}
.hud h1 { margin: 18px 0 0; font-size: 30px; font-weight: 800; letter-spacing: .5px; text-shadow: var(--lift); }
.hud [hidden] { display: none !important; }
.counter {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  color: var(--mustard);
  font-family: var(--font-mono);
  text-shadow: var(--lift);
  transition: color .35s, text-shadow .35s;
}
.counter b { font-size: 44px; font-weight: 700; line-height: 1; display: inline-block; }
.counter span { font-size: 12px; font-weight: 700; letter-spacing: 2px; margin-top: 2px; }
.counter b.bump { animation: bump .18s ease-out; }
@keyframes bump { 50% { transform: scale(1.2); } }
.counter.rank { color: #fff; text-shadow: var(--lift), 0 0 10px rgb(255 207 51 / .55); }

/* +1 that drifts up off the counter */
.plus {
  position: absolute; left: calc(100% + 4px); top: 0;
  font: 700 14px var(--font-mono); color: var(--mustard); text-shadow: var(--lift);
  pointer-events: none; animation: plus .6s ease-out forwards;
}
@keyframes plus { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-22px); opacity: 0; } }

/* Stage */
#stage {
  flex: 1; position: relative; min-height: 0; overflow: hidden;
  touch-action: manipulation; cursor: pointer;
}

/* Prompt */
#prompt {
  position: absolute; left: 0; right: 0; top: 22%; margin: 0;
  text-align: center; font: 700 20px var(--font-mono); letter-spacing: 3px; color: var(--mustard); text-shadow: var(--lift);
  animation: pulse 1s ease-in-out infinite alternate; pointer-events: none;
}
#prompt[hidden] { display: none; }
@keyframes pulse { to { opacity: .45; } }

/* Intro: UI waits (.pre) until the base has built, then fades in (.reveal). */
.pre { opacity: 0; animation: none !important; }
.reveal { animation: fade-in .3s ease-out both; }
#prompt.reveal { animation: fade-in .3s ease-out both, pulse 1s .3s ease-in-out infinite alternate; }
@keyframes fade-in { from { opacity: 0; } }

/* Pop-ups: rank title on top, CLEAN under it. Each keeps its own slot. */
.pops {
  position: absolute; left: 0; right: 0; top: 9%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.pop {
  opacity: 0; transform: translateY(8px); transition: opacity .12s, transform .12s;
  white-space: nowrap; min-height: 1.2em;
}
.pop.show { opacity: 1; transform: translateY(0); }
#rank-pop {
  transition: opacity .35s, transform .35s;
  font: 800 28px var(--font-sans); letter-spacing: .5px; color: #fff;
  text-shadow: 0 2px 6px rgb(0 0 0 / .4), 0 0 10px rgb(255 207 51 / .55); /* crisp first, then a short glow */
}
#clean-pop { font: 700 18px var(--font-mono); letter-spacing: 3px; color: var(--mustard); text-shadow: var(--lift); }

/* Credit footer: start + game-over screens only. Sits above the card's backdrop. */
#credit {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 2;
  text-align: center; font: 700 12px var(--font-mono); letter-spacing: .5px;
  color: rgb(232 228 220 / .6); text-shadow: var(--lift);
}
#credit[hidden] { display: none; }
#credit a { color: rgb(232 228 220 / .9); text-decoration: none; border-bottom: 1px solid rgb(232 228 220 / .35); }

/* Desktop only: hover states for real mice (phones never get a stuck hover). */
#credit a, #ending button { transition: color .15s, border-color .15s, transform .12s, box-shadow .12s, filter .15s; }
@media (hover: hover) and (pointer: fine) {
  #credit a:hover { color: #fff; border-bottom-color: rgb(232 228 220 / .9); }
  #ending button:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ketchup-dark); }
  body { cursor: pointer; }
  #credit, #ending .card { cursor: default; }
}
/* Keyboard focus only — never shows on click or tap. */
:focus-visible { outline: 2px solid var(--mustard); outline-offset: 3px; border-radius: 4px; }
#ending button:focus-visible { outline-offset: 4px; }

/* Ending card */
#ending {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgb(0 0 0 / .35);
  padding: 16px;
}
#ending[hidden] { display: none; }
#ending .card {
  background: var(--panel); color: var(--ink);
  border-radius: 18px; box-shadow: 0 10px 40px rgb(0 0 0 / .5);
  padding: 18px 20px; width: 100%; max-width: 340px; text-align: center;
  animation: rise .35s ease-out;
}
#ending .mascot[hidden] { display: none; }
#ending .mascot { width: 96px; height: 96px; object-fit: contain; margin: -4px auto 8px; display: block; }
#ending .score-block { margin-bottom: 12px; }
#ending .score { margin: 0; font: 700 60px/1 var(--font-mono); }
#ending .label { margin: 4px 0 0; font: 700 12px var(--font-mono); letter-spacing: 2px; }
#ending .streak {
  display: table; margin: 0 auto 16px; padding: 4px 12px;
  border-radius: 999px; background: rgb(0 0 0 / .06);
  font: 500 13px var(--font-mono); color: #6b675f;
}
#ending h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: .5px; }
#ending .line { margin: 0 0 14px; }
#ending button {
  font: 700 17px var(--font-sans); padding: 10px 22px;
  background: var(--ketchup); color: #fff; border: 0; border-radius: 12px; cursor: pointer;
  box-shadow: 0 4px 0 var(--ketchup-dark);
}
#ending button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ketchup-dark); }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
