/* Eva's & Max's Shop – overlay UI styles.
   Chunky, rounded, touch-first. The 3D scene (#scene) sits behind #ui. */

@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/fredoka-latin-400-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/fredoka-latin-600-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/fredoka-latin-700-normal.woff2) format('woff2');
}

:root {
  /* main.js sets these from shop.theme */
  --sky-top: #ffe2c4;
  --sky-bottom: #ffb88a;
  --accent: #3f7f6e;

  --ink: #3d2c55;
  --ink-soft: #7d6c93;
  --paper: #fffaf2;
  --line: #efe3d2;
  --line-d: #e3d3bc;
  --green: #4cc76a;
  --green-d: #2f9a4c;
  --blue: #4dabf7;
  --blue-d: #2b84cc;
  --yellow: #ffd43b;
  --yellow-d: #dba600;
  --red: #ff6b6b;
  --red-d: #d14848;
  --orange: #ffa94d;
  --purple: #9775fa;
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', 'Varela Round', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Menlo', 'Consolas', 'DejaVu Sans Mono', monospace;
  --hud-h: 60px;
  --panel-w: clamp(360px, 33vw, 420px);
  --edge: 14px;
  --shadow: 0 12px 34px rgba(61, 44, 85, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%) fixed;
  background-color: var(--sky-bottom);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased;
  transition: background 0.6s;
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

#ui > * {
  pointer-events: auto;
}

button {
  font-family: inherit;
  color: inherit;
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(77, 171, 247, 0.7);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

/* ---------- chunky buttons ---------- */

.btn {
  --b: #fff;
  --bd: var(--line-d);
  --fg: var(--ink);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: 18px;
  font-size: 21px;
  font-weight: 600;
  color: var(--fg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%), var(--b);
  box-shadow: 0 6px 0 var(--bd), 0 12px 18px rgba(61, 44, 85, 0.16);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--bd), 0 4px 8px rgba(61, 44, 85, 0.16);
}

.btn:disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: default;
}

.btn .ico {
  font-size: 0.95em;
}

.btn-green { --b: var(--green); --bd: var(--green-d); --fg: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.btn-blue { --b: var(--blue); --bd: var(--blue-d); --fg: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.btn-red { --b: var(--red); --bd: var(--red-d); --fg: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.btn-yellow { --b: var(--yellow); --bd: var(--yellow-d); --fg: #5a3d00; }
.btn-soft { --b: #fff; --bd: var(--line-d); --fg: var(--ink); }
.btn-big { min-height: 64px; font-size: 24px; border-radius: 20px; padding: 0 28px; }
.btn-huge { min-height: 76px; font-size: 31px; border-radius: 24px; box-shadow: 0 8px 0 var(--bd), 0 16px 24px rgba(61, 44, 85, 0.2); }
.btn-huge:active:not(:disabled) { transform: translateY(7px); }

/* ---------- money art ---------- */

.money {
  display: inline-block;
  line-height: 0;
  flex: none;
}

.money svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 2px 0 rgba(61, 44, 85, 0.18));
}

.money svg text {
  font-family: var(--font);
}

.money-note.money-lg { width: 100%; }
.money-coin.money-lg,
.money-coin.money-md { width: calc(100% * var(--coin-scale, 1)); }
.money-note.money-md { width: 96px; }
.money-note.money-sm { width: 70px; }
.money-coin.money-sm { width: calc(42px * var(--coin-scale, 1)); }
.money-note.money-xs { width: 42px; }
.money-coin.money-xs { width: calc(25px * var(--coin-scale, 1)); }

.money-row {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* ---------- panels (change panel, card terminal) ---------- */

.panel,
.terminal-wrap {
  position: fixed;
  top: calc(var(--hud-h) + 10px);
  right: var(--edge);
  bottom: var(--edge);
  width: var(--panel-w);
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.panel {
  gap: 10px;
  padding: 14px;
  background: var(--paper);
  border: 4px solid #fff;
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.panel.entering,
.terminal-wrap.entering {
  animation: slideIn 0.38s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.panel.leaving,
.terminal-wrap.leaving {
  animation: slideOut 0.32s ease-in both;
  pointer-events: none;
}

.panel.shake,
.terminal.shake,
.shake {
  animation: shake 0.45s;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.panel-head h2 {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.panel-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 24px;
  background: #fff1c9;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06);
}

.panel-head.on-dark {
  align-self: center;
  padding: 6px 18px 6px 6px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(61, 44, 85, 0.12);
}

.panel-head.on-dark h2 {
  font-size: 21px;
}

.panel-head.on-dark .panel-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  background: #e7f5ff;
}

/* change panel */

.cp-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cp-display.single {
  grid-template-columns: 1fr;
}

.cp-stat {
  padding: 6px 12px 7px;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 18px;
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.cp-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-soft);
}

.cp-amount {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cp-left .cp-amount {
  color: #d9480f;
}

.cp-left.done {
  background: #e6f9ea;
  border-color: var(--green);
}

.cp-left.done .cp-amount,
.cp-left.done .cp-label {
  color: var(--green-d);
}

.cp-left.over {
  background: #fff0f0;
  border-color: var(--red);
}

.cp-left.over .cp-amount {
  color: var(--red-d);
}

.cp-left.over .cp-label {
  color: var(--red-d);
}

.cp-tray {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: center;
  gap: 6px;
  flex: 1 1 82px;
  min-height: 82px;
  overflow-y: auto;
  padding: 9px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.35), transparent 60%),
    linear-gradient(180deg, #5b9e7a, #4a8a68);
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.25), 0 3px 0 #fff;
  border: 4px solid #8a5a3c;
  transition: box-shadow 0.2s;
}

.cp-tray-empty {
  flex: 1;
  align-self: center;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  padding: 4px 10px;
}

.cp-tray-piece {
  padding: 2px;
  border: 0;
  background: none;
  border-radius: 10px;
  line-height: 0;
  min-height: 40px;
  display: inline-grid;
  place-items: center;
}

.cp-tray-piece:active {
  transform: scale(0.9);
}

.cp-tray-piece.pop-in {
  animation: dropIn 0.38s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.cp-money-area {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  overflow-y: auto;
  /* room for the hint glow, which would otherwise be clipped by the scroll box */
  margin: -10px -12px;
  padding: 14px 12px 16px;
}

.cp-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.cp-grid {
  --per: 3;
  --slots: 3;
  width: calc((100% + 9px) * var(--per) / var(--slots) - 9px);
  margin: 0 auto;
}

.cp-grid > * {
  flex: 0 0 calc((100% - (var(--per) - 1) * 9px) / var(--per));
}

.cp-money {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 52px;
  padding: 7px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 5px 0 var(--line-d), 0 8px 12px rgba(61, 44, 85, 0.1);
  transition: transform 0.08s, box-shadow 0.08s;
}

.cp-money.coin {
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 5px;
}

.cp-money:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--line-d), 0 2px 4px rgba(61, 44, 85, 0.1);
}

.cp-money.tapped .money {
  animation: tapBounce 0.3s;
}

.cp-message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  max-width: calc(100% - 28px);
  padding: 10px 18px;
  border-radius: 18px;
  background: var(--red);
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 5px 0 var(--red-d), 0 10px 20px rgba(0, 0, 0, 0.15);
  transform: translate(-50%, -40%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.cp-message.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.cp-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 9px;
  padding-bottom: 5px;
}

.cp-actions .btn {
  padding: 0 10px;
  font-size: 19px;
}

.cp-actions .cp-ok {
  font-size: 25px;
  min-height: 62px;
}

.change-panel.success .cp-ok {
  animation: tapBounce 0.4s;
}

/* hints */

.hint-glow {
  z-index: 3;
  animation: hintPulse 0.9s ease-in-out infinite;
}

.cp-money.hint-glow,
.key.hint-glow,
.btn.hint-glow {
  box-shadow: 0 0 0 5px var(--yellow), 0 0 26px 10px rgba(255, 212, 59, 0.85), 0 5px 0 var(--line-d);
}

.cp-tray.hint-glow {
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.25), 0 0 0 5px var(--yellow), 0 0 26px 8px rgba(255, 212, 59, 0.8);
  animation: none;
}

.hint-hand {
  position: absolute;
  z-index: 8;
  font-size: 46px;
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, 0);
  filter: drop-shadow(0 4px 2px rgba(0, 0, 0, 0.25));
  animation: handPoke 0.9s ease-in-out infinite;
}

.hint-hand.from-above {
  transform: translate(-50%, -100%);
  animation-name: handPokeDown;
}

/* ---------- card terminal ---------- */

.terminal-wrap {
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.terminal {
  position: relative;
  width: min(340px, 100%);
  padding: 14px 18px 26px;
  border-radius: 36px 36px 48px 48px;
  background:
    radial-gradient(circle at 30% 0%, rgba(255, 255, 255, 0.14), transparent 55%),
    linear-gradient(180deg, #43475c, #262935 70%, #1f212b);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    inset 0 -4px 0 rgba(0, 0, 0, 0.35),
    0 9px 0 #14151b,
    0 22px 40px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.3s;
}

.terminal.approved {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    0 9px 0 #14151b,
    0 0 0 6px var(--green),
    0 0 40px 12px rgba(76, 199, 106, 0.7);
}

.terminal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 10px;
}

.terminal-brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #9ea3bd;
}

.terminal-lights {
  display: flex;
  gap: 6px;
}

.terminal-lights i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff6b6b;
  box-shadow: 0 0 6px rgba(255, 107, 107, 0.7);
}

.terminal-lights i:nth-child(2) { background: #ffd43b; box-shadow: 0 0 6px rgba(255, 212, 59, 0.7); }
.terminal-lights i:nth-child(3) { background: #51cf66; box-shadow: 0 0 6px rgba(81, 207, 102, 0.7); animation: blink 1.2s infinite; }

.lcd {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 9px 14px 8px;
  border-radius: 14px;
  border: 4px solid #101116;
  background: radial-gradient(ellipse at 50% 0%, #1c4a2f, #0b2214 80%);
  color: #74ffa2;
  text-shadow: 0 0 10px rgba(116, 255, 162, 0.55);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.6);
}

.lcd::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.lcd-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lcd-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.6px;
  opacity: 0.85;
}

.lcd-icon {
  width: 22px;
  height: 22px;
  opacity: 0.9;
}

.lcd-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.lcd-amount {
  min-height: 58px;
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 700;
  line-height: 58px;
  text-align: right;
  white-space: nowrap;
  letter-spacing: 1px;
}

.lcd-amount .sym {
  margin-right: 4px;
  opacity: 0.9;
}

.lcd-amount .ghost {
  opacity: 0.28;
}

.lcd-amount .cursor {
  display: inline-block;
  width: 4px;
  height: 40px;
  margin-left: 3px;
  vertical-align: -5px;
  background: currentColor;
  animation: blink 1s steps(1) infinite;
}

.lcd-flash {
  display: block;
  font-family: var(--font);
  font-size: 34px;
  text-align: center;
  letter-spacing: 1px;
}

.lcd.lcd-good {
  background: radial-gradient(ellipse at 50% 0%, #2f8a4b, #10411f 80%);
  color: #c8ffd8;
}

.lcd.lcd-bad {
  background: radial-gradient(ellipse at 50% 0%, #5a1d1d, #2a0b0b 80%);
  color: #ff9a9a;
  text-shadow: 0 0 10px rgba(255, 120, 120, 0.6);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px 12px;
}

.key {
  position: relative;
  height: 60px;
  border: 0;
  border-radius: 16px;
  font-size: 30px;
  font-weight: 700;
  color: #2b2d3a;
  background: linear-gradient(180deg, #ffffff, #e2e5ee);
  box-shadow: 0 5px 0 #8e92a8, 0 8px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.07s, box-shadow 0.07s;
}

.key:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #8e92a8, 0 2px 4px rgba(0, 0, 0, 0.3);
}

.key.tapped {
  animation: keyFlash 0.25s;
}

.key-back {
  color: #c2410c;
  background: linear-gradient(180deg, #fff4e6, #ffd8a8);
  box-shadow: 0 5px 0 #c98a3e, 0 8px 10px rgba(0, 0, 0, 0.3);
}

.key-clear {
  color: #6b4b00;
  background: linear-gradient(180deg, #fff3bf, var(--yellow));
  box-shadow: 0 5px 0 var(--yellow-d), 0 8px 10px rgba(0, 0, 0, 0.3);
}

.key-ok {
  grid-column: span 2;
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, #6ee08a, var(--green));
  box-shadow: 0 5px 0 var(--green-d), 0 8px 10px rgba(0, 0, 0, 0.3);
}

.key.hint-glow {
  box-shadow: 0 0 0 5px var(--yellow), 0 0 28px 10px rgba(255, 212, 59, 0.9), 0 5px 0 #8e92a8;
}

.terminal-slot {
  position: absolute;
  left: 50%;
  bottom: 9px;
  width: 46%;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 6px;
  background: #0d0e12;
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.12);
}

.ct-message {
  padding: 10px 18px;
  border-radius: 18px;
  background: var(--red);
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 5px 0 var(--red-d);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 1.5, 0.4, 1);
  min-height: 46px;
}

.ct-message.show {
  opacity: 1;
  transform: scale(1);
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(10px + env(safe-area-inset-left, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  height: calc(var(--hud-h) - 8px);
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none !important;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s, transform 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.hud.in {
  opacity: 1;
  transform: none;
}

.hud > * {
  pointer-events: auto;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hud-center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.hud-pill,
.hud-logo,
.hud-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(61, 44, 85, 0.12), 0 6px 14px rgba(61, 44, 85, 0.1);
  font-size: 19px;
  font-weight: 600;
  white-space: nowrap;
}

.hud-logo {
  font-size: 16px;
  font-weight: 700;
  gap: 4px;
  color: #ff6b6b;
}

.hud-logo b:nth-of-type(2) {
  color: var(--blue-d);
}

.hud-logo i {
  font-style: normal;
  color: var(--orange);
}

.hud-logo span {
  color: #fff;
  background: var(--green);
  padding: 1px 8px 2px;
  border-radius: 8px;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hud-where {
  padding-right: 6px;
}

.hud-shop {
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-day {
  padding: 3px 11px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 16px;
  font-weight: 700;
}

.hud-player:empty {
  display: none;
}

.hud-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.hud-ico {
  font-size: 20px;
}

.hud-score .hud-num { color: #d08700; }
.hud-streak .hud-num { color: #e8590c; }
.hud-till .hud-num { color: var(--green-d); }

.bump {
  animation: bump 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.hud-dots {
  gap: 7px;
  padding: 0 14px;
}

.hud-dots .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #eadfce;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.08);
  transition: background 0.3s;
}

.hud-dots .dot.done {
  background: var(--green);
  box-shadow: inset 0 -2px 0 var(--green-d);
}

.hud-dots .dot.current {
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.hud-dots .dot.pop {
  animation: bump 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.hud-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  font-size: 22px;
  background: #fff;
  box-shadow: 0 4px 0 var(--line-d), 0 6px 14px rgba(61, 44, 85, 0.12);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}

.hud-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line-d);
}

.hud-btn.off {
  opacity: 0.55;
  background: #f1ebe2;
}

.hud-menu {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

/* ---------- receipt ---------- */

.receipt {
  position: fixed;
  left: 18px;
  bottom: 30px;
  z-index: 8;
  width: 262px;
  padding: 14px 16px 10px;
  background: #fff;
  border-radius: 6px 6px 0 0;
  color: #3a3346;
  filter: drop-shadow(0 8px 12px rgba(61, 44, 85, 0.25));
  transform: rotate(-1.5deg);
  scale: var(--rc-scale, 1);
  transform-origin: bottom left;
  animation: printIn 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) both;
  pointer-events: none !important;
}

.receipt::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -11px;
  height: 12px;
  background:
    linear-gradient(135deg, #fff 6px, transparent 0) 0 0 / 12px 12px repeat-x,
    linear-gradient(-135deg, #fff 6px, transparent 0) 0 0 / 12px 12px repeat-x;
}

.receipt.leaving {
  animation: printOut 0.4s ease-in both;
}

.rc-head {
  text-align: center;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 2px dashed #d9d2e2;
}

.rc-shop {
  font-size: 18px;
  font-weight: 700;
}

.rc-sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: #8b8299;
}

.rc-sub span {
  margin-left: 6px;
}

.rc-line {
  display: none;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 16px;
}

.rc-line.shown {
  display: grid;
  animation: lineIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.rc-emoji {
  font-size: 19px;
  text-align: center;
}

.rc-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 500;
}

.rc-money {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.rc-total {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding-top: 7px;
  border-top: 2px dashed #d9d2e2;
  font-size: 21px;
  font-weight: 700;
}

.rc-total .rc-money {
  font-size: 21px;
}

.rc-unknown {
  padding: 0 8px;
  border-radius: 8px;
  color: #7048e8;
  background: #fff3bf;
  animation: wiggle 1.6s ease-in-out infinite;
}

.rc-note {
  flex-basis: 100%;
  text-align: right;
  font-style: normal;
  font-size: 15px;
  font-weight: 600;
  color: #e8590c;
  transform: rotate(-2deg);
}

.rc-payment {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 2px dashed #d9d2e2;
}

.rc-payment .money-row {
  justify-content: flex-end;
  width: 100%;
  margin: 2px 0 4px;
}

.rc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  padding: 2px 0;
}

.rc-change {
  font-size: 19px;
  font-weight: 700;
  color: var(--green-d);
}

.rc-change .rc-money {
  font-size: 19px;
}

.rc-approved {
  color: var(--green-d);
}

.rc-in {
  animation: lineIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

/* ---------- speech bubble ---------- */

.bubble {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9;
  pointer-events: none !important;
  will-change: transform;
}

.bubble-inner {
  position: relative;
  max-width: 300px;
  padding: 11px 18px 12px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(61, 44, 85, 0.1), 0 10px 26px rgba(61, 44, 85, 0.2);
  text-align: center;
  transform-origin: var(--tail-x, 50%) 100%;
}

.bubble-inner::after {
  content: '';
  position: absolute;
  left: var(--tail-x, 50%);
  bottom: -10px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  background: #fff;
  border-radius: 0 0 6px 0;
  transform: rotate(45deg);
  box-shadow: 5px 5px 6px rgba(61, 44, 85, 0.08);
}

.bubble-inner.pop {
  animation: bubblePop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.bubble.leaving .bubble-inner {
  animation: bubbleOut 0.22s ease-in both;
}

.bubble-text {
  position: relative;
  z-index: 1;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.2;
}

.bubble .money-row {
  position: relative;
  z-index: 1;
  margin-top: 8px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 0;
  right: var(--inset, 0px);
  top: 27%;
  z-index: 80;
  display: flex;
  justify-content: center;
  pointer-events: none !important;
}

.toast-text {
  position: relative;
  z-index: 1;
  padding: 14px 32px 16px;
  border-radius: 999px;
  font-size: 42px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  animation: toastIn 0.55s cubic-bezier(0.2, 1.7, 0.4, 1) both;
}

.toast-good .toast-text { background: linear-gradient(180deg, #69db7c, var(--green)); box-shadow: 0 7px 0 var(--green-d), 0 18px 40px rgba(47, 154, 76, 0.4); }
.toast-bad .toast-text { background: linear-gradient(180deg, #ff8787, var(--red)); box-shadow: 0 7px 0 var(--red-d), 0 18px 40px rgba(209, 72, 72, 0.4); }
.toast-info .toast-text { background: linear-gradient(180deg, #74c0fc, var(--blue)); box-shadow: 0 7px 0 var(--blue-d), 0 18px 40px rgba(43, 132, 204, 0.4); }

.toast.leaving .toast-text {
  animation: toastOut 0.45s ease-in both;
}

.burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
}

.burst .bit {
  position: absolute;
  left: -6px;
  top: -4px;
  width: 12px;
  height: 8px;
  border-radius: 2px;
  font-style: normal;
  animation: burst 1.1s cubic-bezier(0.1, 0.8, 0.3, 1) var(--delay, 0ms) both;
}

.burst .bit.star {
  width: auto;
  height: auto;
  font-size: 28px;
  left: -14px;
  top: -16px;
}

/* ---------- title screen ---------- */

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  padding: 16px;
  pointer-events: none !important;
}

.title-screen.leaving {
  animation: titleOut 0.45s ease-in both;
}

.title-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(600px, 52vw);
  max-height: 100%;
  overflow: hidden;
  pointer-events: auto;
  background: var(--paper);
  border: 5px solid #fff;
  border-radius: 34px;
  box-shadow: 0 18px 50px rgba(61, 44, 85, 0.3);
  animation: titleIn 0.6s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

.awning {
  position: relative;
  flex: none;
  height: 34px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 36px, #fff 36px 72px);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08);
}

.awning::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 18px;
  background:
    radial-gradient(circle at 18px 0, var(--accent) 17.5px, transparent 18.5px) 0 0 / 72px 18px repeat-x,
    radial-gradient(circle at 54px 0, #fff 17.5px, transparent 18.5px) 0 0 / 72px 18px repeat-x;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.07));
  z-index: 2;
}

.title-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 26px 6px;
}

.logo {
  margin: 4px 0 0;
  text-align: center;
  line-height: 1;
}

.logo-top {
  display: block;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-top .ltr {
  display: inline-block;
  color: var(--c);
  transform: rotate(var(--tilt));
  text-shadow:
    3px 0 #fff, -3px 0 #fff, 0 3px #fff, 0 -3px #fff,
    2px 2px #fff, -2px -2px #fff, 2px -2px #fff, -2px 2px #fff,
    0 7px 0 rgba(61, 44, 85, 0.22);
  animation: letterIn 0.6s cubic-bezier(0.2, 1.8, 0.4, 1) calc(var(--i) * 45ms + 150ms) both;
}

.logo-top .sp {
  display: inline-block;
  width: 0.3em;
}

.logo-shop {
  display: block;
  margin-top: -2px;
}

.logo-shop-text {
  display: inline-block;
  font-size: 76px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--yellow);
  transform: rotate(-2deg);
  text-shadow:
    4px 0 var(--ink), -4px 0 var(--ink), 0 4px var(--ink), 0 -4px var(--ink),
    3px 3px var(--ink), -3px -3px var(--ink), 3px -3px var(--ink), -3px 3px var(--ink),
    0 10px 0 var(--ink), 3px 10px 0 var(--ink), -3px 10px 0 var(--ink);
  animation: shopIn 0.7s cubic-bezier(0.2, 1.8, 0.4, 1) 0.7s both;
}

/* Eva and Max stand either side of the logo, waving. */
.title-hero {
  --kid-h: 138px;
  position: relative;
  padding: 0 calc(var(--kid-h) * 0.62);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: calc(var(--kid-h) - 10px); /* tall enough for the kids: the logo alone is shorter */
}

.kid {
  position: absolute;
  bottom: -6px;
  width: calc(var(--kid-h) * 0.8);
  height: var(--kid-h);
  overflow: visible;
  pointer-events: none;
  animation: kidIn 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) 1s both;
}

.kid-eva { left: -10px; }
.kid-max { right: -10px; animation-delay: 1.15s; }

.kid-shadow { fill: rgba(61, 44, 85, 0.16); animation: kidShadow 0.9s ease-in-out infinite alternate; }
.kid-body { animation: kidBob 0.9s ease-in-out infinite alternate; }
.kid-head { animation: kidTilt 1.8s ease-in-out infinite alternate; }
.kid-eyes { animation: kidBlink 4.2s infinite; }
.kid-eva .kid-wave { animation: kidWaveL 0.42s ease-in-out infinite alternate; }
.kid-pony { animation: kidPony 0.9s ease-in-out infinite alternate; }
.kid-max .kid-wave { animation: kidWaveR 0.42s ease-in-out -0.2s infinite alternate; }
.kid-max .kid-body,
.kid-max .kid-shadow { animation-delay: -0.45s; }
.kid-max .kid-head { animation-delay: -0.9s; animation-direction: alternate-reverse; }
.kid-max .kid-eyes { animation-delay: 1.6s; }

/* Family mode: the family's kids (avatar.js) stand where Eva and Max do; with
   3 or 4 the inner ones stand half a kid further in, behind the outer ones. */
.title-hero.family { isolation: isolate; }
.title-hero.family.many { padding: 0 calc(var(--kid-h) * 1.08); }
.title-hero.family .kid { animation-delay: calc(1s + var(--k) * 0.15s); }
.title-hero.family .kid.l { left: calc(-10px + var(--j) * var(--kid-h) * 0.5); }
.title-hero.family .kid.r { right: calc(-10px + var(--j) * var(--kid-h) * 0.5); }
.title-hero.family .kid.inner { z-index: -1; }
@media (max-width: 640px) {
  /* Four kids and the wordmark must still fit a 360px phone on one line. */
  .title-hero.family.many { --kid-h: min(66px, 15.5vw); padding: 0 calc(var(--kid-h) * 0.98); }
  .title-hero.family.many .kid.l { left: calc(-8px + var(--j) * var(--kid-h) * 0.42); }
  .title-hero.family.many .kid.r { right: calc(-8px + var(--j) * var(--kid-h) * 0.42); }
  .title-hero.family.many .logo-top { font-size: min(28px, 7.2vw); }
}
.title-hero.family .kid .kid-body,
.title-hero.family .kid .kid-shadow { animation-delay: calc(var(--k) * -0.3s); }
.title-hero.family .kid .kid-head { animation-delay: calc(var(--k) * -0.6s); }
.title-hero.family .kid .kid-eyes { animation-delay: calc(var(--k) * 0.9s); }
.title-hero.family .kid.l .kid-wave { animation: kidWaveL 0.42s ease-in-out calc(var(--k) * -0.1s) infinite alternate; }
.title-hero.family .kid.r .kid-wave { animation: kidWaveR 0.42s ease-in-out calc(var(--k) * -0.1s) infinite alternate; }

/* A family kid's face in the player picker instead of a letter. */
.avatar.av-kid { position: relative; display: block; overflow: hidden; background: #fff4e0; }
.avatar.av-kid .kid { left: -25%; top: -12%; bottom: auto; width: 150%; height: 187.5%; animation: none; }
.avatar.av-kid .kid * { animation: none; }

/* Music toggle in the corner of the title card, over the awning, and the
   home button (back to all the games) in the other corner. */
.title-music,
.title-home {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 3;
  width: 44px;
  height: 44px;
  font-size: 20px;
}

.title-home {
  right: auto;
  left: 10px;
  text-decoration: none;
}

.tagline {
  margin: 8px 0 4px;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink-soft);
}

.title-section {
  margin-top: 14px;
}

.title-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  font-size: 20px;
  font-weight: 700;
}

.title-section h3 span {
  font-size: 20px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip,
.pick {
  position: relative;
  border: 3px solid var(--line);
  background: #fff;
  box-shadow: 0 5px 0 var(--line-d);
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.15s, background 0.15s;
}

.chip:active,
.pick:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--line-d);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 56px;
  padding: 5px 18px 5px 6px;
  border-radius: 999px;
  font-size: 21px;
  font-weight: 600;
}

.chip.selected {
  border-color: var(--blue);
  background: #e7f5ff;
  box-shadow: 0 5px 0 var(--blue-d);
}

.chip.selected::after,
.pick.selected::after {
  content: '✓';
  position: absolute;
  top: -9px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  border: 3px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: bump 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: var(--av, var(--blue));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.avatar.sm {
  width: 32px;
  height: 32px;
  font-size: 17px;
}

.add-chip {
  padding: 5px 20px 5px 10px;
  border-style: dashed;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.6);
}

.add-chip .plus {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  color: #fff;
  background: var(--orange);
}

.add-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid var(--orange);
  box-shadow: 0 5px 0 #e8890c;
}

.add-input {
  width: 160px;
  height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  font: 600 21px var(--font);
  color: var(--ink);
  background: #fff8ec;
  -webkit-user-select: text;
  user-select: text;
}

.add-input:focus {
  outline: none;
  background: #fff3dc;
}

.mini-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink-soft);
  background: #f1ebe2;
}

.mini-btn.ok {
  color: #fff;
  background: var(--green);
  box-shadow: inset 0 -3px 0 var(--green-d);
}

.pick-row {
  display: grid;
  gap: 11px;
}

.pick {
  border-radius: 20px;
  font-weight: 600;
  color: var(--ink);
}

.pick.selected {
  border-color: var(--card-accent, var(--blue));
  box-shadow: 0 5px 0 var(--card-accent, var(--blue-d));
  background: color-mix(in srgb, var(--card-accent, var(--blue)) 10%, #fff);
}

.pick.tapped {
  animation: bump 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.shops {
  grid-template-columns: repeat(3, 1fr);
}

.shop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 6px 9px;
}

.shop-icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 58px;
  border-radius: 14px;
  font-size: 40px;
  background: linear-gradient(180deg, var(--sky-a), var(--sky-b));
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.06);
}

.shop-name {
  font-size: 18px;
}

.modes {
  grid-template-columns: repeat(2, 1fr);
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 8px 10px;
  text-align: left;
}

.mode-emoji {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 28px;
  background: color-mix(in srgb, var(--card-accent) 22%, #fff);
}

.mode-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mode-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
}

.mode-blurb {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-soft);
}

.currencies {
  grid-template-columns: repeat(3, 1fr);
}

.cur-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 10px 6px 6px;
  text-align: left;
}

.cur-sym {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  color: #6b4b00;
  background: radial-gradient(circle at 35% 30%, #fff3bf, var(--yellow) 70%);
  box-shadow: inset 0 -3px 0 var(--yellow-d);
}

.cur-name {
  flex: 1;
  font-size: 16px;
  line-height: 1.1;
}

.cur-flag {
  font-size: 22px;
}

.title-foot {
  flex: none;
  display: flex;
  gap: 12px;
  padding: 14px 22px 20px;
  border-top: 3px dashed var(--line);
  background: linear-gradient(180deg, rgba(255, 250, 242, 0), var(--paper) 30%);
}

.scores-btn {
  flex: none;
  padding: 0 18px;
}

.go-btn {
  flex: 1;
  animation: breathe 2.2s ease-in-out infinite;
}

.go-btn:active {
  animation: none;
}

/* ---------- modals ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(80, 50, 120, 0.22), rgba(45, 28, 66, 0.5));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 0.25s both;
}

.modal-back.leaving {
  animation: fadeOut 0.28s both;
  pointer-events: none;
}

.modal-card {
  position: relative;
  width: min(580px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 26px 26px 24px;
  background: var(--paper);
  border: 5px solid #fff;
  border-radius: 34px;
  box-shadow: 0 24px 60px rgba(30, 15, 50, 0.35);
  text-align: center;
  animation: popIn 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.modal-back.leaving .modal-card {
  animation: popOut 0.25s ease-in both;
}

.modal-title {
  margin: 0 0 14px;
  font-size: 32px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}

.modal-actions .btn {
  min-width: 140px;
}

/* summary */

.summary-card {
  overflow-x: hidden;
}

.sum-ribbon {
  display: inline-block;
  padding: 10px 34px 12px;
  border-radius: 18px;
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ff8787, var(--red));
  box-shadow: 0 7px 0 var(--red-d);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
  transform: rotate(-2deg);
  animation: letterIn 0.6s cubic-bezier(0.2, 1.8, 0.4, 1) 0.1s both;
}

.sum-sub {
  margin: 14px 0 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-soft);
}

.sum-stars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin: 4px 0 -4px;
}

.big-star {
  font-size: 84px;
  line-height: 1;
  color: #e9dfd0;
  text-shadow: 0 5px 0 #d9ccb8;
}

.big-star:nth-child(2) {
  font-size: 104px;
  transform: translateY(-6px);
}

.big-star.earned {
  animation: starFill 0.6s cubic-bezier(0.2, 1.8, 0.4, 1) var(--d) both;
}

.sum-cheer {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.sum-score {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 8px;
  padding: 6px 26px;
  border-radius: 999px;
  background: #fff6d6;
  border: 3px solid #ffe08a;
}

.sum-score-label {
  font-size: 20px;
  font-weight: 600;
  color: #b07800;
}

.sum-score-num {
  font-size: 48px;
  font-weight: 700;
  color: #d08700;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

.sum-best {
  display: block;
  width: fit-content;
  margin: 12px auto 0;
  padding: 7px 20px;
  border-radius: 999px;
  font-size: 21px;
  font-weight: 700;
  color: #6b4b00;
  background: linear-gradient(180deg, #fff3bf, var(--yellow));
  box-shadow: 0 5px 0 var(--yellow-d);
  animation: wiggle 1.4s ease-in-out infinite;
}

.sum-tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.sum-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px 9px;
  border-radius: 18px;
  background: #fff;
  border: 3px solid var(--line);
}

.sum-emoji {
  font-size: 26px;
  line-height: 1.1;
}

.sum-val {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.sum-tile.wide .sum-val {
  font-size: 21px;
  line-height: 1.45;
  color: var(--green-d);
}

.sum-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* scores */

.scores-card {
  width: min(640px, 100%);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-height: 48px;
  padding: 0 16px;
  border: 3px solid var(--line);
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  background: #fff;
  box-shadow: 0 4px 0 var(--line-d);
}

.tab.selected {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 4px 0 var(--blue-d);
}

.score-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 200px;
  text-align: left;
}

.score-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 8px;
  border-radius: 16px;
  background: #fff;
  border: 3px solid var(--line);
  animation: lineIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) calc(var(--i) * 40ms) both;
}

.score-row.top:nth-child(1) { background: #fff8db; border-color: #ffe08a; }
.score-row.top:nth-child(2) { background: #f4f6fa; border-color: #dde2ea; }
.score-row.top:nth-child(3) { background: #fff1e6; border-color: #f6cfae; }

.score-rank {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  color: var(--ink-soft);
}

.score-row:not(.top) .score-rank {
  font-size: 20px;
}

.score-who {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 20px;
  font-weight: 600;
}

.score-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-meta {
  font-size: 13.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.score-pts {
  font-size: 21px;
  font-weight: 700;
  color: #d08700;
  white-space: nowrap;
}

.score-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 200px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
}

.score-empty span {
  font-size: 56px;
}

/* confirm */

.confirm-card {
  width: min(440px, 100%);
}

.confirm-emoji {
  font-size: 60px;
  line-height: 1;
}

.confirm-text {
  margin: 12px 0 0;
  font-size: 25px;
  font-weight: 600;
  line-height: 1.25;
}

/* ---------- responsive ---------- */

/* Smaller landscape tablets */
@media (max-width: 1150px) {
  .hud-logo {
    display: none;
  }
}

@media (max-width: 1080px) and (min-aspect-ratio: 1/1) {
  .title-card {
    width: min(560px, 56vw);
  }
}

/* Short landscape screens (1024x768, 1280x800 browsers with chrome, phones) */
@media (max-height: 860px) and (min-aspect-ratio: 1/1) {
  .title-scroll { padding: 10px 22px 4px; }
  .logo-top { font-size: 38px; }
  .logo-shop-text { font-size: 56px; letter-spacing: 6px; }
  .title-hero { --kid-h: 112px; }
  .tagline { margin: 2px 0 0; font-size: 16px; }
  .title-section { margin-top: 8px; }
  .title-section h3 { margin-bottom: 6px; font-size: 18px; }
  .shop-card { flex-direction: row; justify-content: flex-start; gap: 8px; padding: 6px 8px 6px 6px; }
  .shop-icon { width: 46px; height: 46px; flex: none; font-size: 28px; }
  .shop-name { font-size: 17px; line-height: 1.1; text-align: left; }
  .mode-card { min-height: 58px; padding: 5px 8px; }
  .mode-emoji { width: 40px; height: 40px; font-size: 23px; border-radius: 13px; }
  .mode-blurb { font-size: 13px; }
  .cur-chip { min-height: 52px; }
  .title-foot { padding: 10px 20px 14px; }
  .btn-huge { min-height: 66px; font-size: 28px; }
  .chip { min-height: 52px; }
  .avatar { width: 36px; height: 36px; font-size: 20px; }
}

/* Portrait: panels go to the bottom, the shop shows above them. */
@media (orientation: portrait), (max-width: 640px) {
  :root {
    --edge: 10px;
  }

  .panel,
  .terminal-wrap {
    top: auto;
    left: var(--edge);
    right: var(--edge);
    width: auto;
    max-height: 56vh;
  }

  .change-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      'head display'
      'tray tray'
      'money money'
      'actions actions';
    align-items: center;
    column-gap: 14px;
  }

  .change-panel .panel-head { grid-area: head; }
  .change-panel .cp-display { grid-area: display; }
  .change-panel .cp-tray { grid-area: tray; min-height: 74px; max-height: 110px; }
  .change-panel .cp-money-area { grid-area: money; flex-direction: row; align-items: center; gap: 14px; }
  .change-panel .cp-actions { grid-area: actions; }
  .change-panel .cp-grid { width: auto; margin: 0; }
  .change-panel .cp-notes { flex: 1.15; }
  .change-panel .cp-coins { flex: 1; }

  .terminal-wrap {
    gap: 10px;
    flex-direction: column-reverse;
  }

  .terminal-wrap .panel-head {
    display: none;
  }

  .terminal {
    width: min(360px, 100%);
  }

  .ct-message {
    position: absolute;
    top: -58px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    white-space: nowrap;
  }

  .ct-message.show {
    transform: translateX(-50%) scale(1);
  }

  .receipt {
    top: calc(var(--hud-h) + 10px);
    bottom: auto;
    left: 12px;
    --rc-scale: 0.88;
    transform-origin: top left;
  }

  .title-screen {
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
  }

  .title-card {
    width: 100%;
    max-width: 760px;
    max-height: 82%;
  }

  .hud-player {
    display: none;
  }

  .hud-pill,
  .hud-dots {
    height: 42px;
    padding: 0 11px;
    font-size: 17px;
  }

  .hud-dots .dot {
    width: 13px;
    height: 13px;
  }

  .hud-btn {
    width: 46px;
    height: 46px;
  }
}

/* Narrow portrait (phones) */
@media (max-width: 640px) {
  :root {
    --hud-h: 108px;
  }

  .hud {
    flex-wrap: wrap;
    height: auto;
    row-gap: 8px;
    gap: 6px;
  }

  .hud-center {
    order: 3;
    flex-basis: 100%;
  }

  .hud-till,
  .hud-voice,
  .hud-shop,
  .hud-player {
    display: none !important;
  }

  .hud-where {
    padding: 0 4px;
  }

  .hud-pill,
  .hud-dots {
    padding: 0 10px;
  }

  .hud-right {
    gap: 5px;
  }

  .hud-btn {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .panel,
  .terminal-wrap {
    max-height: 62vh;
  }

  /* Change panel: compact, so the shop still shows above it. Notes in one
     row, coins in even rows, nothing to scroll. */
  .change-panel {
    display: flex;
    gap: 7px;
    padding: 9px 10px 10px;
    border-width: 3px;
    border-radius: 24px;
    overflow-y: auto;
  }

  .change-panel .panel-head {
    display: none;
  }

  .change-panel .cp-stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
    padding: 3px 10px 4px;
    border-radius: 14px;
  }

  .cp-label { font-size: 11px; letter-spacing: 0.4px; }
  .cp-amount { font-size: 21px; }

  .change-panel .cp-tray {
    flex: none;
    min-height: 50px;
    max-height: 92px;
    padding: 5px;
    border-width: 3px;
    border-radius: 16px;
  }

  .cp-tray-empty { font-size: 14px; padding: 2px 6px; }

  .change-panel .cp-money-area {
    flex-direction: column;
    gap: 8px;
    margin: -6px -8px;
    padding: 8px 8px 10px;
  }

  .change-panel .cp-grid {
    display: grid;
    width: auto;
    gap: 6px;
  }

  .change-panel .cp-notes,
  .change-panel .cp-coins {
    flex: none;
  }

  .change-panel .cp-notes {
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
  }

  .change-panel .cp-coins {
    grid-template-columns: repeat(var(--per), 1fr);
  }

  .change-panel .cp-coins .cp-money {
    justify-self: center;
    width: min(100%, 46px);
  }

  .cp-money {
    min-height: 0;
    padding: 4px;
    border-radius: 12px;
    box-shadow: 0 3px 0 var(--line-d), 0 5px 8px rgba(61, 44, 85, 0.1);
  }

  .cp-actions { grid-template-columns: 1fr 1fr 1.6fr; gap: 7px; padding-bottom: 3px; }
  .cp-actions .btn { min-height: 46px; font-size: 16px; }
  .cp-actions .cp-ok { min-height: 50px; font-size: 21px; }

  /* Card machine: a card-reader keypad (4 columns, tall OK), with the
     prompt beside the amount. */
  .terminal-wrap { gap: 8px; }

  .terminal {
    width: 100%;
    max-width: 420px;
    padding: 10px 12px 18px;
    border-radius: 26px 26px 32px 32px;
  }

  .terminal-top { display: none; }

  .lcd {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 3px 12px;
    border-width: 3px;
  }

  .lcd-top {
    flex: none;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 2px;
    width: 62px;
  }

  .lcd-label { font-size: 10px; letter-spacing: 1px; line-height: 1.15; }
  .lcd-icon { width: 15px; height: 15px; }
  .lcd-amount { flex: 1; min-height: 42px; font-size: 32px; line-height: 42px; }
  .lcd-amount .cursor { height: 28px; vertical-align: -4px; }
  .lcd-flash { font-size: 22px; }

  .keypad {
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas:
      'k1 k2 k3 back'
      'k4 k5 k6 clear'
      'k7 k8 k9 ok'
      'dot k0 k0 ok';
    gap: 7px 8px;
  }

  .key { height: 46px; font-size: 24px; border-radius: 13px; }
  .key:nth-child(1) { grid-area: k1; }
  .key:nth-child(2) { grid-area: k2; }
  .key:nth-child(3) { grid-area: k3; }
  .key:nth-child(4) { grid-area: k4; }
  .key:nth-child(5) { grid-area: k5; }
  .key:nth-child(6) { grid-area: k6; }
  .key:nth-child(7) { grid-area: k7; }
  .key:nth-child(8) { grid-area: k8; }
  .key:nth-child(9) { grid-area: k9; }
  .key:nth-child(10) { grid-area: dot; }
  .key:nth-child(11) { grid-area: k0; }
  .keypad .key-back { grid-area: back; }
  .keypad .key-clear { grid-area: clear; }
  .keypad .key-ok { grid-area: ok; height: auto; font-size: 22px; letter-spacing: 1px; }

  .title-card { max-height: 100%; }
  .title-scroll { padding: 14px 16px 4px; }
  .logo-top { font-size: min(34px, 8.6vw); }
  .logo-shop-text { font-size: 54px; }
  .title-hero { --kid-h: min(84px, 19vw); } /* the kids' padding plus the logo's top line must fit the card */
  .title-music { top: 4px; right: 6px; width: 40px; height: 40px; font-size: 18px; }
  .title-home { top: 4px; left: 6px; width: 40px; height: 40px; font-size: 18px; }
  .shops, .currencies { grid-template-columns: repeat(3, 1fr); }
  .modes { grid-template-columns: 1fr; }
  .cur-chip { justify-content: center; }
  .cur-name { display: none; }
  .title-foot { flex-direction: column-reverse; padding: 10px 14px 14px; }
  .scores-btn { width: 100%; }

  .sum-tiles { grid-template-columns: repeat(2, 1fr); }
  .sum-tile.wide { grid-column: span 2; }
  .score-meta { display: none; }
  .score-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .toast-text { font-size: 30px; white-space: normal; text-align: center; }
  .receipt { --rc-scale: 0.62; top: calc(var(--hud-h) + 4px); }
}

/* The narrowest phones: no room for the music button in the HUD (it is on the
   title screen), and the change panel's words shrink to stay on one line. */
@media (max-width: 379px) {
  .hud-music { display: none; }
  .change-panel .cp-stat { padding: 3px 8px 4px; }
  .cp-label { font-size: 10px; letter-spacing: 0; white-space: nowrap; }
  .cp-amount { font-size: 19px; }
  .cp-tray-empty { font-size: 12.5px; padding: 2px; }
}

/* Phones held sideways: very little height */
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  :root {
    --hud-h: 52px;
    --panel-w: min(360px, 46vw);
  }

  .hud-pill, .hud-dots { height: 38px; font-size: 16px; padding: 0 10px; }
  .hud-btn { width: 42px; height: 42px; font-size: 19px; }
  .hud-player, .hud-till { display: none; }

  .panel { padding: 8px; gap: 6px; overflow-y: auto; border-radius: 22px; }
  .change-panel {
    --panel-w: min(560px, 58vw);
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 'display money' 'tray money' 'actions money';
    column-gap: 10px;
  }
  .change-panel .panel-head { display: none; }
  .change-panel .cp-display { grid-area: display; grid-template-columns: 1fr; gap: 4px; }
  .change-panel .cp-stat { padding: 2px 10px 3px; border-radius: 14px; }
  .change-panel .cp-tray { grid-area: tray; min-height: 48px; padding: 6px; }
  .change-panel .cp-money-area { grid-area: money; overflow-y: auto; gap: 8px; padding: 2px; }
  .change-panel .cp-actions { grid-area: actions; grid-template-columns: 1fr 1fr; }
  .change-panel .cp-actions .cp-ok { grid-column: span 2; min-height: 50px; font-size: 21px; }
  .cp-money { min-height: 0; padding: 4px; border-radius: 12px; }
  .cp-label { font-size: 11px; }
  .cp-amount { font-size: 20px; }
  .cp-tray-empty { font-size: 13px; }
  .cp-actions .btn { min-height: 46px; font-size: 16px; }

  .terminal-wrap { --panel-w: min(560px, 60vw); }
  .terminal-wrap .panel-head { display: none; }
  .terminal {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    align-items: start;
    gap: 12px;
    width: 100%;
    padding: 12px 14px 20px;
    border-radius: 26px;
  }
  .terminal-top { display: none; }
  .lcd { margin: 0; }
  .lcd-amount { font-size: 28px; min-height: 40px; line-height: 40px; }
  .lcd-flash { font-size: 20px; }
  .keypad { gap: 6px 8px; }
  .key { height: 42px; font-size: 22px; border-radius: 12px; }
  .ct-message { position: absolute; left: 12px; bottom: 12px; width: calc(40% - 12px); font-size: 15px; padding: 6px 10px; min-height: 0; transform: scale(0.8); white-space: normal; }
  .ct-message.show { transform: scale(1); }

  .receipt { --rc-scale: 0.7; bottom: 20px; }

  .title-card { width: min(560px, 62vw); }
  .title-hero { --kid-h: 96px; }
  .modal-card { padding: 16px; }
  .big-star { font-size: 56px; }
  .big-star:nth-child(2) { font-size: 68px; }
  .sum-ribbon { font-size: 26px; }
  .sum-score-num { font-size: 34px; }
  .sum-tiles { margin-top: 10px; }
}

/* ---------- animations ---------- */

@keyframes slideIn { from { transform: translateX(110%); } to { transform: none; } }
@keyframes slideOut { to { transform: translateX(115%); opacity: 0.6; } }
@media (orientation: portrait), (max-width: 640px) {
  @keyframes slideIn { from { transform: translateY(110%); } to { transform: none; } }
  @keyframes slideOut { to { transform: translateY(115%); opacity: 0.6; } }
}

@keyframes shake {
  0%, 100% { translate: 0; }
  15% { translate: -12px 0; }
  30% { translate: 10px 0; }
  45% { translate: -8px 0; }
  60% { translate: 6px 0; }
  75% { translate: -3px 0; }
}

@keyframes dropIn {
  from { transform: translateY(-50px) scale(0.4) rotate(-20deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes tapBounce {
  0% { transform: scale(1); }
  40% { transform: scale(0.86); }
  100% { transform: scale(1); }
}

@keyframes hintPulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.07; }
}

@keyframes handPoke {
  0%, 100% { transform: translate(-50%, 8px); }
  50% { transform: translate(-50%, -4px); }
}

@keyframes handPokeDown {
  0%, 100% { transform: translate(-50%, calc(-100% - 8px)); }
  50% { transform: translate(-50%, calc(-100% + 4px)); }
}

@keyframes keyFlash {
  0% { filter: brightness(1.15); }
  100% { filter: none; }
}

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.25; }
}

@keyframes printIn {
  from { transform: rotate(-1.5deg) translateY(120%); }
  to { transform: rotate(-1.5deg); }
}

@keyframes printOut {
  to { transform: rotate(-8deg) translate(-40px, 130%); opacity: 0; }
}

@keyframes lineIn {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: none; }
}

@keyframes wiggle {
  0%, 100% { rotate: 0deg; }
  25% { rotate: -3deg; }
  75% { rotate: 3deg; }
}

@keyframes bubblePop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes bubbleOut {
  to { transform: scale(0.6); opacity: 0; }
}

@keyframes toastIn {
  0% { transform: scale(0.3) translateY(30px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

@keyframes toastOut {
  to { transform: translateY(-50px) scale(0.9); opacity: 0; }
}

@keyframes burst {
  0% { transform: translate(0, 0) scale(0.4) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 60px)) scale(1) rotate(var(--rot)); opacity: 0; }
}

@keyframes titleIn {
  from { transform: translateX(-40px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes titleOut {
  to { transform: translateX(-60px); opacity: 0; }
}

@keyframes letterIn {
  0% { transform: translateY(-40px) scale(0.4) rotate(var(--tilt, 0deg)); opacity: 0; }
  100% { transform: rotate(var(--tilt, 0deg)); opacity: 1; }
}

@keyframes shopIn {
  0% { transform: scale(0.2) rotate(-12deg); opacity: 0; }
  100% { transform: rotate(-2deg); opacity: 1; }
}

@keyframes breathe {
  0%, 100% { scale: 1; }
  50% { scale: 1.03; }
}

@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

@keyframes popIn {
  from { transform: scale(0.7) translateY(30px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes popOut {
  to { transform: scale(0.85); opacity: 0; }
}

@keyframes starFill {
  0% { color: #e9dfd0; scale: 1; }
  30% { color: #e9dfd0; scale: 0.75; }
  65% { color: #ffd84d; scale: 1.3; }
  100% { color: #ffc61a; text-shadow: 0 5px 0 #e09b00, 0 0 24px rgba(255, 198, 26, 0.6); scale: 1; }
}

@keyframes kidIn { from { opacity: 0; transform: translateY(40px) scale(0.3); } to { opacity: 1; transform: none; } }
@keyframes kidBob { from { transform: translateY(0); } to { transform: translateY(-5px); } }
@keyframes kidShadow { from { transform: scale(1); } to { transform: scale(0.86); } }
@keyframes kidTilt { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes kidWaveL { from { transform: rotate(-18deg); } to { transform: rotate(-46deg); } }
@keyframes kidWaveR { from { transform: rotate(18deg); } to { transform: rotate(46deg); } }
@keyframes kidPony { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes kidBlink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
