/* Barista Rage (baristarage.com). © 2026 Jonathan Landa (@yonicrisis). All rights reserved. See LICENSE. */
:root {
  --bg: #14151a;
  --panel: #1b1c22;
  --ink: #f4f1ea;
  --muted: #b8b3a8;
  --accent: #f0b43c;
  --good: #3ddc84;
  --warn: #ffd23f;
  --bad: #ff4d4d;
  /* design tokens from the Figma frames (Home, Paused, About, Lab) */
  --screen-bg: #2c3139;   /* the game screen and the full screens (splash, pause, about) */
  --lab-bg: #000000;      /* Lab pages (lab/lab.css has its own copy) */
  --cta: #e01919;         /* primary button */
  --cta-shadow: #a82218;  /* its flat bottom edge */
  --secondary: #555555;   /* grey button */
  --secondary-shadow: #404040;
  --link: #ffd000;        /* text links, screen titles */
  --text: #c2c2c2;
  --heading: #ffffff;
  --date: #8a8a8a;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
  /* where the screen buttons sit: the stack (primary, secondary, text link) ends this far above the bottom */
  --actions-bottom: max(11cqh, calc(env(safe-area-inset-bottom) + 3cqh));
  /* the height under the primary button in that stack, so a lone primary (About's BACK) lands in the same place */
  --below-primary: calc(1.5cqw + 3.5cqw + max(9.5cqw, 38px) + 1.5cqw + 3.5cqw + max(44px, 11cqw));
  color-scheme: dark; /* the game is dark by design, in every theme */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: var(--sans);
}
button { font: inherit; color: inherit; border: 0; padding: 0; background: none; touch-action: none; cursor: pointer; }
svg { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* The game always lives in a portrait column, also on desktop. */
#game {
  position: relative;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  width: min(100vw, calc(100vh * 0.58));
  width: min(100vw, calc(100dvh * 0.58));
  container-type: size;
  overflow: hidden;
  background: var(--screen-bg);
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top) + 2.2cqw) 3cqw 0;
  display: flex; flex-direction: column; gap: 1.6cqw;
  pointer-events: none;
}
#rageBar {
  position: relative; height: max(5.4cqw, 20px); border-radius: 99px;
  background: rgba(10, 10, 14, .72); border: .5cqw solid rgba(255, 255, 255, .2); overflow: hidden;
}
#rageFill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, #ffd23f, #ff8a2b 55%, #ff3b30);
  transition: width .25s ease-out;
}
#rageLabel {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 800; letter-spacing: .22em; font-size: max(2.9cqw, 11px);
  text-shadow: 0 1px 2px #000;
}
#rageBar.near { animation: throb .7s ease-in-out infinite; }
.rage #rageBar { animation: rainbow 1s linear infinite; }
@keyframes throb { 50% { box-shadow: 0 0 3cqw #ff5a36; } }
@keyframes rainbow { to { filter: hue-rotate(360deg); } }

#hudRow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; }
#hudRight { text-align: right; }
#money { text-align: right; }
/* the clock is the pause button: a black box with the time, "PAUSE" under it */
#clock {
  /* fixed width for the longest text ("12:00 PM", 8 characters), so the box never resizes or wraps as the time changes */
  display: block; width: calc(8ch + 7cqw); padding: 1.6cqw 3cqw; border-radius: 1cqw; text-align: center; white-space: nowrap;
  background: #000; border: .5cqw solid transparent; color: #ffe167;
  font: 700 max(4cqw, 15px)/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums;
}
/* last CFG.shiftWarnSeconds of the shift: red, throbbing text and a blinking outline */
#clock.late { color: var(--bad); animation: throb .7s ease-in-out infinite, outlineBlink 1s linear infinite; }
@keyframes outlineBlink { 0%, 49% { border-color: var(--bad); } 50%, 100% { border-color: transparent; } }
#lives { display: flex; gap: 1.4cqw; }
.life { width: 6.6cqw; height: 6.6cqw; transition: transform .3s, filter .3s, opacity .3s; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.life.lost { filter: grayscale(1) brightness(.55); opacity: .5; transform: scale(.8); }
#money {
  font-weight: 800; font-size: max(5.6cqw, 21px);
  text-shadow: 0 2px 4px rgba(0, 0, 0, .7); color: #ffe27a;
}
#money.neg { color: var(--bad); }
#money.hurt { animation: hurt .45s; }
@keyframes hurt { 0%, 100% { transform: none; } 20% { transform: translateX(-1.5cqw); color: var(--bad); } 60% { transform: translateX(1.5cqw); color: var(--bad); } }

#vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  box-shadow: inset 0 0 22cqw rgba(255, 60, 30, .6);
}
.rage #vignette { opacity: 1; animation: vig .8s ease-in-out infinite alternate; }
@keyframes vig { to { box-shadow: inset 0 0 30cqw rgba(255, 60, 30, .85); } }

#banner {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none;
  font-weight: 900; font-size: max(13cqw, 40px); letter-spacing: .04em; color: #fff; opacity: 0;
  text-shadow: 0 .6cqw 0 #c4281c, 0 0 4cqw rgba(255, 90, 40, .9);
}
#banner.small { font-size: max(9.5cqw, 30px); }
#banner.show { animation: banner 1.5s ease-out; }
@keyframes banner {
  0% { opacity: 0; transform: scale(.4); }
  18% { opacity: 1; transform: scale(1.15); }
  30% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.1); }
}

/* ---------- order bubbles ---------- */
#bubbles { position: absolute; inset: 0; pointer-events: none; --bs: 56px; }
.bubble { position: absolute; left: 0; top: 0; width: var(--bs); height: var(--bs); will-change: transform; }
.bin { position: relative; width: 100%; height: 100%; animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); transform-origin: 50% 100%; }
.bubble.out .bin { animation: popout .35s ease-in forwards; }
@keyframes pop { from { transform: scale(0); } }
@keyframes popout { to { transform: scale(1.25) translateY(-30%); opacity: 0; } }
.bubble .ring { position: absolute; inset: 0; transform: rotate(-90deg); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45)); }
.ring .bg { fill: #555867; }
.ring .trk { fill: none; stroke: rgba(0, 0, 0, .28); stroke-width: 7; }
.ring .arc { fill: none; stroke: var(--good); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 100 100; transition: stroke .25s; }
.bubble[data-state="g"] .arc { stroke: var(--good); }
.bubble[data-state="y"] .arc { stroke: var(--warn); }
.bubble[data-state="r"] .arc { stroke: var(--bad); }
.bubble[data-state="r"] .bin { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1), shiver .35s linear .35s infinite; }
@keyframes shiver { 25% { transform: translateX(-3%); } 75% { transform: translateX(3%); } }
.bubble .face { position: absolute; inset: 26%; }
.bubble .mods { position: absolute; left: 50%; bottom: -16%; transform: translateX(-50%); display: flex; gap: 4%; }
.bubble .m {
  width: calc(var(--bs) * .4); height: calc(var(--bs) * .4); padding: 12%;
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
/* modifier badges take the colour of their button: A decaf red, B plant milk green */
.bubble .m.decaf, #modDecaf { background: #f93446; }
.bubble .m.plant, #modPlant { background: #00b158; }
#bubbles.frozen .bubble { filter: grayscale(1) brightness(.8); }

#baristaMods { position: absolute; left: 0; top: 0; display: flex; gap: 1cqw; pointer-events: none; }
#baristaMods .m {
  width: 8.4cqw; height: 8.4cqw; padding: 1.2cqw; border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .5); animation: pop .25s cubic-bezier(.2, 1.6, .4, 1);
}

#floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
  position: absolute; font-weight: 900; font-size: max(7cqw, 24px); white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .6), 0 0 8px rgba(0, 0, 0, .6);
  animation: rise 1s ease-out forwards;
}
.floater.good { color: var(--good); }
.floater.bad { color: var(--bad); }
.floater.gold { color: #ffd23f; font-size: max(9cqw, 30px); }
@keyframes rise {
  from { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
  15% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); }
  to { transform: translate(-50%, -330%) scale(1); opacity: 0; }
}

/* ---------- controls ---------- */
/* Layout and colours follow references/ui/control-pad.svg (402 px wide, so 1 px there is about .25cqw). */
#pad {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 3.5cqw 3cqw max(2.5cqw, env(safe-area-inset-bottom));
  background: #1f2024;
  border-radius: 10cqw 10cqw 0 0;
}

/* d-pad: one rounded cross (the shape from the reference), a dark circle in the middle, a drink at each arm */
/* .hp-dpad and .hp-ab are the same pad drawn inside the how-to-play cards (bottom of this file) */
#dpad, .hp-dpad {
  display: grid; grid-template-columns: 12.4cqw 15.2cqw 12.4cqw; grid-template-rows: 12.4cqw 15.2cqw 12.4cqw;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'%3E%3Cpath fill='%23555867' d='M111 14C111 6.3 104.7 0 97 0H63.8C56 0 49.8 6.3 49.8 14V35.8C49.8 43.5 43.5 49.8 35.8 49.8H14C6.3 49.8 0 56 0 63.8V97C0 104.7 6.3 111 14 111H35.8C43.5 111 49.8 117.3 49.8 125V146C49.8 153.7 56 160 63.8 160H97C104.7 160 111 153.7 111 146V125C111 117.3 117.3 111 125 111H146C153.7 111 160 104.7 160 97V63.8C160 56 153.7 49.8 146 49.8H125C117.3 49.8 111 43.5 111 35.8V14Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
#dpad { margin-top: 6.9cqw; }
.dbtn { position: relative; border-radius: 3.5cqw; display: grid; place-items: center; transition: background .06s; }
.dbtn[data-b="up"] { grid-area: 1 / 2; }
.dbtn[data-b="left"] { grid-area: 2 / 1; }
.dbtn[data-b="right"] { grid-area: 2 / 3; }
.dbtn[data-b="down"] { grid-area: 3 / 2; }
.dcenter { grid-area: 2 / 2; place-self: center; width: 11.9cqw; height: 11.9cqw; border-radius: 50%; background: #232c36; }
.dbtn .ico { display: block; width: 8.7cqw; height: 8.7cqw; }
/* small nudges so each drink sits where the reference puts it (handles stick out to the right) */
.dbtn[data-b="up"] .ico { translate: 0 .9cqw; }
.dbtn[data-b="right"] .ico { translate: 1cqw .45cqw; }
.dbtn[data-b="down"] .ico { translate: 1cqw 0; }
/* the arrows sit at the inner end of each arm, pointing out, next to the centre circle */
.dbtn .chev { position: absolute; width: 3.5cqw; height: 3.5cqw; color: #232c36; }
.dbtn[data-b="up"] .chev { bottom: -1.4cqw; left: 50%; margin-left: -1.75cqw; }
.dbtn[data-b="down"] .chev { top: -1.4cqw; left: 50%; margin-left: -1.75cqw; }
.dbtn[data-b="left"] .chev { right: -1.4cqw; top: 50%; margin-top: -1.75cqw; }
.dbtn[data-b="right"] .chev { left: -1.4cqw; top: 50%; margin-top: -1.75cqw; }
.dbtn.down { background: rgba(255, 255, 255, .16); }
.rage .dbtn .ico { display: none; }
.rage .dbtn .chev { position: static; margin: 0; width: 8cqw; height: 8cqw; color: #fdfbf8; }

/* the order lane: a ticket printer. A grey frame round a black slot with the printer mouth at the bottom.
   Each new ticket prints out of the mouth and pushes the strip up; the top ticket is the oldest, the next order.
   Nothing clips the strip: a long line rises out of the pad over the game (up to CFG.maxOrders tickets).
   The lane never takes taps, so tickets over the game never block anything under them. */
#lane {
  position: relative; width: 24.9cqw; height: 64cqw; border-radius: 5cqw; background: #555867; pointer-events: none;
  --pitch: 12.4cqw; --mouth: 8.5cqw; --print: .5s cubic-bezier(.25, .8, .35, 1);
}
#lane::before { content: ""; position: absolute; inset: 1cqw 1cqw 4cqw; border-radius: 4cqw; background: #000; }
/* the lip of the mouth, drawn over the paper so new tickets seem to come out from under it */
#lane::after {
  content: ""; position: absolute; left: 1.8cqw; right: 1.8cqw; bottom: calc(var(--mouth) - 1.2cqw); height: 1.6cqw;
  border-radius: .8cqw; background: #6c6f7a;
}
.ticket {
  --y: calc((1 - var(--k, 1)) * var(--pitch)); /* --k = 1 for the newest ticket, at the mouth */
  position: absolute; left: 2.5cqw; right: 2.5cqw; bottom: var(--mouth); height: var(--pitch);
  transform: translateY(var(--y));
  display: flex; align-items: center; gap: 1cqw; padding: .6cqw 1.2cqw .6cqw 3.2cqw;
  background: #d9d9d9; color: #111;
  transition: transform var(--print), opacity .25s, background .2s;
  animation: ticketIn var(--print);
}
.ticket::after {
  content: ""; position: absolute; left: 1.25cqw; right: 1.25cqw; bottom: 0; height: 1px;
  background: repeating-linear-gradient(90deg, #000 0 1.95cqw, transparent 1.95cqw 2.9cqw);
}
.ticket.front { background: #fffdf4; }
.ticket.hide { opacity: 0; }
.ticket .strip { position: absolute; left: 0; top: 0; bottom: 0; width: 1.8cqw; background: var(--good); }
.ticket[data-state="y"] .strip { background: var(--warn); }
.ticket[data-state="r"] .strip { background: var(--bad); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.ticket .tl { display: flex; flex-direction: column; align-items: center; gap: .3cqw; }
.ticket .arr { display: block; width: 6.4cqw; height: 6.4cqw; color: #111; }
.ticket .pr { font: 700 max(2.7cqw, 10px)/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.ticket .cm { display: flex; flex-direction: column; gap: .6cqw; }
.ticket .cm:empty { display: none; }
.ticket .m { display: block; width: 4.4cqw; height: 4.4cqw; }
.ticket .stamp {
  position: absolute; left: 50%; top: 46%; opacity: 0; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-14deg); border: .5cqw solid #111; padding: .3cqw 1cqw;
  font: 900 3.4cqw/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; background: rgba(255, 253, 244, .88);
}
.ticket.done { animation: tear .75s ease-in forwards; }
.ticket.done .stamp { animation: stampIn .22s ease-out forwards; }
.ticket.gone { opacity: 0; transform: translateY(var(--y)) scale(.7); }
.ticket.wrong { animation: tshake .4s; }
/* printing: the ticket rises out of the mouth while the part still inside is cut off (same timing as the strip sliding up) */
@keyframes ticketIn {
  from { transform: translateY(calc(var(--y) + var(--pitch))); clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0); } /* an explicit end, or the clip would jump instead of sliding */
}
@keyframes tear {
  0%, 32% { transform: translateY(var(--y)) rotate(0); opacity: 1; }
  100% { transform: translate(19cqw, calc(var(--y) - 5cqw)) rotate(16deg); opacity: 0; }
}
@keyframes stampIn {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(1.9); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(-14deg) scale(1); }
}
@keyframes tshake {
  0%, 100% { transform: translateY(var(--y)); }
  25% { transform: translate(-1.2cqw, var(--y)); }
  75% { transform: translate(1.2cqw, var(--y)); }
}
.rage #lane .ticket { visibility: hidden; } /* not display: none, so the tickets do not print again when rage ends */

#rageBox { display: none; position: absolute; inset: 1cqw 1cqw 4cqw; flex-direction: column; align-items: center; justify-content: center; gap: 1.2cqw; }
.rage #rageBox { display: flex; }
#rageBox .rl { font-size: max(2.6cqw, 10px); font-weight: 800; letter-spacing: .15em; color: var(--muted); }
#rageSecs { font-weight: 900; font-size: max(13cqw, 42px); line-height: 1; color: #ffd23f; text-shadow: 0 0 3cqw rgba(255, 140, 40, .7); }
#power { position: relative; width: 5.4cqw; flex: 1; max-height: 18cqw; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; }
#powerFill { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; background: linear-gradient(0deg, #ffd23f, #ff3b30); }

/* A (decaf, red) top right, B (plant milk, green) bottom left; flat circles like the reference */
#abpad, .hp-ab { width: 27.4cqw; height: 34.8cqw; }
#abpad { position: relative; margin-top: 9.4cqw; }
.abtn {
  position: absolute; width: 17.4cqw; height: 17.4cqw; border-radius: 50%; display: grid; place-items: center;
  transition: transform .06s, box-shadow .12s;
}
#btnA, .hp-ab .A { right: 0; top: 0; background: #f93446; }
#btnB, .hp-ab .B { left: 0; bottom: 0; background: #00b158; }
.abtn .ico { display: block; width: 10cqw; height: 10cqw; }
.abtn .ico-r { display: none; width: 9cqw; height: 9cqw; }
.rage .abtn .ico-n { display: none; }
.rage .abtn .ico-r { display: block; }
.abtn .lt {
  position: absolute; top: -.8cqw; left: -.8cqw; width: 5.6cqw; height: 5.6cqw; border-radius: 50%;
  background: #1f2024; color: #fdfbf8; border: .4cqw solid #555867;
  display: grid; place-items: center; font-weight: 800; font-size: max(3.2cqw, 12px);
}
.abtn.down { transform: scale(.93); }
.abtn.on { box-shadow: 0 0 0 1cqw var(--warn), 0 0 5cqw var(--warn); transform: scale(1.07); }
.abtn::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(rgba(0, 0, 0, .6) calc(var(--cd, 0) * 360deg), transparent 0);
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 6cqw;
  background: rgba(10, 11, 15, .8); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); text-align: center;
}
.card { width: 100%; }
.card h1 { margin: 0 0 4cqw; font-size: max(13cqw, 42px); line-height: .95; letter-spacing: .03em; color: #ffd23f; text-shadow: 0 .7cqw 0 #b3361b; }
.card p { margin: 0 0 2cqw; color: var(--muted); font-size: max(4cqw, 15px); }
.card ul { list-style: none; padding: 0; margin: 0 auto 6cqw; max-width: 78cqw; text-align: left; font-size: max(4cqw, 15px); line-height: 1.4; }
.card li { padding: 1.4cqw 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.card li b { color: #ffd23f; }
#overStats { margin: 3cqw auto 4cqw; }
#overStats li { display: flex; justify-content: space-between; color: var(--muted); }
#overStats b { white-space: nowrap; } /* "11:45 AM" stays on one line */
#overScore { font-size: max(16cqw, 52px); font-weight: 900; color: #ffe27a; margin: 2cqw 0; }
/* Buttons: pills with a flat bottom edge in a darker shade. Primary (red) is 60 x 13cqw at least,
   secondary (.alt, grey) 40 x 9.5cqw. Labels Inter 800, wide letter-spacing.
   One press for every pill: it moves down 1.2cqw onto its edge and the edge shrinks to .3cqw. The colours
   come from two variables (--btn-color, --btn-edge), so a variant (.alt, .armed) only swaps the colours and
   never sets its own shadow. The press uses `translate`, not `transform`, so it also works on TAP TO START,
   whose pulse animation owns `transform`. No transition: the press is instant (also for reduced motion). */
.cta {
  --btn-color: var(--cta); --btn-edge: var(--cta-shadow);
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 3cqw; margin-bottom: 1.5cqw; min-width: 60cqw; min-height: max(13cqw, 48px); padding: 0 7cqw;
  border-radius: 99px; background: var(--btn-color); color: #fff;
  font-family: var(--sans); font-weight: 800; letter-spacing: .13em; font-size: max(4.7cqw, 17px); line-height: 1.1;
  box-shadow: 0 1.5cqw 0 var(--btn-edge);
  touch-action: manipulation;
}
.cta:active { translate: 0 1.2cqw; box-shadow: 0 .3cqw 0 var(--btn-edge); }
.cta.alt { --btn-color: var(--secondary); --btn-edge: var(--secondary-shadow); }
.cta.armed { --btn-color: var(--cta); --btn-edge: var(--cta-shadow); } /* "END SHIFT? TAP AGAIN" */
.cta:disabled:active { translate: none; box-shadow: 0 1.5cqw 0 var(--btn-edge); } /* a disabled pill does not move */

/* ---------- pause, countdown, throw costs ---------- */
#pauseBtn { pointer-events: auto; position: relative; display: flex; flex-direction: column; align-items: center; gap: 1cqw; touch-action: manipulation; }
#pauseBtn .plabel {
  font-weight: 700; font-size: max(3.2cqw, 12px); letter-spacing: .14em; color: #f3e9dc;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}
#pauseBtn::after { content: ""; position: absolute; inset: -2cqw; } /* a bigger tap area than it looks */
#pauseBtn:active #clock { background: #2a2c34; }
.over-state #pauseBtn { pointer-events: none; }
.over-state #pauseBtn .plabel { visibility: hidden; }
.cta.alt {
  min-width: 40cqw; min-height: max(9.5cqw, 38px); padding: 0 6cqw; margin-top: 4cqw;
  font-size: max(2.6cqw, 11px); letter-spacing: .16em;
}
.btnrow { display: flex; gap: 3cqw; justify-content: center; }
.btnrow .cta { min-width: 0; flex: 1; max-width: 40cqw; padding-left: 3cqw; padding-right: 3cqw; }
#retryBtn, #againBtn { display: flex; margin-left: auto; margin-right: auto; }
#retryBtn + #againBtn { margin-top: 3cqw; }
#menuBtn { display: flex; align-items: center; justify-content: center; margin: 1cqw auto 0; } /* MENU, under PLAY AGAIN */
#challengeNote, #overChallenge { color: #ffd23f; font-weight: 800; }
#over { overflow-y: auto; touch-action: pan-y; place-items: start center; }
#over .card { margin: auto 0; }

/* ---------- barista name and save status (results screen) ---------- */
#nameBlock { max-width: 78cqw; margin: 0 auto 2cqw; text-align: left; }
#nameBlock label { display: block; margin-bottom: 1.5cqw; color: var(--ink); font-weight: 800; font-size: max(3.8cqw, 14px); }
.namerow { display: flex; gap: 2cqw; align-items: stretch; }
#nameInput {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 3cqw; border-radius: 2.5cqw;
  border: 2px solid rgba(255, 255, 255, .22); background: #0f1014; color: var(--ink);
  font: inherit; font-weight: 700; font-size: max(4.4cqw, 16px); /* 16px or more: iOS does not zoom in */
  user-select: text; -webkit-user-select: text; touch-action: manipulation; scroll-margin: 25cqh 0;
}
#nameInput:focus { outline: none; border-color: var(--accent); }
#nameSave { margin: 0; min-width: 0; padding: 0 4.5cqw; min-height: 48px; font-size: max(3.8cqw, 14px); touch-action: manipulation; }
#nameSave:disabled { opacity: .45; cursor: default; }
#nameBlock p { margin: 1.5cqw 0 0; font-size: max(3.2cqw, 12px); line-height: 1.4; }
#nameHint { color: var(--bad); font-weight: 700; }
#nameBlock .namenote { color: var(--muted); }
#shiftStatus {
  display: block; width: 100%; min-height: 44px; margin-top: 1.5cqw; padding: 1cqw 0; text-align: left;
  font-weight: 800; font-size: max(3.8cqw, 14px); color: var(--muted); cursor: default; touch-action: manipulation;
}
#shiftStatus.saved { color: var(--good); }
#shiftStatus.failed { color: var(--warn); text-decoration: underline; text-underline-offset: .25em; cursor: pointer; }
#boardBtn { display: flex; margin: 3cqw auto 1.5cqw; }
#boardBtn + #retryBtn, #boardBtn + .hidden + #againBtn { margin-top: 3cqw; }

/* ---------- full screens: pause and about (the splash is below) ---------- */
/* A yellow title near the top and the button stack (.actions) near the bottom, in the same place on the
   splash, pause and about screens. The backgrounds differ: see #pause and #about below. */
.overlay.screen { display: block; padding: 0; background: var(--screen-bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
/* Pause: the frozen game stays visible behind, dimmed with --screen-bg at 82%. No blur: the scene is still
   drawn every frame while paused, so a backdrop blur would be redone every frame on phones. */
#pause { background: rgba(44, 49, 57, .82); }
/* a soft dark halo keeps the yellow text clear over a busy frozen scene (the rage banner, the lane) */
#pause .screen-title, #pause .textlink { text-shadow: 0 0 2.5cqw rgba(20, 22, 27, .9), 0 .4cqw 1cqw rgba(20, 22, 27, .8); }
.screen-title {
  position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 18.5cqh); margin: 0;
  font-family: var(--sans); font-weight: 900; font-size: max(12.4cqw, 38px); line-height: 1; letter-spacing: .08em; color: var(--link);
}
.screen-title { padding-left: .08em; } /* letter-spacing adds space after the last letter; this keeps it centred */
.actions {
  position: absolute; left: 0; right: 0; bottom: var(--actions-bottom);
  display: flex; flex-direction: column; align-items: center; gap: 3.5cqw;
}
.actions .cta { margin: 0 0 1.5cqw; } /* the bottom margin is the flat edge (a shadow takes no room) */
/* plain yellow text that acts as a button (ABOUT); at least 44px to tap */
.textlink {
  min-height: max(44px, 11cqw); min-width: 40cqw; padding: 0 4cqw; touch-action: manipulation;
  font-family: var(--sans); font-weight: 800; font-size: max(3.4cqw, 13px); letter-spacing: .12em; color: var(--link);
}
.textlink:active { opacity: .7; }

/* About is dark and see-through like the how-to cards: .overlay's rgba(10, 11, 15, .8) with its 3px blur,
   over the still splash. Opened from Pause (.live, set by js/ui.js) the 3D scene behind is redrawn every
   frame, so there is no blur there. The buttons of the screen underneath are hidden while About is open; the
   scene is already dimmed by #pause, so a lighter shade gives about the same darkness. */
#about.overlay.screen { background: rgba(10, 11, 15, .8); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#about.overlay.screen.live { background: rgba(10, 11, 15, .6); backdrop-filter: none; -webkit-backdrop-filter: none; }
#game.about-open #start .actions, #game.about-live #pause > * { visibility: hidden; } /* no ghost buttons behind About */
#about .screen-title, #about .about-body { text-shadow: 0 0 2cqw rgba(10, 11, 15, .9); }

/* About: title, then the groups with equal gaps, then BACK where the primary button sits on the other
   screens. The space above the title and under BACK are two spacers (::before, ::after) that shrink on short
   phones before anything scrolls; only when they are at their minimum does the screen scroll. */
#about {
  display: flex; flex-direction: column; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain;
  padding: 0 4cqw;
  font-family: var(--mono); font-size: 16px; line-height: 1.4; letter-spacing: .02em; color: var(--text);
  user-select: text; -webkit-user-select: text;
}
#about .screen-title { position: static; flex: none; }
#about::before { content: ""; flex: 0 1 calc(env(safe-area-inset-top) + 18.5cqh); min-height: calc(env(safe-area-inset-top) + 6cqw); }
#about::after { content: ""; flex: 0 1 calc(var(--actions-bottom) + var(--below-primary)); min-height: var(--actions-bottom); }
.about-body {
  flex: 1 0 auto; display: flex; flex-direction: column; justify-content: space-evenly; gap: 5cqw;
  padding: 5cqw 0 4cqw;
}
.about-body p { margin: 0; }
.about-body b { color: var(--heading); font-weight: 700; }
.about-group { display: flex; flex-direction: column; align-items: center; }
#about a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  color: var(--link); text-decoration: underline; text-underline-offset: .2em; touch-action: manipulation;
}
#about a.plain { color: var(--text); text-decoration-color: rgba(194, 194, 194, .45); }
#about a.armed { color: var(--bad); font-weight: 700; } /* "Leave shift: tap again" */
#about .fine { font-size: 13px; line-height: 1.5; color: var(--date); }
.about-foot { flex: none; }
.about-foot .cta { margin: 0; }
#count { position: absolute; inset: 0; z-index: 19; display: grid; place-items: center; background: rgba(10, 11, 15, .45); pointer-events: none; }
#countNum { font-weight: 900; font-size: max(34cqw, 110px); color: #ffd23f; text-shadow: 0 1cqw 0 #b3361b; animation: countPop .9s ease-out; }
@keyframes countPop { from { transform: scale(1.6); opacity: 0; } 25% { opacity: 1; } to { transform: scale(.9); opacity: .9; } }
#game.frozen > *:not(#count):not(#pause), #game.frozen > *:not(#count):not(#pause) * { animation-play-state: paused !important; }
.abtn .cost {
  display: none; position: absolute; bottom: -1cqw; right: -1.6cqw; padding: .4cqw 1.2cqw; border-radius: 99px;
  background: #14151a; border: .4cqw solid rgba(255, 255, 255, .45); font-weight: 800; font-size: max(3cqw, 11px); color: #ffd23f;
}
.rage .abtn .cost { display: block; }
.abtn.broke { filter: grayscale(1) brightness(.6); opacity: .55; }

/* ---------- start screen (splash) ---------- */
/* The picture (assets/ui/splash-bg.webp, logo included) covers the screen, anchored at the top so the logo is
   never cropped. Under it lies a text title, seen only when the picture does not load (the single-file build).
   The layers are children of #start, so main.js's "WebGL needed" card (which replaces them) sits on plain dark. */
#start { background: var(--screen-bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.splash-title {
  position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 28cqw);
  font-weight: 900; font-size: max(17cqw, 52px); line-height: .95; letter-spacing: .03em; color: #ffd23f; text-shadow: 0 .9cqw 0 #b3361b;
}
.splash-pic { position: absolute; inset: 0; background: url("../assets/ui/splash-bg.webp") 50% 0 / cover no-repeat; }
.splash-shade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30%; pointer-events: none;
  background: linear-gradient(to top, rgba(10, 11, 15, .7), transparent);
}
#start #challengeNote {
  margin: 0 6cqw; padding: 2cqw 4cqw; border-radius: 3cqw; font-size: max(4cqw, 15px); line-height: 1.3;
  background: rgba(10, 11, 15, .85); box-shadow: 0 1cqw 3cqw rgba(0, 0, 0, .5);
}
#startBtn { animation: startPulse 1.6s ease-in-out infinite; }
@keyframes startPulse { 50% { transform: scale(1.04); } }

/* ---------- how to play (three swipeable cards, js/howto.js) ---------- */
#howto {
  display: flex; flex-direction: column; place-items: unset; padding: 0;
  padding-top: calc(env(safe-area-inset-top) + 3cqw); padding-bottom: calc(env(safe-area-inset-bottom) + 4cqw);
}
.hclose {
  position: absolute; z-index: 2; top: calc(env(safe-area-inset-top) + 1cqw); right: 2cqw; width: 48px; height: 48px;
  font-size: 34px; line-height: 1; color: var(--muted); touch-action: manipulation;
}
/* the swipe area: the page itself is touch-action: none, this strip scrolls sideways and snaps to a card */
.htrack {
  flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; touch-action: pan-x; scrollbar-width: none; overscroll-behavior-x: contain;
}
.htrack::-webkit-scrollbar { display: none; }
.hcard {
  flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; padding: 0 6cqw;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.5cqw; text-align: center;
}
.hcard h2 {
  margin: 0; font-size: max(8.5cqw, 28px); line-height: 1; letter-spacing: .04em; color: #ffd23f; text-shadow: 0 .5cqw 0 #b3361b;
}
.hcard p { margin: 0; font-size: max(4.4cqw, 16px); line-height: 1.3; color: var(--ink); }
.hcard p b { color: #ffd23f; }
.hcard p.hsmall { font-size: max(3.4cqw, 13px); color: var(--muted); }
.hdots { display: flex; justify-content: center; gap: 1cqw; margin: 2cqw 0 1cqw; }
.hdots button { position: relative; width: 6cqw; height: 6cqw; touch-action: manipulation; }
.hdots button::before {
  content: ""; position: absolute; inset: 1.5cqw; border-radius: 50%; background: rgba(255, 255, 255, .28); transition: transform .2s, background .2s;
}
.hdots button.on::before { background: #ffd23f; transform: scale(1.35); }
#howNext { align-self: center; margin-top: 1cqw; touch-action: manipulation; }

/* the little animated scenes: sizes in cqw like the game, so the pad in a scene is the size of the real pad */
.hscene {
  position: relative; width: 100%; height: 98cqw; flex: none; overflow: hidden; pointer-events: none;
  border-radius: 6cqw; background: linear-gradient(#4b5360, #2d3138); border: .6cqw solid #2c2e36;
}
.sc-pad {
  position: absolute; left: 0; right: 0; bottom: 0; height: 47cqw; background: #1f2024; border-radius: 8cqw 8cqw 0 0;
}
.hp-dpad { position: absolute; left: 6cqw; top: 5cqw; }
.hp-dpad .dbtn { transition: background .1s; }
.hp-ab { position: absolute; right: 6cqw; top: 8cqw; }

/* a press: the control dips and a yellow ring spreads from it; a number badge tells the order */
.hscene .dbtn.down { background: rgba(255, 210, 63, .35); }
.rip {
  position: absolute; inset: -1cqw; border: .9cqw solid #ffd23f; border-radius: inherit; pointer-events: none;
  animation: ripple .55s ease-out forwards;
}
@keyframes ripple { from { transform: scale(.7); opacity: 1; } to { transform: scale(1.55); opacity: 0; } }
.step {
  position: absolute; z-index: 3; top: -3cqw; right: -3cqw; width: 7.4cqw; height: 7.4cqw; border-radius: 50%;
  display: grid; place-items: center; background: #ffd23f; color: var(--bg); font-weight: 900; font-size: max(4.4cqw, 15px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .6); animation: pop .25s cubic-bezier(.2, 1.6, .4, 1);
}

/* customers and their bubbles */
.hcust { position: absolute; width: 24cqw; height: 26.1cqw; left: 32.5cqw; top: 23.5cqw; }
.hcust svg { width: 100%; height: 100%; }
.hcust.in { animation: custIn .5s ease-out; }
.hcust.out { animation: custOut .6s ease-in forwards; }
@keyframes custIn { from { transform: translateX(45cqw); opacity: 0; } }
@keyframes custOut { to { transform: translateX(-45cqw); opacity: 0; } }
.hcust.hit { animation: hit .5s linear forwards; }
@keyframes hit { 20%, 60% { transform: translateX(-2cqw) rotate(-6deg); } 40%, 80% { transform: translateX(2cqw) rotate(6deg); } 100% { transform: translateY(-4cqw) scale(.5); opacity: 0; } }
.hcust.aim svg { filter: drop-shadow(0 0 1.2cqw #ff3b30) drop-shadow(0 0 1.2cqw #ff3b30); }
.hscene .bubble { --bs: 20cqw; left: 34.5cqw; top: 0; }
.hscene .bubble.sm { --bs: 14cqw; }
.hscene .floater { z-index: 4; }

/* scene 3: the rage bar, the banner and the thrown mug */
.hrage {
  position: absolute; left: 4cqw; right: 4cqw; top: 4cqw; height: 6cqw; border-radius: 99px; overflow: hidden;
  background: rgba(10, 10, 14, .72); border: .5cqw solid rgba(255, 255, 255, .2);
}
.hrage i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #ffd23f, #ff8a2b 55%, #ff3b30); transition: width .5s ease-out; }
.hrage span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; letter-spacing: .22em; font-size: max(3cqw, 11px); text-shadow: 0 1px 2px #000; }
.rage .hrage { animation: rainbow 1s linear infinite; }
.hbanner {
  position: absolute; left: 0; right: 0; top: 14cqw; text-align: center; opacity: 0; z-index: 5;
  font-weight: 900; font-size: max(11cqw, 34px); letter-spacing: .04em; color: #fff;
  text-shadow: 0 .6cqw 0 #c4281c, 0 0 4cqw rgba(255, 90, 40, .9);
}
.hbanner.show { animation: banner 1.5s ease-out; }
.hscene.rage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 14cqw rgba(255, 60, 30, .8); }
.hproj { position: absolute; z-index: 4; width: 9cqw; height: 9cqw; left: 69cqw; top: 63cqw; opacity: 0; }
.hproj.fly { opacity: 1; transition: transform .6s cubic-bezier(.3, .7, .5, 1); }

/* "Reduce motion" on the phone or computer: no sliding, flying or pulsing. The blinking sequences still play,
   because they are the lesson. */
@media (prefers-reduced-motion: reduce) {
  #startBtn { animation: none; }
  .hcust.in { animation: none; }
  .hcust.out, .hcust.hit { animation: none; opacity: 0; }
  .hproj.fly { transition: none; }
}
