/* ——— Mathy: the palace look is the default (css/palace.css and friends);
   css/town.css and css/open.css are the other looks ——— */

:root {
  color-scheme: light;
  --ink: #4a2a5c;
  --ink-soft: #82639a;
  --outline: #5b3a6e;
  --pink: #ff5fa2;
  --pink-deep: #e0408a;
  --pink-soft: #ffe0ee;
  --lilac: #a07cf5;
  --lilac-deep: #7d58d6;
  --lilac-soft: #efe6ff;
  --gold: #ffc53d;
  --gold-deep: #e09a00;
  --mint: #3ccaa2;
  --mint-deep: #22a37f;
  --sky: #6fbfff;
  --card: rgba(255, 255, 255, 0.92);
  --shadow: 0 12px 30px rgba(150, 70, 150, 0.16);
  --radius: 28px;
  --bounce: cubic-bezier(0.3, 1.6, 0.5, 1);
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: #fbeaf6;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid var(--lilac); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

/* ——— Sky backdrop ——— */

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(180deg, #ffe4f2 0%, #f6e8ff 45%, #e3f2ff 100%);
}
.sky-rainbow {
  position: absolute;
  width: 80vmax;
  height: 80vmax;
  right: -32vmax;
  top: -36vmax;
  border-radius: 50%;
  background: radial-gradient(circle,
    transparent 55%,
    rgba(255, 110, 160, 0.22) 55.5% 58.5%,
    rgba(255, 170, 90, 0.2) 58.5% 61.5%,
    rgba(255, 220, 100, 0.22) 61.5% 64.5%,
    rgba(110, 215, 165, 0.2) 64.5% 67.5%,
    rgba(110, 180, 255, 0.2) 67.5% 70.5%,
    rgba(170, 130, 255, 0.2) 70.5% 73.5%,
    transparent 74%);
}
.cloud {
  position: absolute;
  left: -220px;
  width: var(--w);
  opacity: var(--o, 0.95);
  filter: drop-shadow(0 6px 0 rgba(210, 170, 225, 0.35));
  animation: cloud-drift var(--d) linear var(--delay) infinite;
}
.cloud svg { display: block; width: 100%; }
.cloud path { fill: #fff; }
.c0 { top: 7%; --w: 190px; --d: 75s; --delay: -12s; }
.c1 { top: 24%; --w: 120px; --d: 95s; --delay: -55s; --o: 0.85; }
.c2 { top: 50%; --w: 160px; --d: 85s; --delay: -32s; --o: 0.7; }
.c3 { top: 70%; --w: 105px; --d: 110s; --delay: -80s; --o: 0.6; }
.hills { position: absolute; left: 0; bottom: 0; width: 100%; height: 20vh; }
.floater {
  position: absolute;
  bottom: -40px;
  font-size: var(--size);
  opacity: 0.4;
  animation: float-up var(--dur) linear var(--delay) infinite;
}

/* ——— Layout ——— */

/* The top bar spans the whole window on every screen, so Back is always in the
   top-left corner and the gems, music, and sound in the top-right, whether the
   page under it is a centered column or a full-screen world. Screens without
   the bar (a round, sign-up) put their own Back in the same corner (.corner-back). */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}
.spacer { flex: 1; }
.screen {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px calc(40px + env(safe-area-inset-bottom));
}
.view { animation: view-in 0.4s var(--bounce); }

.round-btn {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--card);
  font-size: 26px;
  box-shadow: 0 5px 0 #eed3e6, var(--shadow);
  transition: transform 0.1s;
}
.round-btn:active { transform: translateY(3px) scale(0.95); }
.round-btn.off { opacity: 0.45; filter: grayscale(1); }
.back-pill {
  flex-shrink: 0;
  height: 54px;
  padding: 0 20px 0 14px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: var(--pink);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  box-shadow: 0 5px 0 var(--pink-deep), var(--shadow);
  transition: transform 0.1s;
}
.back-pill:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--pink-deep); }
.corner-back {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 20;
}
.view:has(> .corner-back) { padding-top: 64px; }
.player-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 54px;
  padding: 0 18px 0 8px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: var(--card);
  box-shadow: 0 5px 0 #eed3e6, var(--shadow);
  font-size: 20px;
  font-weight: 600;
}
.pp-avatar { font-size: 30px; }
.pp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }
/* Offline / back online (js/netstatus.js): beside the gems, only when it matters. */
.net-pill {
  margin-right: 8px; padding: 8px 14px; border-radius: 999px; border: 3px solid #fff;
  background: #fff1c2; color: #8a5a00; font: inherit; font-size: 16px; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap;
}
.net-pill[data-state="back"] { background: #dff7e3; color: #1f7a4a; }
.net-pill[hidden] { display: none; }
@media (max-width: 520px) { .net-pill { padding: 8px 10px; } .net-pill .net-text { display: none; } }

.gem-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 54px;
  padding: 0 18px 0 12px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: linear-gradient(180deg, #fff6d6, #ffdf80);
  box-shadow: 0 5px 0 #f2c14a, var(--shadow);
  font-size: 22px;
  font-weight: 700;
  color: #8a5a00;
}
.gem-icon { display: inline-block; animation: gem-shine 3s ease-in-out infinite; }
.gem-pill.bump { animation: bump 0.5s var(--bounce); }

/* ——— Buttons ——— */

.btn {
  --b: var(--pink);
  --d: var(--pink-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  background: var(--b);
  box-shadow: 0 6px 0 var(--d), 0 12px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--d), 0 6px 12px rgba(0, 0, 0, 0.1); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-gold { --b: var(--gold); --d: var(--gold-deep); color: #6b4300; }
.btn-lilac { --b: var(--lilac); --d: var(--lilac-deep); }
.btn-mint { --b: var(--mint); --d: var(--mint-deep); }
.btn-white { --b: #fff; --d: #e8d0e4; color: var(--ink); }
.btn-danger { --b: #ff6b6b; --d: #d94848; }
.btn-big { font-size: 26px; padding: 16px 34px; }
.link-btn {
  display: block;
  margin: 26px auto 0;
  background: none;
  border: none;
  color: var(--ink-soft);
  text-decoration: underline;
  font-size: 17px;
}

/* ——— Mascot ——— */

.mascot {
  position: relative;
  display: inline-block;
  width: var(--size, 140px);
  cursor: pointer;
  transform-origin: 50% 100%;
}
.mascot-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  transform-origin: 50% 100%;
  animation: m-bob 2.6s ease-in-out infinite;
}
.mascot .m-head { transform-origin: 100px 150px; animation: m-tilt 4.2s ease-in-out infinite; }
.mascot .m-tail { transform-origin: 150px 178px; animation: m-wag 1.3s ease-in-out infinite; }
.mascot .m-eye-open { transform-box: fill-box; transform-origin: center; animation: m-blink 4.8s infinite; }
.mascot .m-eye-joy,
.mascot .m-eye-star,
.mascot .m-mouth,
.mascot .m-sparkles { display: none; }
.mascot[data-mood='happy'] .m-mouth-smile,
.mascot[data-mood='oops'] .m-mouth-soft,
.mascot[data-mood='think'] .m-mouth-o,
.mascot[data-mood='joy'] .m-mouth-open,
.mascot[data-mood='wow'] .m-mouth-open { display: inline; }
.mascot[data-mood='joy'] .m-eye-open,
.mascot[data-mood='wow'] .m-eye-open { display: none; }
.mascot[data-mood='joy'] .m-eye-joy,
.mascot[data-mood='wow'] .m-eye-star,
.mascot[data-mood='joy'] .m-sparkles,
.mascot[data-mood='wow'] .m-sparkles { display: inline; }
.m-sparkles path { transform-box: fill-box; transform-origin: center; animation: twinkle 0.7s ease-in-out infinite alternate; }
.m-sparkles path:nth-child(2) { animation-delay: 0.2s; }
.m-sparkles path:nth-child(3) { animation-delay: 0.35s; }
.m-sparkles path:nth-child(4) { animation-delay: 0.5s; }
.mascot[data-mood='oops'] .m-head { animation: m-oops 1.2s ease-in-out; }
.mascot.jump { animation: m-jump 0.75s var(--bounce); }
.mascot.wiggle { animation: m-wiggle 0.6s ease-in-out; }
.mascot.spin { animation: m-spin 0.9s ease-in-out; }
.mascot.dance { animation: m-dance 1s ease-in-out infinite; }

.mascot-bubble {
  position: absolute;
  z-index: 5;
  bottom: 90%;
  left: 62%;
  width: max-content;
  max-width: min(250px, 56vw);
  padding: 10px 16px;
  border-radius: 22px;
  border: 3px solid var(--outline);
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 5px 0 rgba(91, 58, 110, 0.18);
  pointer-events: none;
  transform-origin: 10% 100%;
}
.mascot-bubble::after {
  content: '';
  position: absolute;
  left: 16px;
  bottom: -11px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-right: 3px solid var(--outline);
  border-bottom: 3px solid var(--outline);
  transform: rotate(45deg);
}
.bubble-top .mascot-bubble { left: 50%; translate: -50% 0; bottom: 96%; transform-origin: 50% 100%; }
.bubble-top .mascot-bubble::after { left: calc(50% - 8px); }
.mascot-bubble.pop-in { animation: pop-in 0.4s var(--bounce); }

/* ——— Profiles ——— */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: calc(40px + env(safe-area-inset-top)) 0 14px;
  text-align: center;
}
.hero-mascot { margin-bottom: -6px; }
.hero-title {
  display: flex;
  gap: 2px;
  font-size: clamp(64px, 13vw, 110px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 2px;
}
.hero-title span {
  display: inline-block;
  text-shadow:
    0 5px 0 #fff, 5px 0 0 #fff, -5px 0 0 #fff, 0 -5px 0 #fff,
    4px 4px 0 #fff, -4px 4px 0 #fff, 4px -4px 0 #fff, -4px -4px 0 #fff,
    0 12px 0 rgba(110, 90, 150, 0.22);
  animation: letter-bounce 2.4s ease-in-out infinite;
}
/* A rainbow, red to blue: the logo is the same in the link preview card. */
.hero-title span:nth-child(1) { color: #f25a4a; animation-delay: 0s; }
.hero-title span:nth-child(2) { color: #ff9a3d; animation-delay: 0.12s; }
.hero-title span:nth-child(3) { color: #f5b800; animation-delay: 0.24s; }
.hero-title span:nth-child(4) { color: #2fc296; animation-delay: 0.36s; }
.hero-title span:nth-child(5) { color: #3d8bff; animation-delay: 0.48s; }
.hero-sub { margin-top: 10px; font-size: 22px; font-weight: 500; color: var(--ink-soft); }
.section-title { margin: 14px 0 20px; text-align: center; font-size: 28px; }

.profile-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.profile-card {
  position: relative;
  width: 190px;
  padding: 22px 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-radius: 32px;
  border: 4px solid #fff;
  background: var(--card);
  box-shadow: 0 7px 0 #f0d3e5, var(--shadow);
  transition: transform 0.15s var(--bounce);
  animation: pop-in 0.5s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 80ms);
}
.profile-card:hover { transform: translateY(-5px) rotate(-1.5deg); }
.profile-card:active { transform: scale(0.96); }
.profile-avatar { font-size: 76px; line-height: 1.1; }
.profile-name { max-width: 100%; font-size: 26px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-gems { padding: 2px 12px; border-radius: 999px; background: #fff4cc; color: #a46d00; font-size: 18px; font-weight: 600; }
.profile-card.add { border: 4px dashed #d9c3f3; background: rgba(255, 255, 255, 0.55); box-shadow: none; }
.profile-card.add .profile-avatar { color: var(--pink); font-weight: 400; }
.profile-card.managing { animation: wiggle 0.5s ease-in-out infinite; }
.profile-delete {
  position: absolute;
  top: -10px;
  right: -10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #ff6b6b;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 3px 0 #d94848;
}

.panel {
  padding: 24px;
  border-radius: var(--radius);
  border: 4px solid #fff;
  background: var(--card);
  box-shadow: var(--shadow);
}
.panel.narrow { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.new-mascot { display: flex; justify-content: center; margin-top: -10px; }
.panel-title { text-align: center; font-size: 34px; }
.field-label { font-size: 20px; font-weight: 600; color: var(--ink-soft); }
.name-input {
  width: 100%;
  padding: 14px 20px;
  border-radius: 22px;
  border: 4px solid var(--pink-soft);
  outline: none;
  background: #fff;
  font: inherit;
  font-size: 30px;
  font-weight: 600;
  color: var(--ink);
}
.name-input:focus { border-color: var(--pink); box-shadow: 0 0 0 6px rgba(255, 95, 162, 0.15); }
.avatar-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 8px; }
.avatar-choice {
  aspect-ratio: 1;
  padding: 0;
  border-radius: 18px;
  border: 4px solid transparent;
  background: #fff;
  box-shadow: 0 4px 0 #f0dcea;
  font-size: clamp(28px, 3.2vw, 36px);
  transition: transform 0.15s var(--bounce);
}
.avatar-choice.chosen { border-color: var(--pink); background: var(--pink-soft); transform: scale(1.1) rotate(-4deg); }

/* ——— Home ——— */

.home-hero { display: flex; align-items: flex-end; gap: 6px; margin: 30px 0 22px; }
.home-mascot { flex-shrink: 0; }
.greeting { padding-bottom: 14px; }
.greeting h1 { font-size: clamp(34px, 6vw, 52px); }
.greeting p { margin-top: 4px; font-size: 20px; color: var(--ink-soft); }
.wave { display: inline-block; transform-origin: 70% 80%; animation: wave 2s ease-in-out infinite; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.tile {
  --d: #e0408a;
  position: relative;
  overflow: hidden;
  min-height: 190px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  text-align: left;
  border: 5px solid rgba(255, 255, 255, 0.95);
  border-radius: 36px;
  color: #fff;
  box-shadow: 0 9px 0 var(--d), var(--shadow);
  transition: transform 0.12s;
  animation: pop-in 0.55s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 90ms + 100ms);
}
.tile:hover .tile-icon { animation: icon-wiggle 0.6s ease-in-out; }
.tile:active { transform: translateY(6px); box-shadow: 0 3px 0 var(--d), var(--shadow); }
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.55) 0 6px, transparent 7px),
    radial-gradient(circle at 26% 34%, rgba(255, 255, 255, 0.35) 0 3px, transparent 4px),
    radial-gradient(circle at 48% 12%, rgba(255, 255, 255, 0.4) 0 4px, transparent 5px),
    radial-gradient(ellipse at 80% 120%, rgba(255, 255, 255, 0.25) 0 40%, transparent 41%);
}
.tile-ribbon {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--pink-deep);
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
  animation: ribbon-bob 1.4s ease-in-out infinite;
}
.first-buy {
  margin: 0 0 12px;
  padding: 12px 18px;
  border-radius: 20px;
  border: 3px solid #fff;
  background: linear-gradient(90deg, #fff6d6, #ffe7f2);
  font-size: 18px;
  box-shadow: var(--shadow);
  animation: pop-in 0.5s var(--bounce);
}
.tile-icon {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 76px;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.15));
  animation: float-icon 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.7s);
}
.tile-title { position: relative; font-size: 32px; font-weight: 700; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.1); }
.tile-sub { position: relative; font-size: 18px; font-weight: 500; }
.tile-pink { background: linear-gradient(140deg, #ff9fcb, #ff5fa2); --d: #e0408a; }
.tile-lilac { background: linear-gradient(140deg, #c4a8ff, #8f68f0); --d: #6f4bd0; }
.tile-gold { background: linear-gradient(140deg, #ffe07a, #ffb52e); --d: #d98f00; color: #6b4300; }
.tile-mint { background: linear-gradient(140deg, #8be8cb, #36c49c); --d: #1f9c78; }
.garden-banner {
  width: 100%;
  margin-top: 20px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  border-radius: 28px;
  border: 4px solid #fff;
  background: linear-gradient(90deg, #f0fff8, #fff0f7);
  box-shadow: 0 6px 0 #d8eee3, var(--shadow);
  font-size: 22px;
  animation: pop-in 0.55s var(--bounce) 0.5s backwards;
}
.garden-banner small { font-size: 17px; color: var(--ink-soft); }
.garden-flowers { flex-shrink: 0; font-size: 34px; letter-spacing: -6px; white-space: nowrap; }
.garden-arrow { margin-left: auto; font-size: 40px; color: var(--pink); }

.help-pill {
  margin-top: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: var(--lilac-soft);
  color: var(--lilac-deep);
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 4px 0 #d9c8f7;
}
.help-pill:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9c8f7; }

/* ——— Tour ——— */

.view-tour { min-height: 100dvh; display: flex; }
.tour {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.tour-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.tour-top h1 { font-size: 30px; }
.tour-skip { margin: 0; }
.tour-art {
  position: relative;
  width: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  border-radius: 36px;
  border: 5px solid #fff;
  background: radial-gradient(circle at 50% 40%, #fff 0 30%, #ffeaf4 100%);
  box-shadow: 0 9px 0 #f2cfe2, var(--shadow);
  overflow: hidden;
}
.tour-art.enter > * { animation: pop-in 0.5s var(--bounce); }
.tour-talk { width: 100%; display: flex; align-items: flex-end; gap: 6px; }
.tour-mascot { flex-shrink: 0; }
.tour-text {
  position: relative;
  flex: 1;
  margin-bottom: 30px;
  padding: 16px 20px;
  border-radius: 26px;
  border: 3px solid var(--outline);
  background: #fff;
  font-size: clamp(19px, 3.6vw, 24px);
  font-weight: 600;
  line-height: 1.3;
  box-shadow: 0 5px 0 rgba(91, 58, 110, 0.18);
}
.tour-text::before {
  content: '';
  position: absolute;
  left: -12px;
  bottom: 22px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-left: 3px solid var(--outline);
  border-bottom: 3px solid var(--outline);
  transform: rotate(45deg);
}
.tour-dots { display: flex; gap: 10px; }
.tour-dots button { width: 14px; height: 14px; padding: 0; border: none; border-radius: 50%; background: #f0d6e6; cursor: pointer; transition: transform 0.2s; }
.tour-dots button.on { background: var(--pink); transform: scale(1.3); }
.tour-nav { width: 100%; display: flex; justify-content: space-between; align-items: center; }

.art-hello { position: relative; width: 240px; height: 220px; display: grid; place-items: center; }
.art-castle { font-size: 150px; animation: bob 3s ease-in-out infinite; }
.art-float { position: absolute; font-size: 36px; animation: float-icon 2.4s ease-in-out infinite; }
.art-float.f1 { top: 6px; left: 0; }
.art-float.f2 { top: 20px; right: 0; animation-delay: -0.6s; }
.art-float.f3 { bottom: 20px; left: 4px; animation-delay: -1.2s; }
.art-float.f4 { bottom: 6px; right: 10px; animation-delay: -1.8s; }

.art-earn { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px; }
.art-card {
  padding: 10px 26px;
  border-radius: 24px;
  border: 5px solid #ffd0e6;
  background: #fff;
  font-size: 54px;
  font-weight: 700;
  box-shadow: 0 6px 0 #f7bcd9;
}
.art-card i { font-style: normal; color: var(--pink); }
.art-answer { padding: 0 12px; border-radius: 14px; background: #e2fbf2; color: var(--mint-deep); }
.art-gems { display: flex; gap: 12px; font-size: 44px; }
.art-gems span { animation: gem-hop 1.2s ease-in-out infinite; }
.art-gems span:nth-child(2) { animation-delay: 0.15s; }
.art-gems span:nth-child(3) { animation-delay: 0.3s; }
.art-bonuses { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.art-bonuses span { padding: 5px 14px; border-radius: 999px; background: linear-gradient(180deg, #ffe58f, #ffc53d); color: #6b4300; font-weight: 700; font-size: 17px; }

.art-help { display: flex; align-items: center; gap: 18px; padding: 20px; }
.art-bulb { font-size: 80px; animation: pulse 1.2s ease-in-out infinite; }
.art-frame { width: min(340px, 60vw); }

.art-shop { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 20px; }
.art-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 5px 0 #efd9e8;
  animation: pop-in 0.5s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 0.12s);
}
.art-item span { font-size: clamp(40px, 9vw, 60px); }
.art-item b { font-size: 15px; color: #8a5a00; }

.art-room { position: relative; width: min(420px, 80vw); aspect-ratio: 4 / 3; border-radius: 22px; overflow: hidden; container-type: inline-size; }
.art-room .wall { position: absolute; inset: 0 0 30% 0; }
.art-room .floor { position: absolute; inset: 70% 0 0 0; }
.art-thing { position: absolute; font-size: 15cqw; transform: translate(-50%, -100%); }
.art-thing.t1 { left: 30%; top: 92%; font-size: 20cqw; }
.art-thing.t2 { left: 70%; top: 90%; animation: drag-demo 2.6s ease-in-out infinite; }
.art-thing.t3 { left: 50%; top: 40%; }
.art-finger { position: absolute; left: 72%; top: 80%; font-size: 10cqw; animation: drag-demo 2.6s ease-in-out infinite; }

.art-garden { display: flex; align-items: center; gap: 10px; font-size: clamp(48px, 11vw, 80px); }
.art-garden b { font-size: 36px; color: var(--pink); }
.art-garden span { animation: pop-in 0.5s var(--bounce) backwards; animation-delay: calc(var(--i) * 0.35s); }

.breakdown {
  width: min(380px, 100%);
  margin: 0;
  padding: 10px 18px;
  list-style: none;
  border-radius: 22px;
  border: 4px solid #fff;
  background: var(--card);
  box-shadow: var(--shadow);
}
.breakdown li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 19px;
  font-weight: 500;
  animation: pop-in 0.4s var(--bounce) backwards;
  animation-delay: calc(1s + var(--i) * 0.18s);
}
.breakdown li + li { border-top: 2px dashed #f2dfeb; }
.breakdown b { color: #a46d00; }

/* ——— Page heads & levels ——— */

.page-head { margin: 6px 0 22px; text-align: center; }
.page-head.left { text-align: left; margin: 0; }
.page-head h1 { font-size: clamp(32px, 6vw, 46px); }
.page-head p { margin-top: 4px; font-size: 19px; color: var(--ink-soft); }

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(250px, 30%), 1fr)); gap: 20px 18px; }
.level-card {
  position: relative;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  border-radius: 32px;
  border: 4px solid #fff;
  background: var(--lv-bg);
  box-shadow: 0 8px 0 var(--lv-d), var(--shadow);
  transition: transform 0.12s;
  animation: pop-in 0.5s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 70ms);
}
.level-card:hover .level-icon { animation: icon-wiggle 0.6s ease-in-out; }
.level-card:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--lv-d), var(--shadow); }
.lv-pink { --lv-bg: linear-gradient(170deg, #fff, #ffe0ee); --lv-d: #f4bcd6; }
.lv-peach { --lv-bg: linear-gradient(170deg, #fff, #ffe6d4); --lv-d: #f6c6a2; }
.lv-sky { --lv-bg: linear-gradient(170deg, #fff, #ddefff); --lv-d: #b2d6f6; }
.lv-mint { --lv-bg: linear-gradient(170deg, #fff, #dcf8ee); --lv-d: #a8e4cf; }
.lv-lilac { --lv-bg: linear-gradient(170deg, #fff, #ece2ff); --lv-d: #cdb9f6; }
.lv-gold { --lv-bg: linear-gradient(170deg, #fff, #fff0c2); --lv-d: #f2d27a; }
.level-icon { font-size: 58px; line-height: 1.1; }
.level-name { font-size: 25px; font-weight: 700; }
.level-blurb { font-size: 17px; color: var(--ink-soft); }
.level-example {
  margin: 4px 0;
  padding: 4px 18px;
  border-radius: 16px;
  border: 3px dashed var(--lv-d);
  background: #fff;
  font-size: 27px;
  font-weight: 600;
}
.level-meta { display: flex; align-items: center; gap: 10px; }
.stars { font-size: 24px; letter-spacing: 2px; }
.star.on { color: var(--gold); text-shadow: 0 2px 0 var(--gold-deep); }
.star.off { color: #e9dcea; }
.gem-badge { padding: 3px 10px; border-radius: 999px; background: #fff4cc; color: #8a5a00; font-size: 15px; font-weight: 600; }
.level-best { font-size: 17px; font-weight: 600; color: var(--ink-soft); }
.level-progress { width: 80%; height: 12px; border-radius: 99px; background: #fff; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08); }
.level-progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--pink), var(--lilac)); }
.ribbon {
  position: absolute;
  top: -14px;
  left: 50%;
  padding: 4px 16px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--pink-deep);
  translate: -50% 0;
  animation: ribbon-bob 1.6s ease-in-out infinite;
}

/* ——— Worlds ——— */

.wt-meadow, .wp-meadow, .w-meadow { --w: #ff5fa2; --w-deep: #e0408a; --w-soft: #ffd0e6; --w-bg: linear-gradient(140deg, #ffb0d4, #ff5fa2); }
.wt-lagoon, .wp-lagoon, .w-lagoon { --w: #1fb3c6; --w-deep: #12899a; --w-soft: #bdeef3; --w-bg: linear-gradient(140deg, #8fe6ee, #1fb3c6); }
.wt-kingdom, .wp-kingdom, .w-kingdom { --w: #6d5ce6; --w-deep: #4a3bbf; --w-soft: #d9d2ff; --w-bg: linear-gradient(140deg, #ab9fff, #5b49d6); }

.world-tabs { max-width: 1100px; margin: 0 auto 22px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.world-tab {
  position: relative;
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 4px solid #fff;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 6px 0 var(--w-soft), var(--shadow);
  transition: transform 0.12s;
  animation: pop-in 0.5s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 70ms);
}
.world-tab:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--w-soft), var(--shadow); }
.world-tab.active { background: var(--w-bg); color: #fff; box-shadow: 0 6px 0 var(--w-deep), var(--shadow); }
.world-tab.active .wt-name { text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }
.world-tab.locked { border-style: dashed; border-color: #e6d3e8; background: rgba(255, 255, 255, 0.6); box-shadow: none; color: var(--ink-soft); }
.world-tab.locked.active { border-color: var(--w); background: #fff; color: var(--ink); box-shadow: 0 6px 0 var(--w-soft); }
.wt-icon { font-size: 40px; line-height: 1.15; }
.wt-name { font-size: 19px; font-weight: 700; line-height: 1.1; }
.wt-stars { font-size: 15px; font-weight: 600; }
.world-blurb { margin: -4px 0 18px; text-align: center; font-size: 19px; color: var(--ink-soft); }
.world-blurb b { color: var(--w-deep); }
.world-blurb:has(+ .pay-tip) { margin-bottom: 8px; }
.world-panel .pay-tip { margin: 0 auto 18px; }
.pay-tip { width: fit-content; max-width: 100%; padding: 6px 16px; border-radius: 999px; background: #eafbf1; color: #1f7a4d; font-size: 16px; font-weight: 600; text-align: center; }

.locked-world {
  max-width: 560px;
  margin: 10px auto;
  padding: 26px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  border-radius: 32px;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 0 var(--w-soft), var(--shadow);
  animation: pop-in 0.45s var(--bounce);
}
.lw-art { position: relative; font-size: 96px; line-height: 1.05; }
.lw-icon { display: inline-block; filter: grayscale(0.5) opacity(0.6); animation: bob 3s ease-in-out infinite; }
.lw-lock { position: absolute; right: -22px; bottom: -4px; font-size: 48px; animation: wiggle 1.4s ease-in-out infinite; }
.locked-world h2 { font-size: 30px; color: var(--w-deep); }
.lw-blurb { font-size: 18px; color: var(--ink-soft); }
.lw-hint { margin-top: 6px; font-size: 22px; font-weight: 500; }
.lw-hint b { color: #c88400; white-space: nowrap; }
.lw-meter { width: 80%; height: 16px; border-radius: 99px; background: #f3e8f1; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08); }
.lw-meter span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #ffe07a, var(--gold)); }
.lw-levels { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 8px 0 2px; font-size: 34px; }
.lw-levels span { filter: grayscale(1) opacity(0.45); animation: pop-in 0.4s var(--bounce) backwards; animation-delay: calc(0.2s + var(--i) * 60ms); }

/* ——— Play ——— */

.view-play { animation: none; }
.play {
  max-width: 760px;
  margin: 0 auto;
  padding-top: calc(2px + env(safe-area-inset-top)); /* + the screen's 8px: level with the top bar */
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.play-top {
  position: relative;
  z-index: 5; /* Back stays tappable over Sprinkles' speech bubble */
  display: flex;
  align-items: center;
  gap: 12px;
  /* As wide as the window, like the top bar: Back and the gems sit in its corners. */
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
.play-top .hearts, .play-top .timer { max-width: 560px; margin-inline: auto; }
.hearts { flex: 1; display: flex; justify-content: center; gap: 1px; font-size: clamp(18px, 4.4vw, 30px); }
.heart { display: inline-block; }
.heart.filled { animation: pop-in 0.4s var(--bounce); }
.heart.current { animation: heartbeat 1s ease-in-out infinite; }
.timer {
  position: relative;
  flex: 1;
  height: 34px;
  overflow: hidden;
  border-radius: 999px;
  border: 4px solid #fff;
  background: #fff;
  box-shadow: var(--shadow);
}
.timer-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.25) 0 10px, transparent 10px 20px), linear-gradient(90deg, var(--mint), var(--sky));
  background-size: 28px 28px, 100% 100%;
  animation: stripes 0.8s linear infinite;
  transition: width 0.1s linear;
}
.timer.low .timer-fill { background-color: transparent; background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.25) 0 10px, transparent 10px 20px), linear-gradient(90deg, #ff9a7a, var(--pink)); }
.timer.low { animation: heartbeat 0.5s ease-in-out infinite; }
.timer-text { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; font-weight: 700; }

.stage { position: relative; margin-top: 56px; }
.play-mascot { position: absolute; z-index: 4; left: -4px; top: -78px; }
.play-mascot .mascot { width: 96px; }
.card {
  position: relative;
  padding: 44px 18px 18px;
  text-align: center;
  border-radius: 40px;
  border: 6px solid #ffd0e6;
  background:
    radial-gradient(circle at 8% 88%, #fff2f8 0 22px, transparent 23px),
    radial-gradient(circle at 94% 80%, #f4eeff 0 16px, transparent 17px),
    #fff;
  box-shadow: 0 10px 0 #f7bcd9, 0 22px 40px rgba(150, 70, 150, 0.2);
}
.card::before {
  content: '👑';
  position: absolute;
  top: -36px;
  left: 50%;
  translate: -50% 0;
  font-size: 46px;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.12));
}
.w-lagoon .card { border-color: #c4eff4; box-shadow: 0 10px 0 #9fe0e9, 0 22px 40px rgba(30, 140, 160, 0.2); }
.w-kingdom .card { border-color: #ddd6ff; box-shadow: 0 10px 0 #c3b8fb, 0 22px 40px rgba(90, 70, 200, 0.2); }
.w-lagoon .level-tag { background: #dcf7f9; }
.w-kingdom .level-tag { background: #ebe7ff; }
.card.enter { animation: card-in 0.45s var(--bounce); }
.card.shake { animation: shake 0.45s; }
.card.celebrate { animation: celebrate 0.5s var(--bounce); }
.level-tag {
  position: absolute;
  top: 12px;
  left: 50%;
  translate: -50% 0;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.speak-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 50px;
  height: 50px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--lilac-soft);
  font-size: 24px;
  box-shadow: 0 4px 0 #dccdf6;
}
.speak-btn:active { transform: translateY(3px); }
.bonus {
  position: absolute;
  bottom: -20px;
  left: 50%;
  translate: -50% 0;
  z-index: 2;
  padding: 6px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe58f, #ffc53d);
  color: #6b4300;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 0 var(--gold-deep);
}
.bonus.pop-in { animation: pop-in 0.4s var(--bounce); }
.speed-spark {
  position: absolute;
  top: 10px;
  left: 16px;
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 197, 61, 0.9));
}
.bloom-tag { position: absolute; bottom: 10px; left: 14px; font-size: 26px; line-height: 1; }
.bloom-tag:not([hidden]) { animation: pop-in 0.4s var(--bounce); }
.speed-spark.run { animation: speed-window var(--fluent, 3.5s) linear forwards; }
.speed-spark.done { animation-play-state: paused; }
.speed-spark.won { animation: speed-won 0.6s var(--bounce) forwards; }
.equation {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.18em;
  font-size: clamp(46px, 12.5vw, 112px);
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.equation.long { gap: 0.14em; font-size: clamp(40px, 11vw, 100px); }
.equation .op { color: var(--pink); }
.blank {
  display: inline-grid;
  place-items: center;
  min-width: 1.15em;
  padding: 0 0.1em;
  border-radius: 0.24em;
  border: 0.055em dashed var(--lilac);
  background: var(--lilac-soft);
  color: var(--lilac);
  animation: blank-glow 1.6s ease-in-out infinite;
}
.blank.right { border-style: solid; border-color: var(--mint); background: #e2fbf2; color: var(--mint-deep); animation: pop-big 0.5s var(--bounce); }
.blank.reveal { border-style: solid; border-color: var(--gold); background: #fff5d6; color: #c88400; animation: pop-big 0.5s var(--bounce); }
.blank.typing { border-style: solid; background: #fff; color: var(--ink); animation: none; }
.blank.wrong { border-style: solid; border-color: #ff9a9a; background: #fff0f0; color: #e25c5c; animation: shake 0.4s; }
.blank.nudge { animation: shake 0.35s; }
.feedback { min-height: 32px; margin-top: 6px; font-size: 23px; font-weight: 600; color: var(--pink-deep); }

.helper {
  padding: 14px;
  text-align: center;
  border-radius: 28px;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  animation: pop-in 0.4s var(--bounce);
}
.frame {
  max-width: 380px;
  margin: 0 auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  border-radius: 20px;
  border: 4px solid #ffcfe4;
  background: #fff;
}
.dot {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px dashed #ecdff3;
  font-size: 24px;
  font-weight: 700;
  animation: dot-in 0.35s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 50ms);
}
.dot.pink,
.dot.purple,
.dot.gone { border: 3px solid rgba(91, 58, 110, 0.25); }
.dot.pink { background: radial-gradient(circle at 34% 30%, #fff 0 12%, #ff9cc8 14% 100%); }
.dot.purple { background: radial-gradient(circle at 34% 30%, #fff 0 12%, #b89aff 14% 100%); }
.dot.gone { background: #ffe3ef; border-style: dashed; }
.dot.gone::after { content: '🦋'; font-size: 22px; animation: fly-away 1.8s ease-in-out infinite; }
.dot.mystery { border-color: var(--lilac); background: #f7f2ff; color: var(--lilac); }
.dot.away { border-color: var(--pink); background: #fff1f7; color: var(--pink); }
.dot.mystery::after,
.dot.away::after { content: '?'; }
.caption { margin-top: 10px; font-size: 19px; font-weight: 500; color: var(--ink-soft); }

/* Two ten-frames side by side, for within 20. */
.frames.two { display: flex; justify-content: center; gap: 12px; }
.frames.two .frame { flex: 1; max-width: 330px; margin: 0; }
.frames.two .dot { animation-delay: calc(var(--i) * 35ms); }

/* Base-ten blocks, for within 100: tens rods and ones cubes, one unit = --u. */
.blocks { --u: clamp(9px, 1.5vw, 13px); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 12px; }
.bt-group {
  display: flex;
  align-items: flex-end;
  gap: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 1.4) 10px 8px;
  border-radius: 18px;
  border: 3px solid #f3e4f2;
  background: #fff;
}
.bt-group.answer { border-color: var(--gold); background: #fffaf0; animation: pop-in 0.45s var(--bounce); }
.bt-rods { display: flex; gap: calc(var(--u) * 0.4); }
.bt-cubes {
  display: grid;
  grid-template-rows: repeat(10, var(--u));
  grid-auto-flow: column;
  grid-auto-columns: var(--u);
  column-gap: 3px;
  transform: scaleY(-1); /* fill from the bottom up, like stacking blocks */
}
.rod, .cube {
  --c: #ff9cc8;
  --line: #f57db3;
  position: relative;
  border: 2px solid rgba(91, 58, 110, 0.28);
  border-radius: 4px;
  background: var(--c);
  animation: dot-in 0.35s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 25ms);
}
.rod {
  width: var(--u);
  height: calc(var(--u) * 10);
  background: repeating-linear-gradient(180deg, var(--c) 0 calc(var(--u) - 2px), var(--line) calc(var(--u) - 2px) calc(var(--u) - 0.8px)) var(--c);
  background-position: 0 -1px;
}
.cube { width: var(--u); height: var(--u); border-radius: 3px; }
.rod.purple, .cube.purple { --c: #b89aff; --line: #9a78f0; }
.rod.gold, .cube.gold { --c: #ffd45e; --line: #efb21d; }
.rod.gone, .cube.gone { --c: #ffe6f1; --line: #f7cadf; border: 2px dashed #ec8fbb; }
.rod.broken { --c: #f3edff; --line: #ded1ff; border: 2px dashed var(--lilac); }
.rod.gone::before, .rod.broken::before {
  position: absolute;
  top: calc(var(--u) * -1.3);
  left: 50%;
  translate: -50% 0;
  font-size: calc(var(--u) * 1.15);
  animation: fly-away 1.8s ease-in-out infinite;
}
.rod.gone::before { content: '🦋'; }
.rod.broken::before { content: '✨'; }
.bt-sign { font-size: clamp(28px, 4vw, 40px); font-weight: 700; color: var(--pink); }

.pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; padding-bottom: 6px; }
.key {
  --k: #ffd0e4;
  --kd: #f2a5c8;
  aspect-ratio: 1.15;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 55%), var(--k);
  box-shadow: 0 6px 0 var(--kd), 0 10px 18px rgba(0, 0, 0, 0.08);
  color: var(--ink);
  font-size: clamp(26px, 6.5vw, 46px);
  font-weight: 700;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.key:active { transform: translateY(4px) scale(0.97); box-shadow: 0 2px 0 var(--kd); }
.key:nth-child(6n + 2) { --k: #ffdcc4; --kd: #f2b48c; }
.key:nth-child(6n + 3) { --k: #fff0a6; --kd: #e6cd58; }
.key:nth-child(6n + 4) { --k: #c6f3e1; --kd: #86d6b6; }
.key:nth-child(6n + 5) { --k: #cbe7ff; --kd: #8cc0ef; }
.key:nth-child(6n + 6) { --k: #e4d5ff; --kd: #b79cf0; }
.key.wrong { opacity: 0.3; transform: scale(0.92); }
.key.right { --k: #9ff0d3; --kd: #2fb48d; animation: pop-big 0.4s var(--bounce); }
.key.pulse { --k: #fff0a6; --kd: #e0a800; outline: 5px solid var(--gold); outline-offset: 3px; animation: pulse 0.9s ease-in-out infinite; }
.key.hint-key { --k: #fff; --kd: #ead7ee; font-size: clamp(22px, 5vw, 36px); }

/* 0–9 keypad for answers bigger than 10: the ? box is the display. */
.keypad {
  grid-template-columns: repeat(7, 1fr);
  grid-template-areas: 'k1 k2 k3 k4 k5 del hint' 'k6 k7 k8 k9 k0 ok ok';
  grid-auto-rows: clamp(60px, 10.5vh, 92px);
}
.is-fast .keypad { grid-template-areas: 'k1 k2 k3 k4 k5 del del' 'k6 k7 k8 k9 k0 ok ok'; }
.keypad .key { aspect-ratio: auto; }
.k1 { grid-area: k1; } .k2 { grid-area: k2; } .k3 { grid-area: k3; } .k4 { grid-area: k4; } .k5 { grid-area: k5; }
.k6 { grid-area: k6; } .k7 { grid-area: k7; } .k8 { grid-area: k8; } .k9 { grid-area: k9; } .k0 { grid-area: k0; }
.k-del { grid-area: del; } .k-ok { grid-area: ok; } .k-hint { grid-area: hint; }
.keypad .key.k-del { --k: #fff; --kd: #ead7ee; color: var(--ink-soft); }
.keypad .key.k-ok { --k: #6fdcb8; --kd: #22a37f; color: #fff; font-size: clamp(32px, 7vw, 54px); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.15); }

.countdown {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(255, 238, 248, 0.75);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  font-size: clamp(110px, 30vw, 200px);
  font-weight: 700;
  color: var(--pink);
  text-shadow: 0 8px 0 #fff, 0 14px 24px rgba(160, 80, 160, 0.3);
}
.countdown span { animation: zoom-in 0.7s var(--bounce); }
.countdown.times-up { font-size: clamp(54px, 12vw, 96px); color: var(--lilac-deep); }

/* ——— Results ——— */

.results { max-width: 640px; margin: 10px auto; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.big-stars { display: flex; gap: 10px; font-size: clamp(64px, 14vw, 92px); }
.big-star { display: inline-block; animation: star-pop 0.6s var(--bounce) backwards; animation-delay: calc(0.5s + var(--i) * 0.26s); }
.big-star:nth-child(2) { translate: 0 -18px; }
.big-star.off { filter: grayscale(1); opacity: 0.25; }
.results-row { display: flex; align-items: center; gap: 10px; margin-top: 30px; }
.results-text { text-align: left; }
.results h1 { font-size: clamp(36px, 7vw, 50px); }
.results .line { margin-top: 6px; font-size: 22px; }
.gems-won {
  padding: 8px 34px;
  border-radius: 999px;
  border: 5px solid #fff;
  background: linear-gradient(180deg, #fff6d6, #ffdf80);
  color: #a46d00;
  font-size: 56px;
  font-weight: 700;
  box-shadow: 0 7px 0 #f2c14a, var(--shadow);
  animation: pop-in 0.6s var(--bounce) 0.3s backwards;
}
.bloomed { padding: 10px 20px; border-radius: 20px; background: #fff; font-size: 20px; font-weight: 500; box-shadow: var(--shadow); }
.unlocked-world {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px 12px 16px;
  text-align: left;
  border: 4px solid #fff;
  border-radius: 28px;
  background: var(--w-bg);
  color: #fff;
  font-size: 21px;
  box-shadow: 0 6px 0 var(--w-deep), var(--shadow);
  animation: pop-in 0.6s var(--bounce) 1s backwards;
}
.unlocked-world small { font-size: 16px; }
.unlocked-world:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--w-deep), var(--shadow); }
.uw-icon { font-size: 54px; animation: bob 2s ease-in-out infinite; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-top: 10px; }

/* ——— Shop ——— */

.shop-head { display: flex; align-items: flex-end; gap: 10px; margin: 30px 0 16px; }
.balance { color: #a46d00; }
.tabs { display: flex; gap: 10px; padding: 4px 2px 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 10px 18px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: var(--card);
  box-shadow: 0 4px 0 #ecd6e6;
  font-size: 18px;
  font-weight: 600;
}
.tab.active { background: var(--pink); color: #fff; box-shadow: 0 4px 0 var(--pink-deep); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 16px; }
.grid-heading { grid-column: 1 / -1; margin-top: 8px; font-size: 24px; }
.item-card {
  position: relative;
  padding: 16px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-radius: 28px;
  border: 4px solid #fff;
  background: var(--card);
  box-shadow: 0 6px 0 #efd9e8, var(--shadow);
  transition: transform 0.12s var(--bounce);
  animation: pop-in 0.45s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 40ms);
}
.item-card:hover { transform: translateY(-4px); }
.item-card:hover .item-emoji { animation: icon-wiggle 0.6s ease-in-out; }
.item-card:active { transform: scale(0.96); }
.item-card.shake { animation: shake 0.45s; }
.item-emoji {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff 0 42%, #ffe3f1 100%);
  font-size: 62px;
}
.item-card.cant .item-emoji { filter: saturate(0.5); opacity: 0.75; }
.item-name { font-size: 18px; font-weight: 600; line-height: 1.15; }
.price {
  padding: 6px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe58f, #ffc53d);
  color: #6b4300;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 4px 0 var(--gold-deep);
}
.item-card.cant .price { background: #f2e9f0; color: #a58aa0; box-shadow: 0 4px 0 #e2d2de; }
.item-card.using .price { background: var(--mint); color: #fff; box-shadow: 0 4px 0 var(--mint-deep); }
.need { font-size: 14px; color: var(--ink-soft); }
.owned-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--mint);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* ——— Modal & toast ——— */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(74, 42, 92, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s;
}
.modal {
  width: 100%;
  max-width: 440px;
  padding: 28px 24px 24px;
  text-align: center;
  border-radius: 36px;
  border: 6px solid var(--pink-soft);
  background: #fff;
  box-shadow: 0 30px 60px rgba(74, 42, 92, 0.3);
  animation: card-in 0.4s var(--bounce);
}
.modal-icon { display: flex; justify-content: center; margin-bottom: 8px; font-size: 80px; line-height: 1.1; }
.modal-emoji { display: inline-block; font-size: 96px; }
.modal-emoji.bounce { animation: m-dance 1s ease-in-out infinite; }
.modal h2 { font-size: 29px; }
.modal p { margin-top: 8px; font-size: 19px; color: var(--ink-soft); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 22px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 70;
  max-width: calc(100% - 32px);
  padding: 14px 24px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow);
  translate: -50% 0;
  animation: toast-in 0.35s var(--bounce);
}

/* ——— Palace ——— */

.room {
  position: relative;
  width: min(100%, max(320px, calc((100dvh - 330px) * 4 / 3)));
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 34px;
  border: 7px solid #fff;
  box-shadow: 0 9px 0 #efcfe2, var(--shadow);
  container-type: inline-size;
  -webkit-user-select: none;
  user-select: none;
}
.room > .wall { position: absolute; inset: 0 0 30% 0; }
.room > .floor { position: absolute; inset: 70% 0 0 0; box-shadow: inset 0 12px 16px -10px rgba(0, 0, 0, 0.2); }
.room > .floor::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.8cqw;
  background: #fff;
  box-shadow: 0 0.3cqw 0.6cqw rgba(0, 0, 0, 0.08);
}
.window {
  position: absolute;
  left: 50%;
  top: 9%;
  width: 20%;
  aspect-ratio: 3 / 4;
  translate: -50% 0;
  border: 1.3cqw solid #fff;
  border-radius: 50% 50% 1.2cqw 1.2cqw / 34% 34% 1.2cqw 1.2cqw;
  background:
    radial-gradient(circle at 72% 28%, #fff6a8 0 9%, transparent 10%),
    radial-gradient(ellipse at 30% 70%, #fff 0 13%, transparent 14%),
    radial-gradient(ellipse at 42% 64%, #fff 0 10%, transparent 11%),
    linear-gradient(#8fd3ff, #d9f1ff);
  box-shadow: 0 0.7cqw 1.4cqw rgba(0, 0, 0, 0.12), inset 0 0 0 0.3cqw #f6d6e8;
}
.window::before,
.window::after { content: ''; position: absolute; background: #fff; }
.window::before { left: 50%; top: 0; bottom: 0; width: 0.9cqw; translate: -50% 0; }
.window::after { left: 0; right: 0; top: 56%; height: 0.9cqw; }
.curtain {
  position: absolute;
  z-index: 1;
  top: -9%;
  width: 36%;
  height: 116%;
  background: repeating-linear-gradient(90deg, #ffa2cb 0 1.3cqw, #ff86ba 1.3cqw 2.6cqw);
  box-shadow: 0 0.6cqw 1cqw rgba(0, 0, 0, 0.12);
}
.curtain.l { left: -26%; border-radius: 1cqw 0 60% 30%; }
.curtain.r { right: -26%; border-radius: 0 1cqw 30% 60%; }
.wall-night .window {
  background:
    radial-gradient(circle at 70% 30%, #fffbe0 0 10%, transparent 11%),
    radial-gradient(circle at 30% 60%, #fff 0 2%, transparent 3%),
    radial-gradient(circle at 50% 80%, #fff 0 1.5%, transparent 2.5%),
    linear-gradient(#1d1a4a, #46337a);
}

.room-items { position: absolute; inset: 0; }
.room-item {
  position: absolute;
  font-size: calc(8cqw * var(--s, 1));
  line-height: 1;
  transform: translate(-50%, -100%) scaleX(var(--flip, 1));
  transform-origin: 50% 100%;
  touch-action: none;
  cursor: grab;
  filter: drop-shadow(0 0.5cqw 0.4cqw rgba(60, 20, 60, 0.25));
  transition: font-size 0.2s var(--bounce);
}
.room-item span { display: block; animation: item-idle 3.5s ease-in-out infinite; }
.room-item:nth-child(3n + 1) span { animation-delay: -1.2s; }
.room-item:nth-child(3n + 2) span { animation-delay: -2.4s; }
.room-item.selected { outline: 0.45cqw dashed var(--pink); outline-offset: 0.6cqw; border-radius: 1.2cqw; }
.room-item.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 2.4cqw 1.4cqw rgba(60, 20, 60, 0.3));
  transform: translate(-50%, -106%) scaleX(var(--flip, 1)) scale(1.08);
}
.room-item.dragging span { animation: drag-wobble 0.4s ease-in-out infinite; }
.room-item.new span { animation: drop-in 0.8s var(--bounce); }
.room-empty {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.35);
}

.room-tools {
  max-width: 980px;
  min-height: 62px;
  margin: 16px auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.tool {
  padding: 10px 16px;
  border-radius: 999px;
  border: 3px solid #fff;
  background: var(--card);
  box-shadow: 0 4px 0 #ecd6e6;
  font-size: 18px;
  font-weight: 600;
}
.tool:active { transform: translateY(3px); box-shadow: 0 1px 0 #ecd6e6; }
.tool.done { background: var(--mint); color: #fff; box-shadow: 0 4px 0 var(--mint-deep); }
.tool-label { font-size: 21px; font-weight: 600; }
.hint-text { font-size: 18px; color: var(--ink-soft); }
.palace-panels { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.palace-panels h3 { margin-bottom: 12px; font-size: 20px; }
.toybox-items, .decor-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toy {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  border: 3px solid #fff;
  background: #fff;
  box-shadow: 0 4px 0 #ecd6e6;
  font-size: 36px;
}
.muted { font-size: 16px; color: var(--ink-soft); }
.decor-btn { width: 74px; padding: 0; overflow: hidden; border-radius: 18px; border: 4px solid #fff; background: none; box-shadow: 0 4px 0 #ecd6e6; }
.decor-btn.active { border-color: var(--pink); }
.decor-btn .swatch { border: none; border-radius: 0; }

/* Swatches reuse the room's wall/floor patterns in miniature. */
.swatch {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 18px;
  border: 3px solid #fff;
  container-type: inline-size;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.swatch.big { width: 160px; }
.swatch > .wall,
.swatch > .floor { position: absolute; inset: 0; }

/* Wallpapers */
.wall-rose .wall { background: repeating-linear-gradient(90deg, #ffe4f0 0 3.5cqw, #ffd2e6 3.5cqw 7cqw); }
.wall-hearts .wall {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M12 21.4l-1.5-1.3C5.4 15.4 2 12.3 2 8.5 2 5.4 4.4 3 7.5 3c1.7 0 3.4.8 4.5 2.1C13.1 3.8 14.8 3 16.5 3 19.6 3 22 5.4 22 8.5c0 3.8-3.4 6.9-8.5 11.5L12 21.4z' fill='%23ffb3d1'/%3E%3Cpath d='M36 45.4l-1.5-1.3C29.4 39.4 26 36.3 26 32.5c0-3.1 2.4-5.5 5.5-5.5 1.7 0 3.4.8 4.5 2.1 1.1-1.3 2.8-2.1 4.5-2.1 3.1 0 5.5 2.4 5.5 5.5 0 3.8-3.4 6.9-8.5 11.5L36 45.4z' fill='%23ffd2e3'/%3E%3C/svg%3E") 0 0 / 9cqw 9cqw,
    #fff5f9;
}
.wall-lilac .wall {
  background:
    radial-gradient(circle, #d6c2ff 0 22%, transparent 24%) 0 0 / 6cqw 6cqw,
    radial-gradient(circle, #e6dbff 0 14%, transparent 16%) 3cqw 3cqw / 6cqw 6cqw,
    #f3edff;
}
.wall-mint .wall {
  background-color: #e6fbf3;
  background-image:
    linear-gradient(45deg, #c8f2e2 25%, transparent 25%, transparent 75%, #c8f2e2 75%),
    linear-gradient(45deg, #c8f2e2 25%, transparent 25%, transparent 75%, #c8f2e2 75%);
  background-size: 7cqw 7cqw;
  background-position: 0 0, 3.5cqw 3.5cqw;
}
.wall-sky .wall {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 80'%3E%3Cpath d='M22 40a10 10 0 0 1 2-19 14 14 0 0 1 26-5 12 12 0 0 1 20 7 9 9 0 0 1 0 17z' fill='%23fff'/%3E%3Cpath d='M78 74a7 7 0 0 1 1-13 10 10 0 0 1 18-3 8 8 0 0 1 13 5 6 6 0 0 1 0 11z' fill='%23fff' opacity='.8'/%3E%3C/svg%3E") 0 0 / 22cqw 15cqw,
    linear-gradient(#a8dcff, #e3f4ff);
}
.wall-night .wall {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 60'%3E%3Cpath d='M12 6l1.5 4.5L18 12l-4.5 1.5L12 18l-1.5-4.5L6 12l4.5-1.5z' fill='%23ffe680'/%3E%3Ccircle cx='42' cy='20' r='1.6' fill='%23fff'/%3E%3Ccircle cx='30' cy='46' r='1.2' fill='%23fff'/%3E%3Cpath d='M46 40l1 3 3 1-3 1-1 3-1-3-3-1 3-1z' fill='%23fff'/%3E%3C/svg%3E") 0 0 / 10cqw 10cqw,
    linear-gradient(#2c2766, #5b3f96);
}
.wall-gold .wall {
  background:
    repeating-linear-gradient(45deg, transparent 0 3.4cqw, rgba(224, 168, 40, 0.38) 3.4cqw 3.8cqw),
    repeating-linear-gradient(-45deg, transparent 0 3.4cqw, rgba(224, 168, 40, 0.38) 3.4cqw 3.8cqw),
    linear-gradient(#fff9e8, #ffefc6);
}

/* Floors */
.floor-honey .floor {
  background:
    repeating-linear-gradient(90deg, transparent 0 11.8cqw, rgba(150, 90, 30, 0.22) 11.8cqw 12.2cqw),
    repeating-linear-gradient(0deg, #ecbd84 0 4.4cqw, #dfaa6d 4.4cqw 4.8cqw);
}
.floor-carpet .floor {
  background:
    radial-gradient(circle, #d4bfff 0 18%, transparent 20%) 0 0 / 3.5cqw 3.5cqw,
    linear-gradient(#ebdfff, #dccaff);
}
.floor-marble .floor { background: conic-gradient(#ffd3e6 0 25%, #fff 0 50%, #ffd3e6 0 75%, #fff 0) 0 0 / 9cqw 9cqw; }
.floor-meadow .floor {
  background:
    radial-gradient(circle, #fff 0 0.6cqw, transparent 0.7cqw) 0 0 / 6cqw 4cqw,
    radial-gradient(circle, #ffb3d2 0 0.6cqw, transparent 0.7cqw) 3cqw 2cqw / 6cqw 4cqw,
    linear-gradient(#b6eb98, #86d36c);
}
.floor-clouds .floor {
  background:
    radial-gradient(circle at 50% 100%, #fff 0 42%, transparent 44%) 0 0 / 11cqw 5cqw,
    radial-gradient(circle at 50% 100%, #fff 0 42%, transparent 44%) 5.5cqw 2.5cqw / 11cqw 5cqw,
    linear-gradient(#e8f5ff, #c9e4ff);
}

/* ——— Garden ——— */

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-bottom: 18px; font-size: 17px; }
.garden-section {
  margin-bottom: 14px;
  padding: 14px 18px;
  border-radius: 26px;
  border: 4px solid #fff;
  background: var(--card);
  box-shadow: var(--shadow);
}
.garden-section summary { display: flex; align-items: center; gap: 10px; list-style: none; font-size: 22px; font-weight: 600; cursor: pointer; }
.garden-section summary::-webkit-details-marker { display: none; }
.garden-icon { font-size: 28px; }
.garden-count { margin-left: auto; font-size: 17px; color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px; background: #f4eef4; color: #a58fa5; font-size: 16px; font-weight: 600; }
.chip.sprout { background: #fff0e4; color: #b5652c; }
.chip.grow { background: #ffe7f2; color: #c13f7c; }
.chip.bloom { background: linear-gradient(180deg, #ffd6ea, #ffbfdc); color: #a02565; box-shadow: 0 3px 0 #f5a3c9; }
.garden-world { display: flex; align-items: center; gap: 10px; margin: 28px 6px 12px; font-size: 26px; color: var(--w-deep); }
.garden-world:first-of-type { margin-top: 4px; }
.garden-locked { padding: 14px 18px; border-radius: 22px; border: 3px dashed #e8d6ea; background: rgba(255, 255, 255, 0.6); font-size: 18px; color: var(--ink-soft); }
.grownup { max-width: 720px; margin: 22px auto 0; font-size: 15px; color: var(--ink-soft); text-align: center; line-height: 1.5; }

/* ——— Effects ——— */

.confetti { position: fixed; inset: 0; z-index: 80; width: 100%; height: 100%; pointer-events: none; }
.burst {
  position: fixed;
  z-index: 55;
  font-size: 26px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: burst 0.85s ease-out forwards;
}
.float-text {
  position: fixed;
  z-index: 56;
  font-size: 34px;
  font-weight: 700;
  color: #c48600;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 3px 0 #fff, 3px 0 0 #fff, -3px 0 0 #fff, 0 -3px 0 #fff, 0 0 16px #fff;
  transform: translate(-50%, -50%);
  animation: float-text 1.1s ease-out forwards;
}
.flyer { position: fixed; z-index: 57; font-size: 30px; pointer-events: none; }

/* ——— Keyframes ——— */

@keyframes view-in { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.5); } }
@keyframes pop-big { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes card-in { from { opacity: 0; transform: translateY(30px) rotate(-3deg) scale(0.9); } }
@keyframes celebrate { 0% { transform: scale(1); } 40% { transform: scale(1.05) rotate(-1.5deg); } 70% { transform: scale(0.98) rotate(1deg); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-12px) rotate(-1deg); } 40% { transform: translateX(10px) rotate(1deg); } 60% { transform: translateX(-7px); } 80% { transform: translateX(5px); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(1); } 45% { transform: scale(1.12); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes icon-wiggle { 0%, 100% { transform: rotate(8deg); } 25% { transform: rotate(-10deg) scale(1.1); } 50% { transform: rotate(12deg) scale(1.15); } 75% { transform: rotate(-6deg); } }
@keyframes float-icon { 0%, 100% { transform: translateY(0) rotate(8deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes letter-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-14px) rotate(-4deg); } }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(18deg); } 20%, 40% { transform: rotate(-10deg); } }
@keyframes ribbon-bob { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-3px); } }
@keyframes gem-shine { 0%, 80%, 100% { transform: rotate(0) scale(1); } 88% { transform: rotate(-15deg) scale(1.2); } 94% { transform: rotate(10deg) scale(1.1); } }
@keyframes blank-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(160, 124, 245, 0.35); } 50% { box-shadow: 0 0 0 0.12em rgba(160, 124, 245, 0.12); } }
@keyframes dot-in { from { opacity: 0; transform: scale(0.2); } }
@keyframes fly-away { 0%, 100% { transform: translate(0, 0) rotate(-8deg); } 50% { transform: translate(3px, -6px) rotate(8deg); } }
@keyframes stripes { to { background-position: 28px 0, 0 0; } }
@keyframes zoom-in { from { opacity: 0; transform: scale(2.4) rotate(-10deg); } }
@keyframes star-pop { from { opacity: 0; transform: scale(0) rotate(-120deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(0.9); } }
@keyframes burst { to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--r)) scale(0.4); } }
@keyframes float-text { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }
@keyframes float-up { from { transform: translate(0, 0) rotate(0); } to { transform: translate(var(--sway), -115vh) rotate(45deg); } }
@keyframes cloud-drift { from { transform: translateX(0); } to { transform: translateX(calc(100vw + 440px)); } }
@keyframes item-idle { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3%) rotate(1.5deg); } }
@keyframes drag-wobble { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes drop-in { 0% { transform: translateY(-120%) scale(0.4); opacity: 0; } 60% { transform: translateY(6%) scale(1.15, 0.9); opacity: 1; } 100% { transform: none; } }
@keyframes speed-window {
  0% { opacity: 1; transform: scale(1.15) rotate(-8deg); }
  100% { opacity: 0.12; transform: scale(0.7) rotate(0); filter: grayscale(1); }
}
@keyframes speed-won { 0% { transform: scale(1); } 50% { transform: scale(1.8) rotate(12deg); } 100% { transform: scale(1.2); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes gem-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px) rotate(-10deg); } }
@keyframes drag-demo { 0%, 15% { translate: 0 0; } 55%, 75% { translate: -34cqw -4cqw; } 100% { translate: 0 0; } }
@keyframes twinkle { from { transform: scale(0.5) rotate(0); opacity: 0.6; } to { transform: scale(1.15) rotate(25deg); opacity: 1; } }

@keyframes m-bob { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-4%) scale(0.98, 1.02); } }
@keyframes m-tilt { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes m-wag { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(12deg); } }
@keyframes m-blink { 0%, 90%, 96%, 100% { transform: scaleY(1); } 93% { transform: scaleY(0.08); } }
@keyframes m-oops { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-10deg); } 60% { transform: rotate(6deg); } }
@keyframes m-jump {
  0% { transform: translateY(0) scale(1, 1); }
  18% { transform: translateY(0) scale(1.15, 0.82); }
  50% { transform: translateY(-30%) scale(0.92, 1.1); }
  78% { transform: translateY(0) scale(1.08, 0.92); }
  100% { transform: translateY(0) scale(1, 1); }
}
@keyframes m-wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-10deg); } 40% { transform: rotate(9deg); } 60% { transform: rotate(-6deg); } 80% { transform: rotate(4deg); } }
@keyframes m-spin { 0% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-28%) rotate(180deg) scale(1.1); } 100% { transform: translateY(0) rotate(360deg); } }
@keyframes m-dance {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  25% { transform: rotate(0) translateY(-10%) scale(1.03, 0.97); }
  50% { transform: rotate(8deg) translateY(0); }
  75% { transform: rotate(0) translateY(-10%) scale(1.03, 0.97); }
}

/* ——— Bigger worlds: times tables, story problems, fractions, grades ——— */

.wt-forest, .wp-forest, .w-forest { --w: #2fb36f; --w-deep: #1f8a52; --w-soft: #c5efd6; --w-bg: linear-gradient(140deg, #9be7b9, #2fb36f); }
.wt-crystal, .wp-crystal, .w-crystal { --w: #3a8fe0; --w-deep: #2366b0; --w-soft: #cfe5fb; --w-bg: linear-gradient(140deg, #a3d3ff, #3a8fe0); }
.w-forest .card { border-color: #c9f0d8; box-shadow: 0 10px 0 #a3e2bd, 0 22px 40px rgba(40, 150, 90, 0.2); }
.w-crystal .card { border-color: #cfe6fc; box-shadow: 0 10px 0 #a9d0f6, 0 22px 40px rgba(40, 110, 200, 0.2); }
.w-forest .level-tag { background: #ddf6e7; }
.w-crystal .level-tag { background: #e0effd; }

.equation.xlong { gap: 0.12em; font-size: clamp(34px, 9.5vw, 86px); }
.frac { display: inline-flex; flex-direction: column; align-items: center; font-size: 0.6em; line-height: 1.05; }
.frac > span:first-child { padding: 0 0.12em 0.04em; border-bottom: 0.07em solid currentColor; }
.op.of { font-size: 0.55em; }

/* Story problems: big, readable text with the answer box underneath. */
.equation.story { display: block; font-size: clamp(42px, 8vw, 72px); }
.story-text {
  max-width: 660px;
  margin: 2px auto 10px;
  padding: 0 48px; /* clear of the 🔊 button */
  font-size: clamp(20px, 3.3vw, 30px);
  font-weight: 600;
  line-height: 1.35;
  text-wrap: pretty;
}
.story-answer { display: flex; justify-content: center; align-items: center; gap: 0.25em; }
.story-unit { font-size: 0.4em; font-weight: 600; color: var(--ink-soft); }

/* Arrays (rows of dots with skip-counting) and equal groups. */
.array {
  --d: clamp(9px, 1.5vw, 15px);
  display: inline-flex;
  flex-direction: column;
  gap: calc(var(--d) * 0.32);
  padding: 10px 14px;
  border-radius: 18px;
  border: 3px solid #f3e4f2;
  background: #fff;
}
.arr-row { display: flex; align-items: center; gap: 10px; }
.arr-dots { display: flex; gap: calc(var(--d) * 0.32); }
.arr-label { min-width: 2.4em; text-align: left; font-size: calc(var(--d) * 1.15); line-height: 1; color: var(--ink-soft); }
.arr-label.ask { color: var(--lilac); }
.adot {
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  border: 1.5px solid rgba(91, 58, 110, 0.25);
  background: radial-gradient(circle at 34% 30%, #fff 0 12%, #ff9cc8 14% 100%);
  animation: dot-in 0.3s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 8ms);
}
.adot.purple { background: radial-gradient(circle at 34% 30%, #fff 0 12%, #b89aff 14% 100%); }
.adot.pale { border-style: dashed; background: #f6f0f8; }
.eq-groups { --d: clamp(8px, 1.3vw, 13px); display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 8px; }
.eq-group {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--d));
  align-content: center;
  gap: 3px;
  padding: 7px;
  border-radius: 14px;
  border: 3px dashed #e6d6ee;
  background: #fff;
}
.eq-group.picked { border: 3px solid var(--pink); background: #fff3f8; }

/* Step-by-step hints: numbered, appearing one at a time. */
.steps {
  margin: 4px auto 0;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  list-style: none;
  counter-reset: step;
  text-align: left;
  font-size: clamp(17px, 2.5vw, 22px);
  font-weight: 600;
}
.steps li { display: flex; align-items: baseline; gap: 10px; counter-increment: step; animation: pop-in 0.4s var(--bounce) backwards; animation-delay: calc(var(--i) * 0.25s); }
.steps li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 1.5em;
  height: 1.5em;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--lilac-soft);
  color: var(--lilac-deep);
  font-size: 0.8em;
}
.step-q { color: var(--lilac); }
.step-answer { padding: 0 0.3em; border-radius: 0.3em; background: #fff5d6; color: #c88400; }

/* Grades: picked when making a player; grown-ups change them in "manage players". */
.grade-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.grade-choice {
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 20px;
  border: 4px solid transparent;
  background: #fff;
  box-shadow: 0 4px 0 #f0dcea;
  transition: transform 0.15s var(--bounce);
}
.grade-choice b { font-size: 24px; line-height: 1.1; white-space: nowrap; }
.grade-choice small { font-size: 15px; color: var(--ink-soft); }
.grade-choice.chosen { border-color: var(--pink); background: var(--pink-soft); transform: scale(1.06) rotate(-2deg); }
.grade-note { margin-top: -4px; text-align: center; font-size: 17px; color: var(--ink-soft); }
.profile-grade { padding: 2px 10px; border-radius: 999px; background: var(--lilac-soft); color: var(--lilac-deep); font-size: 15px; font-weight: 600; }
.profile-card.managing .profile-delete { background: var(--lilac); box-shadow: 0 3px 0 var(--lilac-deep); }

/* Landscape tablets: keep a 9-row array on screen with the keypad. */
@media (min-aspect-ratio: 1 / 1) and (max-height: 900px) {
  .array.tall { --d: 10px; padding: 6px 12px; }
  .equation.story { font-size: 54px; }
  .story-text { margin-bottom: 6px; font-size: 25px; line-height: 1.3; }
  .steps { gap: 3px; font-size: 19px; }
}

@media (max-width: 640px) {
  .equation.story { font-size: 36px; }
  .story-text { margin: 24px auto 4px; padding: 0; font-size: 19px; line-height: 1.3; } /* starts below the 🔊 button */
  .steps { gap: 3px; font-size: 15px; }
  .array { --d: 9px; padding: 8px 10px; }
  .eq-groups { --d: 7px; gap: 6px; }
  .grade-choice b { font-size: 22px; }
}

/* ——— Subjects: Reading, Science, Geography, and 5th-grade math ——— */

.wt-summit, .wp-summit, .w-summit, .sc-math { --w: #4f9ee0; --w-deep: #2f74b8; --w-soft: #d2e8fb; --w-bg: linear-gradient(140deg, #d6f1ff, #7fb6f5 55%, #a596ff); }
.wt-library, .wp-library, .w-library, .sc-reading { --w: #e8875a; --w-deep: #c0633a; --w-soft: #fbdcca; --w-bg: linear-gradient(140deg, #ffcfa9, #e8875a); }
.wt-lab, .wp-lab, .w-lab, .sc-science { --w: #b05ce0; --w-deep: #8a3bbd; --w-soft: #ecd6fb; --w-bg: linear-gradient(140deg, #e6bbff, #b05ce0); }
.wt-globe, .wp-globe, .w-globe, .sc-geo { --w: #2a9fd0; --w-deep: #17789f; --w-soft: #c6eaf8; --w-bg: linear-gradient(140deg, #9be6ff, #2a9fd0 65%, #34bf8a); }
.sc-math { --w: #ff5fa2; --w-deep: #e0408a; --w-soft: #ffd0e6; --w-bg: linear-gradient(140deg, #ffb0d4, #ff5fa2); }
.w-summit .card { border-color: #d2e8fb; box-shadow: 0 10px 0 #b3d5f6, 0 22px 40px rgba(60, 110, 200, 0.2); }
.w-library .card { border-color: #fbdcca; box-shadow: 0 10px 0 #f5c2a5, 0 22px 40px rgba(190, 100, 50, 0.18); }
.w-lab .card { border-color: #ecd6fb; box-shadow: 0 10px 0 #dbb8f5, 0 22px 40px rgba(140, 60, 190, 0.18); }
.w-globe .card { border-color: #c6eaf8; box-shadow: 0 10px 0 #a3daf0, 0 22px 40px rgba(30, 120, 170, 0.2); }
.w-summit .level-tag { background: #e3f1fd; }
.w-library .level-tag { background: #fdeadf; }
.w-lab .level-tag { background: #f4e6fd; }
.w-globe .level-tag { background: #ddf3fb; }
.w-library .card::before { content: '📚'; }
.w-lab .card::before { content: '🧪'; }
.w-globe .card::before { content: '🌍'; }
.w-summit .card::before { content: '❄️'; }

.world-tabs { grid-template-columns: repeat(var(--n, 5), 1fr); }
.world-tabs[hidden] { display: none; }
.grade-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; }

/* The subject switch on Home (4th grade and up). */
.subject-switch { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 20px; }
.subject-chip {
  position: relative;
  padding: 10px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 4px solid #fff;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 0 var(--w-soft), var(--shadow);
  font-size: 20px;
  font-weight: 700;
  transition: transform 0.12s;
  animation: pop-in 0.5s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 60ms);
}
.subject-chip:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--w-soft), var(--shadow); }
.subject-chip.active { background: var(--w-bg); color: #fff; box-shadow: 0 5px 0 var(--w-deep), var(--shadow); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }
.sc-icon { font-size: 28px; line-height: 1; }
.subject-chip .ribbon { top: -16px; font-size: 13px; padding: 2px 10px; }

/* Multiple choice: four big answers. */
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding-bottom: 6px; }
.options[hidden], .pad[hidden] { display: none; }
.options.long { grid-template-columns: 1fr; gap: 10px; }
.option {
  --c: #fff;
  --cd: #ead7ee;
  min-height: clamp(62px, 9vh, 84px);
  padding: 10px 16px 10px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 60%), var(--c);
  box-shadow: 0 6px 0 var(--cd), 0 10px 18px rgba(0, 0, 0, 0.07);
  color: var(--ink);
  font-size: clamp(18px, 2.6vw, 25px);
  font-weight: 600;
  line-height: 1.2;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.option:nth-child(1) { --c: #ffe3ef; --cd: #f5b8d3; }
.option:nth-child(2) { --c: #fff2c2; --cd: #ecd07a; }
.option:nth-child(3) { --c: #d8f6ea; --cd: #94dbbf; }
.option:nth-child(4) { --c: #dcefff; --cd: #9fcaf0; }
.option:active:not(:disabled) { transform: translateY(4px) scale(0.99); box-shadow: 0 2px 0 var(--cd); }
.option-letter {
  flex-shrink: 0;
  width: 1.8em;
  height: 1.8em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.8em;
  font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}
.option-text { flex: 1; text-wrap: pretty; }
.options.math .option { justify-content: flex-start; font-size: clamp(26px, 4.4vw, 40px); font-variant-numeric: tabular-nums; }
.options.math .option-letter { font-size: 0.55em; }
.option .frac { font-size: 0.62em; }
.option.wrong { --c: #fff0f0; --cd: #f3c4c4; opacity: 0.55; animation: shake 0.4s; }
.option.wrong .option-letter { background: #ff9a9a; color: #fff; }
.option.crossed { opacity: 0.3; filter: grayscale(1); }
.option.wrong .option-text, .option.crossed .option-text { text-decoration: line-through 3px rgba(226, 92, 92, 0.6); }
.option.right { --c: #b7f5de; --cd: #2fb48d; opacity: 1; animation: pop-big 0.4s var(--bounce); }
.option.right .option-letter { background: var(--mint-deep); color: #fff; }
.option.pulse { --c: #fff0a6; --cd: #e0a800; outline: 5px solid var(--gold); outline-offset: 3px; animation: pulse 0.9s ease-in-out infinite; }
.option:disabled { cursor: default; }
.clue-btn {
  grid-column: 1 / -1;
  justify-self: center;
  padding: 6px 22px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  box-shadow: 0 4px 0 #ead7ee;
  font-size: 19px;
  font-weight: 600;
}
.clue-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #ead7ee; }
.clue-btn:disabled { visibility: hidden; }

/* Written questions, and reading passages above them. */
.question-text b { color: var(--w-deep, var(--pink-deep)); }
.is-choice .story-text { margin-bottom: 2px; }
.passage {
  max-width: 680px;
  max-height: min(40vh, 360px);
  margin: 0 auto 12px;
  padding: 14px 18px;
  overflow: auto;
  text-align: left;
  border-radius: 22px;
  border: 3px solid #f6e3cc;
  background: #fffaf2;
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 500;
  line-height: 1.5;
  overscroll-behavior: contain;
}
.passage h3 { margin-bottom: 6px; font-size: 1.1em; color: var(--w-deep); }
.passage p { white-space: pre-line; }
.passage p + p { margin-top: 8px; }

/* Clues, and the answer with why it's right. */
.clue { max-width: 640px; margin: 0 auto; font-size: clamp(17px, 2.4vw, 22px); font-weight: 600; line-height: 1.35; text-wrap: pretty; }
.clue-answer { margin-bottom: 4px; font-size: clamp(22px, 3.4vw, 30px); font-weight: 700; color: var(--mint-deep); }
.clue-answer .frac { font-size: 0.65em; vertical-align: middle; }

/* 5th-grade math: fractions, mixed numbers, and long expressions. */
.equation.xxlong { gap: 0.1em; font-size: clamp(28px, 7vw, 64px); }
.mixed { display: inline-flex; align-items: center; gap: 0.06em; }
.equation .op.paren { color: var(--ink-soft); }
.blank .frac, .blank .mixed { font-size: inherit; }
.blank .frac { font-size: 0.6em; }

.garden-subject { margin: 36px 6px 0; font-size: 30px; text-align: center; }
.garden-subject:first-of-type { margin-top: 8px; }

@media (min-aspect-ratio: 1 / 1) and (max-height: 900px) {
  .option { min-height: 58px; }
  .options.long { grid-template-columns: repeat(2, 1fr); } /* wide screens have room across, not down */
  .options.long .option { font-size: clamp(16px, 2vw, 20px); }
  .passage { max-height: 30vh; font-size: 17px; line-height: 1.4; }
  .is-choice .card { padding-bottom: 8px; }
  .is-choice .feedback { min-height: 26px; margin-top: 2px; font-size: 20px; }
}

@media (max-width: 640px) {
  .subject-switch { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .subject-chip { padding: 8px 4px; font-size: 17px; }
  .sc-icon { font-size: 22px; }
  .options { grid-template-columns: 1fr; gap: 9px; }
  .option { min-height: 52px; padding: 8px 12px 8px 8px; border-radius: 18px; font-size: 17px; }
  .options.math { grid-template-columns: repeat(2, 1fr); }
  .options.math .option { font-size: 26px; }
  .passage { max-height: 34vh; padding: 10px 12px; font-size: 15px; line-height: 1.4; }
  .grade-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ——— Responsive ——— */

/* Narrow play layout: Sprinkles peeks over the card, bubble grows to the right. */
.play-mascot .mascot-bubble { left: 0; translate: none; max-width: 220px; transform-origin: 15% 100%; }
.play-mascot .mascot-bubble::after { left: 30px; }

@media (min-width: 1160px) {
  .stage { margin-top: 40px; }
  .play-mascot { left: -168px; top: auto; bottom: -6px; }
  .play-mascot .mascot { width: 150px; }
  .play-mascot .mascot-bubble { left: 50%; translate: -50% 0; max-width: 200px; transform-origin: 50% 100%; }
  .play-mascot .mascot-bubble::after { left: calc(50% - 8px); }
}

@media (min-aspect-ratio: 1 / 1) and (max-height: 900px) {
  .key { aspect-ratio: 1.3; }
  .frame { max-width: 300px; gap: 6px; }
  .frames.two .frame { max-width: 270px; }
  .helper { padding: 10px; }
  .caption { margin-top: 6px; font-size: 17px; }
  .card { padding-top: 40px; padding-bottom: 12px; }
}

@media (min-aspect-ratio: 1 / 1) and (max-height: 700px) {
  .key { aspect-ratio: 1.7; }
  .stage { margin-top: 44px; }
}

@media (max-width: 640px) {
  .tiles { gap: 12px; }
  .tile { min-height: 150px; padding: 16px 14px; border-radius: 28px; }
  .tile-icon { font-size: 52px; top: 8px; right: 10px; }
  .tile-title { font-size: 23px; }
  .tile-sub { font-size: 15px; }
  .home-hero, .shop-head { margin-top: 72px; }
  .home-mascot .mascot { width: 110px; }
  .shop-mascot .mascot { width: 96px; }
  .home-mascot .mascot-bubble,
  .shop-mascot .mascot-bubble { left: 0; bottom: 98%; max-width: 230px; transform-origin: 15% 100%; }
  .home-mascot .mascot-bubble::after,
  .shop-mascot .mascot-bubble::after { left: 34px; }
  .hero-mascot .mascot-bubble,
  .new-mascot .mascot-bubble { left: 58%; max-width: 150px; }
  .greeting p { font-size: 17px; }
  .profile-card { width: calc(50% - 9px); }
  .profile-avatar { font-size: 60px; }
  .avatar-grid { grid-template-columns: repeat(6, 1fr); }
  .palace-panels { grid-template-columns: 1fr; }
  .round-btn { width: 46px; height: 46px; font-size: 22px; }
  .back-pill { height: 46px; padding: 0 14px 0 10px; font-size: 18px; }
  .back-pill:not([hidden]) ~ .home-btn { display: none; }
  .player-pill, .gem-pill { height: 46px; font-size: 18px; }
  .pp-name { display: none; }
  .player-pill { padding: 0 8px; }
  .pad { gap: 7px; }
  .key { border-radius: 18px; }
  .keypad {
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas: 'k1 k2 k3 del' 'k4 k5 k6 ok' 'k7 k8 k9 ok' 'hint k0 k0 ok';
    grid-auto-rows: clamp(46px, 6.6vh, 60px);
  }
  .is-fast .keypad { grid-template-areas: 'k1 k2 k3 del' 'k4 k5 k6 ok' 'k7 k8 k9 ok' 'k0 k0 k0 ok'; }
  .frames.two { gap: 8px; }
  .frames.two .frame { padding: 6px; gap: 5px; border-width: 3px; }
  .frames.two .dot { border-width: 2px; font-size: 16px; }
  .frames.two .dot.gone::after { font-size: 13px; }
  .blocks { --u: 8px; gap: 6px 8px; }
  .blocks.revealed { --u: 7px; } /* room for the answer on the same row */
  .bt-group { padding: calc(var(--u) * 1.4) 5px 5px; gap: 4px; border-width: 2px; }
  .bt-rods { gap: 2px; }
  .bt-sign { font-size: 24px; }
  .helper { padding: 10px; }
  .caption { margin-top: 6px; font-size: 16px; }
  .feedback { font-size: 19px; }
  .world-tabs { gap: 5px; }
  .world-tab { padding: 8px 2px 6px; border-width: 3px; border-radius: 18px; }
  .wt-icon { font-size: 28px; }
  .wt-name { display: none; } /* six tabs: icons only; the name is right below */
  .wt-stars { font-size: 11px; white-space: nowrap; }
  .lw-hint { font-size: 19px; }
  .card { border-radius: 32px; padding: 40px 10px 14px; }
  .results-row { flex-direction: column; text-align: center; }
  .results-text { text-align: center; }
  .shop-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .item-emoji { width: 88px; height: 88px; font-size: 52px; }
}

/* ——— Toyland (Pre-K): Sprinkles asks out loud, and the answer is a big picture to tap ——— */

.wt-prek, .wp-prek, .w-prek { --w: #ff8a3d; --w-deep: #e0661a; --w-soft: #ffdcc2; --w-bg: linear-gradient(140deg, #ffc48f, #ff8a3d); }
.w-prek .card { border-color: #ffe0c7; box-shadow: 0 10px 0 #ffc9a0, 0 22px 40px rgba(220, 120, 40, 0.2); }
.w-prek .card::before { content: '🧸'; }
.w-prek .level-tag { background: #fff0e2; }

.level-example.art { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 1.6em; }
.level-example.art svg { height: 1.2em; width: auto; }
.level-example .pk-num { font-size: 1em; }
.level-example .pk-ball { width: 0.75em; }
.level-example .pk-sized.big { font-size: 1.15em; }
.level-example .pk-sized.small { font-size: 0.6em; }
.pk-q { color: var(--lilac); }

.is-pictures .card { padding: 44px 14px 12px; }
.is-pictures .speak-btn { top: 8px; right: 8px; width: 62px; height: 62px; font-size: 30px; }
.card.listen .speak-btn { display: none; }
.speak-btn.speaking, .pk-listen.speaking { animation: speaking 0.9s ease-in-out infinite; }
.is-pictures .feedback { min-height: 28px; margin-top: 4px; font-size: 20px; }
.pk-hint {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 52px;
  height: 52px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #fff7d6;
  font-size: 26px;
  box-shadow: 0 4px 0 #f0dca0;
}
.pk-hint:active { transform: translateY(3px); box-shadow: 0 1px 0 #f0dca0; }

.scene { min-height: clamp(130px, 24vh, 220px); display: grid; place-items: center; container-type: inline-size; }

/* The big 🔊 when the question is only spoken (and the shape or number to look for, after a miss). */
.pk-listen-wrap { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 4vw, 40px); }
.pk-listen {
  width: clamp(110px, 19vh, 160px);
  aspect-ratio: 1;
  border: 6px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, var(--lilac-soft) 60%);
  font-size: clamp(52px, 9vh, 76px);
  box-shadow: 0 8px 0 #dccdf6, var(--shadow);
  transition: width 0.3s var(--bounce), font-size 0.3s;
}
.pk-listen:active { transform: translateY(4px); box-shadow: 0 3px 0 #dccdf6; }
.sc-none .pk-listen { width: clamp(100px, 15vh, 130px); font-size: clamp(48px, 7vh, 62px); }
.helping .pk-listen { width: clamp(84px, 13vh, 110px); font-size: clamp(40px, 6vh, 52px); }
.pk-show { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: pop-in 0.45s var(--bounce); }
.pk-show .pk-num { --c: var(--ink); font-size: clamp(90px, 17vh, 140px); } /* match the shape of the number, not its color */
.pk-show .pk-shape { width: clamp(110px, 18vh, 160px); }
.pk-show-dots { display: grid; grid-template-columns: repeat(var(--cols), 14px); gap: 5px; justify-content: center; }
.pk-show-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--pink); border: 2px solid rgba(91, 58, 110, 0.25); }

/* Critters to count: a badge with each number pops up as Sprinkles counts. */
.pk-group {
  display: grid;
  grid-template-columns: repeat(var(--cols), auto);
  justify-content: center;
  gap: 4px clamp(8px, 2vw, 16px);
  font-size: clamp(40px, 7.5vh, 62px);
  line-height: 1.1;
}
.pk-group.mine { position: relative; padding: 10px 18px; border-radius: 26px; border: 4px dashed #d9c6f7; background: #faf6ff; }
.pk-group.mine::after { content: '🦄'; position: absolute; top: -20px; left: -16px; font-size: 34px; }
.pk-critter {
  position: relative;
  display: inline-grid;
  place-items: center;
  rotate: var(--r, 0deg);
  animation: pop-in 0.4s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 60ms);
}
.pk-badge {
  position: absolute;
  top: -0.12em;
  right: -0.2em;
  min-width: 1.45em;
  height: 1.45em;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--gold);
  color: #6b4300;
  font-size: 0.36em;
  font-weight: 700;
  line-height: 1;
  rotate: calc(var(--r, 0deg) * -1);
  opacity: 0;
  scale: 0;
  transition: opacity 0.2s, scale 0.3s var(--bounce);
}
.pk-critter.counted { animation: count-hop 0.45s var(--bounce); }
.pk-critter.counted .pk-badge { opacity: 1; scale: 1; }

/* Quick Look: dots, then a cloud to peek under. */
.pk-peek { position: relative; width: clamp(140px, 23vh, 200px); aspect-ratio: 1; border-radius: 28px; border: 4px solid #f3e4f2; background: #fff; }
.pk-dots { display: block; width: 100%; height: 100%; }
.pk-dot { transform-box: fill-box; transform-origin: center; animation: dot-in 0.35s var(--bounce) backwards; animation-delay: calc(var(--i) * 40ms); }
.pk-dot-n { font: 700 13px var(--font); fill: #fff; text-anchor: middle; dominant-baseline: central; opacity: 0; transition: opacity 0.2s; }
.pk-dot.counted circle { stroke: var(--gold-deep); stroke-width: 4; }
.pk-dot.counted .pk-dot-n { opacity: 1; }
.pk-cover {
  position: absolute;
  inset: -4px;
  display: grid;
  place-items: center;
  border: 4px solid #fff;
  border-radius: 28px;
  background: radial-gradient(circle at 30% 35%, #fff 0 22%, transparent 23%), radial-gradient(circle at 68% 60%, #fff 0 26%, transparent 27%), linear-gradient(160deg, #e9f4ff, #efe6ff);
  font-size: clamp(48px, 8vh, 64px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
.pk-cover span { animation: bob 1.6s ease-in-out infinite; }
.covered .pk-cover { opacity: 1; pointer-events: auto; }

/* What shape is it? The hint traces its outline. */
.pk-thing-art { display: block; width: clamp(140px, 24vh, 210px); }
.pk-trace { opacity: 0; stroke-dasharray: 470; stroke-dashoffset: 470; }
.traced .pk-trace, .solved .pk-trace { opacity: 1; animation: trace 1.8s ease-in-out forwards; }

/* Patterns and sorting. Items size themselves to fit the card (7 in a row on a phone). */
.pk-pattern, .pk-set { --s: clamp(36px, 9vw, 64px); display: flex; align-items: center; justify-content: center; gap: clamp(3px, 1vw, 10px); }
@supports (width: 1cqw) {
  .pk-pattern { --s: min(76px, calc(88cqw / var(--count))); }
}
.pk-set { --s: clamp(56px, 10vh, 84px); padding: 10px 16px; border-radius: 26px; border: 4px dashed #ffd6b3; background: #fffaf3; }
.pk-item {
  width: var(--s);
  height: var(--s);
  display: grid;
  place-items: center;
  border-radius: 16px;
  transition: background 0.3s;
  animation: pop-in 0.4s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 80ms);
}
.pk-item .pk-em { font-size: calc(var(--s) * 0.8); line-height: 1; }
.pk-item .pk-em.small { font-size: calc(var(--s) * 0.42); }
.pk-item .pk-shape { width: 88%; }
.pk-item .pk-ball { width: 82%; }
.pk-item.sing { animation: sing 0.45s var(--bounce); }
.helping .pk-item:not(.pk-slot) { background: #eef6ff; }
.helping .pk-item.odd-unit { background: #ffeef7; }
.pk-slot { border: 4px dashed var(--lilac); background: var(--lilac-soft); color: var(--lilac); font-size: calc(var(--s) * 0.6); animation: blank-glow 1.6s ease-in-out infinite; }
.pk-slot.filled { border-style: solid; border-color: var(--mint); background: #e2fbf2; animation: pop-big 0.5s var(--bounce); }
.pk-slot.filled .pk-sized { font-size: calc(var(--s) * 0.8); }
.pk-ball {
  display: inline-block;
  width: 1em;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid rgba(91, 58, 110, 0.4);
  background: radial-gradient(circle at 34% 30%, #fff 0 12%, var(--c) 14% 100%);
}
.pk-num { font-size: clamp(64px, 12vh, 104px); font-weight: 700; line-height: 1; color: var(--c); text-shadow: 0 4px 0 rgba(91, 58, 110, 0.22); font-variant-numeric: tabular-nums; }
.pk-shape { display: block; overflow: visible; }

/* The choices: two to four big buttons. */
.choices { --n: 3; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: clamp(10px, 2vw, 18px); padding-bottom: 8px; }
.choices.n2 { --n: 2; }
.choices.n4 { --n: 4; }
.choices.rows { grid-template-columns: 1fr; }
.choice {
  --kd: #f4bcd6;
  position: relative;
  min-height: clamp(120px, 22vh, 190px);
  padding: 10px;
  display: grid;
  place-items: center;
  border: 4px solid #fff;
  border-radius: 30px;
  background: linear-gradient(180deg, #fff, #fff6fb);
  box-shadow: 0 7px 0 var(--kd), 0 12px 22px rgba(150, 70, 150, 0.12);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.25s;
  animation: pop-in 0.4s var(--bounce) backwards;
  animation-delay: calc(var(--i) * 70ms + 0.1s);
}
.choice:nth-child(4n + 2) { --kd: #f6c6a2; }
.choice:nth-child(4n + 3) { --kd: #a8e4cf; }
.choice:nth-child(4n + 4) { --kd: #b2d6f6; }
.choice:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--kd); }
.choice.wrong { opacity: 0.3; transform: scale(0.92); pointer-events: none; }
.choice.right { --kd: #2fb48d; border-color: #9ff0d3; background: #e2fbf2; animation: pop-big 0.45s var(--bounce); }
.choice.pulse { --kd: #e0a800; border-color: var(--gold); background: #fff8dc; outline: 5px solid var(--gold); outline-offset: 3px; animation: pulse 0.9s ease-in-out infinite; }
.choice .pk-shape { width: clamp(78px, 14vh, 128px); }
.choice .pk-em { font-size: clamp(54px, 10vh, 90px); line-height: 1.1; }
.choice .pk-em.small { font-size: clamp(26px, 4.6vh, 40px); }
.choice .pk-ball { width: clamp(60px, 10vh, 96px); }
.c-sized, .c-height { place-items: end center; padding-bottom: 14px; }
.pk-sized { display: inline-block; line-height: 1; }
.pk-sized.big { font-size: clamp(78px, 15vh, 128px); }
.pk-sized.small { font-size: clamp(34px, 6vh, 52px); }
.pk-height { display: block; height: clamp(110px, 19vh, 160px); }
.pk-cluster { display: grid; grid-template-columns: repeat(var(--cols), auto); justify-content: center; gap: 0 6px; font-size: clamp(30px, 5.2vh, 46px); line-height: 1.15; }
/* With a keyboard, picture choices show the number key that picks them. */
.kbd .choices:not(.numeric) .choice::after {
  content: attr(data-key);
  position: absolute;
  top: 8px;
  left: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--lilac-soft);
  color: var(--lilac-deep);
  font-size: 16px;
  font-weight: 700;
}
.choices.look .choice { animation: look 0.5s ease-in-out backwards; animation-delay: calc(var(--i) * 0.25s + 1.4s); }

/* More or fewer: two rows. Lining them up (the hint) puts them one above the other. */
.choices.rows .choice { min-height: clamp(84px, 13vh, 116px); justify-items: start; padding: 8px 22px; }
.pk-row { display: flex; align-items: center; gap: calc(var(--gap) * 1em); font-size: clamp(28px, 7.4vw, 54px); transition: gap 0.7s var(--bounce); }
.pk-row .pk-critter { width: 1.15em; translate: 0 calc(var(--dy, 0) * 1em); transition: translate 0.5s var(--bounce); }
.choices.rows .choice.wrong { opacity: 0.8; transform: none; } /* both rows stay visible to compare */
.lined .pk-row { gap: 0.25em; }
.lined .pk-row .pk-critter { translate: 0 0; }
.pk-row .pk-critter.extra { animation: count-hop 0.5s var(--bounce) 0.8s backwards; filter: drop-shadow(0 0 6px var(--gold)); }

@keyframes speaking { 0%, 100% { box-shadow: 0 4px 0 #dccdf6, 0 0 0 0 rgba(160, 124, 245, 0.45); } 50% { box-shadow: 0 4px 0 #dccdf6, 0 0 0 12px rgba(160, 124, 245, 0); } }
@keyframes count-hop { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-22%) scale(1.18); } 100% { transform: translateY(0) scale(1); } }
@keyframes sing { 0% { transform: translateY(0) scale(1); } 45% { transform: translateY(-26%) scale(1.2); } 100% { transform: translateY(0) scale(1); } }
@keyframes look { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg) scale(1.04); } 75% { transform: rotate(5deg) scale(1.04); } }
@keyframes trace { from { stroke-dashoffset: 470; } to { stroke-dashoffset: 0; } }

/* Landscape tablets: keep the card and the choices on one screen. */
@media (min-aspect-ratio: 1 / 1) and (max-height: 900px) {
  .is-pictures .stage { margin-top: 36px; }
  .is-pictures .card { padding-top: 40px; }
  .scene { min-height: clamp(120px, 26vh, 220px); }
  .choice { min-height: clamp(110px, 28vh, 230px); }
  .pk-height { height: clamp(100px, 22vh, 180px); }
}

@media (max-width: 640px) {
  .choices.n4 { --n: 2; }
  .choice { min-height: clamp(110px, 20vh, 170px); border-radius: 24px; padding: 8px; }
  .choices.n4 .choice { min-height: clamp(96px, 15vh, 130px); }
  .choice .pk-shape { width: 74px; }
  .choice .pk-em { font-size: 52px; }
  .choice .pk-em.small { font-size: 24px; }
  .pk-num { font-size: 66px; }
  .pk-sized.big { font-size: 74px; }
  .pk-sized.small { font-size: 32px; }
  .pk-height { height: 100px; }
  .pk-cluster { font-size: 25px; gap: 0 3px; }
  .choices.rows .choice { padding: 8px 14px; min-height: 76px; }
  .pk-group { font-size: 44px; gap: 2px 8px; }
  .is-pictures .speak-btn { width: 54px; height: 54px; font-size: 26px; }
  .pk-hint { width: 46px; height: 46px; font-size: 22px; }
  .grade-choice small { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .floater, .cloud { display: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ——— Adaptive learning: ladders, quests, Royal Review ——— */

.ladder-badge { position: absolute; top: 10px; left: 10px; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.9); color: var(--lilac-deep); font-size: 13px; font-weight: 600; }
.lw-quest { margin-top: 6px; }
.lw-quest-note, .lw-quest-done { max-width: 420px; margin: 4px auto 0; color: var(--ink-soft); font-size: 16px; text-align: center; }
.next-challenge { display: grid; justify-items: center; gap: 10px; padding: 14px 20px; border-radius: 24px; background: #fff; box-shadow: var(--shadow); text-align: center; font-size: 18px; animation: pop-in 0.6s var(--bounce) 1.2s backwards; }
.next-challenge p { margin: 0; }
.nc-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.chip.wilt { background: #f3ece4; color: #8a6a55; filter: saturate(0.6); }
.review-card { display: flex; align-items: center; gap: 14px; max-width: 640px; margin: 0 auto 18px; padding: 12px 18px; border-radius: 24px; background: #fff8e6; border: 3px solid #ffe2a3; box-shadow: var(--shadow); font-size: 18px; }
.review-card p { flex: 1; margin: 0; }
.review-card small { color: var(--ink-soft); font-size: 15px; }
.review-card.calm { background: #f1fbf6; border-color: #c6eedb; }
.rv-icon { font-size: 38px; }
@media (max-width: 520px) { .review-card { flex-wrap: wrap; justify-content: center; text-align: center; } }

/* ——— Grown-up report ——— */

.view-report { max-width: 900px; margin: 0 auto; }
.rp-players { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 18px; }
.rp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.rp-summary div { display: grid; gap: 2px; padding: 12px 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.rp-summary b { font-size: 30px; color: var(--lilac-deep); font-variant-numeric: tabular-nums; }
.rp-summary span { font-size: 14px; color: var(--ink-soft); }
.rp-section { margin-bottom: 26px; }
.rp-section h2 { margin-bottom: 10px; font-size: 24px; }
.rp-table { overflow-x: auto; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.rp-table table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.rp-table th, .rp-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #f1e6f6; white-space: nowrap; }
.rp-table th { color: var(--ink-soft); font-weight: 500; }
.rp-slow { color: #c0572b; font-weight: 600; }
.rp-note, .rp-empty { margin-top: 8px; font-size: 14px; color: var(--ink-soft); }
.rp-ladder { margin-bottom: 12px; padding: 12px 16px; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.rp-ladder h3 { margin-bottom: 6px; font-size: 18px; }
.rp-ladder ol { margin: 0; padding-left: 22px; display: grid; gap: 3px; font-size: 15px; color: var(--ink-soft); }
.rp-ladder li.on { color: var(--ink); }
.rp-ladder li.done { color: var(--mint-deep); }
.rp-ladder small { margin-left: 6px; }

/* A race that opens once a few facts are known (js/daily.js). */
.level-card.race-locked { filter: saturate(0.55); }
.level-card.race-locked .level-icon { opacity: 0.6; }
.level-best.race-need { color: #1f7a4d; font-weight: 600; }
.pay-tip.sparkle-tip { background: #fff6c2; color: #8a5a00; }
