@font-face {
  font-family: Fredoka;
  src: url(fonts/fredoka.woff2) format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

/* Every colour comes from a variable. These are the Candy Shop values, for the
   first paint; the active theme pack (js/themes/) sets all of them at startup. */
:root {
  color-scheme: light;
  --sky: #ff93bf;
  --ink: #5a1838;
  --ink-soft: #8a4a68;
  --cream: #fff7ef;
  --cream-2: #ffe5ef;
  --edge: #fff;
  --on-accent: #fff;
  --card-drop: #e0709f;
  --shade: 90, 0, 50;
  --title-shadow: rgba(120, 0, 60, 0.45);
  --rose-light: #ff9ab8;
  --rose: #ff5d8f;
  --rose-deep: #c81f63;
  --rose-drop: #a3134d;
  --round-light: #ffb3cc;
  --moves-shadow: rgba(120, 0, 40, 0.45);
  --moves-label: #ffe3ee;
  --meter-track: #f3c9da;
  --meter-a: #ffe07a;
  --meter-b: #ff9a3c;
  --meter-stripe: rgba(255,255,255,0.35);
  --star-off: #d9a7bd;
  --gold: #ffc93c;
  /* Stars are the same gold in every theme (the owner: stars and coins look the same
     everywhere); themes don't override these, only --gold (buttons and trim). */
  --star: #ffc21a;
  --star-deep: #b86f00;
  --gold-deep: #c26f12;
  --gold-top: #fff09a;
  --gold-bottom: #ffa726;
  --gold-text: #7a3400;
  --gold-inset: rgba(200, 100, 0, 0.25);
  --gold-glint: rgba(255, 255, 255, 0.6);
  --pink-top: #ffc2d6;
  --pink-mid: #ff76a2;
  --pink-bottom: #f04a82;
  --pink-inset: rgba(160, 0, 60, 0.2);
  --pink-shadow: rgba(120, 0, 50, 0.4);
  --good: #1d9a5c;
  --toggle-bg: rgba(255, 255, 255, 0.8);
  --toggle-off: #a88;
  --map-star-off: rgba(255, 255, 255, 0.55);
  --locked-bg: rgba(255, 255, 255, 0.7);
  --locked-text: #b08;
  --locked-icon: #a07890;
  --backdrop: rgba(70, 0, 40, 0.45);
  --ribbon-top: #ff8fb2;
  --ribbon-shadow: rgba(120, 0, 40, 0.4);
  --panel-shadow: rgba(60, 0, 30, 0.4);
  --result-star-off: #ecc5d6;
  --font: Fredoka, 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --font-display: var(--font);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--edge); outline-offset: 3px; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

/* ------------------------------------------------------------------ HUD */

#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: calc(var(--safe-t) + 12px) 16px 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  max-width: 560px;
  margin: 0 auto;
}
.card {
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  border: 3px solid var(--edge);
  border-radius: 18px;
  box-shadow: 0 4px 0 var(--card-drop), 0 8px 18px rgba(var(--shade), 0.28);
  padding: 6px 10px 8px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}
.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.meter {
  position: relative;
  width: 100%;
  height: 10px;
  margin-top: 4px;
  border-radius: 99px;
  background: var(--meter-track);
  box-shadow: inset 0 2px 3px rgba(var(--shade), 0.25);
}
.meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  border-radius: 99px;
  background:
    repeating-linear-gradient(-45deg, var(--meter-stripe) 0 6px, transparent 6px 12px),
    linear-gradient(180deg, var(--meter-a), var(--meter-b));
  transition: width 0.3s ease-out;
}
.meter-star {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  background: var(--star-off);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  transition: transform 0.25s, background 0.25s;
}
.meter-star.lit { background: var(--star); transform: scale(1.25); filter: drop-shadow(0 1px 0 var(--star-deep)); }
/* On a level the score's meter fills toward a score target, with no stars: they're
   under the moves, and count the moves left. */
.by-moves .meter-star { display: none; }

.moves {
  width: 78px; height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--rose-light), var(--rose) 45%, var(--rose-deep));
  border: 4px solid var(--edge);
  box-shadow: 0 5px 0 var(--rose-drop), 0 10px 18px rgba(var(--shade), 0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--on-accent);
}
/* Under the moves: the best stars still possible, hollow (nothing is earned before the
   win), and the moves left they need. It shakes when the moves drop below them. */
.moves { position: relative; }
.move-stars {
  position: absolute; left: 50%; bottom: -17px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 2px 8px 3px 6px; border-radius: 999px;
  background: linear-gradient(180deg, var(--cream), var(--cream-2)); border: 2px solid var(--edge);
  box-shadow: 0 2px 0 var(--card-drop);
  color: var(--ink); font-size: 12px; font-weight: 700; line-height: 1;
}
.move-stars small { font-size: 12px; }
.ms-icons { display: inline-flex; gap: 1px; }
.move-stars svg { width: 14px; height: 14px; fill: none; stroke: var(--star); stroke-width: 2.2; stroke-linejoin: round; }
.move-stars.drop { animation: stars-drop 0.7s ease-out; }
@keyframes stars-drop { 0%, 100% { transform: translateX(-50%); } 20% { transform: translateX(-50%) scale(1.25); } 45% { transform: translateX(calc(-50% - 4px)); } 65% { transform: translateX(calc(-50% + 4px)); } }
.moves #moves { font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 var(--moves-shadow); }
.moves .label { color: var(--moves-label); font-size: 10px; }
.moves.low { animation: pulse 0.8s ease-in-out infinite; }
.moves.bump #moves { animation: bump 0.25s ease-out; }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes bump { 40% { transform: scale(1.35); } }

.goal-items { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.goal-item { display: flex; align-items: center; gap: 2px; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.goal-item img { width: 28px; height: 28px; }
.goal-item.done { color: var(--good); }
.boss-hp { position: relative; display: block; width: 104px; height: 22px; border-radius: 11px; overflow: hidden;
  background: rgba(0, 0, 0, 0.35); box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.4); }
.boss-hp i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 11px;
  background: linear-gradient(180deg, #ff8a7a, #e8263a 55%, #9a0a1e); transition: width 0.35s ease-out; }
.boss-hp b { position: relative; display: block; text-align: center; line-height: 22px; font-size: 15px; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); font-variant-numeric: tabular-nums; }
/* When the boss arrives its health bar fills up. */
.boss-hp.fill i { animation: hp-fill 0.9s cubic-bezier(0.3, 0.8, 0.4, 1) both; }
@keyframes hp-fill { from { width: 0; } }
.goal-item .tick { width: 16px; height: 16px; }
.goal-target { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

#bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 0 16px calc(var(--safe-b) + 12px);
  display: flex; align-items: center; gap: 12px;
  max-width: 560px; margin: 0 auto;
  pointer-events: none;
}
#bar > * { pointer-events: auto; }
#level-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--on-accent);
  text-shadow: 0 2px 0 var(--title-shadow);
  pointer-events: none;
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-spacer { width: 48px; }
@media (max-width: 479px) {
  .map-top h1 { display: none; }
}
@media (max-width: 360px) {
  .map-pills { gap: 8px; }
  #bar { gap: 10px; }
  #level-label { font-size: 15px; }
  .boosters { gap: 6px; }
  .boost { width: 54px; height: 54px; }
  .boost img { width: 42px; height: 42px; }
  .map-top h1 { font-size: 24px; }
}

.round-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 3px solid var(--edge);
  background: radial-gradient(circle at 35% 30%, var(--round-light), var(--rose) 60%, var(--rose-deep));
  box-shadow: 0 4px 0 var(--rose-drop), 0 6px 12px rgba(var(--shade), 0.3);
  display: grid; place-items: center;
  padding: 0;
}
.round-btn svg { width: 22px; height: 22px; fill: var(--on-accent); }
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rose-drop); }

/* A pack's display font (if it has one) for titles and buttons. */
.ribbon, .big-btn, .map-top h1, .panel h2 { font-family: var(--font-display); }

/* -------------------------------------------------------------- boosters */

.boosters { display: flex; gap: 10px; }
.boost {
  position: relative;
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 3px solid var(--edge);
  background: radial-gradient(circle at 35% 30%, var(--cream), var(--cream-2));
  box-shadow: 0 4px 0 var(--card-drop), 0 6px 12px rgba(var(--shade), 0.3);
  display: grid; place-items: center;
  padding: 0;
  transition: transform 0.12s;
}
.boost img { width: 48px; height: 48px; }
.boost:active { transform: translateY(3px); }
.boost .count, .start-boost .count {
  position: absolute; right: -8px; bottom: -7px;
  min-width: 27px; height: 27px; padding: 0 6px;
  border-radius: 14px;
  border: 2px solid var(--edge);
  background: var(--rose);
  color: var(--on-accent);
  font-size: 16px; font-weight: 700; line-height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.boost.empty .count { background: var(--good); font-size: 20px; }
.boost.on { transform: scale(1.14); box-shadow: 0 0 0 4px var(--gold), 0 4px 0 var(--card-drop); }
#tip {
  position: fixed; left: 50%;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 8px 16px;
  border-radius: 16px;
  border: 3px solid var(--edge);
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  box-shadow: 0 4px 0 var(--card-drop), 0 8px 18px var(--panel-shadow);
  color: var(--ink);
  font-size: 15px; font-weight: 600; text-align: center; text-wrap: balance;
  pointer-events: none;
  z-index: 5;
}
#tip .tip-more { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--ink-soft); opacity: 0.8; }
#coach { position: fixed; inset: 0; z-index: 4; }
.coach-glow { animation: glow 1.1s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); transform: scale(1); }
  50% { filter: drop-shadow(0 0 10px var(--gold)); transform: scale(1.06); }
}
.coins {
  display: flex; align-items: center; gap: 4px;
  font-weight: 700; font-size: 18px; color: var(--on-accent);
  text-shadow: 0 2px 0 var(--title-shadow);
  font-variant-numeric: tabular-nums;
}
.coins img { width: 24px; height: 24px; }
.map-pills { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.lives small { font-size: 12px; font-weight: 600; margin-left: 3px; opacity: 0.9; }
img.coin { width: 20px; height: 20px; vertical-align: -4px; margin: 0 2px; }
.count img.coin { width: 17px; height: 17px; margin: 0 2px 0 0; vertical-align: -3px; }
.start-boosts { display: flex; gap: 18px; justify-content: center; margin: 8px 0 4px; }
.start-boost {
  position: relative; flex: none;
  width: 80px; height: 80px;
  padding: 6px;
  border-radius: 22px;
  border: 3px solid var(--edge);
  background: var(--toggle-bg);
  box-shadow: 0 3px 0 var(--card-drop);
  transition: transform 0.12s;
}
.start-boost img { width: 100%; height: 100%; }
.start-boost[aria-pressed="true"] { transform: scale(1.08); box-shadow: 0 0 0 4px var(--gold), 0 3px 0 var(--card-drop); }
.start-boost.no { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.panel p.small { font-size: 15px; margin: 12px 0 4px; }
.panel p.boost-ask { font-size: 20px; font-weight: 700; color: var(--ink); margin: 14px 0 6px; }
.panel p#m-cost { margin: 8px 0 0; min-height: 1em; }
.earned {
  display: flex; justify-content: center; align-items: center; gap: 6px;
  margin-top: 6px;
  font-size: 22px; font-weight: 700; color: var(--ink);
}
.earned img { width: 30px; height: 30px; }
.big-btn[disabled] { filter: grayscale(0.7); opacity: 0.6; }
.panel p.version { font-size: 12px; margin: 10px 0 0; opacity: 0.6; }
.link-btn {
  border: none; background: none; padding: 6px 10px;
  font: inherit; font-size: 15px; font-weight: 600;
  color: var(--on-accent); text-shadow: 0 2px 0 var(--title-shadow);
  text-decoration: underline; text-underline-offset: 3px;
}
.panel.about { padding-bottom: 16px; }
.about-body {
  text-align: left;
  max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px);
  overflow-y: auto; margin: 0 -8px; padding: 0 8px;
}
.panel.about .buttons { margin-top: 10px; }
.panel.about h3 { margin: 14px 0 4px; font-size: 17px; color: var(--ink); }
.panel.about p { font-size: 15px; text-wrap: pretty; }
.panel textarea {
  width: 100%; height: 88px; margin: 6px 0;
  padding: 8px; border-radius: 12px;
  border: 2px solid var(--card-drop); background: var(--toggle-bg);
  font: 12px/1.35 ui-monospace, monospace; color: var(--ink);
  resize: none; word-break: break-all;
}
.panel pre.licence {
  max-height: 180px; overflow: auto; white-space: pre-wrap;
  font: 11px/1.4 ui-monospace, monospace; color: var(--ink-soft);
  background: var(--toggle-bg); border-radius: 12px; padding: 8px;
}
.panel .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 6px 0; }
.panel .note { font-size: 14px; min-height: 1.2em; text-align: center; color: var(--good); }
.panel .note.bad { color: var(--rose-deep); }

/* --------------------------------------------------------------- screens */

.screen {
  position: fixed;
  inset: 0;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
}
#title {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px;
}
#logo { width: min(92vw, 440px); height: auto; aspect-ratio: 440 / 250; max-width: 100%; }
.big-btn {
  min-width: 210px;
  padding: 14px 36px 16px;
  border-radius: var(--btn-radius);
  border: 4px solid var(--edge);
  background: linear-gradient(180deg, var(--gold-top), var(--gold) 55%, var(--gold-bottom));
  box-shadow: 0 7px 0 var(--gold-deep), 0 14px 24px rgba(var(--shade), 0.3), inset 0 -4px 0 var(--gold-inset);
  font-size: 28px; font-weight: 700;
  color: var(--gold-text);
  text-shadow: 0 2px 0 var(--gold-glint);
  transition: transform 0.08s;
}
.big-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--gold-deep), 0 6px 12px rgba(var(--shade), 0.3); }
.big-btn.small { min-width: 0; font-size: 21px; padding: 10px 22px 12px; }
.big-btn.pink {
  background: linear-gradient(180deg, var(--pink-top), var(--pink-mid) 55%, var(--pink-bottom));
  box-shadow: 0 7px 0 var(--rose-drop), 0 14px 24px rgba(var(--shade), 0.3), inset 0 -4px 0 var(--pink-inset);
  color: var(--on-accent); text-shadow: 0 2px 0 var(--pink-shadow);
}
#title .big-btn { animation: breathe 2.4s ease-in-out infinite; }

/* The first-launch theme picker and the returning player's welcome. */
#intro, #welcome { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.logo { height: min(22vh, 190px); width: auto; max-width: 92vw; flex: none; }
.intro-head {
  margin: 0; flex: none; font-family: var(--font-display); font-size: 30px; font-weight: 700;
  color: var(--on-accent); text-shadow: 0 3px 0 var(--title-shadow); text-align: center;
}
.intro-themes {
  display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: max-content; gap: 12px; align-content: start;
  width: min(92vw, 430px); flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 4px 10px;
}
.intro-theme {
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  border: 4px solid var(--edge); border-radius: 18px; background: var(--cream);
  box-shadow: 0 4px 0 var(--card-drop), 0 8px 16px rgba(var(--shade), 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}
.intro-theme:last-child:nth-child(odd) { grid-column: span 2; justify-self: center; width: calc(50% - 6px); }
.intro-theme canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.intro-theme span { padding: 6px 4px 8px; font-size: 16px; font-weight: 700; color: var(--ink); }
.intro-theme.on { border-color: var(--gold); transform: scale(1.04); box-shadow: 0 0 0 4px var(--gold-bottom), 0 8px 18px rgba(var(--shade), 0.35); }
.intro-theme.picked { animation: bump 0.45s ease-out; }
.glow-btn { flex: none; font-size: clamp(22px, 7.5vw, 32px); white-space: nowrap; padding-left: 28px; padding-right: 28px; animation: breathe 2.4s ease-in-out infinite; }
.welcome-cards {
  display: flex; flex-direction: column; gap: 12px;
  width: min(92vw, 430px); flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 4px 10px;
}
.wcard {
  flex-shrink: 0; padding: 12px 14px; text-align: center; color: var(--ink);
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  border: 3px solid var(--edge); border-radius: 20px;
  box-shadow: 0 4px 0 var(--card-drop), 0 8px 18px rgba(var(--shade), 0.28);
}
.wcard h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 21px; }
.wcard h3 small { font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-left: 6px; }
.wcard p { margin: 2px 0 6px; font-size: 15px; color: var(--ink-soft); }
.wcard .days { margin: 8px 0 2px; }
.wcard .ach-list { overflow: visible; flex: none; margin: 4px 0 0; }
.wcard .ach-list li:last-child { border-bottom: 0; }
.wcard.gift { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bottom), 0 8px 18px rgba(var(--shade), 0.3); }
.wcard .got { animation: pop-in 0.35s ease-out; }
.ach-new { margin-left: 6px; padding: 1px 7px; border-radius: 9px; background: var(--rose); color: var(--on-accent); font-size: 11px; font-weight: 700; vertical-align: 2px; }
.rw.lives-full img { width: 32px; height: 32px; }
/* A line from the live settings (MESSAGE), e.g. for testers. */
.notice {
  margin: 0; max-width: min(88vw, 360px); padding: 8px 14px;
  border-radius: 14px; background: var(--toggle-bg); color: var(--ink);
  font-size: 15px; line-height: 1.35; text-align: center;
}
@keyframes breathe { 50% { transform: scale(1.05); } }

.toggles { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px 8px 10px;
  border-radius: var(--btn-radius);
  border: 3px solid var(--edge);
  background: var(--toggle-bg);
  box-shadow: 0 3px 0 var(--card-drop);
  font-size: 15px; font-weight: 600;
}
.toggle svg { width: 20px; height: 20px; fill: var(--rose-deep); }
.toggle[aria-pressed="false"] { opacity: 0.55; }
.toggle[aria-pressed="false"] svg { fill: var(--toggle-off); }

/* The Volume panel: three sliders, the song playing and Next song. */
.sliders { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 14px; }
.slider { display: grid; grid-template-columns: 76px 1fr 38px; align-items: center; gap: 10px; font-weight: 600; }
.slider b { text-align: right; font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--rose); height: 28px; }
.now-playing { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 8px; text-align: center; }
.now-playing span { font-size: 15px; color: var(--ink-soft); }
.now-playing .big-btn svg { width: 18px; height: 18px; fill: currentColor; vertical-align: -3px; margin-right: 6px; }

/* ------------------------------------------------------------------ map */

#map { display: flex; flex-direction: column; padding-bottom: 0; }
.map-top { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.map-top h1 {
  flex: 1; margin: 0;
  font-size: 30px; font-weight: 700; color: var(--on-accent); text-align: center;
  text-shadow: 0 3px 0 var(--title-shadow);
}
.map-stars {
  display: flex; align-items: center; gap: 4px;
  min-width: 48px; justify-content: flex-end;
  font-weight: 700; font-size: 18px; color: var(--on-accent);
  text-shadow: 0 2px 0 var(--title-shadow);
}
.map-stars svg { width: 20px; height: 20px; fill: var(--star); }
.map-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -16px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.map-path { position: relative; margin: 0 auto; max-width: 480px; }
.map-path svg.trail { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.node {
  position: absolute;
  width: 72px; height: 72px;
  margin: -36px 0 0 -36px;
  border: none;
  padding: 0;
  background: none;
}
.node img { width: 100%; height: 100%; filter: drop-shadow(0 4px 3px rgba(var(--shade), 0.3)); }
/* Where a world begins on the map. */
.world-sign {
  position: absolute; transform: translate(-50%, -50%); z-index: 1; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; max-width: 46%;
  padding: 5px 14px 7px; border-radius: 16px; border: 3px solid var(--edge);
  background: linear-gradient(180deg, var(--ribbon-top), var(--rose-deep));
  box-shadow: 0 4px 0 var(--rose-drop), 0 8px 16px rgba(var(--shade), 0.3);
  color: var(--on-accent); text-shadow: 0 2px 0 var(--pink-shadow); text-align: center;
}
.world-sign span { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; opacity: 0.9; }
.world-sign b { font-family: var(--font-display); font-size: 18px; line-height: 1.1; }
.panel p.world-line { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--rose-deep); }
.node .num {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  min-width: 34px; height: 34px; padding: 0 6px;
  border-radius: 17px;
  background: var(--edge);
  box-shadow: 0 2px 0 var(--card-drop);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; color: var(--ink);
}
.node .stars { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); display: flex; gap: 1px; margin-top: 1px; }
.node .stars svg { width: 18px; height: 18px; fill: var(--map-star-off); }
.node .stars svg.on { fill: var(--star); filter: drop-shadow(0 1px 0 var(--star-deep)); }
.node.locked img { filter: grayscale(1) brightness(1.15) opacity(0.55); }
.node.locked .num { background: var(--locked-bg); color: var(--locked-text); box-shadow: none; }
.node.locked .num svg { width: 16px; height: 16px; fill: var(--locked-icon); }
.node.boss { width: 92px; height: 92px; margin: -46px 0 0 -46px; }
.node.boss img { object-fit: contain; filter: drop-shadow(0 0 8px var(--gold)) drop-shadow(0 4px 3px rgba(var(--shade), 0.35)); }
.node.boss .num { background: var(--gold); color: var(--gold-text); }
.node.current::before {
  content: '';
  position: absolute; inset: -8px;
  border-radius: 50%;
  border: 4px solid var(--edge);
  animation: ring 1.4s ease-out infinite;
}
@keyframes ring { from { transform: scale(0.85); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }

/* --------------------------------------------------------------- themes */

#themes, #shop { display: flex; flex-direction: column; padding-bottom: 0; }
#title { gap: 22px; }
.theme-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -16px;
  padding: 6px 16px calc(var(--safe-b) + 24px);
  display: flex; flex-direction: column; gap: 18px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.theme-card {
  width: 100%; max-width: 460px; margin: 0 auto;
  flex-shrink: 0; /* overflow: hidden would otherwise let the list squash cards instead of scrolling */
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  border: 3px solid var(--edge);
  border-radius: 22px;
  box-shadow: 0 5px 0 var(--card-drop), 0 10px 20px rgba(var(--shade), 0.25);
  overflow: hidden;
}
.theme-card canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; max-width: 100%; }
.theme-card.locked canvas { filter: grayscale(0.7) brightness(0.85); }
.theme-info { display: flex; align-items: center; gap: 12px; padding: 10px 14px 14px; }
.theme-info .txt { flex: 1; min-width: 0; }
.theme-info h2 { margin: 0; font-size: 21px; line-height: 1.15; }
.theme-info p { margin: 3px 0 0; font-size: 14px; line-height: 1.3; color: var(--ink-soft); }
.theme-state { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 16px; color: var(--good); white-space: nowrap; }
.theme-state svg { width: 20px; height: 20px; }
.theme-state.locked { color: var(--locked-icon); }
.theme-state.locked svg { fill: var(--locked-icon); }

/* ---------------------------------------------------------------- modal */

#modal {
  position: fixed; inset: 0;
  z-index: 10;
  display: grid; place-items: center;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
  background: var(--backdrop);
  animation: fade 0.2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.panel {
  position: relative;
  width: min(100%, 360px);
  padding: 44px 20px 22px;
  border-radius: 28px;
  border: 4px solid var(--edge);
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  box-shadow: 0 8px 0 var(--card-drop), 0 20px 40px var(--panel-shadow);
  text-align: center;
  animation: pop-in 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes pop-in { from { transform: scale(0.6); opacity: 0; } }
.ribbon {
  position: absolute;
  left: 50%; top: -22px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 8px 28px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--ribbon-top), var(--rose) 50%, var(--rose-deep));
  border: 3px solid var(--edge);
  box-shadow: 0 4px 0 var(--rose-drop);
  color: var(--on-accent);
  font-size: 24px; font-weight: 700;
  text-shadow: 0 2px 0 var(--ribbon-shadow);
}
.panel h2 { margin: 0 0 6px; font-size: 22px; }
.panel p { margin: 6px 0; font-size: 17px; color: var(--ink-soft); text-wrap: balance; }
.panel .big-goals { display: flex; justify-content: center; gap: 14px; margin: 10px 0 8px; flex-wrap: wrap; }
.panel .big-goals .goal-item { font-size: 22px; }
.panel .big-goals img { width: 52px; height: 52px; }
.panel .buttons { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.panel .big-btn { min-width: 0; padding-left: 22px; padding-right: 22px; }
.panel .toggles { margin-top: 10px; }
.result-stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 4px 0 6px; }
.result-stars svg { width: 64px; height: 64px; fill: var(--result-star-off); }
.result-stars svg:nth-child(2) { width: 80px; height: 80px; }
.result-stars svg.on { fill: var(--star); filter: drop-shadow(0 3px 0 var(--star-deep)); animation: star-in 0.45s cubic-bezier(0.2, 1.8, 0.4, 1); }
@keyframes star-in { from { transform: scale(0) rotate(-40deg); } }
.result-score { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0 0; color: var(--ink); }
.best { font-size: 15px; color: var(--ink-soft); }
.new-best { color: var(--good); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
@media (max-height: 600px) {
  .card { min-height: 60px; padding: 4px 8px 6px; }
  .moves { width: 66px; height: 66px; }
  .moves #moves { font-size: 26px; }
}

/* A flash of light over the whole screen (the HUD too), for packs with fx.screen. */
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 1000; mix-blend-mode: screen; }

/* ------------------------------------------------------------ rewards */

.title-row { display: flex; gap: 12px; justify-content: center; width: min(92vw, 380px); }
.title-links { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.title-row .big-btn { flex: 1 1 0; min-width: 0; padding: 9px 8px 11px; font-size: clamp(16px, 5vw, 21px); line-height: 1.1; }
@media (max-height: 640px) {
  #title { gap: 10px; }
  #title #logo { width: min(92vw, 440px, 42vh); }
  #title #btn-play { padding-top: 10px; padding-bottom: 12px; }
}
@media (max-height: 600px) {
  #title { gap: 8px; }
  #title .title-row .big-btn { padding-top: 7px; padding-bottom: 9px; }
}
.map-bar { display: flex; align-items: center; gap: 10px; padding: 0 2px 8px; }
.map-streak, .map-chest {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: rgba(var(--shade), 0.28);
  color: var(--on-accent); font-weight: 700; font-size: 16px;
  text-shadow: 0 1px 0 var(--title-shadow);
}
.map-streak small, .map-chest small { font-size: 12px; font-weight: 600; opacity: 0.85; }
.map-streak svg, .map-chest svg { width: 22px; height: 22px; fill: var(--on-accent); flex: none; }
.map-streak.hot svg { fill: #ff8a2a; filter: drop-shadow(0 0 4px #ff6a00); animation: flicker 0.9s ease-in-out infinite alternate; }
@keyframes flicker { from { transform: scale(1) rotate(-3deg); } to { transform: scale(1.12) rotate(3deg); } }
.map-chest { margin-left: auto; border: 0; font: inherit; font-weight: 700; }
.map-chest svg { fill: var(--gold); }
.map-chest.ready { background: linear-gradient(180deg, var(--gold-top), var(--gold-bottom)); color: var(--gold-text); text-shadow: none; animation: glow 1.1s ease-in-out infinite; }
.map-chest.ready svg { fill: var(--gold-deep); }
.streak-note {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px;
  margin: 10px 0 0; font-size: 14px; font-weight: 700; color: var(--ink);
}
.streak-note svg { width: 20px; height: 20px; fill: #ff7a1a; }
.streak-gift { width: 30px; height: 30px; }
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 6px; }
.day {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 72px; padding: 6px 2px;
  border-radius: 14px; border: 3px solid transparent;
  background: var(--toggle-bg); color: var(--ink); font-weight: 700; font-size: 14px;
}
.day small { font-size: 11px; opacity: 0.75; }
.day:last-child { grid-column: span 2; }
.day.done { opacity: 0.45; }
.day.today { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-bottom); animation: glow 1.1s ease-in-out infinite; }
.rw { display: inline-flex; align-items: center; gap: 1px; margin: 0 3px; font-weight: 700; color: var(--ink); }
.rw img:not(.coin) { width: 28px; height: 28px; }
.rewards { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 8px 0 4px; font-size: 20px; }
.rewards .rw img:not(.coin) { width: 40px; height: 40px; }
.chest-meter, .ach-bar { height: 10px; border-radius: 6px; background: var(--meter-track); overflow: hidden; }
.chest-meter { margin: 10px 0; }
.chest-meter i, .ach-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--meter-a), var(--meter-b)); }
.panel.tall { max-height: 88vh; display: flex; flex-direction: column; }
.ach-list { list-style: none; margin: 8px -6px 0; padding: 0 6px; overflow-y: auto; text-align: left; flex: 1; min-height: 0; }
.ach-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(var(--shade), 0.12); }
.ach-list li:not(.done) { opacity: 0.8; }
.ach-icon svg { width: 28px; height: 28px; fill: var(--ink-soft); }
.ach-list li.done .ach-icon svg { fill: var(--gold); filter: drop-shadow(0 0 4px var(--gold)); }
.ach-icon .medal { width: 34px; height: 42px; display: block; }
.ach-list li.done .ach-icon .medal { filter: drop-shadow(0 1px 3px rgba(var(--shade), 0.35)); }
.ach-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.ach-txt b { font-size: 15px; }
.ach-txt small { font-size: 12px; color: var(--ink-soft); }
.ach-bar { height: 6px; margin-top: 3px; }
.ach-pay { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.lb-box { margin: 6px 0 2px; }
.lb-box .buttons { margin-top: 6px; }
.lb { list-style: none; margin: 6px 0 4px; padding: 0; text-align: left; }
.lb li { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 10px; color: var(--ink); font-size: 15px; }
.lb li:nth-child(odd) { background: rgba(var(--shade), 0.07); }
.lb li.me { background: var(--gold); color: var(--gold-text); font-weight: 700; }
.lb li b { width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.lb li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb li em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
#panel .link-btn { color: var(--ink); text-shadow: none; text-decoration: underline; font-size: 13px; padding: 0 4px; }
#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); z-index: 900;
  pointer-events: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px;
  border: 3px solid var(--gold);
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  box-shadow: 0 4px 0 var(--card-drop), 0 8px 18px var(--panel-shadow);
  color: var(--ink); font-weight: 700; font-size: 15px;
  pointer-events: none; transform: translateX(-50%);
}
#toast.in { animation: toast 3.2s ease both; }
@keyframes toast { 0% { transform: translate(-50%, -140%); } 10%, 88% { transform: translate(-50%, 0); } 100% { transform: translate(-50%, -140%); } }
#toast svg { width: 24px; height: 24px; fill: var(--star); }
#toast span { display: flex; align-items: center; color: var(--ink-soft); }

/* ------------------------------------------------------------ celebrations */
/* A new achievement's medal and a star chest opening take the whole screen, over any
   dialog. Parts of it wait (.later) until js/game.js reveals them in turn (.pop). */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
#celebrate {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 16px);
  background: radial-gradient(circle at 50% 34%, rgba(52, 26, 82, 0.88), rgba(6, 3, 14, 0.97) 72%);
  overflow: hidden;
  animation: fade 0.25s ease-out;
}
#cel-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.cel { position: relative; z-index: 1; width: min(100%, 380px); display: flex; flex-direction: column; align-items: center; text-align: center; color: #fff; transition: opacity 0.25s, transform 0.25s; }
.cel.leaving { opacity: 0; transform: scale(0.94); }
.cel-stage { position: relative; width: min(62vw, 250px, 36vh); aspect-ratio: 1; display: grid; place-items: center; }
.cel-rays {
  position: absolute; left: 50%; top: 50%; width: 270%; aspect-ratio: 1;
  background: repeating-conic-gradient(from 0deg, rgba(255, 236, 160, 0.3) 0deg 8deg, rgba(255, 236, 160, 0) 8deg 22.5deg);
  -webkit-mask-image: radial-gradient(circle, #000 10%, transparent 60%); mask-image: radial-gradient(circle, #000 10%, transparent 60%);
  transform: translate(-50%, -50%); opacity: 0; transition: opacity 0.6s;
  animation: cel-spin 16s linear infinite; pointer-events: none;
}
@keyframes cel-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.cel-glow { position: absolute; inset: -12%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 232, 150, 0.8), rgba(255, 200, 70, 0.28) 42%, transparent 68%);
  opacity: 0; transform: scale(0.5); transition: opacity 0.45s, transform 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
#celebrate.lit .cel-rays { opacity: 1; }
#celebrate.lit .cel-glow { opacity: 1; transform: scale(1); }
.cel-art { position: relative; width: 80%; height: 80%; display: grid; place-items: center; transition: transform 2.2s cubic-bezier(0.5, 0, 0.9, 0.6); }
.cel-art.swell { transform: scale(1.14); }
.cel-art > svg { width: 100%; height: 100%; overflow: visible; }
.cel-kicker { margin-top: 4px; font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55); }
.cel-name { margin: 2px 0 0; font-family: var(--font-display); font-size: clamp(28px, 9vw, 40px); line-height: 1.1; color: #fff; text-wrap: balance;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), 0 0 20px rgba(255, 220, 120, 0.55); }
.cel-text { margin: 6px 0 0; font-size: 17px; line-height: 1.3; color: rgba(255, 255, 255, 0.88); text-wrap: balance; }
.cel-rewards { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 0; min-height: 48px; font-size: 28px; font-weight: 700; }
.cel-rewards .rw { color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55); gap: 3px; }
.cel-rewards .rw img { width: 48px; height: 48px; }
.cel-rewards .rw img.coin { width: 36px; height: 36px; }
.cel-rewards .rw b { font-variant-numeric: tabular-nums; }
.cel-note { margin: 6px 0 0; min-height: 1.3em; font-size: 14px; color: rgba(255, 255, 255, 0.72); }
#cel-go { margin-top: 16px; }
.cel .later { visibility: hidden; }
.cel .pop { animation: cel-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes cel-pop { from { transform: scale(0.3); opacity: 0; } }

/* Medals: the tier's metal, the pack's ribbon, an emblem for what it's for. */
.medal .rib.a { fill: var(--rose); }
.medal .rib.b { fill: var(--rose-deep); }
.medal .rim { stroke: rgba(0, 0, 0, 0.28); stroke-width: 1.5; }
.medal .edge { fill: none; stroke-width: 2.4; stroke-dasharray: 1.6 3.2; }
.medal .emblem.hi { fill: rgba(255, 255, 255, 0.6); }
.medal .glint { fill: rgba(255, 255, 255, 0.45); }
.medal .sweep { fill: rgba(255, 255, 255, 0.6); transform: translateX(-20px); }
.medal.gold .rim { fill: url(#g-gold); } .medal.gold .face { fill: url(#g-gold-face); } .medal.gold .emblem { fill: #9a5c00; } .medal.gold .edge { stroke: #b87400; }
.medal.silver .rim { fill: url(#g-silver); } .medal.silver .face { fill: url(#g-silver-face); } .medal.silver .emblem { fill: #566176; } .medal.silver .edge { stroke: #7d889c; }
.medal.bronze .rim { fill: url(#g-bronze); } .medal.bronze .face { fill: url(#g-bronze-face); } .medal.bronze .emblem { fill: #5e2a08; } .medal.bronze .edge { stroke: #874416; }
.medal.off { filter: grayscale(1); opacity: 0.4; }
.cel-art .drop { animation: cel-drop 0.62s cubic-bezier(0.3, 1.2, 0.5, 1) both; }
@keyframes cel-drop {
  0% { transform: translateY(-80vh) rotate(-30deg) scale(0.7); }
  70% { transform: translateY(5%) rotate(4deg) scale(1.08, 0.94); }
  86% { transform: translateY(-3%) rotate(-2deg) scale(0.98, 1.02); }
  100% { transform: none; }
}
.cel-art .medal.landed, .cel-art .prize.landed, .cel-art .road-star.landed { animation: cel-float 3.2s ease-in-out infinite; }
/* The Star Road's milestone: a big gold star with its number on it. */
.cel-art .road-star { position: relative; width: 82%; height: 82%; display: grid; place-items: center; }
.cel-art .road-star svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: var(--star); filter: drop-shadow(0 4px 0 var(--star-deep)) drop-shadow(0 8px 22px rgba(255, 220, 120, 0.6)); }
.cel-art .road-star b { position: relative; top: 6%; font-size: clamp(30px, 11vw, 52px); color: #6a3a00; text-shadow: 0 2px 0 rgba(255, 245, 200, 0.7); }
.cel-art .prize { width: 82%; height: 82%; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(255, 220, 120, 0.55)); }
.spare-note svg { fill: var(--star); }
.star-rule { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; margin: 8px 0 2px; font-size: 14px; }
.star-rule p { flex-basis: 100%; margin: 0 0 2px; }
.star-rule > span { white-space: nowrap; padding: 2px 8px; border-radius: 99px; background: rgba(var(--shade), 0.08); }
.rule-stars { display: inline-flex; vertical-align: -2px; margin-right: 2px; }
.rule-stars svg { width: 14px; height: 14px; fill: var(--star); filter: drop-shadow(0 1px 0 var(--star-deep)); }
.star-hint { margin: 6px 0 0; }
@keyframes cel-float { 50% { transform: translateY(-4%) rotate(2deg); } }
.cel-art .medal.landed .sweep { animation: cel-sweep 3.2s ease-in-out infinite; }
@keyframes cel-sweep { 0% { transform: translateX(-20px); } 35%, 100% { transform: translateX(150px); } }

/* The star chest, in the pack's colours; its lid lifts off when it bursts open. */
#g-chest .c1 { stop-color: var(--rose); }
#g-chest .c2 { stop-color: var(--rose-deep); }
.big-chest .wood { fill: url(#g-chest); stroke: rgba(0, 0, 0, 0.3); stroke-width: 2; }
.big-chest .plank { fill: rgba(0, 0, 0, 0.18); }
.big-chest .band, .big-chest .lock { fill: url(#g-gold); stroke: rgba(120, 60, 0, 0.45); stroke-width: 1.2; }
.big-chest .rivet { fill: #fff3b0; }
.big-chest .lock-star { fill: #fff; }
.big-chest .lid-hi { stroke: rgba(255, 255, 255, 0.35); stroke-width: 4; stroke-linecap: round; }
.big-chest .chest-shade { fill: rgba(0, 0, 0, 0.35); }
.big-chest .chest-inner { fill: url(#g-chest-glow); opacity: 0; transition: opacity 0.2s; }
.big-chest .chest-beam { fill: url(#g-beam); opacity: 0; transform-origin: 100px 96px; transform: scaleY(0); transition: transform 0.5s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.3s; }
.big-chest .chest-lid { transform-origin: 100px 30px; transition: transform 0.55s cubic-bezier(0.2, 1.7, 0.4, 1); }
.big-chest.idle { animation: chest-idle 1.6s ease-in-out infinite; transform-origin: 50% 95%; }
@keyframes chest-idle { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.big-chest.shake1 { --amp: 2.5; animation: chest-shake 0.22s linear infinite; }
.big-chest.shake2 { --amp: 5; animation: chest-shake 0.14s linear infinite; }
.big-chest.shake3 { --amp: 9; animation: chest-shake 0.08s linear infinite; }
@keyframes chest-shake {
  25% { transform: translate(calc(var(--amp) * -1px), calc(var(--amp) * -0.5px)) rotate(calc(var(--amp) * -0.5deg)); }
  75% { transform: translate(calc(var(--amp) * 1px), calc(var(--amp) * -0.3px)) rotate(calc(var(--amp) * 0.5deg)); }
}
.big-chest.open .chest-lid { transform: translate(6px, -46px) rotate(-8deg) scaleY(0.62); }
.big-chest.open .chest-inner { opacity: 1; }
.big-chest.open .chest-beam { opacity: 1; transform: scaleY(1); }

/* ------------------------------------------------------------------ shop */
.shop-list {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  margin: 0 -16px; padding: 6px 16px calc(var(--safe-b) + 24px);
  display: flex; flex-direction: column; gap: 16px;
  -webkit-overflow-scrolling: touch; touch-action: pan-y;
}
.shop-card {
  width: 100%; max-width: 460px; margin: 0 auto; flex-shrink: 0;
  background: linear-gradient(180deg, var(--cream), var(--cream-2));
  border: 3px solid var(--edge); border-radius: 22px;
  box-shadow: 0 5px 0 var(--card-drop), 0 10px 20px rgba(var(--shade), 0.25);
  padding: 12px 14px 14px; text-align: center;
}
.shop-card h2 { margin: 0 0 6px; font-size: 22px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.shop-card h2 svg { width: 24px; height: 24px; fill: var(--star); filter: drop-shadow(0 1px 0 var(--star-deep)); }
.shop-card .small { margin: 4px 0 8px; }
.shop-card > .big-btn { margin: 8px auto 4px; animation: glow 1.1s ease-in-out infinite; }
.shop-items, .road-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 16px; background: rgba(var(--shade), 0.06); text-align: left; }
.shop-item > img { width: 44px; height: 44px; flex: none; object-fit: contain; }
.shop-item .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.shop-item .txt b { font-size: 17px; }
.shop-item .txt small { font-size: 12px; color: var(--ink-soft); line-height: 1.3; }
.shop-item.locked { opacity: 0.7; }
.buys { display: flex; flex-direction: column; gap: 6px; flex: none; }
.buy {
  display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 96px;
  padding: 6px 10px; border-radius: 999px; border: 3px solid var(--edge); font: inherit; font-weight: 700; font-size: 15px;
  background: linear-gradient(180deg, var(--gold-top), var(--gold) 55%, var(--gold-bottom)); color: var(--gold-text);
  box-shadow: 0 3px 0 var(--gold-deep);
}
.buy img, .rw img.coin, .road-rw img { width: 20px; height: 20px; }
.buy.deal { background: linear-gradient(180deg, var(--pink-top), var(--pink-mid) 55%, var(--pink-bottom)); color: var(--on-accent); box-shadow: 0 3px 0 var(--rose-drop); text-shadow: 0 1px 0 var(--pink-shadow); }
.buy:active { transform: translateY(2px); box-shadow: none; }
.buy:disabled { filter: grayscale(1); opacity: 0.5; }
.buy.no { animation: shake 0.3s; }
.bundle-items, .road-rw { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.bundle-items .rw, .road-rw .rw { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 14px; }
.bundle-items img { width: 26px; height: 26px; }
.road-step { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 14px; background: rgba(var(--shade), 0.06); }
.road-step.done { opacity: 0.55; }
.road-step.ready { background: linear-gradient(180deg, var(--gold-top), var(--gold-bottom)); color: var(--gold-text); }
.road-more { padding: 4px 8px; font-weight: 700; font-size: 14px; color: var(--gold-text); }
.road-stars { display: inline-flex; align-items: center; gap: 2px; min-width: 58px; font-weight: 700; font-size: 17px; }
.road-stars svg { width: 20px; height: 20px; fill: var(--star); filter: drop-shadow(0 1px 0 var(--star-deep)); }
.road-rw { flex: 1; }
.road-state { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 14px; color: var(--ink-soft); flex: none; }
.road-state svg { width: 16px; height: 16px; fill: currentColor; }
.road-state.done svg { width: 22px; height: 22px; color: #2eaa4a; }
.road-state.ready { color: var(--gold-text); }
/* Shop buttons: the title's, and the map's coins; a badge when the Star Road pays. */
.shop-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.shop-btn img { width: 26px; height: 26px; }
button.coins { border: 0; background: rgba(var(--shade), 0.28); border-radius: 999px; padding: 4px 10px 4px 6px; font: inherit; font-weight: 700; font-size: 18px; }
button.coins .plus { font-style: normal; display: grid; place-items: center; width: 20px; height: 20px; margin-left: 2px; border-radius: 50%; background: var(--gold); color: var(--gold-text); font-size: 16px; line-height: 1; text-shadow: none; }
.badge { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: #ff2e4d; color: #fff; font-size: 13px; line-height: 22px; text-shadow: none; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); animation: glow 1.1s ease-in-out infinite; }

/* Each theme's own progress on the Themes screen (levels are won separately in each). */
.theme-progress { display: flex; align-items: center; gap: 3px; margin: 4px 0 0; font-size: 13px; font-weight: 700; }
.theme-progress svg { width: 14px; height: 14px; fill: var(--star); filter: drop-shadow(0 1px 0 var(--star-deep)); }
