/* ═══════════════════════════════════════════════════════════
   MOO FACTORY — style.css (layout & structure)
   Pixel-art farm UI · mobile + desktop
   ═══════════════════════════════════════════════════════════ */

/* ── local pixel fonts (no external requests) ── */
@font-face {
  font-family: 'Press Start 2P';
  src: url('../assets/fonts/PressStart2P-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'VT323';
  src: url('../assets/fonts/VT323-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #f7ecd2;
  --cream-dark: #e8d5ab;
  --wood: #5b4326;
  --wood-dark: #3d2c17;
  --ink: #3a2c18;
  --ink-soft: #6b5638;
  --green: #58b04c;
  --green-dark: #3a7a34;
  --gold: #ffb733;
  --gold-dark: #c98514;
  --red: #d9534f;
  --red-dark: #a03a37;
  --sky: #8ecae6;
  --milk: #ffffff;
  --shadow: 0 4px 0 rgba(0,0,0,.35);
  --px-border: 3px solid var(--wood);
  --font-px: 'Press Start 2P', 'Courier New', monospace;
  --font-body: 'VT323', 'Courier New', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #1a3320;
  font-family: var(--font-body);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
}

canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

#game, #uifx {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: 1;
}
#uifx { z-index: 40; pointer-events: none; }

.hidden { display: none !important; }

/* ═══════════ SPLASH + TITLE SCREEN (live world behind) ═══════════ */
/* v1.8.26 CrazyGames QA #1.1 + #5 — RESERVED-BAND LAYOUT:
   The title screen is a flex COLUMN that centers the menu inside the
   space that is actually FREE: below the hanging sign zone
   (--title-sign-h) and above the banner's reserved band
   (--cg-banner-h, published live by crazygames.js; 0 when no banner).
   The menu therefore centers responsively at ANY viewport/aspect and
   can never slide under the banner or off-screen — no hard-coded
   pixel offsets. (Old layout: .title-inner was absolutely pinned at
   top:40% and grew downward — on short/mobile-landscape screens its
   menu rows and save chip landed underneath the fixed banner.) */
#titleScreen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  overflow: hidden;
  background: transparent;   /* the live game world shows through */
  padding-top: var(--title-sign-h, 240px);                                /* hanging sign zone (JS measures the live height) */
  /* v1.8.29: bottom reserve = banner band + icon dock (~70px) — the
     centered menu column can never collide with either. */
  padding-bottom: calc(var(--cg-banner-h, 0px) + 78px + env(safe-area-inset-bottom));
}/* soft vignette so UI text stays readable over the world.
   v1.8.29: added a gentle RADIAL scrim centered on the menu column —
   the living world stays visible (that's the charm) but recedes behind
   the save chip + hero PLAY button, so the menu reads first. */
.title-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 64% 48% at 50% 54%, rgba(15,22,10,.32) 0%, rgba(15,22,10,.14) 48%, rgba(15,22,10,0) 76%),
    linear-gradient(180deg, rgba(15,22,10,.42) 0%, rgba(15,22,10,0) 26%,
      rgba(15,22,10,0) 62%, rgba(15,22,10,.38) 100%);
}

/* ── splash veil: black → world ── */
#splashVeil {
  position: absolute; inset: 0; z-index: 30;
  background: #0c120a;
  animation: veilOut .9s ease-out .25s forwards;
  pointer-events: none;
}
@keyframes veilOut { from { opacity: 1; } to { opacity: 0; } }

/* ── studio card: SRAMYDEV presents ── */
#studioCard {
  position: absolute; z-index: 40; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: studioCycle 2.3s ease-in-out .45s forwards;
  opacity: 0; pointer-events: none;
}
.studio-ico { display: flex; }
.studio-ico .pix-ico { width: 64px; height: 64px; }
.studio-name {
  font-family: var(--font-px); font-size: clamp(18px, 4.6vw, 30px);
  color: #ffe28a; letter-spacing: 4px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.55);   /* v1.8.19 QA #9: tighter, crisper */
}
.studio-sub {
  font-family: var(--font-px); font-size: clamp(9px, 2vw, 13px);
  color: rgba(255,255,255,.82); letter-spacing: 6px;
  text-shadow: 2px 2px 0 rgba(0,0,0,.5);
}
@keyframes studioCycle {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.92); }
  14% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  72% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-52%) scale(1.04); }
}

/* v1.8.29 menu redesign (player reference layout): the inner column is
   now just the save chip + hero PLAY button — everything else moved to
   the bottom icon dock. Centered in the free space between the sign
   zone and the dock/banner reserve, so the button sits lower-center
   with generous negative space at ANY viewport. */
.title-inner {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 0 12px;
  width: min(92vw, 620px);
  z-index: 2;
  margin-top: -6px;   /* optical lift: the sign's weight sits above */
}

/* ── hanging wooden sign: anchored at the very top of the screen ── */
.title-sign-zone {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; justify-content: center;
  pointer-events: none;
}
.title-sign-wrap {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  transform-origin: 50% 0;
  animation: signDrop .85s cubic-bezier(.34,1.45,.5,1) 2.35s both,
             signSway 4.6s ease-in-out 3.3s infinite alternate;
}
@keyframes signDrop {
  0% { transform: translateY(-102%); }
  100% { transform: translateY(0); }
}
@keyframes signSway {
  0% { transform: rotate(-1.1deg); }
  100% { transform: rotate(1.1deg); }
}
/* v1.8.20 CrazyGames QA (rope continuity): the ropes used to butt
   EXACTLY against the board's top edge (height == margin-top) and the
   screen top (top: 0) — two butt joints with zero overlap. During the
   ±1.1° sway the subpixel rasterization of the separately-rendered
   rope/board elements opened a visible 1-2px gap (rope “too short”).
   Fix: overlap BOTH joints — every rope starts 12px ABOVE the viewport
   edge (clipped, can never detach from the screen top when rotated)
   and runs 20px PAST the board's top edge, tucked behind it (the board
   has z-index 2 over the ropes' z-index 1). Overlapped joints cannot
   separate at any rotation angle. */
.sign-rope {
  position: absolute; top: -12px; width: 7px; height: 98px;
  background:
    repeating-linear-gradient(180deg, #a8823f 0 5px, #7d5c28 5px 8px, #5f4520 8px 10px);
  border-left: 2px solid rgba(0,0,0,.28);
  border-right: 2px solid rgba(0,0,0,.28);
  z-index: 1;
}
.rope-l { left: 20px; }
.rope-r { right: 20px; }
.title-sign {
  position: relative; z-index: 2;
  margin-top: 78px;
  display: flex; flex-direction: column; align-items: center; line-height: 1;
  background: #8a6a42;
  background-image:
    repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, #97744d 0%, #8a6a42 30%, #7c5e39 100%);
  border: 5px solid #4a2f18;
  box-shadow:
    inset 0 4px 0 rgba(255,235,200,.22),
    inset 0 -5px 0 rgba(0,0,0,.3),
    0 8px 0 rgba(0,0,0,.32);
  padding: 18px 30px 15px 30px;
  min-width: min(320px, 80vw);
}
.sign-bolt {
  position: absolute; width: 7px; height: 7px; background: #c9ced6;
  box-shadow: 1px 1px 0 #6a7280, inset -1px -1px 0 #9aa0a6;
}
.bolt-tl { top: 5px; left: 6px; }
.bolt-tr { top: 5px; right: 6px; }
.bolt-bl { bottom: 5px; left: 6px; }
.bolt-br { bottom: 5px; right: 6px; }
.title-top {
  font-family: var(--font-px); font-size: clamp(40px, 10vw, 66px);
  color: #fff6df; letter-spacing: 10px; text-indent: 10px;
  /* v1.8.19 QA #9: single tight offset (was a fat 4px+6px double drop
     that smeared the letters). Crisp pixel offset, no second layer. */
  text-shadow: 3px 3px 0 #2e2412;
}
.title-bottom {
  font-family: var(--font-px); font-size: clamp(19px, 5vw, 32px);
  color: #ffe28a; letter-spacing: 5px; text-indent: 5px; margin-top: 10px;
  text-shadow: 2px 2px 0 #2e2412;
  display: inline-flex; align-items: center; gap: 12px;
}
.sign-cow { display: inline-flex; }
/* v2.2: cowHead is baked 32×32 native (scale 2, 16×16 map) — 32px slot
   = perfect 1:1 pixels (was 48×42 squeezed into 34px). */
.sign-cow img, .sign-cow canvas { width: 32px; height: 32px; image-rendering: pixelated; }

/* ── staggered menu entrance (v1.8.29: column + dock) ── */
.title-save, #btnStart, .title-dock {
  opacity: 0;
  animation: menuPop .5s cubic-bezier(.3,1.4,.5,1) forwards;
}
.title-save { animation-delay: 3.3s; }
#btnStart { animation-delay: 3.15s; }
.title-dock { animation-delay: 3.45s; }
@keyframes menuPop {
  0% { opacity: 0; transform: translateY(14px) scale(.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── v2.3 PLAY press → menu exit choreography ──
   Plays under the pixel-tile transition veil (js/transition.js):
   the sign swings up out of frame, the menu column pops down and
   the dock drops away — everything has left the stage by the time
   the veil fully covers the screen (~430ms after the press). */
#titleScreen.menu-exit .title-sign-wrap {
  animation: signExitUp .34s cubic-bezier(.5,-.3,.75,.4) forwards;
}
#titleScreen.menu-exit .title-inner > *,
#titleScreen.menu-exit .title-dock {
  animation: menuOutDown .3s ease-in forwards;
}
@keyframes signExitUp {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-56px) rotate(-2.5deg); opacity: 0; }
}
@keyframes menuOutDown {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(12px) scale(.94); opacity: 0; }
}

/* ═══ v1.8.29 BOTTOM ICON DOCK ═══
   Player-requested layout ("simple clean, all buttons in one place"):
   a full-width dark wood strip pinned above the reserved banner band —
   the same idea as the reference screenshot's footer bar. Every
   secondary action (help / credits / sound / privacy / new game) is an
   icon-only button in ONE place, so the screen above stays empty
   except for the hero PLAY button. --cg-banner-h is published live by
   crazygames.js (0 when no banner), so the dock re-anchors itself the
   moment a banner mounts, resizes or unmounts — it can never sit on
   top of the ad. */
.title-dock {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--cg-banner-h, 0px) + 8px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  display: flex; align-items: stretch; justify-content: center;
  gap: clamp(8px, 2.6vw, 20px);
  padding: 9px 12px;
  background: linear-gradient(180deg, #4a3620 0%, #3a2a16 55%, #31230f 100%);
  border-top: 3px solid #241708;
  border-bottom: 3px solid #241708;
  box-shadow:
    inset 0 2px 0 rgba(255,226,138,.14),
    0 -4px 12px rgba(0,0,0,.28);
}
.dock-btn {
  width: clamp(48px, 12vw, 58px); height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,246,222,.07);
  border: 2px solid rgba(255,246,222,.18);
  cursor: pointer;
  padding: 0;
  transition: background .12s, transform .06s;
}
.dock-btn:hover { background: rgba(255,246,222,.17); }
.dock-btn:active { transform: translateY(2px); background: rgba(255,246,222,.24); }
.dock-btn .dock-ico { display: inline-flex; }
.dock-btn .dock-ico .pix-ico { width: 26px; height: 26px; }
/* v3.1.0: the SPEEDRUN LEADERBOARD trophy — a warm gold frame so it
   reads as the race button, not just another utility. The glint
   lights up once at least one finished run is on the board
   (has-runs, set by refreshTitleMenu from the live records).
   v3.1.1: with the dock's stopwatch shortcut removed, this is the
   dock's ONE speedrun button (history only — runs still start
   behind PLAY → the hanging SPEEDRUN sign). */
.dock-btn-lb { position: relative; border-color: rgba(255, 184, 51, .55); }
.dock-btn-lb:hover { background: rgba(255, 184, 51, .16); }
.dock-btn-lb.has-runs { border-color: rgba(255, 184, 51, .95); }
.dock-btn-lb.has-runs::after {
  content: ''; position: absolute; right: 3px; top: 3px;
  width: 8px; height: 8px;
  background: var(--gold);
  box-shadow: 1px 1px 0 rgba(0,0,0,.4);
  animation: chipPulse 1.4s steps(2) infinite;
}
/* (the v2.9.0 .dock-btn-sr stopwatch rules retired in v3.1.1 — the
   button itself is gone from the dock) */

/* version tag lives INSIDE the dock bar (far right, dimmed) — it rides
   the dock's banner-aware anchoring automatically. Hidden on narrow
   screens where the five icons need the full bar width. */
.title-ver {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-px); font-size: 8px; color: rgba(255,246,222,.55);
  text-shadow: 1px 1px 0 rgba(0,0,0,.4);
  pointer-events: none;
}
@media (max-width: 520px) { .title-ver { display: none; } }

/* play-button icon (v1.8.29: only remaining .btn-ico user — the menu
   row buttons became icon-only dock buttons above) */
.btn-ico {
  display: inline-flex; width: 20px; height: 20px; flex: 0 0 auto;
}
.btn-ico .pix-ico, .btn-ico.pix-ico { width: 20px; height: 20px; }

/* big wooden PLAY button */
/* v1.8.21 CrazyGames QA (shadow readability): #btnStart carries BOTH
   .btn (ui.css base: flat cream bg + dark ink text) and .btn-play (this
   rule: wood gradient + cream text). ui.css loads AFTER style.css, so at
   equal specificity .btn silently won background/color/border/padding/
   font-size — flattening the hero CTA into a small cream chip with DARK
   text, while .btn-play's dark 2px hard shadow (designed to sit under
   CREAM-on-WOOD text) still applied. Dark text + dark hard offset on a
   light cream background = the unreadable double-image QA reported.
   Fix: compound selector .btn.btn-play (0,2,0) beats .btn (0,1,0)
   regardless of stylesheet order, so the button renders as designed:
   light cream text on wood with a crisp dark pixel rim — the shadow now
   separates instead of smearing. Wood gradient also deepened ~8%
   luminance so the text band clears 5:1 contrast (was 4.0:1 at the old
   top stop). */
.btn.btn-play {
  display: inline-flex; align-items: center; gap: 12px;
  /* v1.8.29 hero CTA: the menu's ONE focus point — noticeably larger,
     fluid clamp so it stays proportional on every device without the
     old per-breakpoint font-size jumps. */
  font-family: var(--font-px); font-size: clamp(13px, 2.4vw, 18px); letter-spacing: 2px;
  color: #fff6df;
  /* crisp pixel shadow under LIGHT text — separates, never smears */
  text-shadow: 2px 2px 0 #3a2612;
  background: linear-gradient(180deg, #8f6c43 0%, #7f5e36 45%, #6a4c28 100%);
  border: 4px solid #4a2f18;
  box-shadow:
    inset 0 3px 0 rgba(255,235,200,.25),
    inset 0 -4px 0 rgba(0,0,0,.35),
    0 6px 0 #3a2612, 0 9px 14px rgba(0,0,0,.38);
  padding: clamp(14px, 2.4vh, 18px) clamp(26px, 5.4vw, 44px);
  cursor: pointer;
}
.btn.btn-play:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 3px 0 rgba(255,235,200,.25),
    inset 0 -4px 0 rgba(0,0,0,.35),
    0 2px 0 #3a2612, 0 4px 8px rgba(0,0,0,.35);
}
#btnStart .btn-ico { width: 20px; height: 20px; }
#btnStart .btn-ico .pix-ico, #btnStart .btn-ico.pix-ico { width: 20px; height: 20px; }

/* v1.8.29: returning-player chip — small + translucent dark so it reads
   as context ABOVE the hero button instead of competing with it (the
   old cream+gold chip was the loudest element on the screen). */
.title-save {
  font-size: 17px; color: rgba(255, 238, 203, .94); letter-spacing: .5px;
  /* v2.2: opacity up a touch (.62 → .74) — the chip now floats over the
     painted TitleBG scene rather than the live world, and the darker
     backing keeps the save summary crisp against the bright meadow.
     v3.3.0: reads as a game chip instead of debug text — double pixel
     border (gold hairline inside the dark rail) + a touch more
     breathing room. */
  background: rgba(30, 20, 9, .78);
  border: 2px solid rgba(255, 226, 138, .38);
  box-shadow: inset 0 0 0 2px rgba(30, 20, 9, .78), inset 0 2px 0 rgba(255, 235, 200, .12);
  padding: 4px 15px;
  text-shadow: 1px 1px 0 rgba(0,0,0,.55);
}

/* fast-forward state: skip all splash animations */
#titleScreen.splash-skip #splashVeil { animation: none; opacity: 0; }
#titleScreen.splash-skip #studioCard { animation: none; opacity: 0; }
#titleScreen.splash-skip .title-sign-wrap { animation: none; }
#titleScreen.splash-skip #btnStart,
#titleScreen.splash-skip .title-save,
#titleScreen.splash-skip .title-dock { animation: none; opacity: 1; }

/* menu buttons are not clickable until the splash finishes (or is skipped) */
#titleScreen:not(.menu-live):not(.splash-skip) .title-inner,
#titleScreen:not(.menu-live):not(.splash-skip) .title-dock { pointer-events: none; }

/* v3.0.0 THE SIGN SWAP — v3.0.3 layout note
   Pressing PLAY is a little rigging scene now: the MOO FACTORY board
   is WINCHED UP out of frame (ropes and all), and two hanging mode
   signs are LOWERED DOWN on their own ropes into the CENTER of the
   screen — plain signs only, no gate or frame around them. The menu
   column steps aside, the question sits beneath the signs (clear of
   every rope), and a small NOT YET chip brings everything back.
   State driver: .mode-stage on #titleScreen (main.js). */
#titleScreen.mode-stage .title-sign-zone .title-sign-wrap {
  animation: signPullUp .5s cubic-bezier(.6,-.28,.74,.4) forwards;
}
@keyframes signPullUp {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  18%  { transform: translateY(7px) rotate(.7deg); opacity: 1; }   /* the yank takes up the slack */
  100% { transform: translateY(-130%) rotate(-3.5deg); opacity: 0; }
}
/* leaving the stage: the factory board re-drops straight away (the
   original entrance animations carry 2.3s+ splash delays — replaying
   them would hang the menu; .sign-redrop swaps in the same moves with
   zero delay and restores the wrap's opacity, which signPullUp's fill
   left at 0). Stays on until the next mode-stage entry overrules it. */
#titleScreen.sign-redrop .title-sign-zone .title-sign-wrap {
  opacity: 1;
  animation: signDrop .7s cubic-bezier(.3,1.3,.45,1) 0s both,
             signSway 4.6s ease-in-out .8s infinite alternate;
}
#titleScreen.sign-redrop .title-save,
#titleScreen.sign-redrop #btnStart,
#titleScreen.sign-redrop .title-dock {
  animation: menuPop .4s cubic-bezier(.3,1.4,.5,1) 0s forwards;
}

/* ── the mode-sign stage itself ──
   v3.0.3: the boards lead the cluster — the question rides UNDER the
   signs, where no rope can ever cross it (ropes only run above boards).
   A touch of top padding biases the pair back toward true screen center
   so the trailing question + NOT YET chip don't drag the boards high. */
#modeZone {
  position: absolute; inset: 0; z-index: 6;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(20px, 5vh, 44px);
  padding-top: clamp(0px, 13vh, 110px);
  pointer-events: none;   /* the zone never blocks the dock below — children re-enable */
}
#titleScreen.mode-stage #modeZone { display: flex; }

/* the question label — v3.3.0: it sits on a quiet caption plaque now
   (dark wood rail, gold pinline) so the line between the hanging
   signs reads as part of the scene instead of floating text over
   the meadow. Still centered, still screen-centered signs above. */
.mode-label {
  font-family: var(--font-px);
  font-size: clamp(10px, 2.2vw, 14px);
  color: #fff6df; letter-spacing: 3px; text-indent: 3px;
  text-shadow: 2px 2px 0 rgba(20,14,4,.75);
  background: rgba(30, 22, 10, .66);
  border: 2px solid rgba(255, 226, 138, .38);
  box-shadow: inset 0 2px 0 rgba(255,235,200,.10);
  padding: 7px 14px 6px 14px;
  opacity: 0;
  animation: msFadeInUp .5s ease-out 1.1s forwards;
}
@keyframes msFadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes msFadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* the two signs, side by side (stacked on phones — tier below) */
.mode-signs {
  display: flex; align-items: flex-start; justify-content: center;
  gap: clamp(18px, 4.5vw, 46px);
}
/* v3.4.0: the trio variant (farm + speedrun + the CRAZYGAMES
   LEADERBOARDS weekly sign) — tighter gaps and slightly slimmer
   boards so all three hang side by side down to ~640px viewports,
   no clipping. Phones still stack them (tier below).
   v3.5.9 "THE WEEKLY PAUSE": DORMANT — the trio class is off the
   DOM and the weekly sign is removed from index.html; these rules
   (and every #modeSignWeekly rule below) sleep until the race
   returns. The base two-sign layout above is active again. */
.mode-signs.trio { gap: clamp(12px, 3vw, 46px); }
.mode-signs.trio .ms-board { width: clamp(210px, 26vw, 300px); }
.mode-sign-btn {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 0; margin: 0; border: 0; background: none;
  font: inherit; color: inherit; cursor: pointer;
  pointer-events: auto;
  /* lowered in from above — staggered, farm first (the menu-exit wipe
     covers the odd case where both states collide) */
  animation: msDrop .7s cubic-bezier(.3,1.32,.44,1) both;
}
/* stacked (phones): the upper sign's board paints over the lower
   sign's ropes as they pass behind it */
#modeSignFarm { z-index: 2; animation-delay: .12s; }
#modeSignSpeedrun { animation-delay: .26s; }
#modeSignWeekly { animation-delay: .40s; }   /* v3.4.0: the third rope drops last */
@keyframes msDrop {
  0%   { transform: translateY(-75vh); }
  100% { transform: translateY(0); }
}
.mode-sign-btn:focus-visible { outline: 3px dashed rgba(255,226,138,.9); outline-offset: 6px; }

/* the rig: ropes + board sway together around the screen-top anchor */
.ms-rig {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  transform-origin: 50% 0;
  animation: msSway 5.4s ease-in-out 1.15s infinite alternate;
}
@keyframes msSway {
  0%  { transform: rotate(-.85deg); }
  100% { transform: rotate(.85deg); }
}
/* the ropes run up past the top of the viewport (the sign was lowered
  from the fly loft) and tuck 26px behind the board's top edge — the
  same overlapped-joint trick the factory sign uses, so sway can never
  open a gap. #titleScreen clips whatever runs off-screen. */
.ms-rope {
  position: absolute; top: -68vh; width: 7px; height: calc(68vh + 26px);
  background:
    repeating-linear-gradient(180deg, #a8823f 0 5px, #7d5c28 5px 8px, #5f4520 8px 10px);
  border-left: 2px solid rgba(0,0,0,.28);
  border-right: 2px solid rgba(0,0,0,.28);
  z-index: 1;
}
.mode-sign-btn .rope-l { left: 22px; }
.mode-sign-btn .rope-r { right: 22px; }

/* the board — same wooden family as the factory sign, with a painted
  accent rail along the bottom edge (green = farm, gold = speedrun) */
.ms-board {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  width: clamp(238px, 30vw, 300px);
  background: #8a6a42;
  background-image:
    repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, #97744d 0%, #8a6a42 30%, #7c5e39 100%);
  border: 5px solid #4a2f18;
  box-shadow:
    inset 0 4px 0 rgba(255,235,200,.22),
    inset 0 -5px 0 rgba(0,0,0,.3),
    0 8px 0 rgba(0,0,0,.32);
  padding: 16px 16px 13px 16px;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.ms-board::after {   /* the painted accent rail */
  content: ''; position: absolute; left: 8px; right: 8px; bottom: 6px;
  height: 4px; background: var(--green);
  box-shadow: 0 1px 0 rgba(0,0,0,.35);
}
#modeSignSpeedrun .ms-board::after { background: var(--gold); }
#modeSignWeekly .ms-board::after { background: #9b6fd0; }   /* v3.4.0: the weekly race's grape rail */
.ms-head {
  display: flex; align-items: center; gap: 10px;
}
.ms-ico { display: inline-flex; }
.ms-ico .pix-ico { width: 30px; height: 30px; }
.ms-name {
  font-family: var(--font-px);
  font-size: clamp(10px, 1.6vw, 13px);
  color: #fff6df; letter-spacing: 1px; line-height: 1.35;
  text-shadow: 2px 2px 0 #2e2412;
}
.ms-sub {
  font-family: var(--font-body);
  font-size: clamp(15px, 1.9vw, 18px);
  color: #ffe9c4; line-height: 1.2; margin-top: 8px;
  text-shadow: 1px 1px 0 rgba(0,0,0,.5);
  min-height: 2.3em;   /* both boards keep equal height even with one-line subs */
}
.ms-sub b { font-weight: 400; color: #ffe28a; }   /* VT323 faux-bold → gold normal */
.ms-chip {
  font-family: var(--font-px); font-size: 8px;
  color: #fff; background: var(--green); border: 2px solid var(--green-dark);
  padding: 4px 10px 3px; margin-top: 9px;
  text-shadow: 1px 1px 0 rgba(0,0,0,.4);
}
.ms-chip.gold { background: var(--gold); border-color: var(--gold-dark); color: #5b3a00; text-shadow: none; }

/* hover = a hand steadying the board: it lifts a touch and brightens */
.mode-sign-btn:hover .ms-board,
.mode-sign-btn:focus-visible .ms-board {
  transform: translateY(-5px);
  box-shadow:
    inset 0 4px 0 rgba(255,235,200,.3),
    inset 0 -5px 0 rgba(0,0,0,.3),
    0 12px 0 rgba(0,0,0,.34);
  filter: brightness(1.07);
}
#modeSignFarm:hover .ms-board { border-color: #2f5a2c; }
#modeSignSpeedrun:hover .ms-board { border-color: #8a5e12; }
#modeSignWeekly:hover .ms-board { border-color: #6b4a99; }   /* v3.4.0 */
.mode-sign-btn:active .ms-board { transform: translateY(1px); filter: brightness(1.02); }

/* NOT YET — v3.3.0: a proper chunky chip (was a small afterthought
   button parked low); comfortable to hit, same wooden family. */
#modeBack {
  pointer-events: auto;
  font-family: var(--font-px); font-size: 9px; letter-spacing: 1px;
  color: #fff6df; text-shadow: 1px 1px 0 rgba(0,0,0,.5);
  background: linear-gradient(180deg, #4a3620 0%, #3a2a16 100%);
  border: 3px solid #241708;
  box-shadow: inset 0 2px 0 rgba(255,226,138,.14), 0 3px 0 rgba(0,0,0,.3);
  padding: 9px 18px 8px 18px; cursor: pointer;
  opacity: 0;
  animation: msFadeIn .5s ease-out 1.15s forwards;
  transition: background .12s, transform .06s;
}
#modeBack:hover { background: linear-gradient(180deg, #57411f 0%, #43301a 100%); }
#modeBack:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255,226,138,.14), 0 1px 0 rgba(0,0,0,.3); }

/* during the stage the menu column leaves (msOut fills to opacity 0 —
  pointer-events off so the faded column can't eat taps) and the dock
  dims but stays usable (sound toggle etc.). The #btnStart selector is
  spelled out so it beats the splash-skip rule that also names the id. */
#titleScreen.mode-stage .title-inner > *,
#titleScreen.mode-stage .title-inner > #btnStart {
  animation: msOut .28s ease-in forwards;
  pointer-events: none !important;
}
@keyframes msOut {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(10px) scale(.95); }
}
#titleScreen.mode-stage .title-dock { filter: brightness(.72) saturate(.85); }
.title-dock { transition: filter .3s ease; }
/* the wipe exit (farm sign) hides the rigging outright */
#titleScreen.menu-exit #modeZone { display: none; }

/* ── mode-sign responsive tiers ── */
@media (max-width: 620px) {
  /* phones: the signs stack — each board stays centered, ropes still
     run off-screen top; cluster fits any phone screen ≥ 560px tall */
  .mode-signs { flex-direction: column; gap: 18px; }
  /* v3.4.1 rope-overlap fix: the stacked trio needs a strictly
     DESCENDING z-order so every board paints over the ropes of the
     signs below it. The old two-sign ladder only elevated the farm
     sign (#modeSignFarm z-2); the weekly rig — later in the DOM at
     equal z-index — drew its ropes right over the SPEEDRUN board's
     edges. On desktop the signs hang side by side and never cross,
     so the ladder lives safely inside this phone tier. */
  #modeSignFarm { z-index: 4; }
  #modeSignSpeedrun { z-index: 3; }
  #modeSignWeekly { z-index: 2; }
  .ms-board { width: min(320px, 88vw); }
  .ms-sub { min-height: 0; }
  .mode-label { font-size: 10px; letter-spacing: 2px; }
  #modeZone { gap: 18px; padding-top: clamp(0px, 6vh, 54px); }
}
@media (max-height: 560px) and (orientation: landscape) {
  /* short landscape: side by side with compact boards, short drop */
  .mode-signs { gap: 14px; }
  .ms-board { width: clamp(196px, 34vw, 250px); padding: 10px 12px 9px 12px; }
  /* v3.4.0: three signs in short landscape — slimmer boards so the
     trio still fits a 700px-wide phone sideways */
  .mode-signs.trio .ms-board { width: clamp(170px, 28vw, 230px); }
  .ms-sub { font-size: 14px; margin-top: 5px; min-height: 0; }
  .ms-ico .pix-ico { width: 24px; height: 24px; }
  .ms-chip { margin-top: 6px; }
  #modeZone { gap: 12px; padding-top: clamp(0px, 5vh, 28px); }
  .mode-label { font-size: 9px; }
  .mode-sign-btn { animation-duration: .55s; }
}

/* ── mobile: tighter vertical rhythm ── */
@media (max-width: 560px) {
  .title-sign { padding: 13px 18px 11px 18px; }
  .sign-rope { height: 78px; }   /* 58 visible + 20 tucked behind the board */
  .title-sign { margin-top: 58px; }
  .rope-l { left: 14px; }
  .rope-r { right: 14px; }
  .title-inner { gap: 10px; }
  .btn.btn-play { font-size: clamp(12px, 3.4vw, 14px); letter-spacing: 1px; }
  .title-save { font-size: 16px; padding: 2px 12px; }
  .title-dock { padding: 7px 10px; }
  .dock-btn { height: 46px; }
}
/* ── short viewports: compact sign + dock (touch targets stay ≥40px;
     the sign band is MEASURED by ui.js so the reserved space always
     matches the real sign — these tiers just make it smaller) ── */
@media (max-height: 620px) {
  .title-inner { gap: 8px; margin-top: -4px; }
  #titleScreen { padding-bottom: calc(var(--cg-banner-h, 0px) + 68px + env(safe-area-inset-bottom)); }
}
@media (max-height: 520px) {
  .sign-rope { height: 60px; }   /* 40 visible + 20 tucked behind the board */
  .title-sign { margin-top: 40px; padding: 9px 16px 8px 16px; }
  /* compact dock: thinner bar + buttons, icons stay legible at 22px */
  .title-dock { padding: 5px 10px; }
  .dock-btn { height: 40px; }
  .dock-btn .dock-ico .pix-ico { width: 22px; height: 22px; }
  #titleScreen { padding-bottom: calc(var(--cg-banner-h, 0px) + 56px + env(safe-area-inset-bottom)); }
}
@media (max-height: 440px) {
  .sign-rope { height: 36px; }    /* 16 visible + 20 tucked behind the board */
  .title-sign { margin-top: 20px; padding: 6px 12px 5px 12px; }
  .title-top { font-size: clamp(24px, 4.4vw, 40px); letter-spacing: 6px; text-indent: 6px; }
  .title-bottom { font-size: clamp(12px, 2.4vw, 20px); margin-top: 5px; gap: 8px; }
  .sign-cow img, .sign-cow canvas { width: 22px; height: 22px; }
  .title-inner { gap: 6px; margin-top: -2px; }
  .btn.btn-play { font-size: 11px; letter-spacing: 1px; padding: 9px 16px; gap: 7px; }
  #btnStart .btn-ico, #btnStart .btn-ico .pix-ico, #btnStart .btn-ico.pix-ico { width: 14px; height: 14px; }
  .title-save { font-size: 14px; padding: 2px 10px; }
  #titleScreen { padding-bottom: calc(var(--cg-banner-h, 0px) + 52px + env(safe-area-inset-bottom)); }
}
@media (max-height: 400px) {
  /* extreme short landscape: the save chip yields its room FIRST (same
     policy the old tagline had) — the hero button keeps its breathing
     room; "CONTINUE FARMING" on the button is enough context. */
  .title-save { display: none; }
}
@media (max-height: 380px) {
  .title-inner { gap: 3px; }
  .title-save { font-size: 12px; padding: 1px 8px; }
  .title-dock { padding: 4px 10px; }
  .dock-btn { height: 36px; }
  .dock-btn .dock-ico .pix-ico { width: 20px; height: 20px; }
  #titleScreen { padding-bottom: calc(var(--cg-banner-h, 0px) + 48px + env(safe-area-inset-bottom)); }
}

/* ═══════════ HUD ═══════════ */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 50; pointer-events: none;
  padding: calc(8px + env(safe-area-inset-top)) 10px 0 10px;
  display: flex; flex-direction: column; gap: 4px;   /* v1.8.26 QA #6: one tight top strip — objective sits right under the chips */
}
#hudTop { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.hud-left { display: flex; flex-wrap: wrap; gap: 6px; max-width: 72%; pointer-events: auto; }

/* v1.8.19 QA #4: the right stack is a flex column whose children each
   right-align and size to their OWN content. SELL is anchored to the
   upper-right corner by the flex layout itself; the AD BOOST button
   below it cannot stretch, shift or otherwise influence SELL's rect —
   its visibility, state text or width changes only ever move its OWN
   left edge. (Old bug: .cg-boost was width:100% of this container, so
   the container width followed the boost label and dragged SELL with
   it.) */
.hud-right {
  pointer-events: auto;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  max-width: 40%;
}

#hudSecond {
  /* v2.4.6 player QA round 2 ("I want it on top, not under the coins /
     sell button / per-sec chips"): the objective strip now rides IN the
     top row itself — vertically centered on the resource-chip band and
     horizontally centered on the SCREEN (the player's red-rect spec),
     clamped so it can never touch the chips on the left or the
     SELL/AD-BOOST stack on the right.
     v2.4.5 had it one full row LOWER (under the chips) and the player
     rejected that placement twice — the objective must be LEVEL with
     the money/milk/per-sec chips.
       --quest-top   = vertical center of the chip band   (JS: measureNotifZones)
       --quest-left  = strip left edge  (screen-centered, clamped off the chips)
       --quest-right = strip right edge (clear of the SELL/boost stack)
     Fallbacks (9px / 10px / 10px) apply only before the first JS
     measurement. Phones (< 260px free width) keep the v2.4.5
     below-stack full-width band — see ui.js MIN_SIDEW. */
  position: absolute; top: var(--quest-top, 9px);
  left: var(--quest-left, 10px); right: var(--quest-right, 10px);
  display: flex; flex-direction: column; gap: 5px; align-items: center;
  pointer-events: none;   /* the world must stay clickable through the band */
}
#hudSecond > * { max-width: 100%; }   /* nothing in the strip may overflow its measured zone */

.chip {
  /* v1.8.28 "calm HUD": one unified translucent-dark chip family.
     The old cream chips + 3px wood borders + hard offset shadows fought
     the (already dark) quest banner and each other — a top strip of five
     competing frames read as visual noise over the bright world. The
     whole top band now speaks ONE language: dark glass, thin 2px
     accent borders, no hard shadows (soft 2px lift only). Readability
     over any world pixel improves too (white-on-dark > ink-on-cream). */
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(28, 38, 22, .78);
  border: 2px solid rgba(255, 226, 138, .28);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  padding: 6px 10px;
  font-family: var(--font-px);
  font-size: 12px;
  line-height: 1;
  color: #fff6df;
}
.chip-icon { width: 20px; height: 20px; display: inline-block; image-rendering: pixelated; background-size: contain; background-repeat: no-repeat; }
.chip-money { color: #ffd76a; border-color: rgba(255, 226, 138, .45); }
.chip-money.bump { animation: moneyBump .35s ease; }
@keyframes moneyBump { 30% { transform: scale(1.12); } }
.chip-res { color: #fff6df; }
/* v3.5.0: the income rate rides INSIDE the money chip as a small
   second line — the top-left strip is three chips (money+rate, milk,
   products) instead of four, and "how much" + "how fast" read as one
   number. The old standalone .chip-rate chip is retired. */
.chip-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; line-height: 1; }
.chip-stack small {
  font-family: var(--font-px);
  font-size: 8px;
  color: #a8d9a0;   /* the old chip-rate green — income stays green */
  line-height: 1;
}
/* (v3.1.2: the world-name chip retired — .chip-world/.w2 and its
   small-screen + body.sr-on hide rules are gone; the top bar is pure
   resources + the speedrun clock) */
/* v2.9.0: the SPEEDRUN clock chip — gold-bordered while the run is
   live, solid gold + frozen when finished. It stays visible even on
   small screens (the whole point of a run is the clock). */
.chip-sr { color: #ffd76a; border-color: rgba(255, 226, 138, .45); font-size: 11px; letter-spacing: .5px; }
.chip-sr.gold-medal { animation: srGoldPulse 1s steps(2) infinite; }
.chip-sr.done { background: var(--gold); color: #5b3a00; border-color: var(--gold-dark); }
/* v3.4.0: the weekly race chip — the live season score, grape-tinted
   so it never reads as a second speedrun clock */
.chip-wk { color: #dcc8f6; border-color: rgba(155, 111, 208, .55); font-size: 11px; letter-spacing: .5px; }
@keyframes srGoldPulse { 50% { filter: brightness(1.18); } }
/* ═══ v3.0.2 AUTOSAVE TRUST CHIP ═══
   A tiny green "SAVED" flash in the bottom-right corner each time the
   20s autosave (or an exit checkpoint) really lands. Fixed-position so
   it floats free of the HUD flex rows; pointer-events none — it is a
   status whisper, not a control. The 1.7s keyframe handles the whole
   life cycle (pop in → hold → fade); JS just re-triggers it by
   removing/re-adding .show with a reflow between. */
.save-chip {
  position: fixed;
  right: 12px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 58;
  display: flex; align-items: center; gap: 7px;
  background: #2f7a3d;
  border: 3px solid #1c4a26;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  color: #d6f5cf;
  padding: 7px 11px;
  font-family: var(--font-px); font-size: 9px; letter-spacing: 1px;
  pointer-events: none;
  opacity: 0;
}
.save-chip .chip-icon { width: 16px; height: 16px; }
.save-chip.show { animation: saveChipFlash 1.7s ease forwards; }
@keyframes saveChipFlash {
  0%   { opacity: 0; transform: translateY(8px); }
  12%  { opacity: 1; transform: translateY(0); }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .save-chip.show { animation: saveChipFlash 2.4s ease forwards; }
}
/* v1.8.28 (v3.5.0: now the rate LINE inside the money chip): on small
   screens the income rate gives its slot back to the game — the money
   balance alone carries the top-left corner. (Still on desktop, still
   in the Stats panel everywhere.) */
@media (max-width: 480px) {
  .chip-stack small { display: none; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .chip-stack small { display: none; }
}

/* v1.8.19 QA #5/#6 — passive OBJECTIVE INDICATOR (not a button):
   • flat translucent dark chip (matches the title-save family), no
     pointer cursor, no press states, no button border/shadow
   • centered under the top HUD, clamped so it can never touch the
     SELL/BOOST stack or the resource chips
   • progress counter + pixel progress bar live INSIDE the banner
     (v2.4.7 QA #3 — one self-contained panel)
   v2.4.7 QA #3: the banner is fully RESPONSIVE — the quest text wraps
   to multiple lines at every viewport instead of being clipped to a
   single nowrap line with an ellipsis (on ~700-850px screens the whole
   objective "Upgrade the Milk Processor to level 2" was unreadable).
   Rows wrap (text+star / counter / bar) inside the SAME container, so
   the full description, the "1 / 2" counter and the progress bar stay
   clearly visible together at any width. */
.quest-banner {
  pointer-events: none;
  display: inline-flex; flex-wrap: wrap;
  align-items: center; align-content: center; justify-content: center;
  column-gap: 8px; row-gap: 4px;
  background: rgba(43, 61, 26, .78);
  border: 2px solid rgba(255, 226, 138, .35);
  color: #fff6df; font-size: 18px; letter-spacing: .5px;
  line-height: 1.25;
  padding: 4px 12px;
  /* v2.4.6: clamp to the measured strip — the banner may never touch the
     chips (left) or the SELL/boost stack (right). JS publishes both
     edges; fallbacks hold until the first measurement. */
  max-width: min(86vw, 560px, calc(100vw - var(--quest-left, 10px) - var(--quest-right, 10px)));
  text-align: center;
}
/* v2.4.7 QA #3: WRAP, never clip — the objective text always stays fully
   readable (multi-line when the strip is narrow). min-width:0 lets the
   flex item shrink below its preferred width so wrapping engages. */
#questText { white-space: normal; overflow-wrap: break-word; min-width: 0; flex: 1 1 auto; }
@media (max-width: 560px) {
  .quest-banner { font-size: 16px; padding: 3px 9px; max-width: min(88vw, calc(100vw - var(--quest-left, 10px) - var(--quest-right, 10px))); }
}
.quest-star { display: inline-flex; line-height: 1; }
.quest-star .pix-ico { width: 15px; height: 15px; }
/* progress counter — pixel font, gold */
.quest-prog {
  font-family: var(--font-px);
  font-size: 10px;
  color: var(--gold);
  background: rgba(0, 0, 0, .38);
  border: 2px solid rgba(255, 226, 138, .45);
  padding: 3px 7px;
  white-space: nowrap;
  line-height: 1.3;
}
.quest-prog.done { color: #3a7a34; background: #ffe9b0; border-color: var(--gold-dark); }
/* mini pixel progress bar — v2.4.7 QA #3: INSIDE the banner, as its own
   full-width row (flex-basis 100% forces the wrap), capped so it never
   looks stretched on a wide desktop banner. */
.quest-pbar {
  flex: 1 1 100%;
  max-width: min(300px, 100%);
  height: 8px;
  margin-top: 1px;
  background: rgba(0, 0, 0, .45);
  border: 2px solid rgba(255, 226, 138, .4);
  overflow: hidden;
}
.quest-pbar i {
  display: block; height: 100%; width: 0%;
  background: repeating-linear-gradient(90deg, var(--gold) 0 7px, #e5a428 7px 14px);
  transition: width .3s linear;
}
/* completion flash (passive celebration — still not a button) */
.quest-banner.done {
  background: rgba(58, 122, 52, .92);
  border-color: var(--gold);
  animation: questDone .5s ease 2;
}
@keyframes questDone { 50% { transform: scale(1.03); } }

/* ═══ v3.6.0 "THE CLEAR LADDER" — the banner is a button now ═══
   Tap → the JOURNEY modal (ui.js showJourney). Only the banner's own
   rect turns interactive — the strip around it stays click-through
   to the world, exactly like the HUD chips. The chevron is a pure-CSS
   triangle (no glyph — so it renders identically under every font),
   and the whole banner keeps a visible focus ring for keyboard play. */
.quest-banner.tappable {
  pointer-events: auto;
  cursor: pointer;
  border-color: rgba(255, 226, 138, .5);
}
.quest-banner.tappable:active { transform: translateY(1px); }
.quest-banner.tappable:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 193, 49, .55);
}
.quest-chev {
  flex: 0 0 auto;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--gold);
  margin: 0 1px 0 3px;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, .45));
}
@media (max-width: 560px) {
  .quest-chev { border-top-width: 4px; border-bottom-width: 4px; border-left-width: 6px; }
}

#buffBar { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
/* v1.8.28 "calm buffs": the old saturated-gold chips were the loudest
   elements on the screen — three glowing yellow bars screaming over a
   passive quest banner. Buffs are STATUS, not actions: compact, quiet,
   one line, thin gold accent on dark glass (same family as the chips
   above). They now read as a footnote under the objective, not a
   second headline row. */
.buff-chip {
  background: rgba(43, 61, 26, .78);
  border: 2px solid rgba(255, 183, 51, .55);
  color: #ffe9b0; font-size: 14px;
  padding: 2px 8px; line-height: 1.25;
  display: inline-flex; gap: 5px; align-items: center;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.buff-chip .pix-ico { width: 13px; height: 13px; }

/* Sell button — independently anchored top-right (see .hud-right note).
   v1.8.28: same gold family but a shade deeper + thin border so it stays
   the brightest ACTION in the strip without neon-shouting over the
   quieter stat chips. */
.btn-sell {
  display: flex; align-items: center; gap: 9px;
  background: linear-gradient(180deg, #ffc247 0%, #f0a51f 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
  color: #5b3a00; cursor: pointer;
  padding: 8px 14px;
  font-family: var(--font-px); font-size: 12px; line-height: 1.3;
  min-width: 128px; justify-content: center;   /* v1.8.19: own $ value changes never move the button */
}
.btn-sell:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn-sell-icon { width: 26px; height: 26px; background-size: contain; background-repeat: no-repeat; image-rendering: pixelated; }
.btn-sell small { font-size: 10px; }
.btn-sell.ready { animation: sellGlow 1s ease-in-out infinite; }
@keyframes sellGlow { 50% { filter: brightness(1.18); } }

/* ═══════════ EVENT BADGE ═══════════ */
/* v1.8.19 QA #7: top/right driven by --badge-top (measured from the live
   SELL + AD BOOST stack by UI.measureNotifZones) — it can never sit on
   top of those buttons at any viewport. */
.event-badge {
  position: fixed; top: var(--badge-top, 100px); right: 10px; z-index: 55;
  display: flex; align-items: center; gap: 8px;
  background: #7b4fd0; border: 3px solid #4c2d85;
  box-shadow: var(--shadow);
  color: #fff; cursor: pointer;
  padding: 8px 12px;
  font-family: var(--font-px); font-size: 11px;
  animation: badgeWiggle 1s ease-in-out infinite;
}
@keyframes badgeWiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.event-badge-icon { display: inline-flex; line-height: 1; }
.event-badge-icon .pix-ico { width: 18px; height: 18px; }

/* ═══════════ NAV DOCK ═══════════ */
#navDock {
  position: fixed;
  bottom: calc(6px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 60;
  display: flex; gap: 4px;
  background: var(--cream);
  border: var(--px-border);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
  padding: 6px;
  max-width: calc(100vw - 12px);
}
.nav-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  min-width: 72px; padding: 6px 4px 5px 4px;   /* v3.5.0: 5-button dock — roomier tiles, readable 9px labels */
  color: var(--ink);
}
.nav-btn:active .nav-icon { transform: scale(.9); }
/* v3.3.0: desktop hover — the icon hops up a hair and the tile warms.
   (hover: hover) keeps touch devices on the plain tap feedback. */
@media (hover: hover) {
  .nav-btn { transition: background .12s ease; }
  .nav-btn:hover { background: rgba(91, 67, 38, .12); }
  .nav-btn:hover .nav-icon { transform: translateY(-2px); }
}
.nav-icon { width: 32px; height: 32px; image-rendering: pixelated; background-size: contain; background-repeat: no-repeat; transition: transform .12s ease; }
.nav-label { font-family: var(--font-px); font-size: 9px; letter-spacing: 0; max-width: 100%; overflow: hidden; }
.nav-dot {
  position: absolute; top: 2px; right: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--red); border: 2px solid #fff;
}
.nav-dot.hidden { display: none !important; }

/* ═══════════ v2.8.0 SIDE DOCK (stats & worlds sidebar) ═══════════
   A toggleable sidebar on the exact spot the old square Worlds button
   lived: fixed to the LEFT edge, vertically centred, same wood/cream
   pixel language as the nav dock. Collapsed it is ONE chunky handle;
   tapping it unfolds a labelled column (WORLDS + STATS). The WORLDS
   button is ghosted for brand-new farmers until quest 12 (ui.js
   updateWorldsDot reveals it with a pop + toast); STATS is there from
   the first tap. In World 2 the worlds button warms to gold so the
   player always knows where they stand. */
#sideDock {
  position: fixed;
  left: calc(8px + env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;   /* same layer as the nav dock; panels (70) / toasts (90) / modals (300) / ending (320) stay above */
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: worldsIn .35s cubic-bezier(.34, 1.56, .64, 1);
}
#sideDock.hidden { display: none; }
.side-toggle, .side-btn {
  position: relative;
  width: 58px;
  background: var(--cream);
  border: var(--px-border);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink);
  font-family: var(--font-px);
}
.side-toggle { height: 58px; flex: 0 0 auto; flex-direction: column; gap: 2px; }
.side-toggle:hover, .side-btn:hover { filter: brightness(1.06); }
.side-toggle:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.side-ico { width: 32px; height: 32px; image-rendering: pixelated; background-size: contain; background-repeat: no-repeat; background-position: center; }
/* v3.5.8: the handle's own dot (#dotSide) mirrors "a rail button has
   news" while the rail is FOLDED — the folded handle is 58px tall, so
   the dot is always inside it (no height:0 phantom to fight). */
.side-toggle .nav-dot { top: 3px; right: 3px; }

/* the expandable buttons: collapsed = height 0 / no border (the column
   shrinks back to just the handle); expanded = labelled pixel buttons
   in the nav-dock idiom. steps() keeps the motion chunky.
   v3.5.8: collapsed buttons are now also visibility:hidden — they used
   to sit in the accessibility tree as 0px phantom buttons (tab stops /
   screen-reader targets that could never be clicked). visibility rides
   the same transition so the fold/unfold animation is unchanged. */
.side-btn {
  flex-direction: column;
  gap: 2px;
  height: 0;
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  border-width: 0;
  box-shadow: none;
  pointer-events: none;
  visibility: hidden;
  transition: height .16s steps(3), opacity .16s steps(3), border-width .16s steps(3), visibility .16s steps(3);
}
#sideDock.open .side-btn {
  height: 58px;
  opacity: 1;
  border-width: 3px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
  pointer-events: auto;
  visibility: visible;
}
.side-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.side-label { font-size: 7px; letter-spacing: 0; line-height: 1; }
.side-btn .nav-dot { top: 3px; right: 3px; }
.side-btn.w2 { border-color: var(--gold-dark); background: #fff3cf; }   /* standing on the Sunset Isles */

/* brand-new farmers: the ferry hasn't docked yet — the WORLDS button
   is ghosted until ui.js updateWorldsDot earns it (quest 12) */
.side-btn.ghost { display: none; }
/* the reveal moment: slides in from off the left edge with a bounce */
.side-btn.pop { animation: sidePop .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes sidePop { from { transform: translateX(-84px) scale(.6); opacity: 0; } }
@keyframes worldsIn { from { transform: translateY(-50%) translateX(-70px); } }

/* tutorial soft-lock: same treatment as the nav dock — dimmed and
   non-clickable while a tutorial step waits for its action */
#sideDock.tut-lock .side-btn,
#sideDock.tut-lock .side-toggle { opacity: .4; pointer-events: none; }

/* v1.8.11 NOTE: this narrow-phone block is intentionally superseded by
   the ≤430px / ≤380px blocks at the END of this file — it sits before
   the ≤560px block, so on any screen ≤560px wide the later block won
   the cascade here and these rules never took effect (that cascade
   order bug is what smeared the labels together on 360px phones). */
/* v1.8.11 NOTE: this narrow-phone block was superseded by the phone
   tiers at the END of this file and has been REMOVED (v3.5.0) — the
   ≤560/≤430/≤380 tiers below are the only nav sizing rules now. */

/* ═══════════ PANEL — v1.8.19 QA #3/#10: ONE centered layout for every
   viewport. The wrapper is a full-viewport flex centering layer; the
   card inside keeps its own width caps, so the exact same rule centers
   panels on desktop, mobile, portrait, landscape and any aspect ratio.
   No per-device pixel offsets — the close button lives inside the
   header and can never be clipped at a screen edge. Max height leaves
   the top HUD band and the nav dock visible. ═══════════ */
#panelWrap {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  /* v1.8.26 CrazyGames QA #6: the top band is MEASURED, not hard-coded —
     UI.measureNotifZones publishes --hud-h (live bottom of the HUD strip:
     chips + quest banner + progress bar) and the panel opens strictly
     BELOW it, so the objective can never be covered. If the HUD wraps to
     two rows on a narrow screen the panel follows automatically. */
  padding: calc(var(--hud-h, 126px) + 8px) 12px calc(84px + env(safe-area-inset-bottom));
  pointer-events: none;
}
#panelWrap > * { pointer-events: auto; }   /* card + its children stay interactive; the wrapper never blocks the world */
/* v1.8.28 "focus dim": while a panel is open the WORLD (both canvases)
   dims ~25%. The player's eye lands on the bright card instead of
   parsing farm + panel at once; the HUD/nav stay fully lit so the
   objective (CrazyGames QA #6) and nav dots remain readable. Purely a
   CSS filter — zero layout/interaction change, cheap on GPU (color
   matrix), and the tutorial ring/arrow (z 250) stay bright over it. */
body.panel-open #game,
body.panel-open #uifx {
  filter: brightness(.74) saturate(.92);
  transition: filter .18s ease;
}
#game, #uifx { transition: filter .18s ease; }
#panelCard {
  display: flex; flex-direction: column;
  background: var(--cream);
  border: var(--px-border);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .32);
  width: min(94vw, 540px);
  max-height: 100%;
  animation: panelPop .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes panelPop { from { transform: translateY(16px) scale(.97); opacity: 0; } }

#panelHead {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, #63492a 0%, var(--wood) 100%);
  color: var(--cream);
  padding: 9px 14px;
  font-family: var(--font-px); font-size: 13px;
  flex: 0 0 auto;
}
#panelTitle { display: inline-flex; align-items: center; gap: 9px; }
#panelTitle .pix-ico { width: 20px; height: 20px; }
.btn-panel-close {
  background: var(--red); border: 2px solid var(--red-dark);
  color: #fff; font-size: 16px; font-family: var(--font-px);
  width: 30px; height: 30px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.panel-close-ico { display: inline-flex; width: 14px; height: 14px; }
.panel-close-ico .pix-ico, .panel-close-ico.pix-ico { width: 14px; height: 14px; }
.btn-panel-close:active { transform: translateY(2px); }

#panelBody {
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 10px;
  flex: 1 1 auto;
}

/* Short landscape screens: shrink the reserved HUD/nav bands so the
   centered card still gets sensible height (measured layout, no magic
   per-device offsets — env() handles notches everywhere). */
@media (max-height: 560px) {
  #panelWrap { padding: calc(var(--hud-h, 96px) + 6px) 10px calc(70px + env(safe-area-inset-bottom)); }
  #panelCard { width: min(96vw, 620px); }   /* wider, not taller — list rows use the space */
}

/* ═══════════ TOASTS / NOTIFICATIONS ═══════════ */
/* v1.8.25: notifications ride the BOTTOM-CENTER band, truly centered on
   the viewport (left:50%), floating just above the navigation dock —
   or above an open panel card / the tutorial hint when those are up.
   --notif-bottom is written by UI.measureNotifZones from the LIVE
   nav/panel/hint rectangles (every 500ms + on resize). (v1.8.19's
   top-band placement centered toasts on the HUD gap — visibly off-
   centre — and stacked them over the objective indicator.) */
#toastZone {
  position: fixed;
  bottom: var(--notif-bottom, 96px);
  left: 50%; transform: translateX(-50%);
  z-index: 90;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none;
  width: min(92vw, var(--notif-maxw, 420px));
}

/* ═══════════ MODAL ═══════════ */
#modalWrap {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(20, 25, 15, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
#modalCard {
  background: var(--cream);
  border: var(--px-border);
  box-shadow: 0 6px 0 rgba(0,0,0,.4);
  width: min(92vw, 460px);
  max-height: 84vh;
  overflow-y: auto;
  padding: 18px;
  animation: popIn .2s cubic-bezier(.34,1.56,.64,1);
  touch-action: pan-y;
}
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }

/* ═══════════ TUTORIAL (v1.8.17 — responsive state machine) ═══════════
   #tutRoot  — one stacking layer for every tutorial element (z 250:
   above panels so guidance stays visible with a panel open, below
   modals z 300 and the ad veil z 5000)
   #tutHint  — instruction card, JS-positioned every frame from live
   measurements (never hard-coded coordinates)
   #tutArrow — floating directional arrow, rotated toward its target
   #tutRing  — pulsing highlight ring for world (canvas) targets */
#tutRoot {
  position: fixed; inset: 0;
  z-index: 250;
  pointer-events: none;
}
#tutRoot.hidden { display: none; }

#tutHint {
  position: fixed;   /* positioned by tutorial.js (left/top, viewport space) */
  left: 0; top: 0;
  background: rgba(43, 61, 26, .94);
  border: 3px solid var(--gold);
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
  color: #fff;
  padding: 10px 16px;
  font-size: 20px; line-height: 1.25; text-align: center;
  width: min(88vw, 400px);
  pointer-events: none;
}
#tutHint.tut-anim { animation: tutPop .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes tutPop { from { transform: translateY(14px) scale(.92); opacity: 0; } }
#tutTop {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 7px;
}
#tutStep {
  display: inline-block;
  font-family: var(--font-px); font-size: 8px;
  color: var(--gold);
  background: rgba(0, 0, 0, .35);
  border: 2px solid var(--gold-dark);
  padding: 3px 7px;
  white-space: nowrap;
}
#tutDots { display: inline-flex; gap: 5px; }
#tutDots span {
  width: 10px; height: 10px;
  background: rgba(0,0,0,.4);
  border: 2px solid var(--gold-dark);
}
#tutDots span.on { background: var(--gold); border-color: #ffe28a; }

/* progress row: bar + counter share ONE flex row with a gap —
   instruction text and progress bar can never overlap each other.
   v2.4.8: counter-only steps (progress === null → bar gets .bare)
   used to render [24px INVISIBLE bar][8px gap][label] left-packed,
   so the action label ("TAP THE MACHINE" / "PACKS READY: 5" /
   "OPEN THE FARM PANEL" / "COW: $28") sat far left of the card's
   centre axis — player-reported on tutorial steps 2-5 (screenshots:
   label centre ~60-100px left of the card centre). The row now
   centres its content and the bare bar is removed from the flow
   entirely (display:none, not a hidden 24px spacer), so a lone
   counter label centres in the card like every other row (tutTop,
   tutText). With a real bar the flex:1 track still fills the row —
   identical layout to before. */
#tutProgRow {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px;
}
#tutProgRow.hidden { display: none; }
#tutProg {
  position: relative; overflow: hidden;
  flex: 1 1 auto;
  height: 12px;
  background: rgba(0,0,0,.45);
  border: 2px solid var(--gold-dark);
}
#tutProg.bare { display: none; }   /* counter-only steps: no spacer, label centres */
#tutProgFill {
  position: absolute; left: 2px; top: 2px; bottom: 2px;
  width: calc(0% - 4px);
  background: repeating-linear-gradient(90deg, var(--gold) 0 8px, #e5a428 8px 16px);
  transition: width .25s linear;
}
#tutCount {
  flex: 0 0 auto;
  font-family: var(--font-px); font-size: 9px;
  color: #ffe28a;
  white-space: nowrap;
  line-height: 1.25;   /* v2.4.8: matches the STEP chip's Press Start 2P rhythm — 1.4 left the pixel glyphs riding ~1px high inside the row */
}
#tutSkip {
  pointer-events: auto;
  position: absolute; top: -13px; right: -13px;
  width: 30px; height: 30px;
  font-family: var(--font-px); font-size: 10px; line-height: 1;
  background: var(--red); color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,.4);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
#tutSkip:active { transform: translateY(2px); }

/* ═══ v3.5.1 — THE LOOP STRIP ═══
   A tiny map of the dairy loop — COW → MILK → FACTORY → PACK → $ —
   always in the card, one node lit per step. Steps 4-5 (reinvest)
   light the cow node again AND the loop-back bracket underneath
   (.looped): the loop restarts. The final YOUR GOALS step lights the
   whole strip (.complete) — the loop is the player's now. Built from
   the same baked pixel icons as the rest of the UI; the separator is
   a rotated pixel diamond, the bracket a plain CSS under-curve whose
   arrowhead inherits the border color (dim gold → gold when lit). */
#tutLoop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: -moz-fit-content;
  width: fit-content;
  margin: 2px auto 0;
  padding-bottom: 11px;   /* room for the loop-back bracket */
}
.tl-node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px; height: 26px;
  background: rgba(0, 0, 0, .4);
  border: 2px solid var(--gold-dark);
  opacity: .5;
}
.tl-node .pix-ico { width: 16px; height: 16px; vertical-align: middle; }
.tl-node.on {
  opacity: 1;
  border-color: var(--gold);
  animation: tlNodePulse 1.2s ease-in-out infinite;
}
@keyframes tlNodePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.tl-sep {
  flex: 0 0 auto;
  width: 6px; height: 6px;
  background: var(--gold-dark);
  transform: rotate(45deg);
}
/* the loop-back bracket: under-curve from the $ node back to the cow */
.tl-back {
  position: absolute;
  left: 13px; right: 13px; bottom: 0;
  height: 7px;
  border: 2px solid var(--gold-dark);
  border-top: none;
  opacity: .45;
}
/* arrowhead at the bracket's left end, pointing up into the cow node */
.tl-back::after {
  content: '';
  position: absolute;
  left: -3px; top: -6px;
  width: 0; height: 0;
  border: 4px solid transparent;
  border-bottom-color: inherit;   /* tracks the bracket's own color */
}
#tutLoop.looped .tl-back,
#tutLoop.complete .tl-back {
  opacity: 1;
  border-color: var(--gold);
}
/* the graduation look: every node softly gold on the final step */
#tutLoop.complete .tl-node {
  opacity: .9;
  border-color: var(--gold);
}

/* v3.5.1 — step-6 acknowledgment button (chunky pixel button, matches
   the modal .btn-green family; the card itself is pointer-events:none,
   so the button opts back in exactly like #tutSkip does) */
#tutGotIt {
  pointer-events: auto;
  display: inline-block;
  margin-top: 9px;
  font-family: var(--font-px);
  font-size: 11px;
  line-height: 1.5;
  padding: 10px 24px;
  color: #fff;
  background: var(--green);
  border: 3px solid var(--green-dark);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: filter .1s;
}
#tutGotIt:hover { filter: brightness(1.06); }
#tutGotIt:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
#tutGotIt.hidden { display: none; }

/* floating directional arrow — outer box is placed & rotated by JS,
   inner box bounces along the (rotated) pointing axis toward the target */
#tutArrow {
  position: fixed;
  width: 30px; height: 30px;
  pointer-events: none;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,.45));
  z-index: 2;
}
#tutArrow.hidden { display: none; }
#tutArrowBounce {
  width: 30px; height: 30px;
  animation: tutArrowNudge .75s ease-in-out infinite;
}
#tutArrowBounce .pix-ico { width: 30px; height: 30px; vertical-align: top; }
@keyframes tutArrowNudge {
  0%, 100% { transform: translateY(-5px); }
  50% { transform: translateY(5px); }
}

/* ═══ v1.8.18 PIXEL-ART HIGHLIGHT RING (world targets) ═══
   The old ring was a smooth rounded rectangle with a blurry glow —
   it clashed with the pixel-art world (CrazyGames QA feedback).
   The new ring is built like a retro game selection frame:
     • chunky bright corner blocks (2-tone pixel bevel, hard shadow)
     • dashed pixel-block edges (7px on / 5px off), zero blur
     • square corners only — never rounded, never a circle
     • hard-stepped retro blink between gold and pale gold
   Sized every frame by tutorial.js — follows targets through camera
   pans/zooms at any viewport, DPR and aspect ratio. */
#tutRing {
  position: fixed;
  pointer-events: none;
  z-index: 1;
}
#tutRing.hidden { display: none; }
#tutRing i { position: absolute; display: block; }

/* corner blocks: bright gold with a darker bottom/right pixel bevel
   and a hard offset drop shadow (no blur = no anti-aliasing) */
#tutRing .tr-c {
  width: 9px; height: 9px;
  background: #ffe28a;
  box-shadow: inset -3px -3px 0 var(--gold-dark), 3px 3px 0 rgba(0, 0, 0, .3);
  animation: tutPixCorners 1.1s infinite;
}
#tutRing .c-tl { left: 0;    top: 0; }
#tutRing .c-tr { right: 0;   top: 0; }
#tutRing .c-bl { left: 0;    bottom: 0; }
#tutRing .c-br { right: 0;   bottom: 0; }

/* edge strips: dashed pixel blocks, 5px thick, inset between the
   corner blocks; the ::after overlay in pale gold blinks on with
   HARD steps — the retro two-phase pulse (no smooth fade, no glow) */
#tutRing .tr-e {
  background: repeating-linear-gradient(90deg, var(--gold) 0 7px, transparent 7px 12px);
}
#tutRing .tr-e::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, #ffe28a 0 7px, transparent 7px 12px);
  animation: tutPixBlink 1.1s infinite;
}
#tutRing .e-t { left: 9px; right: 9px; top: 2px;    height: 5px; }
#tutRing .e-b { left: 9px; right: 9px; bottom: 2px; height: 5px; }
#tutRing .e-l, #tutRing .e-r { top: 9px; bottom: 9px; width: 5px; }
#tutRing .e-l {
  left: 2px;
  background: repeating-linear-gradient(180deg, var(--gold) 0 7px, transparent 7px 12px);
}
#tutRing .e-r {
  right: 2px;
  background: repeating-linear-gradient(180deg, var(--gold) 0 7px, transparent 7px 12px);
}
#tutRing .e-l::after, #tutRing .e-r::after {
  background: repeating-linear-gradient(180deg, #ffe28a 0 7px, transparent 7px 12px);
}

/* hard-stepped blink: ON for the first half, OFF for the second.
   The 49.99% → 50% jump is a 0.1ms switch — effectively instantaneous,
   exactly like a retro hardware palette blink. */
@keyframes tutPixBlink {
  0%, 49.99%  { opacity: 1; }
  50%, 100%   { opacity: 0; }
}
@keyframes tutPixCorners {
  0%, 49.99%  { background: #fff3c4; }
  50%, 100%   { background: #ffe28a; }
}

/* small rings (< 56px on either axis — zoomed-out camera, tiny
   viewport, or a heavily clamped target) switch the dashed edges to
   SOLID bars so the frame still reads clearly with under ~4 dashes.
   tutorial.js toggles .tr-solid from the live ring size every frame. */
#tutRing.tr-solid .tr-e,
#tutRing.tr-solid .e-l,
#tutRing.tr-solid .e-r { background: var(--gold); }
#tutRing.tr-solid .tr-e::after,
#tutRing.tr-solid .e-l::after,
#tutRing.tr-solid .e-r::after { background: #ffe28a; }

/* ═══ v1.8.18 PIXEL-ART highlight for DOM targets (SELL button, nav
   buttons, BUY buttons) — same retro language as the ring: crisp
   gold outline + hard offset shadow + hard-stepped bright blink.
   No blur, no rounded glow. ═══ */
.tut-target {
  position: relative;
  animation: tutTargetPulse 1.1s infinite !important;
}
@keyframes tutTargetPulse {
  0%, 49.99% {
    box-shadow: 0 0 0 3px var(--gold), 3px 3px 0 3px rgba(0, 0, 0, .35);
  }
  50%, 100% {
    box-shadow: 0 0 0 3px #ffe28a, 3px 3px 0 3px rgba(0, 0, 0, .35);
  }
}
.tut-target.btn-sell { border-radius: 0; }

/* tutorial nav soft-lock: unrelated nav buttons dim & ignore input,
   while the step's own target button stays fully interactive */
#navDock.tut-lock .nav-btn { opacity: .4; pointer-events: none; }
#navDock.tut-lock .nav-btn.tut-target,
#navDock.tut-lock .nav-btn[data-panel="settings"] { opacity: 1; pointer-events: auto; }

/* ── tutorial responsive tightening ── */
@media (max-width: 560px) {
  #tutHint { font-size: 18px; padding: 8px 12px; }
  #tutArrow, #tutArrowBounce { width: 26px; height: 26px; }
  #tutArrowBounce .pix-ico { width: 26px; height: 26px; }
  #tutCount { font-size: 8px; }
  /* v3.5.1: the loop strip shrinks with the card (26px nodes → 22px,
     full strip 194px → 174px — still one clean row on 320px screens) */
  #tutLoop { gap: 4px; padding-bottom: 9px; }
  .tl-node { width: 22px; height: 22px; }
  .tl-node .pix-ico { width: 14px; height: 14px; }
  .tl-back { left: 11px; right: 11px; }
  #tutGotIt { font-size: 10px; padding: 12px 22px; }   /* v3.5.1: 45px tall — meets the 44px touch minimum */
}
@media (max-height: 520px) {
  #tutHint { font-size: 16px; padding: 6px 10px; line-height: 1.2; width: min(88vw, 340px); }
  #tutTop { margin-bottom: 4px; }
  #tutProgRow { margin-top: 5px; }
}
/* compact card while a panel shares the screen — keeps the guidance
   readable without covering the sheet/side panel */
#tutHint.tut-compact {
  font-size: 17px;
  padding: 7px 11px;
  line-height: 1.2;
  width: min(88vw, 340px);
}
#tutHint.tut-compact #tutTop { margin-bottom: 4px; }
#tutHint.tut-compact #tutProgRow { margin-top: 5px; }
/* v1.8.27: side-docked hint (panel fills the viewport height — see
   tutorial.js placeHint ladder step 3). Narrower box so it fits the
   free column beside a centered panel card; must come AFTER the
   .tut-compact rules so it wins the width cascade. */
#tutHint.tut-side,
#tutHint.tut-compact.tut-side {
  width: min(30vw, 260px);
  font-size: 15px;
  padding: 6px 9px;
  line-height: 1.18;
}
/* v3.5.1: the narrow side-dock card gets the small loop strip too —
   174px fits the 200-260px column without wrapping */
#tutHint.tut-side .tl-node { width: 22px; height: 22px; }
#tutHint.tut-side .tl-node .pix-ico { width: 14px; height: 14px; }
#tutHint.tut-side #tutLoop { gap: 4px; padding-bottom: 9px; }
#tutHint.tut-side .tl-back { left: 11px; right: 11px; }
@media (max-width: 560px) {
  #tutHint.tut-compact { font-size: 15px; padding: 6px 9px; }
}

/* Offline / summary list rows — v1.8.28: money is the headline (hero row,
   pixel font + gold), secondary production stats whisper (minor row):
   the returning player reads ONE number, skims the rest. */
.sum-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 20px; padding: 5px 4px;
  border-bottom: 2px dashed rgba(91,67,38,.25);
}
.sum-row b { color: var(--green-dark); }
.sum-row.hero { padding: 8px 4px; }
.sum-row.hero b {
  font-family: var(--font-px); font-size: 14px; line-height: 1.4;
  color: var(--gold-dark);
}
.sum-row.minor { font-size: 16px; color: var(--ink-soft); }
.sum-row.minor b { color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════ SMALL PHONES (≤ 400px) — tighter, readable HUD ═══════════
   v1.8.25: toast-zone / event-badge positions are JS-measured
   (—notif-bottom / —badge-top); the old fixed offsets are gone. */
@media (max-width: 400px) {
  .chip { padding: 5px 7px; font-size: 10px; gap: 5px; }
  .chip-icon { width: 16px; height: 16px; }
  .btn-sell { padding: 6px 9px; font-size: 10px; gap: 6px; min-width: 104px; }
  .btn-sell-icon { width: 22px; height: 22px; }
  .btn-sell small { font-size: 9px; }
  #hud { padding: calc(6px + env(safe-area-inset-top)) 6px 0 6px; }
  .hud-left { max-width: 74%; gap: 4px; }
  .quest-banner { font-size: 16px; padding: 3px 9px; max-width: min(88vw, calc(100vw - var(--quest-left, 10px) - var(--quest-right, 10px))); }
  .buff-chip { font-size: 13px; padding: 2px 7px; }
  .toast { font-size: 17px; padding: 8px 10px; }
  .toast-ico .pix-ico { width: 22px; height: 22px; }
  .event-badge { padding: 6px 9px; font-size: 9px; }
}

/* ═══════════ PHONES (≤ 560px) — compact nav dock ═══════════ */
/* v3.5.0: the dock is FIVE buttons now (Cows · Machines · Products ·
   Upgrades · More) — the old 8-in-a-row squeezed every tile to ~41px,
   under the 44px touch minimum. Five tiles at 58px keep real
   thumb-sized targets with room for readable 7px labels. */
@media (max-width: 560px) {
  #navDock { padding: 4px; gap: 2px; bottom: calc(4px + env(safe-area-inset-bottom)); }
  .nav-btn { min-width: 58px; padding: 7px 2px 6px 2px; }
  .nav-icon { width: 26px; height: 26px; }
  .nav-label { font-size: 7px; }
  .buy-btn { width: 84px; }
  .shop-side { max-width: 88px; }
}

/* ═══════════ v1.8.11 UI fix — VERY NARROW PHONES (≤ 430px) ═══════════
   PressStart2P advances at a fixed 1em per glyph: "Machines" (8
   glyphs) is 6px × 8 = 48px at this tier — the 56px tiles fit it with
   room to spare (the old 8-button row had to crush labels to 5px). */
@media (max-width: 430px) {
  #navDock { gap: 2px; }
  .nav-btn { min-width: 56px; padding: 7px 0 6px 0; }
  .nav-label { font-size: 6px; }
}
/* ≤380px: 5 × 52px + gaps still clears 100vw with labels intact */
@media (max-width: 380px) {
  #navDock { gap: 1px; padding: 3px; }
  .nav-btn { min-width: 52px; padding: 7px 0 6px 0; }
  .nav-label { font-size: 5px; }
}

/* ═══════════ SHORT LANDSCAPE PHONES — keep dock out of the way ═══════════ */
@media (max-height: 480px) and (orientation: landscape) {
  /* panel + notification positions are JS-measured (v1.8.19) */
}

/* ═══════════ v2.8.0 SIDE DOCK — responsive ═══════════
   Same compaction ladder as the nav dock: smaller squares, smaller
   glyphs, tighter gap. The collapsed handle keeps a comfortable
   finger target (48px) even on the narrowest phones. */
@media (max-width: 560px) {
  #sideDock { left: calc(5px + env(safe-area-inset-left)); gap: 3px; }
  .side-toggle, .side-btn { width: 48px; }
  .side-toggle { height: 48px; }
  #sideDock.open .side-btn { height: 50px; }
  .side-ico { width: 26px; height: 26px; }
  .side-label { font-size: 6px; }
}
