/* ============================================================
   YEETCAT — style.css
   Comic-sticker UI: chunky ink borders, hard shadows,
   Bangers display type, slight panel tilt.
   ============================================================ */

:root {
  --ink: #14122b;
  --paper: #fffdf5;
  --yeet: #ff6b1a;
  --gold: #ffd23f;
  --lime: #8be04a;
  --sky: #7ec9ff;
  --shadow: 6px 6px 0 rgba(20, 18, 43, 0.85);

  /* ---- responsive layout tokens ----
     --app-w/--app-h are written by Main.resize() from visualViewport: the box
     the player can actually see. The dvh/vw values are only the first-frame
     fallback (and the answer for browsers without visualViewport). Everything
     full-screen sizes off these instead of 100vh, which on mobile is the
     TALLER layout viewport and is what pushed UI outside the game frame. */
  --app-w: 100vw;
  --app-h: 100dvh;

  /* iOS notch / Android gesture bar. Zero on every other device. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  /* Height the portal banner reserves at the bottom; 0 until one mounts. */
  --banner-h: 0px;

  /* Measured height of the hint pill, published by UI.hint(). 0 when no
     hint is showing, so the toast stack drops back down to the edge. */
  --hint-h: 0px;

  /* Gutter every screen and overlay keeps between itself and the frame edge.
     vmin so it tracks the SHORT side — a landscape phone gets a small gutter
     for the same reason a narrow portrait one does. */
  --gutter: clamp(8px, 2.4vmin, 16px);
}

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

html, body {
  width: 100%; height: 100%;
  height: 100dvh;              /* mobile: the *visible* viewport, not the layout one */
  height: var(--app-h);        /* ...and the measured one once JS is up */
  overflow: hidden;
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--ink);
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}

/* Pin the document. A mobile browser will happily scroll the whole page when
   an ad iframe or a transient overflow makes it one pixel too tall, which
   drags the game out of frame and reads as "the layout is extended". Fixed
   body means there is nothing to scroll — overlays do their own scrolling. */
body {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: var(--app-h);
  overscroll-behavior: none;   /* and no iOS rubber-band drag either */

  /* The height a panel can occupy and still clear the notch and the banner.
     Percentage heights don't resolve against an auto-sized grid area, so
     anything that must be bounded uses this instead.

     Declared HERE, not on :root: a custom property substitutes its var()s
     using the values on the element that declares it, and --banner-h is set
     on body.hasBanner. On :root this silently resolved the banner as 0px. */
  --fit-h: calc(var(--app-h) - var(--banner-h) - var(--safe-t) - var(--safe-b) - 2 * var(--gutter));
}

/* ----------------------------------------------------------------
   NO SCROLLBARS, EVER.
   The page must never show one — not from our own transient overflow
   (confetti, compact-layout screens) and not when the CrazyGames SDK
   mounts an ad container and briefly makes the document scrollable
   (the flicker QA saw when a rewarded ad opens). Scrolling itself
   still works everywhere it's needed (wheel / touch / drag); only the
   bar is suppressed. A classic scrollbar also steals ~15px of width
   and reflows the whole page for its lifetime, so hiding it kills
   that layout jump too.
   ---------------------------------------------------------------- */
html, body, .screen, .shopPanel {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* legacy Edge */
}
html::-webkit-scrollbar, body::-webkit-scrollbar,
.screen::-webkit-scrollbar, .shopPanel::-webkit-scrollbar {
  display: none;                /* Chrome / Safari / new Edge */
}

#game {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: var(--app-h);
  display: block;
  cursor: crosshair;
  touch-action: none;          /* no scroll/zoom gesture stealing a launch */
}

.hidden { display: none !important; }

/* ---------------- screens ---------------- */

.screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: var(--app-h);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: clamp(6px, 1.8vmin, 14px);
  pointer-events: none;
  /* the frame edge, the notch, and the banner strip all paid for at once */
  padding:
    calc(var(--gutter) + var(--safe-t))
    calc(var(--gutter) + var(--safe-r))
    calc(var(--gutter) + var(--safe-b) + var(--banner-h))
    calc(var(--gutter) + var(--safe-l));
  overflow: hidden;
}
/* Nothing inside a screen may be wider than the screen. This one line is the
   backstop for every "extends outside the frame" case: a long button row, a
   grid with a stubborn min column, an oversized art asset. */
.screen > * { max-width: 100%; }
.screen > * { pointer-events: auto; }

.panel {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(12px, 3vmin, 20px) clamp(14px, 4vmin, 26px);
  transform: rotate(-1deg);
  max-width: min(100%, 460px);
  text-align: center;
}

.statRow {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  max-width: 100%;
  font-weight: 800; font-size: clamp(12px, 3.2vmin, 15px);
}
.statChip {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  padding: 6px 14px;
}

/* ----------------------------------------------------------------
   COMPETITION MODE  (body.comp)

   Same chrome, different ink: the accent goes from yeet-orange to a
   violet so a glance at any screen says which mode you are in, which
   matters because only this mode feeds the leaderboard. Everything else
   keys off the same tokens, so the swap is a handful of variables.
   ---------------------------------------------------------------- */
body.comp {
  --yeet: #a63cff;
  --paper: #f5ecff;
  --lime: #c8a4ff;
}
body.comp #hudDist { color: #f1dcff; text-shadow: 4px 4px 0 #3a1466; }
body.comp .hudChip { background: rgba(58, 20, 102, 0.82); }
body.comp #hudComp { background: var(--yeet); color: #fff; }
body.comp .btnGhost { background: var(--paper); }

/* this week's challenge card, top of the right column in Competition */
#compCard {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: clamp(8px, 2vmin, 12px) clamp(12px, 3vmin, 18px);
  max-width: min(92vw, 440px);
  text-align: center;
}
.compHead {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(18px, 5vmin, 26px);
  letter-spacing: 1.5px;
  color: var(--yeet);
  -webkit-text-stroke: 0.5px var(--ink);
}
#compDesc { font-weight: 800; font-size: clamp(12px, 3.2vmin, 15px); color: var(--ink); margin-top: 2px; }
#compLeft { font-weight: 800; font-size: clamp(11px, 2.8vmin, 13px); color: #5c5870; margin-top: 4px; }


/* ---------------- banners ---------------- */

/* ----------------------------------------------------------------
   EVERY full-screen overlay obeys the same box: the visible viewport,
   minus the notch, minus the banner strip. They used to lay themselves
   out against 100vh — which on iOS is the tall layout viewport — so
   panels ran off the bottom of what the player could actually see.
   ---------------------------------------------------------------- */
#skinShop, #statsOverlay, #tutorial, #reveal {
  inset: 0 auto auto 0;
  width: 100%; height: var(--app-h);
  padding:
    calc(var(--gutter) + var(--safe-t))
    calc(var(--gutter) + var(--safe-r))
    calc(var(--gutter) + var(--safe-b) + var(--banner-h))
    calc(var(--gutter) + var(--safe-l));
  overflow: hidden;
}
#skinShop > *, #statsOverlay > *, #tutorial > *, #reveal > * {
  max-width: 100%;
}
/* Panels fill at most the box above and scroll their own overflow, so a
   long shop on a short phone scrolls INSIDE the panel — the page itself
   never grows and the frame never moves. */
.shopPanel, .tutPanel, .revealPanel {
  max-height: 100%;
  overflow-y: auto;
  /* ...and NEVER sideways. These panels are columns; anything wider than
     them is decoration that is already being clipped (the reveal's sunray
     disc is 60px wider than its own panel). Left on the default it made
     the panel draggable left-right for no visible gain, which is one more
     thing that reads as "the layout is broken". */
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.tutPanel, .revealPanel { scrollbar-width: none; }
.tutPanel::-webkit-scrollbar, .revealPanel::-webkit-scrollbar { display: none; }

/* THE banner dock: one fixed strip at the bottom-centre of the screen.
   It outlives menu navigation (same container id = the SDK keeps the same
   ad alive) and sits above the overlay backdrops but below every takeover
   (tutorial/reveal/ad break). While it's up, body.hasBanner reserves the
   strip's height on every screen and panel, so it can never cover UI. */
#bannerDock {
  position: fixed; left: 50%;
  bottom: calc(8px + var(--safe-b));
  transform: translateX(-50%);
  width: min(96vw, 728px); height: 90px;
  max-width: calc(100% - var(--safe-l) - var(--safe-r) - 8px);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  z-index: 55;
}
/* One token, and every screen/overlay above already pays for it in its
   padding — no per-container padding overrides to keep in sync. */
body.hasBanner { --banner-h: 106px; }
@media (max-width: 760px) {
  #bannerDock { width: min(96vw, 320px); height: 50px; }
  body.hasBanner { --banner-h: 64px; }
}
/* A short landscape phone cannot spare 64px of a 360px-tall frame for a
   banner AND still show a menu, so the strip shrinks with the frame. */
@media (max-height: 480px) {
  #bannerDock { height: 50px; }
  body.hasBanner { --banner-h: 58px; }
}

/* ---------------- buttons ---------------- */

.btn {
  font-family: 'Bangers', Impact, sans-serif;
  /* vmin, not vw: a landscape phone is short, not narrow, and stepping on
     width alone left these full-size on a 360px-tall frame */
  font-size: clamp(17px, 4.6vmin, 24px);
  letter-spacing: 1.5px;
  color: var(--ink);
  background: var(--gold);
  border: 4px solid var(--ink);
  border-radius: 14px;
  padding: clamp(7px, 1.9vmin, 10px) clamp(14px, 5vmin, 26px);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s;
  max-width: 100%;
}
.btn:hover { transform: translate(-1px, -1px) rotate(-0.5deg); }
.btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 rgba(20,18,43,.85); }
.btn:disabled {
  background: #cfcabc; color: #7a766b;
  cursor: not-allowed; transform: none; box-shadow: var(--shadow);
}
.btnBig {
  font-size: clamp(26px, 7.4vmin, 38px);
  padding: clamp(9px, 2.4vmin, 12px) clamp(22px, 8vmin, 44px);
  background: var(--yeet); color: #fff; -webkit-text-stroke: 1px var(--ink);
}
.btnGhost { background: var(--paper); font-size: clamp(15px, 4vmin, 20px); }
.btnAd { background: var(--lime); }

.cornerBtns {
  position: fixed;
  top: calc(10px + var(--safe-t));
  right: calc(10px + var(--safe-r));
  display: flex; gap: 8px; z-index: 30;
}
.iconBtn {
  /* never below 38px: this is a touch target before it is decoration */
  font-size: clamp(16px, 4.2vmin, 20px);
  width: clamp(38px, 10vmin, 46px);
  height: clamp(38px, 10vmin, 46px);
  flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); border: 3px solid var(--ink);
  border-radius: 12px; box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  cursor: pointer;
}
.iconBtn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(20,18,43,.85); }

/* ---------------- HUD ---------------- */

#hud {
  position: fixed;
  top: calc(10px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  display: flex; flex-direction: column; gap: clamp(4px, 1.2vmin, 8px);
  pointer-events: none; z-index: 20;
  /* the corner buttons own the right side; never grow into them */
  max-width: calc(100% - var(--safe-l) - var(--safe-r) - 130px);
}
#hudDist {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(26px, 7vmin, 52px);
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 4px 4px 0 var(--ink);
}
.hudChip {
  align-self: flex-start;
  background: rgba(20, 18, 43, 0.78);
  color: #fff; font-weight: 800;
  font-size: clamp(12px, 3.2vmin, 15px);
  padding: 4px 12px; border-radius: 999px;
  white-space: nowrap;
}
/* speed chip turns hot once the readout flips to Mach */
#hudSpeed.supersonic {
  background: linear-gradient(90deg, var(--yeet), var(--gold));
  color: var(--ink);
}

#hudCombo {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(21px, 5.6vmin, 30px); color: var(--yeet);
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
  animation: comboPulse 0.4s ease-in-out infinite alternate;
}
@keyframes comboPulse { from { transform: scale(1) rotate(-2deg); } to { transform: scale(1.12) rotate(2deg); } }

/* active power-up: name + a bar that drains as it runs out */
/* ---------------- sound-barrier banner ---------------- */

#machBanner {
  position: fixed; left: 0; right: 0; top: 22%;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none; z-index: 60;
  text-align: center;
}
#machTitle {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(38px, 9vw, 86px);
  letter-spacing: 3px;
  color: #fff;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 0 0 26px rgba(159, 216, 255, 0.95), 6px 6px 0 var(--ink);
}
#machSub {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(15px, 3.2vw, 28px);
  letter-spacing: 2px;
  color: var(--gold);
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
}
/* slam in from too-big, hang, then fall away */
#machBanner.show #machTitle { animation: machSlam 1.9s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
#machBanner.show #machSub   { animation: machSub 1.9s ease-out forwards; }
@keyframes machSlam {
  0%   { opacity: 0; transform: scale(2.6) rotate(-7deg); filter: blur(6px); }
  14%  { opacity: 1; transform: scale(1) rotate(-2deg); filter: blur(0); }
  22%  { transform: scale(1.06) rotate(1deg); }
  30%  { transform: scale(1) rotate(0deg); }
  78%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.86) translateY(-28px); }
}
@keyframes machSub {
  0%   { opacity: 0; transform: translateY(14px); }
  22%  { opacity: 1; transform: translateY(0); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px); }
}
/* the whole screen flashes white for a frame or two on the boom */
#machFlash {
  position: fixed; inset: 0; pointer-events: none; z-index: 55;
  background: #fff; opacity: 0;
}
#machFlash.pop { animation: machFlash 0.42s ease-out forwards; }
@keyframes machFlash { 0% { opacity: 0.72; } 100% { opacity: 0; } }

#hudBoost {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(17px, 4.6vmin, 24px); letter-spacing: 1px;
  color: var(--gold);
  -webkit-text-stroke: 1.2px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
}
#hudBoost.bad { color: #B9AEE0; }
#hudBoostBar {
  width: clamp(96px, 28vmin, 132px); height: 10px;
  background: rgba(20, 18, 43, 0.55);
  border: 2px solid var(--ink); border-radius: 6px;
  overflow: hidden;
}
#hudBoostFill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--yeet), var(--gold));
  transition: width 0.08s linear;
}
#hudBoost.bad #hudBoostFill { background: linear-gradient(90deg, #4A4560, #B9AEE0); }

#fuelWrap {
  width: clamp(120px, 34vmin, 170px); height: clamp(13px, 3.4vmin, 18px);
  background: rgba(20, 18, 43, 0.78);
  border: 3px solid var(--ink); border-radius: 999px;
  overflow: hidden;
}
#fuelFill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--yeet), var(--gold));
  transition: width 0.08s linear;
}

/* ---------------- results ---------------- */

#results .panel {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(6px, 1.8vmin, 12px);
  width: min(100%, 440px);
}
.resTitle {
  font-family: 'Bangers', Impact, sans-serif; letter-spacing: 1px;
  font-size: clamp(20px, 5.4vmin, 30px); color: var(--ink);
}
.resTitle b { color: var(--yeet); font-weight: 400; }
#resNew {
  display: inline-block;
  background: var(--lime); border: 3px solid var(--ink); border-radius: 999px;
  font-weight: 900; padding: 3px 14px; transform: rotate(-2deg);
  animation: comboPulse 0.5s ease-in-out infinite alternate;
}
#resEarned {
  font-family: 'Bangers', Impact, sans-serif; letter-spacing: 2px;
  font-size: clamp(40px, 12vmin, 72px); line-height: 1;
  color: var(--gold); -webkit-text-stroke: 2px var(--ink);
  text-shadow: 4px 4px 0 var(--ink);
}

/* THE MULTIPLIER BAR. Band widths come from CFG.REWARD_BANDS (flex-grow),
   so the art can never disagree with the payout. */
#multBar {
  position: relative; width: 100%;
  height: clamp(34px, 8.4vmin, 48px);
  margin: 4px 0;
}
#multBands {
  display: flex; height: 100%;
  border: 3px solid var(--ink); border-radius: 12px; overflow: hidden;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
}
.multBand {
  flex-basis: 0; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bangers', Impact, sans-serif; letter-spacing: 0.5px;
  font-size: clamp(14px, 3.8vmin, 20px); color: var(--ink);
  border-right: 2px solid rgba(20, 18, 43, 0.35);
}
.multBand:last-child { border-right: none; }
.multBand.m2 { background: #FFD23F; }
.multBand.m3 { background: #FFA62B; }
.multBand.m4 { background: #FF6B1A; color: #fff; }
.multBand.m5 { background: #8BE04A; font-size: clamp(12px, 3.2vmin, 17px); }
#multNeedle {
  position: absolute; top: -7px; bottom: -7px; left: 0;
  width: 8px; margin-left: -4px;
  background: #fff; border: 3px solid var(--ink); border-radius: 4px;
  box-shadow: 2px 2px 0 rgba(20,18,43,.6);
  pointer-events: none;
}
/* Two fixed lines, always: "📺 CLAIM x4" over the amount. The amount used to
   sit inline and wrapped onto a second line once it got long (104.8K), so
   the button grew mid-sweep as the needle changed the number. */
#btnClaim { width: 100%; line-height: 1.05; }
#btnClaim .claimTop, #btnClaim .claimAmt { display: block; white-space: nowrap; }
#btnClaim .claimAmt {
  font-family: 'Nunito', sans-serif; font-weight: 900; letter-spacing: 0;
  font-size: 0.5em; -webkit-text-stroke: 0; margin-top: 2px;
}
.linkBtn {
  background: none; border: none; cursor: pointer;
  font-weight: 800; font-size: clamp(12px, 3.2vmin, 15px);
  color: #6b6880; text-decoration: underline; padding: 4px 8px;
}
.linkBtn:hover { color: var(--ink); }
.linkBtn:disabled { opacity: 0.4; cursor: default; }
#results.compact .panel { gap: 4px; padding: clamp(8px, 2vmin, 12px) clamp(12px, 3vmin, 20px); }
#results.compact #resEarned { font-size: clamp(30px, 10vmin, 52px); }
/* the two-line CLAIM is the tallest thing on the card — it gives first */
#results.compact #btnClaim { font-size: clamp(20px, 6vmin, 30px); padding-top: 4px; padding-bottom: 4px; }
#results.compact #multBar { height: clamp(28px, 7vmin, 40px); margin: 2px 0; }
#results.compact .resTitle { font-size: clamp(17px, 4.6vmin, 26px); }

/* ---------------- overlay panels (Cats, Stats) ---------------- */

.shopPanel {
  background: var(--paper);
  border: 4px solid var(--ink); border-radius: 20px;
  box-shadow: var(--shadow);
  width: min(100%, 720px);
  /* 100% of the overlay's content box, which already has the banner strip,
     the notch and the frame gutter subtracted — panel + ad always fit the
     visible viewport together, and the overflow scrolls inside the panel */
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(12px, 3vmin, 18px);
}
.shopHead {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: clamp(6px, 2vmin, 10px); margin-bottom: clamp(8px, 2.4vmin, 14px);
}
.shopTitle {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(20px, 6vmin, 34px); color: var(--ink);
  margin-right: auto;           /* title left, controls right, at any width */
}
.shopCoins {
  font-weight: 900; font-size: clamp(13px, 3.6vmin, 18px);
  background: var(--gold); border: 3px solid var(--ink);
  border-radius: 999px; padding: 5px 16px;
}
.btnBuy { font-size: 19px; padding: 6px 10px; margin-top: 4px; }

/* ---------------- lifetime stats ---------------- */

#statsOverlay {
  position: fixed;
  background: rgba(20, 18, 43, 0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
}
#statsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: clamp(8px, 2vmin, 12px);
}
.statCard {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  border: 3px solid var(--ink); border-radius: 14px;
  background: #fff; padding: 12px 14px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.18);
}
.statIc { font-size: 28px; line-height: 1; }
.statMeta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.statLabel { font-size: 12px; font-weight: 800; color: #5c5870; text-transform: uppercase; letter-spacing: 0.5px; }
.statVal { font-family: 'Bangers', Impact, sans-serif; font-size: 24px; color: var(--yeet); letter-spacing: 1px; line-height: 1; }
.statSub { font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 800; color: #6b6880; }

/* ---------------- toasts & hints ---------------- */

#toasts {
  position: fixed;
  top: calc(66px + var(--safe-t));
  left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 2 * var(--gutter));
  display: flex; flex-direction: column; gap: 8px;
  z-index: 50; pointer-events: none; align-items: center;
}
.toast {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(17px, 4.6vmin, 24px); letter-spacing: 1px;
  text-align: center;
  color: var(--ink); background: var(--gold);
  border: 3px solid var(--ink); border-radius: 999px;
  padding: 6px 22px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  animation: toastIn 0.25s ease-out;
}
.toast.out { opacity: 0; transform: translateY(-12px); transition: all 0.4s; }
@keyframes toastIn { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#hint {
  position: fixed;
  /* was 9% — a share of a tall portrait frame put this on top of the
     cannon, and on a short one it landed under the banner */
  bottom: calc(14px + var(--safe-b) + var(--banner-h));
  left: 50%; transform: translateX(-50%) rotate(-1deg);
  max-width: calc(100% - 2 * var(--gutter) - var(--safe-l) - var(--safe-r));
  font-weight: 900; font-size: clamp(13px, 3.6vmin, 17px);
  color: var(--paper); background: rgba(20, 18, 43, 0.85);
  border-radius: 999px; padding: 8px 22px;
  z-index: 25; pointer-events: none;
  animation: hintBob 1.4s ease-in-out infinite;
  text-align: center;
}
@keyframes hintBob { 0%, 100% { transform: translateX(-50%) translateY(0) rotate(-1deg); } 50% { transform: translateX(-50%) translateY(-6px) rotate(1deg); } }

/* ---------------- ad placeholder ---------------- */

#adOverlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bangers', Impact, sans-serif;
  font-size: 34px; color: var(--gold); letter-spacing: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #hudCombo, #resNew, #hint, #launchHint, .sideMode, #btnBox.ready .sideIco { animation: none; }
  #machBanner.show #machTitle, #machBanner.show #machSub { animation-duration: 0.01s; animation-fill-mode: none; }
  #machFlash.pop { animation: none; }
}

/* ---------------- tutorial (step-by-step) ---------------- */

#tutorial {
  position: fixed;
  background: rgba(20, 18, 43, 0.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.tutPanel {
  position: relative;
  background: var(--paper);
  border: 4px solid var(--ink); border-radius: 22px;
  box-shadow: var(--shadow);
  width: min(100%, 460px);
  padding: clamp(14px, 3.6vmin, 22px) clamp(14px, 3.6vmin, 22px) clamp(12px, 3vmin, 18px);
  transform: rotate(-0.5deg);
  text-align: center;
}
.tutSkip {
  position: absolute; top: 10px; right: 12px; z-index: 2;
  background: none; border: none; cursor: pointer;
  font-weight: 800; font-size: 13px; color: #9a96aa;
}
.tutSkip:hover { color: var(--ink); }
.tutStep { font-weight: 900; font-size: 13px; color: var(--yeet); letter-spacing: 1px; }
.tutTitle {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: clamp(26px, 8vmin, 54px);
  color: var(--yeet);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 4px 4px 0 var(--ink);
  letter-spacing: 2px; line-height: 1; margin: 2px 0 clamp(6px, 2.4vmin, 12px);
}
.tutStage {
  width: 100%; height: clamp(96px, 22vh, 168px);
  background: linear-gradient(160deg, #eaf6ff, #fff7ea);
  border: 3px solid var(--ink); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.tutStage svg { width: 100%; height: 100%; display: block; }
.tutText {
  font-weight: 700; font-size: clamp(12.5px, 3.4vmin, 15.5px); color: var(--ink);
  line-height: 1.4; margin: clamp(8px, 2.4vmin, 14px) 4px 4px;
  min-height: 0;   /* reserving 64px was pure overflow on a short frame */
}
.tutText b { color: var(--yeet); }
.tutText .gz {
  background: var(--lime); border: 2px solid var(--ink);
  border-radius: 6px; padding: 0 5px; font-weight: 900; white-space: nowrap; color: var(--ink);
}
.tutDots { display: flex; gap: 8px; justify-content: center; margin: clamp(5px, 1.6vmin, 8px) 0 clamp(8px, 2.6vmin, 14px); }
.tutDots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: #d7d2c4; border: 2px solid var(--ink);
  transition: background 0.15s, transform 0.15s;
}
.tutDots span.on { background: var(--yeet); transform: scale(1.25); }
.tutNav {
  display: flex; gap: clamp(8px, 2.4vmin, 12px);
  justify-content: center; align-items: center; flex-wrap: wrap;
}
.tutNav .btn { font-size: clamp(16px, 4.4vmin, 22px); padding: clamp(7px, 2vmin, 9px) clamp(14px, 5vmin, 22px); }
.tutNav .btnBig { font-size: clamp(19px, 5.2vmin, 26px); }
.tutNav .btnGhost.hidden { display: none !important; }

/* little looping animations inside the illustrations */
@keyframes tutSwing { 0%,100% { transform: rotate(-26deg); } 50% { transform: rotate(10deg); } }
@keyframes tutMark  { 0%,100% { transform: translateY(36px); } 50% { transform: translateY(-30px); } }
@keyframes tutDive  { 0% { transform: translate(0,0); opacity:0; } 30% { opacity:1; } 100% { transform: translate(8px,46px); opacity:0; } }
@keyframes tutPop   { 0%,100% { transform: scale(0.9); } 50% { transform: scale(1.15); } }
@keyframes tutRise  { 0% { transform: translateY(6px); } 50% { transform: translateY(-6px); } 100% { transform: translateY(6px); } }
.swing { transform-box: fill-box; transform-origin: 12px 50px; animation: tutSwing 1.8s ease-in-out infinite; }
.mark  { animation: tutMark 1.6s ease-in-out infinite; }
.dive  { animation: tutDive 1.6s ease-in infinite; }
.pop   { transform-box: fill-box; transform-origin: center; animation: tutPop 0.9s ease-in-out infinite; }
.rise  { animation: tutRise 1.6s ease-in-out infinite; }
/* the YEET step's arrow swings the fan about the cannon's pivot (70,128) */
@keyframes tutFan { from { transform: rotate(-15deg); } to { transform: rotate(-75deg); } }
.fanSwing { transform-box: view-box; transform-origin: 70px 128px; animation: tutFan 0.9s ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) {
  .swing, .mark, .dive, .pop, .rise { animation: none; }
  .fanSwing { animation: none; transform: rotate(-45deg); }
}

/* ---------------- skins shop ---------------- */

#skinShop {
  position: fixed;
  background: rgba(20, 18, 43, 0.72);
  /* column: panel + banner slot below */
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  z-index: 45;
}
#skinGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr));
  gap: clamp(8px, 2vmin, 12px);
}
.skinCard {
  position: relative;
  min-width: 0;
  border: 3px solid var(--ink); border-radius: 14px;
  background: #fff; padding: clamp(6px, 2vmin, 10px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.18);
}
.skinCard.equipped { background: #fff7ec; border-color: var(--yeet); }
.skinPrev {
  width: clamp(56px, 18vmin, 88px);
  height: clamp(56px, 18vmin, 88px);
  background: radial-gradient(circle at 50% 40%, #eaf6ff, #fff7ea);
  border: 2px solid var(--ink); border-radius: 12px;
}
.skinName { font-family: 'Bangers', Impact, sans-serif; font-size: clamp(13px, 3.6vmin, 16px); letter-spacing: 0.5px; text-align: center; line-height: 1; }
.skinCard .btnBuy { font-size: 16px; padding: 5px 10px; width: 100%; }
.skinLock {
  position: absolute; top: 6px; right: 8px; font-size: 16px; opacity: 0.7;
}

/* ---------------- gift shake (the home screen's 🎁 when full) ---------------- */

@keyframes boxShake {
  0%, 100% { transform: rotate(-7deg) scale(1); }
  25% { transform: rotate(7deg) scale(1.08); }
  50% { transform: rotate(-5deg) scale(1.04); }
  75% { transform: rotate(5deg) scale(1.08); }
}

/* ---------------- skin reveal ---------------- */

#reveal {
  position: fixed; z-index: 70;
  overflow: hidden;   /* sunray discs are bigger than small phone screens */
  background: rgba(20, 18, 43, 0.85);
  display: flex; align-items: center; justify-content: center;
}
.revealPanel {
  background: var(--paper);
  border: 4px solid var(--ink); border-radius: 22px;
  box-shadow: var(--shadow);
  padding: clamp(14px, 3.6vmin, 22px) clamp(16px, 4.4vmin, 28px); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transform: rotate(-1deg);
}
.revealBurst { font-size: clamp(26px, 7vmin, 40px); animation: comboPulse 0.6s ease-in-out infinite alternate; }
.revealTitle {
  font-family: 'Bangers', Impact, sans-serif; font-size: clamp(20px, 5.6vmin, 30px);
  color: var(--yeet); -webkit-text-stroke: 1.5px var(--ink); letter-spacing: 1px;
}
#revealCanvas {
  /* the element is 180x180 of backing pixels; let CSS shrink the box */
  width: clamp(104px, 30vmin, 180px); height: clamp(104px, 30vmin, 180px);
  background: radial-gradient(circle at 50% 40%, #eaf6ff, #fff7ea);
  border: 3px solid var(--ink); border-radius: 16px;
}
.revealName { font-family: 'Bangers', Impact, sans-serif; font-size: clamp(17px, 4.6vmin, 24px); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .revealBurst { animation: none; }
}

/* ---------------- reveal VFX ---------------- */

.sunrays {
  position: absolute; inset: -60%;
  background: repeating-conic-gradient(from 0deg,
    rgba(255,210,80,0.38) 0deg 9deg, rgba(255,210,80,0) 9deg 18deg);
  border-radius: 50%;
  animation: sunspin 9s linear infinite;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle, #000 12%, transparent 70%);
          mask-image: radial-gradient(circle, #000 12%, transparent 70%);
}
@keyframes sunspin { to { transform: rotate(360deg); } }
.fxLayer { position: absolute; inset: 0; overflow: visible; pointer-events: none; z-index: 5; }
.confetti {
  position: absolute; top: -12px; width: 10px; height: 14px;
  opacity: 0; will-change: transform, opacity;
  animation: confFall linear forwards;
}
@keyframes confFall {
  0%   { opacity: 0; transform: translateY(-10px) rotate(0deg); }
  10%  { opacity: 1; }
  100% { opacity: 0.9; transform: translateY(var(--cd, 320px)) rotate(var(--cr, 540deg)); }
}

.revealStage { position: relative; display: flex; align-items: center; justify-content: center; padding: 10px; }
.revealStage .sunrays { inset: -30%; animation-duration: 12s; }
.revealStage #revealCanvas { position: relative; z-index: 2; }
#revealFx { z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  .sunrays, .confetti { animation: none; }
}

/* ----------------------------------------------------------------
   HOME  (#home) — the aim screen.

   The fan sweeps on the canvas BEHIND this layer, and the layer itself
   takes no clicks (pointer-events: none): a click on empty space falls
   through to the canvas, and that click is the launch. Only the panels
   take clicks. Upgrades down the left, everything else down the right,
   the launch hint in the middle — the layout of the genre.

   The left column's width is read back by UI.relayout() (sceneLeft) so the
   camera moves the cannon out from under it.
   ---------------------------------------------------------------- */
#home {
  position: fixed; inset: 0 auto auto 0;
  width: 100%; height: var(--app-h);
  z-index: 10;
  pointer-events: none;
  padding:
    calc(var(--gutter) + var(--safe-t))
    calc(var(--gutter) + var(--safe-r))
    calc(var(--gutter) + var(--safe-b) + var(--banner-h))
    calc(var(--gutter) + var(--safe-l));
  /* width tracks the SHORT side as well: the row type is sized in vmin, so a
     squarish window has big text and needs the column to match */
  --side-l: clamp(236px, max(33vw, 46vmin), 360px);
  --side-r: clamp(108px, 16vw, 186px);
  --row-gap: clamp(4px, 1.1vmin, 8px);
  display: grid;
  grid-template-columns: var(--side-l) minmax(0, 1fr) var(--side-r);
  /* row 1 is at least as tall as the corner buttons, so the right column
     always starts below them */
  grid-template-rows: minmax(clamp(38px, 10vmin, 46px), auto) minmax(0, 1fr);
  /* the hint takes the empty top-middle cell: below it is where the fan
     rises to, higher still when a banner lifts the scene */
  grid-template-areas:
    "top  hint ."
    "up   .    side";
  column-gap: clamp(8px, 2vmin, 16px);
  row-gap: var(--row-gap);
  overflow: hidden;
}
#home > * { pointer-events: auto; min-width: 0; }

#homeTop {
  grid-area: top;
  justify-self: start;         /* only as wide as its chips — never under the corner buttons */
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-weight: 900; font-size: clamp(13px, 3.4vmin, 17px);
}
#homeTop .statChip { padding: 4px 12px; }

/* ---- the upgrade sidebar ---- */
#upPanel {
  grid-area: up;
  align-self: start;
  max-height: 100%;
  display: flex; flex-direction: column; gap: var(--row-gap);
  min-height: 0;
}
#upList {
  display: flex; flex-direction: column; gap: var(--row-gap);
  min-height: 0;
  overflow-y: auto;            /* last resort only — fitHome() compacts first */
  overflow-x: visible;
  scrollbar-width: none;
  padding: 7px 7px 5px 0;      /* room for the badges and the hard shadows */
  margin: -7px -7px 0 0;       /* no negative bottom: that box would poke out of the panel and read as overflow */
}
#upList::-webkit-scrollbar { display: none; }

.upRow { display: flex; gap: 6px; align-items: stretch; }
.upBuy {
  --row: #FF5A5F;
  position: relative;
  flex: 1 1 auto; min-width: 0;
  /* name and price on the top line, what you have now across the whole
     second line — the long one gets the width */
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "ico name cost" "ico eff eff";
  align-items: center; column-gap: 6px; row-gap: 1px;
  padding: clamp(4px, 1vmin, 7px) clamp(6px, 1.4vmin, 10px);
  background: var(--row);
  border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  color: #fff; text-align: left;
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
}
.upBuy:hover { transform: translate(-1px, -1px); }
.upBuy:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(20,18,43,.85); }
/* one colour per upgrade, like the genre's rows */
.upRow:nth-child(6n+1) .upBuy { --row: #F2545B; }
.upRow:nth-child(6n+2) .upBuy { --row: #25A9E8; }
.upRow:nth-child(6n+3) .upBuy { --row: #4DBF55; }
.upRow:nth-child(6n+4) .upBuy { --row: #F59A23; }
.upRow:nth-child(6n+5) .upBuy { --row: #8E5CF0; }
.upRow:nth-child(6n+6) .upBuy { --row: #E0529C; }

.upIco {
  position: relative;
  font-size: clamp(20px, 5vmin, 28px); line-height: 1;
  filter: drop-shadow(2px 2px 0 rgba(20,18,43,.45));
}
.upLv {
  position: absolute; right: -8px; bottom: -6px;
  min-width: 18px; height: 18px; padding: 0 4px;
  font: 900 11px/15px 'Nunito', sans-serif; font-style: normal; text-align: center;
  color: var(--ink); background: #fff;
  border: 2px solid var(--ink); border-radius: 999px;
  filter: none;
}
.upMeta { display: contents; }
.upIco { grid-area: ico; }
.upName { grid-area: name; min-width: 0; line-height: 1.05; }
.upEff { grid-area: eff; min-width: 0; line-height: 1.1; }
.upCost { grid-area: cost; }
.upName {
  font-family: 'Bangers', Impact, sans-serif; font-weight: 400;
  font-size: clamp(13px, 3.4vmin, 20px); letter-spacing: 0.4px;
  -webkit-text-stroke: 0.6px var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upEff {
  font-weight: 800; font-size: clamp(10px, 2.5vmin, 12.5px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0.95;
}
.upCost {
  font-weight: 900; font-size: clamp(10px, 2.7vmin, 14px);
  background: rgba(20, 18, 43, 0.35);
  border-radius: 999px; padding: 2px 7px;
  white-space: nowrap;
}
.upBadge {
  position: absolute; top: -8px; right: -8px;
  min-width: 22px; height: 22px; padding: 0 5px;
  font: 900 12px/18px 'Nunito', sans-serif; text-align: center;
  color: #fff; background: #E0262C;
  border: 2px solid #fff; border-radius: 999px;
  box-shadow: 0 0 0 2px var(--ink);
}
.upAd {
  flex: 0 0 auto;
  width: clamp(44px, 11vmin, 58px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; line-height: 1;
  font-size: clamp(16px, 4vmin, 22px);
  background: var(--lime);
  border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  cursor: pointer;
}
.upAd small { font: 900 clamp(9px, 2.2vmin, 11px)/1.1 'Nunito', sans-serif; color: var(--ink); }
.upAd:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(20,18,43,.85); }

/* can't afford: the genre dims it; maxed: grey; locked by the week's challenge: faded */
.upRow.cant .upBuy { filter: saturate(0.3) brightness(0.9); }
.upRow.maxed .upBuy { --row: #8b8798; }
.upRow.locked .upBuy { --row: #8b8798; opacity: 0.6; cursor: not-allowed; }

/* ---- ascension, under the upgrades ---- */
#ascRow {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  padding: 4px 6px;
  margin-right: 7px;
}
#ascendBtn {
  flex: 0 0 auto;
  background: var(--yeet); color: #fff; -webkit-text-stroke: 0.6px var(--ink);
  font-size: clamp(14px, 3.6vmin, 19px);
  padding: 3px 10px; border-width: 3px; border-radius: 10px;
  box-shadow: 3px 3px 0 rgba(20,18,43,.85);
}
#ascendBtn.armed { background: #E0262C; animation: comboPulse 0.35s ease-in-out infinite alternate; }
#ascendInfo {
  flex: 1 1 auto; min-width: 0;
  font-weight: 800; font-size: clamp(10px, 2.5vmin, 12.5px); line-height: 1.15;
  color: var(--ink);
}

/* ---- the right column ---- */
#sidePanel {
  grid-area: side;
  align-self: start;
  max-height: 100%; min-height: 0;
  display: flex; flex-direction: column; gap: var(--row-gap);
  overflow: hidden;
  padding: 0 4px 4px 0;          /* the hard shadows */
}
.sideBtn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: clamp(4px, 1.2vmin, 8px) clamp(6px, 1.4vmin, 10px);
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  text-align: left; cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s;
}
.sideBtn:hover { transform: translate(-1px, -1px) rotate(-0.5deg); }
.sideBtn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(20,18,43,.85); }
.sideIco { font-size: clamp(20px, 5.4vmin, 30px); line-height: 1; flex: 0 0 auto; }
.sideTxt { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.sideTxt b {
  font-family: 'Bangers', Impact, sans-serif; font-weight: 400;
  font-size: clamp(14px, 3.8vmin, 21px); letter-spacing: 1px;
}
.sideTxt small { font-weight: 800; font-size: clamp(9px, 2.4vmin, 12px); color: #5c5870; }

/* "Compete on the leaderboards" — the call to click, so it is the loud one */
.sideMode { background: var(--gold); animation: sidePulse 1.6s ease-in-out infinite; }
.sideMode .sideTxt small { color: var(--ink); }
@keyframes sidePulse {
  0%, 100% { transform: rotate(-1deg) scale(1); }
  50%      { transform: rotate(1deg) scale(1.04); }
}
body.comp .sideMode { background: var(--paper); animation: none; }

#btnBox.ready { background: var(--lime); }
#btnBox.ready .sideIco { animation: boxShake 0.6s ease-in-out infinite; }

#sidePanel #compCard {
  max-width: none;
  padding: 6px 8px;
  box-shadow: 4px 4px 0 rgba(20,18,43,.85);
  border-width: 3px;
}
#sidePanel .compHead { font-size: clamp(15px, 3.8vmin, 20px); }
#sidePanel #compDesc { font-size: clamp(10px, 2.6vmin, 12.5px); }
#sidePanel #compLeft { font-size: clamp(9px, 2.4vmin, 11.5px); }

/* ---- the launch hint ---- */
#launchHint {
  grid-area: hint;
  align-self: center; justify-self: center;
  pointer-events: none !important;
  font-family: 'Bangers', Impact, sans-serif; letter-spacing: 2px;
  font-size: clamp(22px, 6vmin, 38px);
  color: #fff; -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
  text-align: center; white-space: nowrap;
  animation: hintFloat 1.3s ease-in-out infinite;
}
@keyframes hintFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---- competition: the same screen, violet ---- */
body.comp .upRow:nth-child(odd) .upBuy  { --row: #8E44FF; }
body.comp .upRow:nth-child(even) .upBuy { --row: #6A2BD0; }
body.comp .upRow.maxed .upBuy, body.comp .upRow.locked .upBuy { --row: #8b8798; }
body.comp .upAd { background: #d9c2ff; }

/* ---- a player's first visit: nothing but the fan and the hint ---- */
body.firstRun #homeTop, body.firstRun #upPanel, body.firstRun #sidePanel,
body.firstRun .cornerBtns { display: none !important; }
body.firstRun #launchHint {
  grid-area: 1 / 1 / 3 / 4;     /* the whole screen: it is the only thing on it */
  margin-top: clamp(40px, 16vh, 160px);
  font-size: clamp(30px, 8vmin, 52px);
}

/* ================================================================
   BREAKPOINTS — last in the file on purpose.
   These override base rules, so they have to come after ALL of them;
   sitting mid-file meant later sections (the skins grid, for one)
   silently won and the small-screen layout never applied.
   ================================================================ */

/* ----------------------------------------------------------------
   NARROW SCREENS (phones portrait, small Chromebook windows).
   Type and padding are already fluid (vmin clamps above), so what is
   left here is STRUCTURE — how many columns, what wraps, what borders
   get thinner. Re-declaring font sizes here would only override the
   clamps and undo the landscape half of the problem.
   ---------------------------------------------------------------- */
@media (max-width: 520px) {
  .btn { border-width: 3px; }
  #skinGrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 108px), 1fr)); }
  #statsGrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
}

/* very narrow (320px-class phones): fixed column counts beat auto-fill,
   which would otherwise drop to a single very tall column */
/* A narrow portrait frame cannot fit a centred toast AND the top-left HUD
   column on the same row — at 320px they collided. During a run the bottom
   of the screen is empty, so the toast stack moves down there, stacking
   upward just above the hint pill (which itself clears the banner). */
@media (max-width: 520px) {
  #toasts {
    top: auto;
    bottom: calc(22px + var(--hint-h, 0px) + var(--safe-b) + var(--banner-h));
    flex-direction: column-reverse;
  }
}

@media (max-width: 380px) {
  #statsGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #skinGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shopHead .shopTitle { width: 100%; margin-right: 0; }
}

/* ----------------------------------------------------------------
   SHORT + WIDE (phones held sideways, and the small landscape frames
   CrazyGames embeds on). A 360px-tall frame has no room for a stacked
   tutorial, so the illustration moves BESIDE the text instead of above
   it — the same content, re-flowed for the aspect ratio.
   ---------------------------------------------------------------- */
/* ----------------------------------------------------------------
   SHORT SCREENS — the results panel is centred when it fits and
   collapses to the top (fully scrollable, nothing clipped) when it
   doesn't, without relying on the `safe` keyword: flex-start plus
   auto-margin spacer pseudo-elements.
   ---------------------------------------------------------------- */
@media (max-height: 760px) {
  .screen {
    justify-content: flex-start;
    overflow-y: auto;
    gap: clamp(4px, 1.2vmin, 8px);
  }
  .screen::before, .screen::after { content: ""; margin: auto; flex: 0 0 0; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .tutPanel {
    width: min(100%, 700px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "step  step"
      "title title"
      "stage text"
      "dots  dots"
      "nav   nav";
    align-items: center;
    column-gap: clamp(10px, 2.6vmin, 18px);
  }
  .tutStep  { grid-area: step; }
  .tutTitle { grid-area: title; margin-bottom: 6px; }
  .tutStage { grid-area: stage; height: clamp(84px, 30vh, 150px); }
  .tutText  { grid-area: text; margin: 0 2px; text-align: left; }
  .tutDots  { grid-area: dots; margin: 8px 0 10px; }
  .tutNav   { grid-area: nav; }
}

/* The unlock celebration has the same problem as the tutorial on a short
   frame: stacked, it needs scrolling to reach its own button. Side by side,
   it fits — the cat portrait next to the name and the confirm. */
@media (orientation: landscape) and (max-height: 560px) {
  .revealPanel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "burst stage"
      "title stage"
      "name  stage"
      "close stage";
    align-items: center;
    justify-items: center;
    column-gap: clamp(12px, 3vmin, 22px);
    row-gap: 4px;
  }
  .revealBurst { grid-area: burst; }
  .revealTitle { grid-area: title; }
  .revealStage { grid-area: stage; padding: 0; }
  .revealName  { grid-area: name; }
  #revealClose { grid-area: close; margin-top: 6px; }
}

/* Landscape phones are wide enough for real columns even though they are
   short — auto-fill sizing off the panel width already handles that, but
   the skins grid gets an explicit floor so cards stay tappable. */
@media (orientation: landscape) and (max-height: 480px) {
  #skinGrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 100px), 1fr)); }
}

/* the canvas takes keyboard focus on every click (see Main.boot) — no ring for it */
#game:focus { outline: none; }

/* the purse pill in the shop holds a purple coin in Competition — no gold behind it */
body.comp .shopCoins { background: var(--lime); }

/* ----------------------------------------------------------------
   HOME THAT DOES NOT FIT  (#home.compact / .tight)
   UI.fitHome() measures the sidebars against the frame and steps down
   only when they really overflow: first tighter rows, then the effect
   lines and the ascension text go. Every row is still one tap.
   ---------------------------------------------------------------- */
#home.compact { --row-gap: 4px; }
#home.compact .upBuy { padding-top: 3px; padding-bottom: 3px; }
#home.compact .upIco { font-size: clamp(17px, 4.4vmin, 24px); }
#home.compact .sideBtn { padding-top: 3px; padding-bottom: 3px; }
#home.compact .sideTxt small { display: none; }
#home.compact #compDesc { display: none; }
#home.tight .upEff { display: none; }
#home.tight .upName { font-size: clamp(12px, 3.3vmin, 17px); }
#home.tight #ascendInfo { display: none; }
#home.tight #ascRow { padding: 2px 4px; }
#home.tight #ascendBtn { font-size: clamp(12px, 3.4vmin, 16px); padding: 2px 8px; white-space: nowrap; }
#home.tight .upLv { display: none; }

/* Still too tall on a short landscape frame (a phone on its side, doubly so
   with the banner up): six rows and Ascend do not fit one column. So the
   list takes the WHOLE left height, Ascend drops to the foot of the right
   column (which has room to spare), the coins move to the top-middle, and
   the launch hint goes — a returning player knows what the fan is. */
body:not(.tall) #home.tight {
  grid-template-rows: minmax(clamp(38px, 10vmin, 46px), auto) minmax(0, 1fr) auto;
  grid-template-areas:
    "list top  ."
    "list .    side"
    "list .    asc";
}
body:not(.tall) #home.tight #upPanel { display: contents; }
body:not(.tall) #home.tight #upList { grid-area: list; align-self: start; max-height: 100%; }
body:not(.tall) #home.tight #ascRow { grid-area: asc; align-self: end; justify-content: center; margin: 0 4px 4px 0; }
body:not(.tall) #home.tight #homeTop { justify-self: center; }
body:not(.tall) #home.tight #launchHint { display: none; }

/* ----------------------------------------------------------------
   TALL FRAMES  (body.tall, set by UI.relayout() when H > W)
   A portrait phone has no width for two sidebars beside the cannon, but
   it has sky to spare: the upgrades become a two-column grid across the
   top, the options a row beneath them, and the cannon keeps the bottom.
   One class decided in JS, so the camera and the CSS agree.
   ---------------------------------------------------------------- */
body.tall #home {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(clamp(38px, 10vmin, 46px), auto) auto auto auto minmax(0, 1fr);
  grid-template-areas: "top" "up" "side" "hint" ".";
}
body.tall #homeTop { max-width: calc(100% - 2 * clamp(38px, 10vmin, 46px) - 16px); }
/* two columns of short rows: name over price, no effect line — the sky
   between the grid and the cannon is where the fan has to show */
body.tall #upList { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
body.tall .upBuy { grid-template-areas: "ico name" "ico cost"; grid-template-columns: auto minmax(0, 1fr); }
body.tall .upCost { justify-self: start; padding: 1px 7px; }
body.tall .upEff { display: none; }
body.tall .upAd { width: clamp(34px, 9.4vmin, 44px); }
body.tall .upName { font-size: clamp(12px, 3.4vmin, 17px); }
body.tall #ascRow { margin-right: 0; }
body.tall #sidePanel { flex-direction: row; flex-wrap: wrap; overflow: visible; padding: 0; }
body.tall .sideBtn {
  flex: 1 1 0; min-width: 0;
  flex-direction: column; justify-content: center; gap: 2px;
  text-align: center;
}
body.tall .sideTxt { align-items: center; }
body.tall .sideTxt b { font-size: clamp(12px, 3.4vmin, 17px); }
body.tall .sideTxt small { display: none; }
body.tall #sidePanel #compCard { flex: 1 1 100%; }
body.tall #launchHint { margin-top: clamp(4px, 2vh, 20px); }
body.tall.firstRun #launchHint { grid-area: 1 / 1 / 6 / 2; margin-top: 30vh; }

