/* Paws Mart — soft pastel, big touch targets, nothing flashes */
:root {
  --ink: #5b4636;
  --ink-soft: #8a7262;
  --paper: #fffaf3;
  --peach: #ffe3d3;
  --coral: #ff9f8e;
  --coral-deep: #f2806c;
  --mint: #9fd8cb;
  --mint-deep: #5fbfa9;
  --sun: #ffd36e;
  --sky: #cfeedd;
  --shadow: 0 6px 0 rgba(91, 70, 54, 0.12), 0 10px 24px rgba(91, 70, 54, 0.12);
  --r: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--sky);
  font-family: 'Mali', system-ui, sans-serif; color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none;
}
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  pointer-events: none; z-index: 5;
}
.hud-side { display: flex; gap: 8px; align-items: center; }
.chip {
  background: var(--paper); border-radius: 999px; padding: 6px 14px; font-size: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip b { font-size: 22px; }
#queue { gap: 4px; padding: 6px 10px; }
#queue .q { font-size: 20px; opacity: 0.3; transition: opacity 0.3s, transform 0.3s; }
#queue .q.now { opacity: 1; transform: scale(1.25); }
#queue .q.done { opacity: 1; }
.mini-coin {
  display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6cf, #f1cc5b 45%, #c99a2e 80%);
  box-shadow: inset 0 0 0 3px #e2e5e8;
}
.mini-coin.big { width: 44px; height: 44px; box-shadow: inset 0 0 0 6px #e2e5e8; }
#parent-btn {
  pointer-events: auto; position: relative; width: 48px; height: 48px; border-radius: 50%;
  background: var(--paper); box-shadow: var(--shadow); font-size: 22px; opacity: 0.75;
}
#parent-btn::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(var(--coral) 0deg, transparent 0deg); opacity: 0; z-index: -1;
}
#parent-btn.holding::after { opacity: 1; animation: hold 2s linear forwards; }
@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes hold { from { --a: 0deg; } to { --a: 360deg; } }
#parent-btn.holding::after { background: conic-gradient(var(--coral) var(--a), transparent var(--a)); }

/* ---------- speech bubble ---------- */
#bubble {
  position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none;
  background: #fff; border-radius: 26px; padding: 10px 16px 10px 12px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: 'face items speak' 'text text text'; gap: 4px 10px;
  align-items: center; max-width: min(460px, 80vw);
}
#bubble::after {
  content: ''; position: absolute; right: -16px; top: 50%; margin-top: -13px;
  border: 13px solid transparent; border-left-color: #fff; border-right: 0;
}
.bub-face { grid-area: face; font-size: 40px; line-height: 1; }
.bub-items { grid-area: items; display: flex; gap: 14px; }
.bub-line { display: flex; align-items: center; gap: 4px; transition: opacity 0.3s; }
.bub-line.full { opacity: 0.55; }
.bub-ico { width: 84px; height: 84px; object-fit: contain; }
.bub-marks { display: flex; flex-direction: column; gap: 5px; }
.mark { width: 24px; height: 24px; border-radius: 50%; border: 3px dashed var(--coral); }
.mark.on { border: 0; background: var(--mint-deep); position: relative; }
.mark.on::after { content: '✓'; color: #fff; font-size: 14px; font-weight: 700; position: absolute; inset: 0; display: grid; place-items: center; }
.bub-text { grid-area: text; font-size: 17px; color: var(--ink-soft); text-align: center; line-height: 1.3; }
#bubble.paying .bub-ico { width: 44px; height: 44px; }
#bubble.paying .bub-marks { display: none; }

/* ---------- checkout ---------- */
#checkout {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: min(46vh, 380px);
  padding: 14px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--paper); border-radius: 30px 30px 0 0; box-shadow: 0 -8px 30px rgba(91, 70, 54, 0.15);
  display: grid; grid-template-columns: 1.15fr 1.1fr 0.95fr; gap: 14px;
  animation: rise 0.35s ease-out;
}
@keyframes rise { from { transform: translateY(100%); } }
.co-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.co-label { font-size: 19px; font-weight: 700; }
.co-pieces {
  flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 10px; padding: 10px;
  background: #f6ead9; border-radius: var(--r); overflow: hidden;
}
.co-pieces.drawer { align-content: center; justify-content: space-around; background: #e9f4ef; }
.co-got { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.co-got .money { transform: scale(0.85); transform-origin: left center; }
.stack { position: relative; width: 84px; height: 92px; display: grid; place-items: center; }
.stack .money { position: absolute; }
.stack .money:nth-child(1) { transform: translate(0, 10px); }
.stack .money:nth-child(2) { transform: translate(0, 5px); }
.stack:has(.note) { width: 136px; }
.co-tray {
  flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 8px; padding: 10px;
  border: 4px dashed var(--mint); border-radius: var(--r); background: #f3fbf8; transition: background 0.3s, border-color 0.3s;
  min-height: 96px;
}
.co-tray.empty { animation: breathe 2.4s ease-in-out infinite; }
.co-tray.right { border-color: var(--mint-deep); border-style: solid; background: #dff5ec; }
@keyframes breathe { 50% { border-color: var(--coral); } }
.co-tray-hint { color: var(--ink-soft); font-size: 17px; }
.co-frames { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.frame { display: grid; grid-template-columns: repeat(5, 30px); gap: 4px; padding: 6px; background: #fff; border-radius: 12px; box-shadow: 0 2px 0 rgba(91, 70, 54, 0.1); }
.cell { width: 30px; height: 30px; border-radius: 50%; transition: background 0.25s, transform 0.25s; }
.cell.none { visibility: hidden; }
.cell.slot { border: 3px dashed #f3b9a9; }
.cell.on { background: #ffb547; transform: scale(1.05); }
.cell.paid { background: #d9d1c9; }
.cell.over { background: #ff8a8a; }
.co-traysum { text-align: center; font-size: 22px; font-weight: 700; min-height: 0; }
.co-board { align-items: stretch; }
.co-items { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.co-item { position: relative; width: 66px; height: 66px; background: #fff; border-radius: 16px; box-shadow: 0 3px 0 rgba(91, 70, 54, 0.1); display: grid; place-items: center; }
.co-item img { width: 54px; height: 54px; object-fit: contain; }
.co-price { position: absolute; right: -6px; bottom: -6px; background: var(--sun); border-radius: 999px; min-width: 28px; height: 28px; padding: 0 6px; display: grid; place-items: center; font-weight: 700; font-size: 17px; }
.co-total { text-align: center; font-size: 22px; }
.co-total b { font-size: 34px; }
.co-total .q { color: var(--coral-deep); }
.co-done {
  margin-top: auto; height: 84px; border-radius: 999px; font-size: 46px; color: #fff;
  background: #c9c2bb; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12); transition: background 0.3s, transform 0.15s;
}
.co-done.ready { background: var(--mint-deep); }
.co-done:active { transform: translateY(3px); }
.co-done.yes { background: var(--sun); animation: pop 0.5s; }
@keyframes pop { 50% { transform: scale(1.12); } }

/* ---------- money: real Thai baht, cartoon drawings ---------- */
.money { position: relative; display: grid; place-items: center; font-weight: 700; flex: none; transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2), opacity 0.2s; touch-action: none; cursor: grab; }
.money.drag { z-index: 50; transition: none; }
.money.floating { position: fixed; z-index: 60; }
.money.gone { opacity: 0; transform: scale(0.4); }
.money.helped { box-shadow: 0 0 0 5px var(--sun), 0 4px 0 rgba(0,0,0,0.15); }
.coin { border-radius: 50%; color: #6b5a4c; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); }
.coin b { font-size: 26px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7); }
.m1 { width: 60px; height: 60px; background: radial-gradient(circle at 35% 30%, #ffffff, #dfe3e7 45%, #a9b1ba); box-shadow: inset 0 0 0 4px #c7cdd3, 0 4px 0 rgba(0,0,0,0.18); }
.m5 { width: 68px; height: 68px; background: radial-gradient(circle at 35% 30%, #ffffff, #dfe3e7 45%, #a9b1ba); box-shadow: inset 0 0 0 5px #d39a6a, inset 0 0 0 8px #c7cdd3, 0 4px 0 rgba(0,0,0,0.18); }
.m10 { width: 76px; height: 76px; background: radial-gradient(circle at 50% 50%, #f6d46a 0 52%, #c99a2e 53% 55%, #e3e7ea 56%, #b7bec5 100%); }
.m10 b { font-size: 28px; }
.note { width: 128px; height: 66px; border-radius: 10px; color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16); overflow: hidden; }
.note b { font-size: 34px; margin-left: 30px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.note small { position: absolute; right: 8px; bottom: 4px; font-size: 13px; }
.note .paw { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.35); display: grid; place-items: center; font-size: 18px; }
.note::before { content: ''; position: absolute; inset: 5px; border: 2px solid rgba(255, 255, 255, 0.45); border-radius: 7px; }
.m20 { background: linear-gradient(135deg, #8fd08a, #5aa86a); }
.m50 { background: linear-gradient(135deg, #8cc3ef, #4f8fcf); }
.m100 { background: linear-gradient(135deg, #f39a92, #d65b5b); }
.nudge { animation: nudge 0.9s ease-in-out 2; }
@keyframes nudge { 25% { transform: translateY(-14px) scale(1.08); } 50% { transform: translateY(0); } 75% { transform: translateY(-7px); } }

/* ---------- floating hearts, banners ---------- */
#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
.floater { position: absolute; transform: translate(-50%, -50%); font-size: 40px; animation: float-up 1.4s ease-out forwards; }
.floater.stars { font-size: 34px; }
@keyframes float-up { to { transform: translate(-50%, -150%); opacity: 0; } }
.banner {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); text-align: center;
  background: var(--paper); padding: 18px 40px; border-radius: 30px; box-shadow: var(--shadow);
  font-size: 40px; font-weight: 700; animation: banner-in 0.45s cubic-bezier(.2,.9,.3,1.3); line-height: 1.2;
}
.banner small { font-size: 22px; font-weight: 500; color: var(--ink-soft); }
.banner.out { opacity: 0; transition: opacity 0.5s; }
@keyframes banner-in { from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(255, 233, 220, 0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: 20px; }
.card { background: var(--paper); border-radius: 34px; padding: 28px 40px; box-shadow: var(--shadow); text-align: center; max-width: 92vw; max-height: 92vh; overflow: auto; }
.card.wide { width: min(720px, 94vw); text-align: left; }
.logo { font-size: 64px; }
h1 { margin: 0; font-size: 56px; color: var(--coral-deep); }
h2 { margin: 0 0 6px; font-size: 32px; }
.sub { margin: 0 0 6px; font-size: 24px; color: var(--ink-soft); }
.start-day { font-size: 22px; margin: 10px 0 18px; }
.go {
  background: var(--coral); color: #fff; font-size: 34px; font-weight: 700; padding: 16px 48px; border-radius: 999px;
  box-shadow: 0 6px 0 var(--coral-deep); min-width: 260px;
}
.go:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--coral-deep); }
.sum-stars { font-size: 70px; margin: 8px 0; }
.star { display: inline-block; filter: grayscale(1); opacity: 0.25; }
.star.on { filter: none; opacity: 1; animation: star-in 0.6s cubic-bezier(.2,.9,.3,1.5) backwards; }
@keyframes star-in { from { transform: scale(0) rotate(-40deg); } }
.sum-grid { display: flex; gap: 28px; justify-content: center; margin: 6px 0 12px; }
.sum-grid > div { display: flex; flex-direction: column; align-items: center; font-size: 18px; }
.sum-grid b { font-size: 36px; }
.big-ico { font-size: 40px; height: 48px; display: grid; place-items: center; }
.sum-level { color: var(--ink-soft); font-size: 18px; margin: 0 0 16px; }
.load-box { background: var(--paper); border-radius: 30px; padding: 28px 44px; font-size: 26px; text-align: center; box-shadow: var(--shadow); }
.paw-spin { font-size: 56px; animation: spin 1.6s ease-in-out infinite; }
@keyframes spin { 50% { transform: rotate(20deg) scale(1.1); } }

/* parents */
.par-head { display: flex; justify-content: space-between; align-items: center; }
.par-close { width: 52px; height: 52px; border-radius: 50%; background: var(--peach); font-size: 24px; }
.par-group { margin: 14px 0; }
.par-title { font-weight: 700; font-size: 19px; margin-bottom: 6px; }
.par-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { background: #f3ebe2; border-radius: 16px; padding: 10px 16px; font-size: 17px; }
.opt small { color: var(--ink-soft); }
.opt.on { background: var(--mint); font-weight: 700; }
.par-stats { margin: 16px 0; color: var(--ink-soft); font-size: 16px; }
.par-reset { background: #fbe1dc; color: #b8584a; border-radius: 14px; padding: 10px 18px; font-size: 16px; }


/* small landscape screens (phones): shrink a bit */
@media (max-height: 520px) {
  .chip { font-size: 16px; padding: 4px 10px; } .chip b { font-size: 17px; }
  #checkout { height: 52vh; gap: 8px; padding: 8px; }
  .m1 { width: 46px; height: 46px; } .m5 { width: 52px; height: 52px; } .m10 { width: 58px; height: 58px; }
  .coin b { font-size: 20px; } .note { width: 100px; height: 52px; } .note b { font-size: 26px; }
  .co-done { height: 60px; font-size: 34px; }
  .bub-ico { width: 52px; height: 52px; }
  .co-item { width: 50px; height: 50px; } .co-item img { width: 40px; height: 40px; }
  .frame { grid-template-columns: repeat(5, 16px); } .cell { width: 16px; height: 16px; }
}
.money.appear { animation: appear 0.3s cubic-bezier(.2,.9,.3,1.4); }
@keyframes appear { from { transform: scale(0.3); opacity: 0; } }

/* the shop helper's words — above the checkout panel, out of the way of the shelves */
#caption {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 7; pointer-events: none;
  transform: translate(-50%, 20px); opacity: 0; transition: opacity 0.25s, transform 0.25s;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(720px, 92vw);
  background: rgba(91, 70, 54, 0.88); color: #fff; border-radius: 999px; padding: 8px 20px 8px 10px; font-size: 20px;
}
#caption.on { opacity: 1; transform: translate(-50%, 0); }
.cap-who { width: 38px; height: 38px; border-radius: 50%; background: var(--sun); display: grid; place-items: center; font-size: 22px; flex: none; }

/* the bubble under / over the customer (narrow screens): the tail points at them */
#bubble.below::after, #bubble.above::after { right: auto; left: var(--tail, 50%); margin: 0 0 0 -13px; border: 13px solid transparent; }
#bubble.below::after { top: -16px; border-bottom-color: #fff; border-top: 0; }
#bubble.above::after { top: auto; bottom: -16px; border-top-color: #fff; border-bottom: 0; }

/* ---------- phones (and any narrow screen) ---------- */
@media (max-width: 700px) {
  #hud { align-items: flex-start; }
  .hud-side { flex-wrap: wrap; gap: 6px; }
  .hud-side:first-child { flex-direction: column; align-items: flex-start; }
  .hud-side:last-child { justify-content: flex-end; max-width: 62vw; }
  .chip { font-size: 15px; padding: 4px 10px; }
  .chip b { font-size: 16px; }
  #queue .q { font-size: 15px; }
  #parent-btn { width: 40px; height: 40px; font-size: 18px; }
  .bub-ico { width: 56px; height: 56px; }
  .bub-face { font-size: 30px; }
  .bub-text { font-size: 15px; }
  .m1 { width: 50px; height: 50px; } .m5 { width: 56px; height: 56px; } .m10 { width: 62px; height: 62px; }
  .coin b { font-size: 22px; }
  .note { width: 104px; height: 54px; } .note b { font-size: 27px; margin-left: 24px; }
  .stack { width: 66px; height: 74px; } .stack:has(.note) { width: 110px; }
  h1 { font-size: 42px; }
  .go { font-size: 28px; min-width: 220px; padding: 14px 36px; }
  .card { padding: 22px 24px; }
  .sum-stars { font-size: 54px; }
  .banner { font-size: 30px; padding: 14px 26px; }
}

/* ---------- portrait (phone or tablet held upright): the shop on top, the panels below it ---------- */
@media (orientation: portrait) {
  #checkout {
    height: auto; max-height: 64vh; gap: 10px;
    grid-template-columns: 1fr 1fr; grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: 'board board' 'src mid';
  }
  .co-board { grid-area: board; display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'items done' 'total done'; align-items: center; gap: 6px 12px; }
  .co-items { grid-area: items; justify-content: flex-start; }
  .co-total { grid-area: total; text-align: left; font-size: 18px; }
  .co-total b { font-size: 26px; }
  .co-done { grid-area: done; margin: 0; width: 92px; height: 92px; }
  .co-src { grid-area: src; }
  .co-mid { grid-area: mid; }
  .co-pieces, .co-tray { min-height: 160px; }
}

/* 🔊 hear it again — the only part of the bubble / caption that takes taps */
.say-again {
  pointer-events: auto; flex: none; width: 48px; height: 48px; border-radius: 50%; font-size: 24px;
  display: grid; place-items: center; background: var(--sun); box-shadow: 0 3px 0 rgba(91, 70, 54, 0.15);
}
.say-again:active { transform: translateY(2px); box-shadow: none; }
#bubble .say-again { grid-area: speak; }
#caption .say-again { width: 42px; height: 42px; font-size: 20px; margin-right: -12px; }
.say-again.playing { animation: speaking 0.8s ease-in-out infinite; }
@keyframes speaking { 50% { transform: scale(1.1); } }
.floater.song { font-size: 22px; font-weight: 700; white-space: nowrap; background: var(--paper); padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow); animation-duration: 2.2s; }
.floater.note { font-size: 28px; color: var(--coral-deep); }
