/* Bright cartoon space: a deep blue sky, white "paper" cards with thick dark outlines and
   hard drop shadows, candy-coloured buttons, smiling planets. Baloo 2 for Hindi and English. */

@font-face {
  font-family: "Baloo 2";
  src: url(../fonts/baloo2-devanagari.woff2) format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF;
}
@font-face {
  font-family: "Baloo 2";
  src: url(../fonts/baloo2-latin.woff2) format("woff2");
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212;
}

:root {
  /* sky */
  --sky: #2a2a8f;
  --sky-glow-1: #4b3bd6;
  --sky-glow-2: #1b6fe0;
  --ink: #ffffff;
  --muted: #d6d2ff;
  /* outlines + paper cards */
  --outline: #1a1446;
  --paper: #ffffff;
  --paper-ink: #1a1446;
  --paper-muted: #5b5790;
  --paper-soft: #f1efff;
  --line: #d9d5f5;
  /* candy */
  --yellow: #ffd23f;
  --cyan: #7ef0ff;
  --pink: #ff9ecb;
  --lime: #9dff8a;
  --orange: #ff8a3d;
  --red: #ff5d8f;
  --violet: #b9a6ff;
  --go: #2bd96b;
  --go-soft: #c9f7da;
  --bad: #ff4d6d;
  --font: "Baloo 2", ui-rounded, "Kohinoor Devanagari", "Noto Sans Devanagari", "Nirmala UI",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --deva: var(--font);
  --edge: 4px solid var(--outline);
  --drop: 0 6px 0 var(--outline);
  color-scheme: dark;
  /* Safe-area padding sits on :root (as in the Claude artifact skeleton) so it is never doubled. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  --safe-y: calc(env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; text-wrap: balance; }
.deva { font-family: var(--deva); }
.muted { color: var(--muted); }
.center { text-align: center; }
.fine { font-size: 0.9rem; color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }

/* ---------- sky: glows, outlined candy stars, two smiling planets ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 8%, var(--sky-glow-1) 0 18%, transparent 46%),
    radial-gradient(circle at 92% 88%, var(--sky-glow-2) 0 16%, transparent 50%),
    var(--sky);
}
.stars { position: absolute; inset: 0; background-repeat: repeat; }
.stars.s1 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='340' height='340'%3E%3Cg stroke='%231a1446' stroke-width='2.5' stroke-linejoin='round'%3E%3Cpolygon transform='translate(40 60)' fill='%23ffd23f' points='0,-12 2.94,-4.05 11.41,-3.71 4.76,1.55 7.05,9.71 0,5 -7.05,9.71 -4.76,1.55 -11.41,-3.71 -2.94,-4.05'/%3E%3Cpolygon transform='translate(262 44) scale(.8)' fill='%23ff9ecb' points='0,-12 2.94,-4.05 11.41,-3.71 4.76,1.55 7.05,9.71 0,5 -7.05,9.71 -4.76,1.55 -11.41,-3.71 -2.94,-4.05'/%3E%3Cpolygon transform='translate(180 220) scale(1.1)' fill='%237ef0ff' points='0,-12 2.94,-4.05 11.41,-3.71 4.76,1.55 7.05,9.71 0,5 -7.05,9.71 -4.76,1.55 -11.41,-3.71 -2.94,-4.05'/%3E%3Cpolygon transform='translate(64 282) scale(.65)' fill='%239dff8a' points='0,-12 2.94,-4.05 11.41,-3.71 4.76,1.55 7.05,9.71 0,5 -7.05,9.71 -4.76,1.55 -11.41,-3.71 -2.94,-4.05'/%3E%3C/g%3E%3Cg fill='%23ffffff'%3E%3Ccircle cx='128' cy='34' r='2.2'/%3E%3Ccircle cx='300' cy='160' r='2.6'/%3E%3Ccircle cx='22' cy='176' r='1.8'/%3E%3Ccircle cx='224' cy='318' r='2'/%3E%3Ccircle cx='126' cy='140' r='1.6'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 340px 340px;
  animation: twinkle 3s ease-in-out infinite alternate;
}
.stars.s2 { display: none; }
.sky::before,
.sky::after {
  position: absolute;
  border: 5px solid var(--outline);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--outline);
  font-weight: 800;
  box-shadow: inset -10px -12px 0 rgba(26, 20, 70, 0.18);
}
.sky::before {
  content: "• ‿ •";
  width: 150px;
  height: 150px;
  right: -46px;
  bottom: -46px;
  padding: 0 40px 36px 0;
  background: var(--orange);
  font-size: 30px;
}
.sky::after {
  content: "";
  width: 62px;
  height: 62px;
  left: -18px;
  bottom: 30%;
  background: var(--lime);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 28px;
}
.screen { display: flex; flex-direction: column; gap: 16px; }

/* ---------- buttons & chips ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 54px;
  padding: 8px 22px;
  border: var(--edge);
  border-radius: 999px;
  background: var(--paper);
  color: var(--paper-ink);
  font: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--drop);
  transition: transform 0.08s, box-shadow 0.08s;
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--outline); }
.btn-primary { background: var(--yellow); }
.btn-ghost { background: var(--paper); }
.btn-danger { background: #ffe1e8; white-space: normal; }
.btn-danger.armed { background: var(--bad); color: #fff; }
.btn-big { width: 100%; min-height: 64px; font-size: 1.3rem; }
.btn-sm { min-height: 46px; padding: 4px 16px; font-size: 1rem; }
.btn .count { color: var(--paper-muted); font-weight: 700; }

.icon-btn {
  width: 50px;
  height: 50px;
  flex: none;
  display: grid;
  place-items: center;
  border: var(--edge);
  border-radius: 50%;
  background: var(--paper);
  color: var(--paper-ink);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--outline);
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 12px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 800;
  font-size: 1rem;
  white-space: nowrap;
}
.tag {
  display: inline-block;
  padding: 0 12px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: var(--cyan);
  color: var(--paper-ink);
  font-weight: 700;
}

.lang-toggle {
  display: inline-flex;
  padding: 3px;
  border: var(--edge);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--outline);
}
.lang-toggle button {
  min-height: 38px;
  min-width: 48px;
  padding: 2px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--paper-muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.lang-toggle button[aria-pressed="true"] { background: var(--cyan); color: var(--paper-ink); }

.stars-row { letter-spacing: 2px; font-size: 1.25rem; }
.stars-row .on { color: var(--yellow); text-shadow: 0 0 1px var(--outline), 0 2px 0 var(--outline); }
.stars-row .off { color: var(--line); }

/* ---------- Timtim ---------- */
.timtim { width: 96px; height: 96px; flex: none; }
.timtim.big { width: 148px; height: 148px; }
.timtim.mini { width: 48px; height: 48px; }
.timtim.float { animation: wiggle 2.6s ease-in-out infinite; }
.timtim.sad { filter: grayscale(0.4); }

.guide { display: flex; align-items: flex-end; gap: 10px; }
.bubble {
  flex: 1;
  position: relative;
  padding: 14px 18px;
  border: var(--edge);
  border-radius: 24px 24px 24px 6px;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 1.2rem;
  font-weight: 600;
  box-shadow: var(--drop);
}
.bubble .say-btn { margin-left: 6px; vertical-align: middle; }

/* ---------- welcome & story ---------- */
.top-right { display: flex; justify-content: flex-end; }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; margin-top: 4px; }
.title {
  margin: 8px 0 0;
  font-size: clamp(2.1rem, 8vw, 2.7rem);
  font-weight: 800;
  color: var(--ink);
  text-shadow: 0 4px 0 var(--outline);
}
.tagline { margin: 0; color: var(--yellow); font-weight: 800; font-size: 1.25rem; text-shadow: 0 2px 0 var(--outline); }

.card {
  padding: 18px;
  border: var(--edge);
  border-radius: 26px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: var(--drop);
}
.card h2 { margin: 0 0 10px; font-size: 1.3rem; }
.card h3 { margin: 12px 0 6px; font-size: 1.05rem; color: var(--paper-muted); }
.card .muted, .card small { color: var(--paper-muted); }
.name-form { display: flex; flex-direction: column; gap: 12px; }
.name-form label { font-weight: 800; font-size: 1.2rem; }
input:not([type]), input[type="text"] {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: var(--edge);
  border-radius: 18px;
  background: var(--paper-soft);
  color: var(--paper-ink);
  font: inherit;
  font-size: 1.3rem;
}

.story { min-height: calc(100dvh - 60px - var(--safe-y)); justify-content: center; }
.story-top { display: flex; justify-content: flex-end; }
.story-art { font-size: 100px; text-align: center; animation: bob 3s ease-in-out infinite; }
.dots { display: flex; justify-content: center; gap: 8px; }
.dots span { width: 12px; height: 12px; border: 2px solid var(--outline); border-radius: 50%; background: var(--paper); }
.dots span.on { background: var(--yellow); width: 30px; border-radius: 8px; }

/* ---------- galaxy ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.h-title { flex: 1; margin: 0; font-size: 1.6rem; text-align: center; text-shadow: 0 3px 0 var(--outline); }
.hello { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hello small { display: block; color: var(--muted); font-size: 0.95rem; font-weight: 700; }
.hello b { display: block; font-size: 1.35rem; text-shadow: 0 2px 0 var(--outline); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row-right { display: flex; align-items: center; gap: 10px; }
.section-title { margin: 6px 0 0; font-size: 1.2rem; font-weight: 800; color: var(--yellow); text-shadow: 0 2px 0 var(--outline); }

.planet-path {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.planet-path::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50px;
  bottom: 50px;
  border-left: 5px dashed rgba(255, 255, 255, 0.35);
  z-index: -1;
}
.pp, .pp-link { display: flex; align-items: center; gap: 16px; text-decoration: none; }
.pp.right, .pp.right .pp-link { flex-direction: row-reverse; text-align: right; }
.pp.left { padding-right: 10%; }
.pp.right { padding-left: 10%; }
.pp-label { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.pp.right .pp-label { align-items: flex-end; }
.pp-label b { font-size: 1.4rem; text-shadow: 0 3px 0 var(--outline); }
.pp-label small { color: var(--muted); font-weight: 600; }
.pp.soon .pp-label { opacity: 0.8; }

.planet {
  --size: 108px;
  position: relative;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: grid;
  place-items: center;
  border: 5px solid var(--outline);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.6) 0 9%, transparent 10%), var(--c1);
  box-shadow: inset -12px -14px 0 rgba(26, 20, 70, 0.2), 0 6px 0 var(--outline);
  animation: bob 5s ease-in-out infinite;
}
/* every planet has a face; planets still to come are asleep */
.planet::before {
  content: "• ‿ •";
  color: var(--outline);
  font-weight: 800;
  font-size: calc(var(--size) * 0.24);
  letter-spacing: 1px;
  transform: translateY(-30%);
}
.pp.soon .planet { filter: saturate(0.45) brightness(0.85); animation: none; }
.pp.soon .planet::before { content: "– ‿ –"; }
.planet .q { position: absolute; top: -10px; right: -12px; font-size: 1.6rem; }
.planet.ring::after {
  content: "";
  position: absolute;
  left: -24%;
  right: -24%;
  top: 52%;
  height: 24%;
  border: 6px solid var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--outline), inset 0 0 0 3px var(--outline);
  transform: rotate(-16deg);
  pointer-events: none;
}
.planet.big { --size: 160px; margin: 6px auto 4px; }
.pp-link:active .planet { transform: scale(0.95); }

/* ---------- planet levels ---------- */
.level-path { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ln-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: var(--edge);
  border-radius: 24px;
  background: var(--paper);
  color: var(--paper-ink);
  text-decoration: none;
  box-shadow: var(--drop);
}
a.ln-link:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--outline); }
.ln-btn {
  width: 62px;
  height: 62px;
  flex: none;
  display: grid;
  place-items: center;
  border: var(--edge);
  border-radius: 50%;
  background: var(--yellow);
  font-size: 28px;
}
.ln.done .ln-btn { background: var(--go); }
.ln.boss .ln-btn { background: var(--pink); }
.ln.locked .ln-link { background: #dcd8f2; box-shadow: 0 6px 0 rgba(26, 20, 70, 0.55); }
.ln.locked .ln-btn { background: #c4bfe3; }
.ln-label { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.ln-label small { color: var(--paper-muted); font-weight: 600; }
.ln-label b { font-size: 1.25rem; }

.chapter { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.ch-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ch-head small { color: var(--muted); font-weight: 700; }
.ch-head h2 { margin: 0; font-size: 1.6rem; text-shadow: 0 3px 0 var(--outline); }
.value-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px;
  border: 3px dashed rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  font-size: 1rem;
}
.value-chip.won {
  border: 3px solid var(--outline);
  background: var(--yellow);
  color: var(--paper-ink);
  box-shadow: 0 3px 0 var(--outline);
}

/* ---------- level intro ---------- */
.intro-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.intro-hero h1 { margin: 0; font-size: 2rem; text-shadow: 0 4px 0 var(--outline); }
.intro-ico { font-size: 80px; line-height: 1.1; animation: bob 3s ease-in-out infinite; }

/* ---------- game frame ---------- */
.game { display: flex; flex-direction: column; gap: 14px; min-height: calc(100dvh - 48px - var(--safe-y)); position: relative; }
.game-top { display: flex; align-items: center; gap: 12px; }
.game-top .icon-btn { background: var(--red); color: #fff; }
.fuel {
  flex: 1;
  position: relative;
  height: 26px;
  border: var(--edge);
  border-radius: 999px;
  background: var(--outline);
}
.fuel-fill {
  position: relative;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: repeating-linear-gradient(135deg, var(--yellow) 0 10px, #ffb800 10px 20px);
  transition: width 0.4s ease;
}
.fuel-fill::after {
  content: "🚀";
  position: absolute;
  right: -16px;
  top: 50%;
  font-size: 24px;
  line-height: 1;
  transform: translateY(-50%) rotate(45deg);
}
.game.type-meteor .fuel-fill { background: repeating-linear-gradient(135deg, var(--red) 0 10px, var(--orange) 10px 20px); transition: width 0.1s linear; }
.game.type-meteor .fuel-fill::after { content: "⏳"; transform: translateY(-50%); }
.game.hurry .fuel { animation: blink 0.6s infinite; }
.streak {
  min-width: 66px;
  height: 46px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: var(--edge);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--paper-muted);
  font-weight: 800;
  font-size: 1.15rem;
}
.streak.hot { background: var(--orange); color: var(--paper-ink); }
.streak.bump { animation: pop 0.35s; }
.game-body { flex: 1; display: flex; flex-direction: column; gap: 16px; position: relative; z-index: 1; }
.game-foot { min-height: 64px; position: relative; z-index: 1; }

.q-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border: var(--edge);
  border-radius: 26px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: var(--drop);
}
.q-card .muted { color: var(--paper-muted); }
.q-pic { font-size: 88px; line-height: 1.05; }
.q-pic.sm { font-size: 60px; }
.q-prompt { margin: 0; text-align: center; font-weight: 800; font-size: 1.25rem; }
.game-body > .q-prompt, .m-q > .q-prompt { text-shadow: 0 2px 0 var(--outline); }
.q-prompt.big { font-size: 1.55rem; }
.say-btn {
  min-height: 44px;
  padding: 2px 18px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: var(--cyan);
  color: var(--paper-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--outline);
}
.say-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.say-btn.sm { min-height: 36px; padding: 0 10px; }

/* Answer buttons: each one a different candy colour */
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.opts.three { grid-template-columns: 1fr; }
.opt {
  position: relative;
  min-height: 76px;
  padding: 6px;
  border: var(--edge);
  border-radius: 24px;
  background: var(--yellow);
  color: var(--paper-ink);
  font: inherit;
  font-size: 2rem;
  font-weight: 700;
  box-shadow: var(--drop);
  cursor: pointer;
  transition: transform 0.08s;
}
.opt:nth-child(4n + 2) { background: var(--cyan); }
.opt:nth-child(4n + 3) { background: var(--pink); }
.opt:nth-child(4n + 4) { background: var(--lime); }
.opts.three .opt { min-height: 64px; font-size: 1.7rem; }
.opt:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--outline); }
.opt:disabled { cursor: default; color: var(--paper-ink); }
.opt.good { background: var(--go); animation: pop 0.35s; }
.opt.good::after {
  content: "✓";
  position: absolute;
  top: -14px;
  right: -10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid var(--outline);
  border-radius: 50%;
  background: var(--paper);
  font-size: 1.1rem;
  font-weight: 800;
}
.opt.bad { background: var(--bad); color: #fff; animation: shake 0.4s; }
.opt.small-text { font-size: 1.35rem; min-height: 62px; line-height: 1.25; }

.fix {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border: var(--edge);
  border-radius: 22px;
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: var(--drop);
}
.fix b { font-size: 1.7rem; color: #0f8a43; }

/* ---------- build (matra machine) ---------- */
.word-tiles { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.tile {
  min-width: 66px;
  height: 80px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--edge);
  border-radius: 18px;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 2.5rem;
  font-weight: 700;
  box-shadow: var(--drop);
}
.tile.open { background: var(--paper-soft); }
.tile .slot { display: inline-block; width: 24px; height: 40px; margin-left: 4px; border: 3px dashed var(--paper-muted); border-radius: 8px; }
.tile.active .slot { border-color: var(--orange); background: #ffe6d4; animation: blink 1s infinite; }
.tile.done { background: var(--go-soft); animation: pop 0.3s; }
.word-tiles.win .tile { background: var(--go); }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.mtile {
  min-height: 66px;
  padding: 2px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: var(--edge);
  border-radius: 18px;
  background: var(--paper);
  color: var(--paper-ink);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--outline);
}
.mtile:nth-child(3n + 2) { background: #e7fbff; }
.mtile:nth-child(3n + 3) { background: #fff0f7; }
.mtile span { font-size: 1.9rem; line-height: 1.1; }
.mtile small { font-size: 0.85rem; color: var(--paper-muted); font-weight: 700; }
.mtile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.mtile.hint { background: var(--yellow); animation: pulse 1s infinite; }
.mtile.shake { background: var(--bad); color: #fff; animation: shake 0.4s; }
.mtile.shake small { color: #fff; }

/* ---------- sort (two doors) ---------- */
.sort-stage { height: 210px; display: grid; place-items: center; }
.sort-card {
  width: 210px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: var(--edge);
  border-radius: 26px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 8px 0 var(--outline);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  transition: transform 0.4s ease, opacity 0.4s ease;
}
.sort-card.enter { animation: enter 0.35s ease; }
.sort-card.dragging { transition: none; cursor: grabbing; z-index: 5; }
.sc-pic { font-size: 58px; line-height: 1.05; }
.sc-word { font-size: 2.3rem; font-weight: 700; }
.bins { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.bin {
  position: relative;
  min-height: 156px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  border: var(--edge);
  border-radius: 26px;
  background: var(--cyan);
  color: var(--paper-ink);
  font: inherit;
  cursor: pointer;
  box-shadow: var(--drop);
  transition: transform 0.15s;
}
.bin[data-g="f"] { background: var(--pink); }
.bin.over { transform: scale(1.05); }
.bin.good { background: var(--go); animation: pop 0.35s; }
.bin.bad { background: var(--bad); color: #fff; animation: shake 0.4s; }
.bin-ico { font-size: 2.6rem; }
.bin b { font-size: 1.55rem; }
.bin small { color: var(--paper-ink); font-weight: 600; opacity: 0.75; }
.bin-count {
  position: absolute;
  top: -12px;
  right: -8px;
  min-width: 34px;
  padding: 0 8px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 800;
}

/* ---------- match ---------- */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.col h3 { margin: 0; text-align: center; font-size: 1.2rem; text-shadow: 0 2px 0 var(--outline); }
.col h3 small { color: var(--muted); font-weight: 600; }
.mbtn {
  min-height: 62px;
  padding: 4px 6px;
  border: var(--edge);
  border-radius: 18px;
  background: var(--paper);
  color: var(--paper-ink);
  font: inherit;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 5px 0 var(--outline);
  cursor: pointer;
  transition: transform 0.1s;
}
.mbtn.sel { background: var(--yellow); transform: translateY(-3px); }
.mbtn.bad { background: var(--bad); color: #fff; animation: shake 0.4s; }
.mbtn.paired { cursor: default; animation: pop 0.3s; }
.mbtn.p0 { background: var(--lime); }
.mbtn.p1 { background: var(--cyan); }
.mbtn.p2 { background: var(--pink); }
.mbtn.p3 { background: #ffc58f; }
.mbtn.p4 { background: var(--violet); }
.mbtn.p5 { background: #fff3a6; }
.mbtn.long { font-size: 1.15rem; }
.mbtn .gloss { display: block; font-size: 0.8rem; font-weight: 600; color: var(--paper-muted); }

/* ---------- story pages ---------- */
.story-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  border: var(--edge);
  border-radius: 28px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: var(--drop);
  text-align: center;
  animation: enter 0.3s ease;
}
.story-title { margin: 0; font-size: 1.6rem; color: #6a3fd1; }
.story-pic { font-size: 78px; line-height: 1.05; }
.story-text { margin: 0; font-size: 1.45rem; line-height: 1.6; font-weight: 600; }
.story-nav { display: flex; gap: 10px; }
.btn-grow { flex: 1; }

/* ---------- spot + order (word chips) ---------- */
.spot-card, .sentence-card { gap: 14px; }
.chips-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.wchip {
  min-height: 56px;
  padding: 2px 14px;
  border: var(--edge);
  border-radius: 16px;
  background: var(--paper);
  color: var(--paper-ink);
  font: inherit;
  font-size: 1.65rem;
  font-weight: 700;
  box-shadow: 0 4px 0 var(--outline);
  cursor: pointer;
}
.chips-line .wchip:nth-child(4n + 2) { background: #e7fbff; }
.chips-line .wchip:nth-child(4n + 3) { background: #fff0f7; }
.chips-line .wchip:nth-child(4n + 4) { background: #efffe9; }
.wchip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.wchip.good { background: var(--go); animation: pop 0.3s; }
.wchip.bad { background: var(--bad); color: #fff; animation: shake 0.4s; }
.wchip.hint { background: var(--yellow); animation: pulse 1s infinite; }
.danda { font-size: 1.9rem; font-weight: 700; }
.center-self { align-self: center; }
.sentence-card { min-height: 96px; justify-content: center; }
.wchip.placed { background: var(--go-soft); cursor: default; }
.sentence-card.win .wchip.placed { background: var(--go); animation: pop 0.3s; }
.wchip.used { opacity: 0.25; box-shadow: none; cursor: default; }
.slot-chip { width: 56px; height: 56px; border: 3px dashed var(--paper-muted); border-radius: 16px; }

/* ---------- meteor ---------- */
.meteor-hud { display: flex; justify-content: space-between; }
.meteor-hud div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 96px;
  padding: 4px 14px;
  border: var(--edge);
  border-radius: 20px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 4px 0 var(--outline);
}
.meteor-hud small { color: var(--paper-muted); font-weight: 700; }
.meteor-hud b { font-size: 2.1rem; line-height: 1; }
.game.hurry [data-time] { color: var(--bad); }
.meteor-card { min-height: 150px; justify-content: center; }
.m-q { display: flex; flex-direction: column; gap: 14px; }
.meteor-field { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.falling { position: absolute; top: -60px; font-size: 34px; animation: fall linear infinite; }
.falling:nth-child(1) { left: 20%; animation-duration: 6s; }
.falling:nth-child(2) { left: 55%; animation-duration: 8s; animation-delay: 1.5s; }
.falling:nth-child(3) { left: 90%; animation-duration: 7s; animation-delay: 3s; }
.falling:nth-child(4) { left: 75%; animation-duration: 9s; animation-delay: 0.7s; font-size: 24px; }
.falling:nth-child(5) { left: 105%; animation-duration: 6.5s; animation-delay: 4s; }
.falling:nth-child(6) { left: 40%; animation-duration: 10s; animation-delay: 2.2s; font-size: 22px; }

/* ---------- result ---------- */
.result { align-items: center; text-align: center; padding-top: 16px; position: relative; }
.result h1 { margin: 0; font-size: 2.3rem; text-shadow: 0 4px 0 var(--outline); }
.result-stars { display: flex; gap: 12px; font-size: 72px; line-height: 1; }
.rstar { color: #4a4596; text-shadow: 0 0 2px var(--outline), 0 5px 0 var(--outline); animation: starIn 0.5s var(--d) both; }
.rstar.on { color: var(--yellow); }
.score-line { margin: 0; font-weight: 800; font-size: 1.25rem; }
.story-line { margin: 0; color: var(--muted); font-size: 1.1rem; }
.new-badges {
  width: 100%;
  padding: 14px;
  border: var(--edge);
  border-radius: 26px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: var(--drop);
}
.new-badges h2 { margin: 0 0 10px; font-size: 1.3rem; }
.nb-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.nb { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 110px; animation: pop 0.5s; }
.actions { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: -1; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 16px; border: 2px solid var(--outline); border-radius: 3px; animation: confetti linear forwards; }

/* Badges look like stickers: a coloured disc with a white rim and a dark outline */
.b-ico {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: var(--edge);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 5px var(--paper), 0 0 0 9px var(--outline);
  font-size: 40px;
  transform: rotate(-6deg);
}
.nb:nth-child(3n + 2) .b-ico, .badge:nth-child(3n + 2) .b-ico { background: var(--cyan); transform: rotate(5deg); }
.nb:nth-child(3n + 3) .b-ico, .badge:nth-child(3n + 3) .b-ico { background: var(--pink); transform: rotate(-2deg); }
.nb .b-ico { width: 64px; height: 64px; font-size: 34px; margin: 8px 0 6px; }

/* ---------- badges screen ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 10px 14px;
  border: var(--edge);
  border-radius: 24px;
  background: var(--paper);
  color: var(--paper-ink);
  text-align: center;
  box-shadow: var(--drop);
}
.badge b { font-size: 1.1rem; margin-top: 8px; }
.badge small { color: var(--paper-muted); line-height: 1.25; }
.badge.locked { background: #dcd8f2; }
.badge.locked .b-ico { background: #c4bfe3; box-shadow: 0 0 0 5px #ece9fb, 0 0 0 9px #9d97c7; filter: grayscale(1); }
.badges .section-title { margin-top: 14px; }

/* ---------- parents ---------- */
.parents p { margin: 0 0 10px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-bottom: 2px dashed var(--line); }
.name-row { flex-direction: column; align-items: stretch; border: 0; padding-top: 8px; gap: 6px; }
.name-row .inline { display: flex; gap: 8px; }
.name-row input { min-height: 50px; font-size: 1.15rem; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 62px;
  height: 36px;
  flex: none;
  margin: 0;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: #dcd8f2;
  cursor: pointer;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border: 3px solid var(--outline);
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch:checked { background: var(--go); }
.switch:checked::after { transform: translateX(26px); }
.progress-table { width: 100%; border-collapse: collapse; }
.progress-table td { padding: 8px 0; border-bottom: 2px dashed var(--line); vertical-align: middle; }
.progress-table td:last-child { text-align: right; white-space: nowrap; }
.covered { margin: 0; padding-left: 20px; }
.covered li { margin-bottom: 6px; }
.actions-card { display: flex; flex-direction: column; gap: 12px; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 0; right: 0; top: 22%; display: flex; justify-content: center; pointer-events: none; z-index: 50; }
.toast-msg {
  position: absolute;
  padding: 4px 22px;
  border: var(--edge);
  border-radius: 999px;
  background: var(--yellow);
  color: var(--paper-ink);
  font-size: 1.6rem;
  font-weight: 800;
  box-shadow: var(--drop);
  animation: floatUp 1.2s ease forwards;
}
.toast-msg.bonus { background: var(--go); }

/* ---------- motion ---------- */
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes wiggle {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-6px) rotate(-6deg); }
  75% { transform: translateY(-3px) rotate(6deg); }
}
@keyframes blink { 50% { opacity: 0.45; } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes twinkle { from { opacity: 0.75; } to { opacity: 1; } }
@keyframes enter { from { opacity: 0; transform: translateY(24px) scale(0.9); } }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(12px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(-46px) scale(1); }
}
@keyframes starIn {
  0% { transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.25) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes fall { to { transform: translate(-40vw, 115vh); } }
@keyframes confetti { to { transform: translateY(110vh) rotate(720deg); } }

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

@media (max-width: 380px) {
  .opt { font-size: 1.7rem; }
  .mbtn { font-size: 1.3rem; }
  .tile { min-width: 58px; font-size: 2.1rem; }
  .palette { gap: 7px; }
  .b-ico { width: 64px; height: 64px; font-size: 34px; }
}

/* Tablets: a little more room and bigger type */
@media (min-width: 700px) {
  #app { max-width: 680px; padding-top: 24px; }
  body { font-size: 20px; }
  .badge-grid { grid-template-columns: repeat(3, 1fr); }
}
