/* ===== Unicorn Rainbow Math ===== */

:root {
  --ink: #4b2e6f;
  --ink-soft: #7d64a0;
  --card: #ffffff;
  --edge: #e3d4fb;
  --pink: #ff5ea8;
  --pink-dark: #d63d86;
  --purple: #9b6dff;
  --purple-dark: #6a3fd1;
  --mint: #38d9a9;
  --mint-dark: #0ca678;
  --gold: #fcc419;
  --gold-dark: #e8a200;
  --world: #ff5e7e;
  --radius: 26px;
  --focus: #ffd43b;
  --rainbow: linear-gradient(90deg, #ff5e7e, #ff922b, #fcc419, #51cf66, #339af0, #5f3dc4, #cc5de8);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #c7b3ff 0%, #f0c4ff 40%, #ffd6ea 75%, #fff3f8 100%);
  background-attachment: fixed;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

input { -webkit-user-select: text; user-select: text; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus { outline: none; }

/* Big, friendly keyboard highlight (only shown while using the keyboard) */
body.kbd button:focus,
body.kbd input:focus,
body.kbd a:focus {
  outline: 5px solid var(--focus);
  outline-offset: 4px;
  box-shadow: 0 0 0 10px rgba(255, 212, 59, 0.35), 0 0 24px 6px rgba(255, 212, 59, 0.7);
  position: relative;
  z-index: 2;
}

.hidden { display: none !important; }

/* ---------- Sky decoration ---------- */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.cloud {
  position: absolute;
  width: 160px;
  height: 50px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50px;
  filter: blur(1px);
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud::before { width: 70px; height: 70px; left: 22px; top: -34px; }
.cloud::after { width: 54px; height: 54px; left: 80px; top: -24px; }
.c1 { top: 8%; animation-duration: 60s; animation-delay: -10s; }
.c2 { top: 30%; transform: scale(.7); animation-duration: 80s; animation-delay: -40s; opacity: .7; }
.c3 { top: 62%; transform: scale(.9); animation-duration: 70s; animation-delay: -25s; opacity: .8; }
.c4 { top: 85%; transform: scale(.6); animation-duration: 90s; animation-delay: -60s; opacity: .6; }

@keyframes drift {
  from { left: -220px; }
  to { left: 110%; }
}

.twinkle-bg {
  position: absolute;
  color: #fff;
  font-size: 22px;
  animation: twinkle 2.6s ease-in-out infinite;
  text-shadow: 0 0 8px #fff;
}

@keyframes twinkle {
  0%, 100% { opacity: .2; transform: scale(.6); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ---------- Layout ---------- */
#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  max-width: 920px;
  margin: 0 auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: screenIn .35s ease; }
.screen.no-scroll { overflow: hidden; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 rgba(155, 109, 255, .18), 0 14px 30px rgba(120, 70, 180, .15);
  padding: 16px 18px;
  width: 100%;
  max-width: 640px;
}

/* ---------- Buttons ---------- */
.btn {
  font-weight: 600;
  font-size: clamp(1.15rem, 3.6vw, 1.45rem);
  color: #fff;
  background: linear-gradient(180deg, #b892ff, #8f5cff);
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  min-height: 62px;
  box-shadow: 0 5px 0 var(--purple-dark), 0 8px 18px rgba(106, 63, 209, .3);
  transition: transform .08s ease, box-shadow .08s ease;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--purple-dark); }
.btn-big { font-size: clamp(1.5rem, 5vw, 2rem); min-height: 76px; padding: 16px 40px; }
.btn-play { background: linear-gradient(180deg, #ff94c9, #ff5ea8); box-shadow: 0 5px 0 var(--pink-dark), 0 8px 18px rgba(214, 61, 134, .35); }
.btn-play:active { box-shadow: 0 1px 0 var(--pink-dark); }
.btn-star { background: linear-gradient(180deg, #ffe066, #fcc419); color: #6b4b00; text-shadow: none; box-shadow: 0 5px 0 var(--gold-dark), 0 8px 18px rgba(232, 162, 0, .3); }
.btn-star:active { box-shadow: 0 1px 0 var(--gold-dark); }
.btn-mint { background: linear-gradient(180deg, #63e6be, #20c997); box-shadow: 0 5px 0 var(--mint-dark), 0 8px 18px rgba(12, 166, 120, .3); }
.btn-mint:active { box-shadow: 0 1px 0 var(--mint-dark); }
.btn-sky { background: linear-gradient(180deg, #74c0fc, #4dabf7); box-shadow: 0 5px 0 #1c7ed6, 0 8px 18px rgba(28, 126, 214, .3); }
.btn-sticker { background: linear-gradient(180deg, #ffa94d, #ff922b); box-shadow: 0 5px 0 #e8590c, 0 8px 18px rgba(232, 89, 12, .3); }
.btn-sticker:active { box-shadow: 0 1px 0 #e8590c; }
.btn-sky:active { box-shadow: 0 1px 0 #1c7ed6; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.menu-grid .btn { padding-left: 12px; padding-right: 12px; white-space: nowrap; }
.menu-grid .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.btn-ghost { background: rgba(255, 255, 255, .7); color: var(--ink); text-shadow: none; box-shadow: 0 5px 0 #d9c8f5; font-size: 1.05rem; min-height: 54px; }
.btn-ghost:active { box-shadow: 0 1px 0 #d9c8f5; }
.link-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-danger { background: linear-gradient(180deg, #ff8787, #fa5252); box-shadow: 0 5px 0 #c92a2a; font-size: 1.05rem; }

.icon-btn {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: #fff;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #d9c8f5;
  transition: transform .08s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9c8f5; }
.icon-btn.small { width: 50px; height: 50px; font-size: 1.4rem; background: #f6f0ff; }

.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  margin-top: 4px;
}
.menu.row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 560px;
}
.menu.row .btn { flex: 1 1 140px; white-space: nowrap; padding-left: 18px; padding-right: 18px; }

.gem-pill, .pill {
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 4px 0 #d9c8f5;
  white-space: nowrap;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 860px;
  flex-shrink: 0;
}
.topbar h2 {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: clamp(1.2rem, 5vw, 1.9rem);
  color: #fff;
  text-shadow: 0 2px 0 rgba(106, 63, 209, .55), 0 0 12px rgba(155, 109, 255, .5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Unicorn ---------- */
.unicorn-slot { width: 170px; flex-shrink: 0; }
.unicorn-slot.big { width: min(58vw, 290px); }
.unicorn-svg { display: block; width: 100%; height: auto; overflow: visible; }
.bob .unicorn-svg { animation: bob 2.4s ease-in-out infinite; }
.u-eye { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
.u-wing { transform-origin: 104px 84px; animation: flap 2.4s ease-in-out infinite; }
.u-tail { transform-origin: 50px 92px; animation: swish 2.4s ease-in-out infinite; }
.u-spark { animation: twinkle 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes blink {
  0%, 94%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(.1); }
}
@keyframes flap {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-5deg); }
}
@keyframes swish {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-8deg); }
}

/* ---------- Title ---------- */
#screen-title { padding-top: max(72px, env(safe-area-inset-top)); }
/* Centered when it fits; starts below the top buttons when it doesn't (instead of hiding under them) */
#screen-title .logo { margin-top: auto; }
#screen-title .menu { margin-bottom: auto; }
.title-gems { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; }
.back-link {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 16px;
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  box-shadow: 0 4px 0 #d9c8f5;
}
.back-link:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9c8f5; }
.logo {
  margin: 0;
  text-align: center;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 0 #9b6dff, 0 8px 20px rgba(106, 63, 209, .35);
  letter-spacing: .02em;
}
.logo span {
  display: block;
  margin-top: 6px;
  font-size: .62em;
  background: var(--rainbow);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 4px 6px rgba(106, 63, 209, .3));
}
.greeting {
  margin: 0;
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}
.kbd-tip {
  margin: 0;
  font-size: .95rem;
  color: var(--ink-soft);
  text-align: center;
  display: none;
}
body.kbd .kbd-tip { display: block; }

/* ---------- Map ---------- */
.level-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 860px; flex-shrink: 0; }
.level-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 48px;
  background: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  box-shadow: 0 4px 0 #d9c8f5;
}
.level-btn.on { background: var(--lc); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--lc) 60%, #000); text-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.level-btn.locked { opacity: .55; }
.level-btn:active { transform: translateY(3px); }
.map-rainbow { position: relative; width: 100%; max-width: 520px; flex-shrink: 0; }
.map-rainbow svg { display: block; width: 100%; height: auto; }
.map-rainbow .arc { transition: stroke .6s; }
.map-rainbow .arc.done { filter: drop-shadow(0 0 4px rgba(255, 255, 255, .8)); }
.map-unicorn { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: 26%; }
.map-tip { margin: 0; font-weight: 600; text-align: center; font-size: 1.1rem; }

.worlds {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 860px;
  padding-bottom: 12px;
}
.world-btn {
  background: #fff;
  border: none;
  border-top: 10px solid var(--c);
  border-radius: 22px;
  padding: 12px 10px 10px;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 55%, #fff), 0 10px 20px rgba(120, 70, 180, .12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  min-height: 140px;
  transition: transform .1s;
}
.world-btn:active { transform: translateY(4px); }
.world-btn .wi { font-size: 2.4rem; line-height: 1.1; }
.world-btn .wn { font-weight: 700; font-size: 1.15rem; }
.world-btn .wd { font-size: .88rem; color: var(--ink-soft); line-height: 1.2; }
.world-btn .ws { font-size: 1.2rem; letter-spacing: 2px; margin-top: 4px; }
.world-btn .ws .dim { filter: grayscale(1); opacity: .3; }
.world-btn.locked { filter: grayscale(.85); opacity: .65; }

/* ---------- Quest ---------- */
#screen-quest { --world: #ff5e7e; }
.track {
  position: relative;
  width: 100%;
  max-width: 640px;
  height: 78px;
  flex-shrink: 0;
}
.track-line {
  position: absolute;
  left: 20px;
  right: 40px;
  bottom: 10px;
  height: 14px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .65);
  overflow: hidden;
}
.track-fill {
  height: 100%;
  width: 0;
  background: var(--rainbow);
  border-radius: 99px;
  transition: width .7s ease;
}
.track-unicorn {
  position: absolute;
  bottom: 14px;
  width: 72px;
  left: calc(var(--p, 0) * (100% - 112px));
  transition: left .8s cubic-bezier(.4, 1.6, .5, 1);
}
.track-unicorn .unicorn-svg { animation: bob 1.2s ease-in-out infinite; }
.track-goal { position: absolute; right: 0; bottom: 2px; font-size: 36px; }

.q-card { border-top: 8px solid var(--world); }
.q-card.enter { animation: cardIn .4s ease; }
@keyframes cardIn {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: none; }
}
.q-tools { display: flex; align-items: center; justify-content: space-between; }
.q-count { font-weight: 700; color: var(--ink-soft); font-size: 1.1rem; }

.q-prompt {
  font-size: clamp(1.3rem, 5vw, 1.85rem);
  text-align: center;
  font-weight: 600;
  line-height: 1.4;
  margin: 8px 0;
}
.q-prompt.word { font-size: clamp(1.15rem, 4.4vw, 1.5rem); text-align: left; font-weight: 500; }
.q-prompt b { color: var(--pink-dark); }
.q-prompt .big { font-size: 1.5em; }
.q-prompt .eq {
  display: inline-block;
  font-size: clamp(2.1rem, 10vw, 3.4rem);
  font-weight: 700;
  white-space: nowrap;
}
.blank {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 .15em;
  border-radius: 14px;
  background: #fff0f8;
  border: 3px dashed #ff8fc8;
  color: var(--pink);
  text-align: center;
  line-height: 1.2;
}

.q-visual { display: flex; justify-content: center; flex-wrap: wrap; margin: 6px 0 4px; }

.q-hint {
  margin-top: 10px;
  padding: 10px 14px;
  background: #fff9db;
  border: 3px solid #ffe066;
  border-radius: 18px;
  font-size: 1.1rem;
  text-align: center;
  line-height: 1.45;
  animation: cardIn .3s ease;
}
.hint-vis {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  font-size: 1.45rem;
}
.hint-vis .op { font-weight: 700; margin: 0 8px; font-size: 1.6rem; }
.ic.gone { opacity: .22; filter: grayscale(1); }
.pair { background: #e7f5ff; border-radius: 12px; padding: 2px 4px; margin: 2px; }
.pair.odd { background: #ffe3e3; }

/* Tens (blue) and ones (orange), used in charts and hints */
.tw { color: #1c7ed6; font-weight: 700; }
.ow { color: #e8590c; font-weight: 700; }
.eq-small { font-size: 1.1rem; color: var(--ink-soft); font-weight: 600; }
.pv {
  display: inline-grid;
  grid-template-columns: 1em 1.4em 1.4em;
  column-gap: .2em;
  row-gap: 2px;
  margin: 4px auto 0;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  font-weight: 700;
  line-height: 1.15;
}
.pv > span { text-align: center; }
.pv .t { color: #1c7ed6; background: #f1f8ff; }
.pv .o { color: #e8590c; background: #fff8f0; }
.pv .pv-h { font-size: .3em; letter-spacing: .04em; text-transform: uppercase; padding: 4px 0; border-radius: 8px 8px 0 0; align-self: end; }
.pv .pv-h.t { background: #d0ebff; color: #1864ab; }
.pv .pv-h.o { background: #ffe8cc; color: #d9480f; }
.pv .pv-op { color: var(--ink); }
.pv-line { grid-column: 1 / -1; height: 5px; margin: 3px 0; border-radius: 3px; background: var(--ink); }
.pv .q { border: 3px dashed currentColor; border-radius: 12px; font-size: .8em; line-height: 1.35; }

/* Base ten blocks */
.blocks { display: flex; align-items: flex-end; justify-content: center; flex-wrap: wrap; gap: 8px; }
.ten {
  box-sizing: content-box;
  width: 16px;
  height: 160px;
  background: repeating-linear-gradient(to bottom, #74c0fc 0 14px, #1c7ed6 14px 16px);
  border: 2px solid #1c7ed6;
  border-radius: 3px;
}
.hundred {
  box-sizing: content-box;
  width: 100px;
  height: 100px;
  background:
    repeating-linear-gradient(to right, transparent 0 9px, #2f9e44 9px 10px),
    repeating-linear-gradient(to bottom, #8ce99a 0 9px, #2f9e44 9px 10px);
  border: 2px solid #2f9e44;
  border-radius: 3px;
}
.ones { display: grid; grid-template-columns: repeat(2, 18px); gap: 3px; }
.one {
  box-sizing: content-box;
  width: 14px;
  height: 14px;
  background: #ffa94d;
  border: 2px solid #e8590c;
  border-radius: 3px;
}

/* Hundred chart (Race to 100): 1 at the bottom left, 100 at the top right */
.hc {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  width: min(100%, 400px, 46vh);
  padding: 4px;
  background: #e5dbff;
  border-radius: 14px;
}
.hc > span {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  font-size: clamp(.72rem, 2.9vw, .95rem);
  font-weight: 700;
  color: var(--ink-soft);
  background: #fff;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.hc .start { background: var(--pink); color: #fff; box-shadow: 0 0 0 2px #d6336c; z-index: 1; }
.hc .start::after { content: '🦄'; position: absolute; top: -.85em; left: 50%; transform: translateX(-50%); font-size: 1.1em; }
.hc .sun { background: radial-gradient(circle, #ffe066 0 45%, #fcc419 46% 100%); color: #8a5a00; clip-path: polygon(50% 0, 61% 20%, 85% 15%, 80% 39%, 100% 50%, 80% 61%, 85% 85%, 61% 80%, 50% 100%, 39% 80%, 15% 85%, 20% 61%, 0 50%, 20% 39%, 15% 15%, 39% 20%); border-radius: 0; }
.hc .goal { background: #d0bfff; color: var(--purple-dark); box-shadow: inset 0 0 0 2px var(--purple); }
.q-visual.solved .hc .path { background: #c3fae8; color: #087f5b; transition: background .2s; }
.q-visual.solved .hc .land:not(.sun) { background: #40c057; color: #fff; box-shadow: 0 0 0 2px #2b8a3e; }
.q-visual.solved .hc .land.sun { color: #2b8a3e; }

/* Sequences */
.seq { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.seq > span {
  min-width: 62px;
  padding: 8px 8px;
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-weight: 700;
  background: #f3f0ff;
  border-radius: 16px;
  text-align: center;
}
.seq > .blank { background: #fff0f8; }

/* Arrays */
.array {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  background: #f8f0fc;
  border-radius: 18px;
  font-size: clamp(1.6rem, 7vw, 2.1rem);
  line-height: 1;
}

/* Coins */
.coins { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; max-width: 520px; }
.coin {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #495057;
  font-size: 1rem;
  border: 3px solid rgba(0, 0, 0, .12);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12), 0 3px 6px rgba(0, 0, 0, .15);
}
.coin.q { width: 74px; height: 74px; background: radial-gradient(circle at 35% 30%, #f8f9fa, #adb5bd); font-size: 1.15rem; }
.coin.n { width: 64px; height: 64px; background: radial-gradient(circle at 35% 30%, #f1f3f5, #a5abb3); }
.coin.d { width: 52px; height: 52px; background: radial-gradient(circle at 35% 30%, #fff, #b8bec5); font-size: .9rem; }
.coin.p { width: 58px; height: 58px; background: radial-gradient(circle at 35% 30%, #ffc078, #c2550c); color: #fff; }

/* Clock */
.clock { width: min(52vw, 220px); height: auto; }
.clock .face { fill: #fff; stroke: #b197fc; stroke-width: 5; }
.clock .tick { stroke: #d0bfff; stroke-width: 1.5; }
.clock .tick5 { stroke: #9775fa; stroke-width: 2.5; }
.clock text { text-anchor: middle; dominant-baseline: central; font-size: 12px; font-weight: 700; fill: var(--ink); font-family: inherit; }
.clock .hour { stroke: #7048e8; stroke-width: 6; stroke-linecap: round; }
.clock .minute { stroke: #f06595; stroke-width: 4; stroke-linecap: round; }
.clock .pin { fill: #4b2e6f; }

/* Choices */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 560px;
  flex-shrink: 0;
}
.choices.n3 { grid-template-columns: repeat(3, 1fr); }
.choice {
  position: relative;
  min-height: 86px;
  padding: 8px;
  font-size: clamp(1.7rem, 7vw, 2.4rem);
  font-weight: 700;
  background: #fff;
  color: var(--ink);
  border: 4px solid var(--cc, #eadff9);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--cc, #d9c8f5);
  transition: transform .08s;
  line-height: 1.1;
}
.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cc, #d9c8f5); }
.choice:nth-child(1) { --cc: #ffc9de; }
.choice:nth-child(2) { --cc: #c5f6fa; }
.choice:nth-child(3) { --cc: #fff3bf; }
.choice:nth-child(4) { --cc: #d3f9d8; }
.choice small { display: block; font-size: .9rem; font-weight: 500; color: var(--ink-soft); }
.choice .key {
  position: absolute;
  top: 6px;
  left: 10px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-soft);
  opacity: 0;
}
body.kbd .choice .key { opacity: .8; }
.choice.correct { background: #d3f9d8; border-color: #51cf66; animation: pop .45s ease; }
.choice.wrong { background: #ffe3e3; border-color: #ffa8a8; opacity: .55; animation: shake .4s ease; }

.feedback {
  min-height: 1.6em;
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  font-weight: 700;
  text-align: center;
  color: var(--pink-dark);
  text-shadow: 0 2px 0 #fff;
}
.feedback.good { color: #2b8a3e; }

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.shake { animation: shake .4s ease; }

/* ---------- Done ---------- */
#screen-done { justify-content: center; }
.done-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; max-width: 560px; }
.done-card h2 { margin: 0; font-size: clamp(1.6rem, 6vw, 2.2rem); }
.done-card p { margin: 0; font-size: 1.2rem; }
.done-stars { font-size: clamp(2.8rem, 12vw, 3.6rem); }
.done-stars span { display: inline-block; animation: starIn .6s backwards cubic-bezier(.3, 1.6, .5, 1); }
.done-stars .dim { filter: grayscale(1); opacity: .3; }
.done-gems { font-size: 1.6rem; font-weight: 700; color: var(--purple-dark); }
@keyframes starIn {
  from { transform: scale(0) rotate(-180deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- Star Catch ---------- */
.catch-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  max-width: 860px;
  flex-shrink: 0;
}
.catch-target {
  background: #fff;
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 1.3rem;
  font-weight: 600;
  box-shadow: 0 4px 0 #d9c8f5;
}
.catch-target b { font-size: 2rem; color: var(--pink); vertical-align: middle; }
.catch-target.flash { animation: pop .5s ease; }
button.catch-target { border: none; color: var(--ink); font-family: inherit; }
.catch-target::after { content: ' 🔊'; font-size: 1rem; }

/* Penalty pause after a wrong tap */
.catch-area.dizzy .fstar { filter: grayscale(.7) blur(1px); }
.catch-area.dizzy::after {
  content: attr(data-dizzy);
  position: absolute;
  left: 0;
  right: 0;
  top: 40%;
  z-index: 4;
  width: max-content;
  max-width: 90%;
  margin: 0 auto;
  padding: 12px 22px;
  border-radius: 999px;
  background: #fff;
  color: var(--pink-dark);
  font-size: clamp(1.1rem, 4.5vw, 1.5rem);
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 0 #d9c8f5;
  animation: pop .4s ease;
  pointer-events: none;
}
.catch-stats { display: flex; gap: 8px; }
.catch-stats { position: relative; z-index: 5; } /* the +10s pop drifts over the star area */
.time-pill { position: relative; }
.time-pill.bonus { animation: timeFlash 1.2s ease; }
@keyframes timeFlash {
  0%, 100% { background: #fff; transform: scale(1); }
  20% { background: #b2f2bb; transform: scale(1.18); }
  60% { background: #d3f9d8; transform: scale(1); }
}
.time-bonus {
  position: absolute;
  left: 50%;
  top: 100%;
  margin-left: -1.4em;
  color: #2f9e44;
  font-weight: 700;
  font-size: 1.3rem;
  text-shadow: 0 2px 0 #fff, 0 0 8px #fff;
  pointer-events: none;
  z-index: 20;
  animation: timeBonus 1.4s ease-out forwards;
}
@keyframes timeBonus {
  0% { transform: translateY(-6px) scale(.6); opacity: 0; }
  20% { transform: translateY(4px) scale(1.15); opacity: 1; }
  100% { transform: translateY(28px) scale(1); opacity: 0; }
}

.catch-area {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 860px;
  min-height: 300px;
  border-radius: 28px;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(2px 2px at 20% 30%, #fff, transparent),
    radial-gradient(2px 2px at 70% 20%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85% 60%, #fff, transparent),
    radial-gradient(2px 2px at 10% 85%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 45%, #fff, transparent),
    linear-gradient(180deg, #2b1f5c, #5f3dc4 65%, #9775fa);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .3), 0 8px 0 rgba(95, 61, 196, .35);
}
.catch-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  color: #fff;
  background: rgba(43, 31, 92, .72);
}
.catch-overlay h3 { margin: 0; font-size: clamp(1.8rem, 7vw, 2.6rem); }
.catch-overlay p { margin: 0; font-size: 1.2rem; line-height: 1.45; }
.catch-overlay .best { font-size: 1.1rem; opacity: .9; }

.fstar {
  position: absolute;
  left: 0;
  top: -110px;
  width: 104px;
  height: 104px;
  padding: 0;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  will-change: transform;
}
.fstar svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 8px rgba(255, 236, 153, .75));
}
.fstar span { position: relative; font-weight: 700; font-size: 1.2rem; color: #5c3c00; margin-top: 6px; }
.fstar.nope { opacity: .55; }
.fstar.nope svg { filter: grayscale(1); }
.fstar.caught > * { animation: caught .35s ease forwards; }
.fstar.picked svg { filter: drop-shadow(0 0 0 4px #fff) drop-shadow(0 0 14px #fff) drop-shadow(0 0 6px var(--focus)); }
.fstar.picked::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 4px dashed #fff;
  border-radius: 50%;
  animation: spin 4s linear infinite;
}
@keyframes caught {
  to { transform: scale(1.8); opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Closet ---------- */
.closet-stage {
  background: rgba(255, 255, 255, .55);
  border-radius: 30px;
  padding: 10px 30px 4px;
  flex-shrink: 0;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; flex-shrink: 0; }
.tab {
  border: none;
  background: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 52px;
  font-weight: 600;
  font-size: 1.05rem;
  box-shadow: 0 4px 0 #d9c8f5;
}
.tab.active { background: var(--purple); color: #fff; box-shadow: 0 4px 0 var(--purple-dark); }
.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 720px;
  flex-shrink: 0;
}
.item {
  background: #fff;
  border: 4px solid transparent;
  border-radius: 20px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: .98rem;
  box-shadow: 0 4px 0 #e0d0fa;
  min-height: 108px;
}
.item.on { border-color: var(--pink); background: #fff0f8; }
.item.confirm { border-color: var(--gold); background: #fff9db; animation: pop .4s ease; }
.closet-actions { flex-shrink: 0; margin-top: 0; }
.item .sw {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 3px solid #eadcff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}
.item.locked .sw { opacity: .55; }
.item .sw-style { width: 64px; height: 60px; border-radius: 16px; background: #faf7ff; overflow: hidden; }
.item .sw-style .unicorn-svg { width: 100%; height: 100%; }
.item .sw-pet { background: #fff7ed; }

/* ---------- Sticker Book ---------- */
.sticker-tabs .tab { font-size: 1.5rem; min-width: 60px; }
.sticker-page { --pc: #ff922b; max-width: 560px; border-top: 10px solid var(--pc); text-align: center; flex-shrink: 0; }
.sticker-title { margin: 0 0 10px; font-size: 1.4rem; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sticker {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  font-size: clamp(2rem, 9vw, 3.2rem);
  border-radius: 18px;
  background: color-mix(in srgb, var(--pc, #ff922b) 14%, #fff);
  border: 3px solid #fff;
  box-shadow: 0 3px 6px rgba(120, 70, 180, .22);
  transform: rotate(var(--tilt, 0deg));
}
.sticker.empty { background: #f5f0ff; color: #cbbcef; font-weight: 700; font-size: clamp(1.4rem, 6vw, 2rem); box-shadow: inset 0 0 0 3px #e5dbff; filter: none; transform: none; border: 2px dashed #d0bfff; }
.sticker.fresh { animation: pop .6s ease 2; }
.sticker-count { margin: 10px 0 0; font-weight: 600; color: var(--ink-soft); }
.pack-overlay { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(75, 46, 111, .45); }
.pack-card { max-width: 420px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.pack-card h3 { margin: 0; font-size: 1.6rem; }
.pack-reveal { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.pack-reveal .sticker { width: 90px; font-size: 3.4rem; }
.pack-reveal .sticker.pop { animation: stickerIn .6s backwards cubic-bezier(.3, 1.6, .5, 1); }
.pack-bonus { width: 100%; margin: 0; font-weight: 700; color: var(--pink-dark); }
@keyframes stickerIn { from { transform: scale(0) rotate(-200deg); opacity: 0; } to { transform: none; opacity: 1; } }
.item .cost { font-size: .9rem; font-weight: 700; color: var(--purple-dark); }
.item.on .cost { color: var(--pink-dark); }

/* ---------- Castle ---------- */
.castle-stage {
  position: relative;
  width: 100%;
  max-width: 640px;
  flex-shrink: 0;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 8px 0 rgba(155, 109, 255, .18), 0 14px 30px rgba(120, 70, 180, .15);
}
.castle-svg { display: block; width: 100%; height: auto; }
.castle-unicorn { position: absolute; left: 1%; bottom: 1%; width: 27%; }
.castle-art.locked .castle { filter: grayscale(1); opacity: .35; }
.castle-art.locked::after {
  content: '🔒';
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-size: clamp(2.4rem, 10vw, 4rem);
}
.castle-locked { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 520px; }
.castle-locked h3 { margin: 0; font-size: clamp(1.3rem, 5vw, 1.7rem); }
.castle-locked p { margin: 0; font-size: 1.15rem; font-weight: 600; }
.castle-locked .btn.confirm { background: linear-gradient(180deg, #ffe066, #fcc419); color: #6b4b00; box-shadow: 0 5px 0 var(--gold-dark); animation: pop .4s ease; }
.progress { width: 100%; max-width: 360px; height: 18px; border-radius: 99px; background: #f1ebff; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .08); }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: var(--rainbow); transition: width .6s ease; }
.castle-shop { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }

.c-flag { transform-box: fill-box; transform-origin: left center; animation: wave 1.6s ease-in-out infinite; }
.c-bulb { animation: twinkle 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.c-burst { transform-box: fill-box; transform-origin: center; animation: burst 2.4s ease-out infinite; }
.c-water { animation: water 0.8s linear infinite; }
.c-balloons { animation: bob 3s ease-in-out infinite; }
@keyframes wave {
  0%, 100% { transform: skewY(0deg) scaleX(1); }
  50% { transform: skewY(8deg) scaleX(.85); }
}
@keyframes burst {
  0% { transform: scale(.1); opacity: 0; }
  15% { opacity: 1; }
  60% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}
@keyframes water { to { stroke-dashoffset: -18; } }

/* Holiday + inside decorations */
.u-flutter { animation: flutter .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes flutter { from { transform: scaleX(1); } to { transform: scaleX(.55); } }
.u-glow { animation: glowPulse 3s ease-in-out infinite; }
@keyframes glowPulse { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }
.u-float, .c-float { animation: floatUp 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes floatUp {
  0% { transform: translateY(4px); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(-14px); opacity: 0; }
}
.c-bat { animation: batFlap .45s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes batFlap {
  from { transform: scaleY(1); }
  to { transform: scaleY(.55) translateY(-2px); }
}
.c-snow { animation: snowFall 6s linear infinite; }
@keyframes snowFall {
  from { transform: translate(0, 0); }
  to { transform: translate(-14px, 320px); }
}
.c-sway { animation: sway 3.2s ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}
.c-rock { animation: rock 2.4s ease-in-out infinite; }
@keyframes rock {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
.c-flame { animation: flicker .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes flicker {
  from { transform: scale(1, 1); }
  to { transform: scale(.9, 1.12); }
}
.castle-door {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 44px;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 3px 0 #d9c8f5;
}

/* Title: castle behind the unicorn */
.title-scene { position: relative; display: flex; justify-content: center; flex-shrink: 0; }
.title-scene.has-castle { width: min(84vw, 460px); margin-bottom: 10px; }
.title-castle .castle-svg { border-radius: 26px; box-shadow: 0 8px 0 rgba(155, 109, 255, .18), 0 14px 30px rgba(120, 70, 180, .15); }
.title-scene.has-castle .unicorn-slot.big { position: absolute; left: 0; bottom: -7%; width: 44%; }

/* Treats */
.fx-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.fx-badges:empty { display: none; }
.fx-badge { font-size: 1rem; padding: 6px 12px; }
.fly-treat {
  position: absolute;
  font-size: 2.6rem;
  transform: translate(-50%, -50%);
  transition: transform .6s cubic-bezier(.3, -.3, .6, 1);
}
.unicorn-slot.fx-bounce .unicorn-svg { animation: bounceFx .6s ease-in-out infinite; }
@keyframes bounceFx {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}
.unicorn-slot.fx-glow .unicorn-svg { filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 14px #ff8fc8) drop-shadow(0 0 22px #b197fc); }
.unicorn-slot.fx-rainbow { animation: hue 3s linear infinite; }
@keyframes hue {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}
.unicorn-slot.fx-giant { scale: 1.3; transform-origin: 50% 100%; }
.unicorn-slot { transition: scale .5s ease; }
.unicorn-slot.fx-hop .unicorn-svg { animation: hop .8s ease; }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-26px) rotate(-4deg); }
  60% { transform: translateY(0); }
  75% { transform: translateY(-8px); }
}

/* ---------- Settings ---------- */
.settings { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.set-label { font-weight: 700; font-size: 1.15rem; margin-top: 4px; }
.text-input {
  font: inherit;
  font-size: 1.3rem;
  padding: 12px 16px;
  border-radius: 16px;
  border: 3px solid var(--edge);
  color: var(--ink);
  outline: none;
}
.text-input:focus { border-color: var(--purple); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 120px;
  min-height: 56px;
  border: 3px solid var(--edge);
  background: #fff;
  border-radius: 16px;
  font-weight: 600;
  font-size: 1.05rem;
}
.seg button.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.set-note { margin: 0; color: var(--ink-soft); font-size: .98rem; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 1.1rem; font-weight: 500; }
.switch {
  flex-shrink: 0;
  width: 76px;
  height: 42px;
  border-radius: 999px;
  border: none;
  background: #dee2e6;
  position: relative;
  transition: background .2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
  transition: left .2s;
}
.switch[aria-checked="true"] { background: var(--mint); }
.switch[aria-checked="true"]::after { left: 38px; }
.skills { margin: 0; padding-left: 4px; list-style: none; line-height: 1.7; font-size: 1rem; }
.keys { margin: 0; line-height: 1.7; font-size: 1rem; }
.keys kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 6px;
  border-radius: 6px;
  border: 2px solid var(--edge);
  border-bottom-width: 4px;
  background: #faf7ff;
  font-family: inherit;
  font-weight: 600;
  text-align: center;
}

/* ---------- FX ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 50;
  transform: translate(-50%, 160%);
  visibility: hidden;
  max-width: calc(100% - 32px);
  padding: 12px 22px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  font-size: 1.15rem;
  text-align: center;
  box-shadow: 0 6px 0 #d9c8f5, 0 10px 24px rgba(120, 70, 180, .25);
  transition: transform .3s cubic-bezier(.4, 1.6, .5, 1);
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.spark {
  position: absolute;
  font-size: 22px;
  animation: fly .8s ease-out forwards;
}
@keyframes fly {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3) rotate(160deg); opacity: 0; }
}
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }

@media (min-width: 700px) and (min-height: 800px) {
  .choice { min-height: 110px; font-size: 2.6rem; }
  .choices { gap: 18px; }
}

/* ---------- Small / landscape phones ---------- */
@media (max-height: 560px) {
  .unicorn-slot.big { width: 150px; }
  .logo { font-size: 2.4rem; }
  .track { height: 58px; }
  .track-unicorn { width: 54px; }
  .choice { min-height: 64px; font-size: 1.6rem; }
  .ten { height: 110px; width: 12px; background: repeating-linear-gradient(to bottom, #74c0fc 0 9px, #1c7ed6 9px 11px); }
  .hundred { width: 70px; height: 70px; background:
    repeating-linear-gradient(to right, transparent 0 6px, #2f9e44 6px 7px),
    repeating-linear-gradient(to bottom, #8ce99a 0 6px, #2f9e44 6px 7px); }
  .one { width: 10px; height: 10px; }
  .ones { grid-template-columns: repeat(2, 14px); }
}

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

.voice-row { display: flex; gap: 10px; align-items: center; }
.voice-pick {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 8px 12px;
  border: 3px solid #e5dbff;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}
.voice-pick:focus { border-color: #b197fc; outline: none; }
.voice-row .btn { flex: 0 0 auto; min-height: 50px; padding: 10px 18px; font-size: 1rem; }
