/* 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;
  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: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
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: #2d3138;
}
#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: center; }
#money { text-align: right; }
#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.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 .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: 20%; }
.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%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); border: 1.5px solid rgba(0, 0, 0, .2);
}
#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%; background: #fff;
  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 ---------- */
#pad {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 3cqw 3cqw calc(env(safe-area-inset-bottom) + 3cqw);
  background: rgba(20, 21, 26, .94);
  border-radius: 6cqw 6cqw 0 0;
  box-shadow: 0 -1cqw 4cqw rgba(0, 0, 0, .45);
}
#dpad { display: grid; grid-template-columns: repeat(3, 12.6cqw); grid-template-rows: repeat(3, 12.6cqw); gap: .6cqw; }
.dbtn {
  position: relative; border-radius: 2.4cqw; background: #34363f;
  box-shadow: inset 0 -.8cqw 0 rgba(0, 0, 0, .38), 0 .5cqw 1cqw rgba(0, 0, 0, .4);
  display: grid; place-items: center; transition: transform .06s, background .06s;
}
.dbtn[data-b="up"] { grid-area: 1 / 2; --c: #f0b43c; }
.dbtn[data-b="left"] { grid-area: 2 / 1; --c: #e9d9bd; }
.dbtn[data-b="right"] { grid-area: 2 / 3; --c: #4a98e8; }
.dbtn[data-b="down"] { grid-area: 3 / 2; --c: #ff6b5e; }
.dcenter { grid-area: 2 / 2; background: #2a2c34; border-radius: 1.4cqw; }
.dbtn .ico { display: block; width: 8.2cqw; height: 8.2cqw; }
.dbtn .chev { position: absolute; width: 3.4cqw; height: 3.4cqw; color: var(--c); }
.dbtn[data-b="up"] .chev { top: .5cqw; left: 50%; margin-left: -1.7cqw; }
.dbtn[data-b="down"] .chev { bottom: .5cqw; left: 50%; margin-left: -1.7cqw; }
.dbtn[data-b="left"] .chev { left: .5cqw; top: 50%; margin-top: -1.7cqw; }
.dbtn[data-b="right"] .chev { right: .5cqw; top: 50%; margin-top: -1.7cqw; }
.dbtn.down { transform: translateY(.5cqw) scale(.96); background: #4b4e5a; }
.rage .dbtn .ico { display: none; }
.rage .dbtn .chev { position: static; margin: 0; width: 7.4cqw; height: 7.4cqw; }

/* the order lane: kitchen tickets hanging from a rail, black ink on paper */
#lane { position: relative; width: 21cqw; height: 52cqw; border-radius: 3cqw; background: rgba(255, 255, 255, .05); overflow: hidden; --pitch: 12.4cqw; }
#lane::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2cqw; z-index: 2;
  background: linear-gradient(#a9acb6, #6c6f7a); box-shadow: 0 .5cqw 1cqw rgba(0, 0, 0, .5);
}
.ticket {
  --y: calc(var(--i, 0) * var(--pitch));
  position: absolute; left: 1cqw; right: 1cqw; top: 2.6cqw; height: 12cqw;
  transform: translateY(var(--y));
  display: flex; align-items: center; gap: 1cqw; padding: .6cqw 1.2cqw 1.6cqw 3.2cqw;
  background: #d8d3c6; color: #111; border-radius: .6cqw .6cqw 0 0;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% 0 / 2.4cqw 100% repeat-x;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% 0 / 2.4cqw 100% repeat-x;
  transition: transform .34s cubic-bezier(.2, .9, .3, 1.15), opacity .25s, background .2s;
  animation: ticketIn .35s ease-out;
}
.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; }
@keyframes ticketIn { from { opacity: 0; transform: translateY(calc(var(--y) + 6cqw)); } }
@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 { display: none; }
.rage #lane::before { display: none; }

#rageBox { display: none; position: absolute; inset: 0; 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); }

#abpad { position: relative; width: 34cqw; height: 38cqw; }
.abtn {
  position: absolute; width: 17cqw; height: 17cqw; border-radius: 50%; display: grid; place-items: center;
  box-shadow: inset 0 -1cqw 0 rgba(0, 0, 0, .28), 0 .8cqw 1.6cqw rgba(0, 0, 0, .45);
  transition: transform .06s, box-shadow .12s;
}
#btnA { right: 0; top: 3cqw; background: #e5484d; }
#btnB { left: 0; bottom: 3cqw; background: #2fae62; }
.abtn .ico { display: block; width: 10cqw; height: 10cqw; }
.abtn .ico-r { display: none; }
.rage .abtn .ico-n { display: none; }
.rage .abtn .ico-r { display: block; }
.abtn .lt {
  position: absolute; top: -1.2cqw; left: -1.2cqw; width: 5.6cqw; height: 5.6cqw; border-radius: 50%;
  background: #14151a; border: .4cqw solid rgba(255, 255, 255, .45);
  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), inset 0 -1cqw 0 rgba(0, 0, 0, .28); 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; }
#overScore { font-size: max(16cqw, 52px); font-weight: 900; color: #ffe27a; margin: 2cqw 0; }
.cta {
  margin-top: 3cqw; padding: 4cqw 9cqw; border-radius: 99px; background: #e5484d; color: #fff;
  font-weight: 900; letter-spacing: .08em; font-size: max(4.4cqw, 16px);
  box-shadow: inset 0 -.9cqw 0 rgba(0, 0, 0, .25), 0 1cqw 3cqw rgba(0, 0, 0, .5);
}
.cta:active { transform: translateY(.5cqw); }

/* ---------- pause, countdown, throw costs ---------- */
#pauseBtn {
  pointer-events: auto; position: relative; width: max(9cqw, 36px); height: max(9cqw, 36px); border-radius: 50%;
  background: rgba(10, 10, 14, .72); border: .5cqw solid rgba(255, 255, 255, .25);
  display: flex; align-items: center; justify-content: center; gap: 1.3cqw;
}
#pauseBtn i { display: block; width: 1.6cqw; height: 3.8cqw; background: #fff; border-radius: .4cqw; }
#pauseBtn::after { content: ""; position: absolute; inset: -2cqw; }
#pauseBtn:active { background: rgba(60, 62, 72, .85); }
.over-state #pauseBtn { visibility: hidden; }
.cta.alt { background: #3a3d49; margin-top: 4cqw; }

/* ---------- about / credits ---------- */
#about { background: rgba(10, 11, 15, .97); }
.link {
  margin-top: 3cqw; padding: 3cqw 5cqw; min-height: 44px; color: var(--muted);
  font-size: max(3.6cqw, 14px); text-decoration: underline; text-underline-offset: .25em;
}
.card a { color: #ffd23f; display: inline-block; padding: 1.5cqw 0; }
.card p b { color: var(--ink); }
.card .fine { margin-top: 5cqw; font-size: max(3.2cqw, 12px); line-height: 1.5; }
#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; }
