@font-face {
  font-family: "Grotesque";
  src: url("../assets/fonts/grotesque.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --cream: #f6e8c6;
  --cream-2: #fbf2da;
  --ink: #1d1916;
  --tomato: #e2452f;
  --magenta: #c42a6b;
  --mustard: #f5b733;
  --cyan: #7fc9e4;
  --green: #4e9f52;
  --shadow: #1d1916;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: "Grotesque", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

button { font-family: inherit; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--cream);
}

#stage, #game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game { touch-action: none; }
#game canvas { display: block; width: 100% !important; height: 100% !important; }

/* newsprint screen over everything */
#grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  background-image: radial-gradient(circle, rgba(29, 25, 22, 0.20) 0.9px, transparent 1.35px);
  background-size: 4px 4px;
  opacity: 0.20;
  mix-blend-mode: multiply;
}

#frame {
  position: absolute;
  inset: 7px;
  z-index: 44;
  pointer-events: none;
  border: 2px solid rgba(29, 25, 22, 0.9);
  box-shadow: 0 0 0 5px rgba(246, 232, 198, 0.9), inset 0 0 40px rgba(29, 25, 22, 0.08);
}

#flash {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(226, 69, 47, 0) 34%, rgba(226, 69, 47, 0.92) 100%);
  transition: opacity 90ms linear;
}
#flash.on { opacity: 1; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.score-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  width: clamp(134px, 25vw, 248px);
  transform: rotate(-4deg);
  filter: drop-shadow(5px 7px 0 rgba(29, 25, 22, 0.20));
  animation: tagSway 6s ease-in-out infinite;
}
@keyframes tagSway {
  0%, 100% { transform: rotate(-4.4deg); }
  50% { transform: rotate(-2.4deg); }
}

.tag-art { display: block; width: 100%; height: auto; }

.tag-panel {
  position: absolute;
  left: 15%;
  top: 27%;
  width: 70%;
  height: 50%;
  transform: rotate(-2.6deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--ink);
  background-color: #f8eccd;
  background-image: radial-gradient(circle, rgba(29, 25, 22, 0.075) 0.7px, transparent 1.05px);
  background-size: 5px 5px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(29, 25, 22, 0.10);
}

.tag-kicker {
  font-family: "Grotesque", "Arial Narrow", sans-serif;
  font-size: clamp(10px, 1.5vw, 17px);
  letter-spacing: 0.08em;
  line-height: 1;
  margin-bottom: 0.12em;
}

.tag-num {
  font-family: "Grotesque", "Arial Narrow", sans-serif;
  font-style: italic;
  font-size: clamp(30px, 5.6vw, 64px);
  line-height: 0.9;
  letter-spacing: -0.04em;
  transform: scaleX(0.92) rotate(-1deg);
  text-shadow: 2px 2px 0 rgba(29, 25, 22, 0.13);
}

.best-burst {
  position: absolute;
  top: 6px;
  right: 8px;
  width: clamp(150px, 27vw, 286px);
  transform: rotate(3deg);
  filter: drop-shadow(5px 7px 0 rgba(29, 25, 22, 0.18));
}
.burst-art { display: block; width: 100%; height: auto; }

.burst-panel {
  position: absolute;
  inset: 13% 14% 12% 14%;
  border-radius: 46% 54% 48% 52% / 52% 46% 54% 48%;
  background-color: var(--magenta);
  background-image: radial-gradient(circle, rgba(255, 235, 246, 0.26) 1px, transparent 1.5px);
  background-size: 7px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff8ea;
  text-align: center;
  transform: rotate(-2deg);
  box-shadow: inset 0 0 0 3px rgba(29, 25, 22, 0.85);
}

.burst-kicker {
  font-size: clamp(7px, 1.15vw, 12px);
  letter-spacing: 0.12em;
  line-height: 1.05;
  -webkit-text-stroke: 1.3px var(--ink);
  paint-order: stroke fill;
}
.burst-sub {
  font-size: clamp(8px, 1.4vw, 14px);
  letter-spacing: 0.10em;
  line-height: 1.1;
  margin-top: 0.15em;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
}
.burst-num {
  font-size: clamp(24px, 4.6vw, 52px);
  line-height: 0.9;
  margin-top: 0.12em;
  letter-spacing: -0.03em;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 2px 2px 0 rgba(29, 25, 22, 0.35);
}

.wordmark {
  position: absolute;
  top: 8px;
  left: 50%;
  width: clamp(180px, 27vw, 420px);
  transform: translateX(-50%) rotate(-1deg);
  filter: drop-shadow(4px 5px 0 rgba(29, 25, 22, 0.16));
  opacity: 0;
  transition: opacity 240ms ease;
}
body.playing .wordmark { opacity: 1; }

/* ---------- painted buttons ---------- */
.painted-btn {
  display: inline-block;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
  transition: transform 70ms ease, filter 70ms ease;
  filter: drop-shadow(2px 4px 0 rgba(29, 25, 22, 0.28));
  touch-action: manipulation;
}
.painted-btn img { display: block; width: 100%; height: auto; pointer-events: none; }
.painted-btn:hover { filter: drop-shadow(1px 2px 0 rgba(29, 25, 22, 0.30)) brightness(1.03); transform: translate(1px, 2px); }
.painted-btn:active { filter: drop-shadow(0 0 0 rgba(29, 25, 22, 0)) brightness(0.9); transform: translate(3px, 5px) scale(0.985); }
.painted-btn:focus-visible { outline: 3px dashed var(--tomato); outline-offset: 4px; }

/* ---------- controls ---------- */
#controls {
  position: absolute;
  z-index: 22;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.round-btn { width: clamp(56px, 7vw, 86px); position: relative; }

.sound-off {
  position: absolute;
  inset: 24% 22%;
  display: none;
  background: linear-gradient(to top right, transparent 44%, var(--tomato) 44%, var(--tomato) 56%, transparent 56%);
  filter: drop-shadow(1px 1px 0 var(--cream));
}
body.muted .sound-off { display: block; }

#hint {
  position: absolute;
  z-index: 21;
  opacity: 0;
  transition: opacity 200ms ease;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) rotate(-1deg);
  white-space: nowrap;
  pointer-events: none;
}
body.playing #hint { opacity: 1; }

.shelf-label {
  display: inline-block;
  font-size: clamp(10px, 1.2vw, 14px);
  letter-spacing: 0.10em;
  color: var(--ink);
  background: var(--mustard);
  padding: 0.52em 0.9em 0.46em;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-1deg);
}

.toast {
  position: absolute;
  z-index: 24;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -10px) rotate(-4deg) scale(0.8);
  opacity: 0;
  pointer-events: none;
  background: var(--magenta);
  color: #fff8ea;
  font-size: clamp(18px, 3vw, 34px);
  letter-spacing: 0.06em;
  padding: 0.2em 0.75em 0.14em;
  border: 3px solid var(--ink);
  box-shadow: 5px 6px 0 var(--ink);
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.on { opacity: 1; transform: translate(-50%, 0) rotate(-4deg) scale(1); }

/* ---------- cover ---------- */
.cover {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 4vw, 52px);
  background-color: rgba(246, 232, 198, 0.92);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(196, 42, 107, 0.10) 0 70px, transparent 72px),
    radial-gradient(circle at 88% 76%, rgba(226, 69, 47, 0.10) 0 110px, transparent 112px),
    radial-gradient(circle, rgba(29, 25, 22, 0.15) 0.8px, transparent 1.2px);
  background-size: auto, auto, 5px 5px;
  transition: opacity 260ms ease, transform 260ms ease;
}
.cover.hidden { opacity: 0; transform: translateY(-2%); pointer-events: none; }

.cover-inner {
  width: min(900px, 94%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(6px, 1.3vh, 16px);
}

.cover-kicker {
  display: flex;
  gap: 0.7em;
  align-items: center;
  font-size: clamp(11px, 1.5vw, 18px);
  letter-spacing: 0.22em;
  color: var(--tomato);
  text-shadow: 1px 1px 0 rgba(29, 25, 22, 0.12);
}
.cover-kicker .dot { color: var(--ink); }

.cover-title {
  width: auto;
  max-width: 92%;
  max-height: 33vh;
  height: auto;
  display: block;
  filter: drop-shadow(6px 9px 0 rgba(29, 25, 22, 0.15));
  transform: rotate(-1.2deg);
}

.cover-sub {
  margin: 0;
  max-width: 46ch;
  font-size: clamp(13px, 1.6vw, 19px);
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.cover-sub::before { content: ""; }

.cover-price {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: clamp(10px, 1.2vw, 14px);
  letter-spacing: 0.14em;
  margin-top: 0.1em;
}
.price-burst {
  display: inline-block;
  background: var(--magenta);
  color: #fff8ea;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 0.24em 0.5em 0.2em;
  transform: rotate(-5deg);
  font-size: clamp(17px, 2.2vw, 26px);
  line-height: 0.9;
}
.price-burst small { font-size: 0.48em; letter-spacing: 0.08em; margin-left: 0.18em; }

.start-btn { width: clamp(190px, 25vw, 290px); margin-top: 0.35em; }

.cover-hint { font-size: clamp(10px, 1.2vw, 14px); }
.cover-best {
  display: none;
  font-size: clamp(11px, 1.3vw, 15px);
  letter-spacing: 0.14em;
  color: var(--ink);
}
.cover-best b { color: var(--tomato); font-size: 1.35em; margin-left: 0.3em; }

/* ---------- pause ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(29, 25, 22, 0.22);
  backdrop-filter: blur(1.5px);
}
.modal.hidden { display: none; }

.shelf-sign {
  position: relative;
  width: min(520px, 96%);
  background: linear-gradient(180deg, var(--cream-2), #f2e0b8);
  border: 3px solid var(--ink);
  box-shadow: 9px 10px 0 var(--ink), inset 0 -16px 0 var(--mustard);
  padding: 22px 22px 34px;
  text-align: center;
  transform: rotate(-1.4deg);
  animation: signDrop 200ms cubic-bezier(.2,.9,.3,1.3);
}
@keyframes signDrop {
  from { transform: translateY(-20px) rotate(-4deg); opacity: 0; }
  to { transform: translateY(0) rotate(-1.4deg); opacity: 1; }
}
.sign-top {
  display: inline-block;
  font-size: clamp(10px, 1.4vw, 14px);
  letter-spacing: 0.2em;
  color: var(--tomato);
}
.shelf-sign h2 {
  margin: 0.1em 0 0.2em;
  font-size: clamp(44px, 8vw, 90px);
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--mustard);
}
.shelf-sign p {
  margin: 0 0 1em;
  font-size: clamp(10px, 1.2vw, 14px);
  letter-spacing: 0.12em;
}
.small-btn { width: clamp(130px, 18vw, 180px); }

/* ---------- receipt ---------- */
.receipt {
  position: relative;
  width: min(470px, 92vw);
  max-height: min(90vh, 780px);
  aspect-ratio: 560 / 744;
  filter: drop-shadow(12px 16px 0 rgba(29, 25, 22, 0.30));
  animation: receiptDrop 420ms cubic-bezier(.2,.9,.25,1.15);
}
@keyframes receiptDrop {
  from { transform: translateY(-32vh) rotate(-5deg); opacity: 0; }
  to { transform: translateY(0) rotate(-0.6deg); opacity: 1; }
}
.receipt-paper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.receipt-body {
  position: absolute;
  inset: 7% 10% 9%;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  text-align: left;
}
.receipt-head {
  font-size: clamp(16px, 2.4vw, 27px);
  letter-spacing: 0.02em;
  line-height: 0.92;
  text-align: center;
}
.receipt-head span {
  display: block;
  font-size: 0.44em;
  letter-spacing: 0.14em;
  margin-top: 0.35em;
}
.receipt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 4% 0 2%;
}
.receipt-owl {
  width: 44%;
  max-height: 110px;
  object-fit: contain;
  transform: rotate(-8deg);
  filter: drop-shadow(2px 3px 0 rgba(29, 25, 22, 0.18));
}
.receipt-stamp {
  width: 42%;
  color: var(--tomato);
  border: 2px solid var(--tomato);
  padding: 0.3em 0.3em;
  transform: rotate(4deg);
  font-size: clamp(9px, 1.4vw, 13px);
  line-height: 1.05;
  letter-spacing: 0.12em;
  text-align: center;
  opacity: 0.92;
}
.receipt-rows { border-top: 2px solid var(--ink); border-bottom: 2px dashed var(--ink); padding: 3% 0 2%; }
.receipt-rows > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: clamp(11px, 1.7vw, 17px);
  letter-spacing: 0.06em;
  padding: 0.15em 0;
}
.receipt-rows span { opacity: 0.82; }
.receipt-rows b { font-size: 1.25em; letter-spacing: -0.01em; }
.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--ink);
  padding: 2.5% 0 3%;
  color: var(--tomato);
  font-size: clamp(13px, 2.1vw, 21px);
  letter-spacing: 0.04em;
}
.receipt-total b { font-size: clamp(22px, 3.6vw, 40px); letter-spacing: -0.02em; }
.receipt-barcode {
  height: 9%;
  min-height: 18px;
  margin: 4% auto 2%;
  width: 82%;
  background-image: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 5px, var(--ink) 5px 6px, transparent 6px 10px, var(--ink) 10px 14px, transparent 14px 17px);
  opacity: 0.9;
}
.again-btn { width: min(150px, 46%); margin: 0.1em auto 0; }
.receipt-foot {
  text-align: center;
  font-size: clamp(8px, 1.1vw, 11px);
  letter-spacing: 0.08em;
  line-height: 1.15;
  margin: 0.4em auto 0;
  max-width: 76%;
  opacity: 0.85;
}

/* ---------- loader ---------- */
.loader {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  transition: opacity 320ms ease;
}
.loader.hidden { opacity: 0; pointer-events: none; }
.loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 3px solid var(--ink);
  background: var(--cream-2);
  box-shadow: 7px 8px 0 var(--ink);
  padding: 20px 30px 24px;
  transform: rotate(-1deg);
}
.loader-top {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--tomato);
}
.loader-card b { font-size: clamp(20px, 3vw, 34px); letter-spacing: 0.04em; }
.loader-dots { display: flex; gap: 6px; margin-top: 4px; }
.loader-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink);
  animation: dotPulse 900ms infinite alternate;
}
.loader-dots i:nth-child(2) { animation-delay: 150ms; }
.loader-dots i:nth-child(3) { animation-delay: 300ms; }
@keyframes dotPulse { from { transform: translateY(0); opacity: 0.3; } to { transform: translateY(-5px); opacity: 1; } }

.hidden { display: none !important; }

/* ---------- narrow screens ---------- */
@media (max-aspect-ratio: 5/4) {
  .score-tag { width: clamp(120px, 33vw, 190px); top: 10px; left: 8px; }
  .best-burst { width: clamp(130px, 36vw, 200px); top: 4px; right: 4px; }
  .wordmark { display: none; }
  .tag-kicker { font-size: clamp(9px, 2.6vw, 12px); }
  .tag-num { font-size: clamp(26px, 7.6vw, 38px); }
  .burst-kicker { font-size: clamp(6px, 1.9vw, 9px); }
  .burst-sub { font-size: clamp(7px, 2.2vw, 10px); }
  .burst-num { font-size: clamp(20px, 6.6vw, 34px); }
  .cover { padding: 10px 14px; }
  .cover-inner { gap: 5px; }
  .cover-title { width: 94%; }
  .cover-sub { font-size: 12px; max-width: 34ch; }
  .cover-hint { font-size: 9px; }
  .cover-best { font-size: 10px; }
  #hint { bottom: 12px; font-size: 9px; padding: 0.42em 0.6em 0.38em; }
  #controls { left: 10px; bottom: 10px; gap: 6px; }
  .round-btn { width: 50px; }
  #frame { inset: 4px; }
  .receipt { width: min(430px, 94vw); }
  .receipt-body { inset: 6.5% 9% 8.5%; }
  .receipt-owl { max-height: 72px; }
  .receipt-top { margin: 2% 0 1%; }
  .receipt-barcode { min-height: 13px; margin: 3% auto 1%; }
  .again-btn { width: min(120px, 42%); }
  .receipt-foot { font-size: 7px; margin-top: 0.25em; }
}

@media (max-height: 620px) {
  .cover-sub { display: none; }
  .cover-price { display: none; }
  .cover-title { width: min(620px, 78%); }
  .start-btn { width: clamp(150px, 20vw, 220px); }
  #hint { display: none; }
  .cover-hint { font-size: 9px; }
}

@media (max-height: 690px) {
  .receipt-owl { max-height: 54px; }
  .receipt-head { font-size: 14px; }
  .receipt-barcode { display: none; }
  .receipt-rows > div { font-size: 10px; padding: 0.05em 0; }
  .receipt-total b { font-size: 22px; }
  .again-btn { width: 110px; }
  .receipt-top { margin: 1% 0; }
  .receipt-foot { font-size: 7px; }
}
