/* SUPERMARKET MAYHEM — price-tag UI */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;800&family=Nunito:wght@600;800&display=swap');

:root {
  --yellow: #ffd23f;
  --red: #ff5c4d;
  --mint: #3ddc97;
  --sky: #4da8ff;
  --grape: #7b4dff;
  --cream: #fff8e7;
  --ink: #2d3436;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; font-family: 'Nunito', sans-serif; background: #bfe8ff; }
canvas#game { position: fixed; inset: 0; display: block; }

.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px;
  background: radial-gradient(circle at 50% 20%, rgba(255, 248, 231, .96), rgba(191, 232, 255, .96));
  overflow-y: auto;
}

.logo {
  font-family: 'Baloo 2', cursive; font-weight: 800;
  font-size: clamp(2.2rem, 9vw, 4.4rem); line-height: .95; text-align: center;
  color: var(--red);
  text-shadow: 0 4px 0 #d63031, 0 8px 18px rgba(0, 0, 0, .18);
  transform: rotate(-3deg);
}
.logo span { color: var(--sky); text-shadow: 0 4px 0 #2f80c9, 0 8px 18px rgba(0, 0, 0, .18); }
.tagline {
  background: var(--yellow); color: var(--ink);
  font-weight: 800; padding: 6px 16px; border-radius: 999px;
  transform: rotate(2deg); box-shadow: 0 3px 0 #d8a900;
}

/* price-tag buttons */
.tagBtn {
  position: relative;
  font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 1.25rem;
  color: var(--ink); background: #fff;
  border: 3px solid var(--ink); border-radius: 14px;
  padding: 12px 26px 12px 40px; min-width: 250px; text-align: left;
  cursor: pointer; box-shadow: 0 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.tagBtn::before {  /* punched hole */
  content: ''; position: absolute; left: 14px; top: 50%;
  width: 12px; height: 12px; border: 3px solid var(--ink); border-radius: 50%;
  transform: translateY(-50%); background: var(--cream);
}
.tagBtn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.tagBtn.big { background: var(--yellow); }
.tagBtn.daily { background: var(--mint); }
.tagBtn.doneToday { background: #dfe6e9; opacity: .85; }
.tagBtn small { display: block; font-family: 'Nunito'; font-weight: 700; font-size: .8rem; opacity: .75; }

.subTitle {
  font-family: 'Baloo 2', cursive; font-weight: 800; font-size: 2rem; color: var(--ink);
  background: var(--yellow); padding: 4px 22px; border-radius: 12px;
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); transform: rotate(-2deg);
}

.howBox {
  background: #fff; border: 3px dashed var(--ink); border-radius: 14px;
  padding: 16px 20px; max-width: 460px; font-weight: 700; line-height: 1.7; color: var(--ink);
}

/* ---------- shop ---------- */
.coinPill {
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 999px;
  font-weight: 800; padding: 4px 16px; box-shadow: 0 3px 0 var(--ink);
}
.shopTabs { display: flex; gap: 8px; }
.shopTab {
  font-family: 'Baloo 2'; font-weight: 800; font-size: 1rem;
  border: 3px solid var(--ink); border-radius: 10px; background: #fff;
  padding: 6px 16px; cursor: pointer; box-shadow: 0 3px 0 var(--ink);
}
.shopTab.active { background: var(--sky); color: #fff; }
.shopGrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; width: min(560px, 92vw); max-height: 46vh; overflow-y: auto; padding: 4px;
}
.shopItem {
  background: #fff; border: 3px solid var(--ink); border-radius: 12px;
  padding: 10px 6px; text-align: center; box-shadow: 0 4px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.shopItem.equipped { background: #eafff4; border-color: var(--mint); box-shadow: 0 4px 0 #1e824c; }
.shopIcon { font-size: 2rem; width: 52px; height: 52px; border-radius: 10px; display: grid; place-items: center; }
.shopName { font-weight: 800; font-size: .8rem; color: var(--ink); }
.tag {
  font-family: 'Baloo 2'; font-weight: 800; font-size: .8rem;
  border: 2px solid var(--ink); border-radius: 8px; padding: 3px 10px; cursor: pointer;
}
.tag.buy { background: var(--yellow); }
.tag.buy.poor { opacity: .45; }
.tag.use { background: var(--sky); color: #fff; }
.tag.eq { background: var(--mint); color: var(--ink); }

/* ---------- leaderboard (receipt) ---------- */
.receipt {
  background: #fff; width: min(380px, 90vw); max-height: 52vh; overflow-y: auto;
  padding: 18px; font-family: 'Nunito'; font-weight: 700; color: var(--ink);
  border-radius: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), 96% 100%, 88% calc(100% - 8px), 80% 100%, 72% calc(100% - 8px), 64% 100%, 56% calc(100% - 8px), 48% 100%, 40% calc(100% - 8px), 32% 100%, 24% calc(100% - 8px), 16% 100%, 8% calc(100% - 8px), 0 100%);
}
.receiptHead { font-family: 'Baloo 2'; font-weight: 800; margin: 10px 0 4px; border-bottom: 2px dashed var(--ink); }
.receiptRow { display: flex; justify-content: space-between; padding: 3px 0; font-size: .9rem; }

/* ---------- results ---------- */
.rBoard { width: min(340px, 88vw); display: flex; flex-direction: column; gap: 8px; }
.rRow {
  display: flex; justify-content: space-between; background: #fff;
  border: 3px solid var(--ink); border-radius: 10px; padding: 8px 16px;
  font-weight: 800; color: var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.rRow.you { background: var(--yellow); }
.placeBig { font-family: 'Baloo 2'; font-weight: 800; font-size: 2.2rem; color: var(--ink); }
.coinGain { font-weight: 800; color: #1e824c; font-size: 1.2rem; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hudTop {
  position: absolute; top: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 10px; align-items: center;
}
.hudPill {
  background: #fff; border: 3px solid var(--ink); border-radius: 999px;
  font-family: 'Baloo 2'; font-weight: 800; padding: 4px 16px; color: var(--ink);
  box-shadow: 0 3px 0 var(--ink); font-size: 1.05rem;
}
#hudTimer.urgent { background: var(--red); color: #fff; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }

#hudObjective {
  position: absolute; top: 58px; left: 0; right: 0; text-align: center;
  font-weight: 800; color: var(--ink); text-shadow: 0 1px 0 #fff;
}

#hudList {
  position: absolute; top: 90px; left: 10px;
  background: rgba(255, 255, 255, .92); border: 3px solid var(--ink);
  border-radius: 12px; padding: 8px 12px; font-weight: 800; color: var(--ink);
  box-shadow: 0 4px 0 var(--ink); font-size: .85rem; max-width: 220px;
}
.listTitle { font-family: 'Baloo 2'; border-bottom: 2px dashed var(--ink); margin-bottom: 4px; }
.listRow { display: flex; justify-content: space-between; gap: 12px; }
.listRow.done { text-decoration: line-through; opacity: .5; }

#eventBanner {
  position: absolute; top: 24%; left: 50%; transform: translateX(-50%) rotate(-3deg) scale(0);
  background: var(--red); color: #fff; font-family: 'Baloo 2'; font-weight: 800;
  font-size: clamp(1.3rem, 5vw, 2.2rem); padding: 8px 28px; border-radius: 14px;
  border: 4px solid #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
#eventBanner.show { transform: translateX(-50%) rotate(-3deg) scale(1); }

#toast {
  position: absolute; bottom: 26%; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; font-weight: 800; padding: 8px 20px;
  border-radius: 999px; opacity: 0; transition: all .25s; white-space: nowrap; max-width: 90vw;
  overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#roundIntro {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 15;
  pointer-events: none; opacity: 0; transition: opacity .3s;
}
#roundIntro.show { opacity: 1; }
.introCard {
  background: var(--yellow); border: 4px solid var(--ink); border-radius: 18px;
  padding: 20px 34px; text-align: center; transform: rotate(-2deg);
  box-shadow: 0 8px 0 var(--ink);
}
.introCard .r { font-weight: 800; color: var(--ink); letter-spacing: 2px; }
.introCard .n { font-family: 'Baloo 2'; font-weight: 800; font-size: 2rem; color: var(--ink); }
.introCard .d { font-weight: 700; color: var(--ink); max-width: 300px; }

/* pause btn + touch controls */
#btnPause {
  position: absolute; top: 10px; right: 10px; pointer-events: auto;
  width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--ink);
  background: #fff; font-size: 1.2rem; box-shadow: 0 3px 0 var(--ink); cursor: pointer;
}
#joy {
  position: absolute; bottom: 24px; left: 20px; width: 120px; height: 120px;
  border-radius: 50%; border: 3px dashed rgba(45, 52, 54, .5);
  background: rgba(255, 255, 255, .25); pointer-events: auto; touch-action: none;
}
#joyKnob {
  position: absolute; left: 50%; top: 50%; margin: -26px 0 0 -26px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--sky); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
#btnEmote {
  position: absolute; bottom: 44px; right: 24px; pointer-events: auto;
  width: 68px; height: 68px; border-radius: 50%; border: 3px solid var(--ink);
  background: var(--yellow); font-size: 1.6rem; box-shadow: 0 4px 0 var(--ink); cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  #joy, #btnEmote { display: none; }
}

.footNote { font-size: .78rem; font-weight: 700; color: var(--ink); opacity: .6; text-align: center; }
