:root {
  --ink: #24223b;
  --cream: #fff8ed;
  --paper: #fffdf8;
  --pink: #f26791;
  --pink-dark: #dc4775;
  --yellow: #ffd464;
  --mint: #a9dfc9;
  --blue: #9fd5e8;
  --shadow: 0 28px 80px rgba(89, 43, 73, 0.2), 0 6px 0 rgba(85, 44, 73, 0.08);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(255,255,255,.72) 0 1.5px, transparent 2px) 0 0 / 28px 28px,
    linear-gradient(145deg, #ffd7df 0%, #f9b9ca 45%, #f6a7bd 100%);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, a { font: inherit; }
button { color: inherit; }

.sprinkles, .sprinkles::before, .sprinkles::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

.sprinkles {
  opacity: .48;
  background:
    linear-gradient(26deg, transparent 49%, #fff 50% 54%, transparent 55%) 7% 17% / 36px 16px no-repeat,
    linear-gradient(70deg, transparent 48%, #f36f68 49% 54%, transparent 55%) 91% 18% / 30px 18px no-repeat,
    linear-gradient(19deg, transparent 48%, #fae888 49% 54%, transparent 55%) 9% 72% / 32px 18px no-repeat,
    linear-gradient(120deg, transparent 48%, #77cabc 49% 54%, transparent 55%) 92% 77% / 34px 18px no-repeat;
}

.sprinkles::before {
  background:
    radial-gradient(ellipse at center, #fff 0 42%, transparent 46%) 16% 35% / 12px 5px no-repeat,
    radial-gradient(ellipse at center, #755b9a 0 42%, transparent 46%) 83% 42% / 13px 6px no-repeat,
    radial-gradient(ellipse at center, #fff 0 42%, transparent 46%) 78% 88% / 12px 5px no-repeat;
  transform: rotate(-16deg);
}

.app-shell {
  width: min(100% - 28px, 920px);
  margin: 0 auto;
  padding: 22px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark { position: relative; width: 46px; height: 50px; display: block; }
.brand-scoop { position: absolute; border-radius: 50%; width: 24px; height: 24px; top: 2px; box-shadow: inset -3px -4px rgba(0,0,0,.07); }
.scoop-a { left: 5px; background: var(--yellow); }
.scoop-b { right: 4px; top: 5px; background: var(--mint); }
.brand-cone { position: absolute; left: 11px; top: 23px; width: 27px; height: 27px; background: #da8548; clip-path: polygon(0 0, 100% 0, 52% 100%); }
.brand small { display: block; font-weight: 800; font-size: 9px; letter-spacing: .26em; line-height: 1; margin-bottom: 2px; }
.brand strong { font-family: "Shrikhand", Georgia, serif; font-size: 22px; line-height: 1; letter-spacing: .01em; }

.icon-button {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(36,34,59,.12);
  border-radius: 50%;
  background: rgba(255,255,255,.48);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .2s, background .2s;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.menu-button { height: 42px; display: flex; align-items: center; gap: 6px; padding: 0 13px; border: 2px solid rgba(36,34,59,.12); border-radius: 100px; background: rgba(255,255,255,.48); color: var(--ink); text-decoration: none; font-size: 11px; font-weight: 800; }
.menu-button:hover { background: rgba(255,255,255,.8); }
.menu-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-button:hover { transform: rotate(-6deg) scale(1.05); background: rgba(255,255,255,.8); }
.icon-button svg { width: 20px; height: 20px; fill: currentColor; }
.sound-on { display: none; }
.icon-button[aria-pressed="true"] .sound-on { display: block; }
.icon-button[aria-pressed="true"] .sound-off { display: none; }

.game-card {
  border: 4px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.scoreboard {
  height: 82px;
  display: grid;
  grid-template-columns: 1fr 2.2fr 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-bottom: 3px solid var(--ink);
  background: #fffdf9;
}

.stat { display: flex; flex-direction: column; }
.stat-right { text-align: right; align-items: flex-end; }
.stat-label { font-size: 10px; letter-spacing: .18em; font-weight: 800; opacity: .55; }
.stat > strong { font-size: clamp(24px, 4vw, 34px); line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat small { font-size: .48em; }

.order { text-align: center; align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; border-inline: 2px dashed rgba(36,34,59,.14); }
.order-flavor { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.order-flavor strong { font-family: "Shrikhand", Georgia, serif; font-size: clamp(17px, 3.2vw, 24px); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-scoop { width: 20px; height: 20px; border-radius: 50% 50% 44% 48%; background: #f486a3; box-shadow: inset -3px -3px rgba(0,0,0,.07); flex: 0 0 auto; }

.game-stage {
  position: relative;
  height: min(64vh, 590px);
  min-height: 430px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.16) 1px, transparent 1px) 0 0 / 100% 56px,
    linear-gradient(180deg, #fff2dc 0%, #ffe7bc 64%, #f7c990 64.2%, #edae6b 100%);
  touch-action: none;
}

.game-stage::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 0; right: 0; top: 64%; height: 5px;
  background: rgba(106,63,49,.14);
  box-shadow: 0 25px 50px rgba(111,57,31,.16);
}

#gameCanvas { width: 100%; height: 100%; display: block; position: relative; z-index: 1; }

.overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(255,255,255,.78), rgba(255,239,211,.9));
  transition: opacity .26s, visibility .26s;
}

.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay-card { width: min(100%, 530px); text-align: center; }
.eyebrow { display: inline-block; font-size: 11px; letter-spacing: .2em; font-weight: 800; color: var(--pink-dark); margin-bottom: 12px; }
.overlay h1, .overlay h2 { font-family: "Shrikhand", Georgia, serif; font-weight: 400; margin: 0; line-height: .98; letter-spacing: .01em; }
.overlay h1 { font-size: clamp(42px, 8vw, 72px); }
.overlay h1 em { color: var(--pink); font-style: normal; -webkit-text-stroke: 1px var(--ink); text-shadow: 3px 3px 0 rgba(36,34,59,.1); }
.overlay h2 { font-size: clamp(38px, 7vw, 60px); }
.overlay-card > p { width: min(100%, 440px); margin: 18px auto; font-size: clamp(14px, 2.5vw, 17px); line-height: 1.55; font-weight: 600; color: rgba(36,34,59,.72); }

.how-to { display: flex; justify-content: center; gap: 10px; margin: 21px 0; flex-wrap: wrap; }
.how-to span { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,.68); border: 1px solid rgba(36,34,59,.12); border-radius: 100px; padding: 7px 11px; font-size: 11px; font-weight: 800; }
.how-to b { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: var(--ink); color: white; font-size: 10px; }

.primary-button {
  min-width: 210px;
  height: 58px;
  border: 3px solid var(--ink);
  border-radius: 100px;
  background: var(--pink);
  color: white;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .15s, box-shadow .15s, background .2s;
}
.primary-button:hover { background: var(--pink-dark); transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.primary-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.keyboard-hint { display: block; margin-top: 14px; font-size: 11px; opacity: .48; font-weight: 700; }

.result-overlay { background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.9), rgba(255,218,227,.95)); }
.result-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%; color: var(--pink-dark); background: var(--yellow); border: 3px solid var(--ink); font-size: 26px; box-shadow: 3px 4px 0 var(--ink); }
.final-score { margin: 15px auto 4px; display: flex; flex-direction: column; line-height: 1; }
.final-score strong { font-size: clamp(62px, 12vw, 94px); font-weight: 800; font-variant-numeric: tabular-nums; }
.final-score span { font-size: 10px; letter-spacing: .28em; opacity: .5; font-weight: 800; }
.result-card > p { margin: 12px auto; }
.best-score { display: inline-flex; align-items: center; gap: 13px; padding: 8px 14px; margin-bottom: 17px; border-radius: 100px; background: rgba(255,255,255,.62); font-size: 12px; font-weight: 700; }
.best-score strong { font-size: 16px; }

.combo-pop {
  position: absolute;
  z-index: 4;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-3deg);
  padding: 9px 16px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  font-family: "Shrikhand", Georgia, serif;
  font-size: clamp(18px, 4vw, 28px);
  box-shadow: 4px 5px 0 var(--ink);
  pointer-events: none;
  animation: combo .75s both;
}
.combo-pop.hidden { display: none; }
@keyframes combo { 0% { opacity: 0; transform: translate(-50%, 10%) scale(.6) rotate(-8deg); } 35% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(3deg); } 100% { opacity: 0; transform: translate(-50%, -85%) scale(1) rotate(-3deg); } }

.game-footer { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; border-top: 3px solid var(--ink); background: #fffdf9; }
.game-footer p { margin: 0; font-size: 12px; font-weight: 700; color: rgba(36,34,59,.66); display: flex; align-items: center; gap: 8px; }
.pulse-dot { width: 8px; height: 8px; background: var(--mint); border-radius: 50%; box-shadow: 0 0 0 4px rgba(105,198,161,.17); }
.text-button { border: 0; background: transparent; padding: 6px; font-size: 12px; font-weight: 800; cursor: pointer; color: var(--pink-dark); }
.text-button:disabled { opacity: .35; cursor: not-allowed; }
.shop-note { margin: 18px 0 0; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: rgba(36,34,59,.6); }
.shop-note span { color: #d54469; }

:focus-visible { outline: 4px solid #4579bf; outline-offset: 3px; }

@media (max-width: 620px) {
  .app-shell { width: min(100% - 16px, 920px); padding-top: 12px; }
  .topbar { margin-bottom: 10px; }
  .brand strong { font-size: 19px; }
  .brand-mark { transform: scale(.88); transform-origin: left center; width: 42px; }
  .menu-button { width: 42px; padding: 0; justify-content: center; }
  .menu-button span { display: none; }
  .game-card { border-width: 3px; border-radius: 22px; }
  .scoreboard { height: 72px; padding: 9px 13px; border-bottom-width: 3px; grid-template-columns: .75fr 2.4fr .75fr; }
  .stat-label { font-size: 8px; letter-spacing: .12em; }
  .order-flavor { gap: 5px; }
  .order-flavor strong { font-size: 16px; }
  .mini-scoop { width: 16px; height: 16px; }
  .game-stage { min-height: 460px; height: calc(100svh - 205px); max-height: 620px; }
  .overlay { padding: 18px; }
  .overlay h1 { font-size: clamp(41px, 13vw, 58px); }
  .overlay-card > p { margin-block: 14px; }
  .how-to { gap: 6px; margin: 15px 0 18px; }
  .how-to span { padding: 6px 8px; font-size: 9px; }
  .keyboard-hint { display: none; }
  .game-footer { padding-inline: 14px; }
}

@media (max-height: 680px) and (orientation: landscape) {
  .app-shell { width: min(100% - 20px, 980px); padding-block: 8px; }
  .topbar { margin-bottom: 5px; }
  .game-stage { height: calc(100vh - 160px); min-height: 350px; }
  .scoreboard { height: 65px; }
  .how-to, .overlay-card > p { margin-block: 10px; }
  .overlay h1 { font-size: 44px; }
  .shop-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
