:root {
  --bg: #f6f4ff;
  --card: #ffffff;
  --ink: #1f1a3d;
  --muted: #625c84;
  --line: #ddd8f3;
  --brand: #5b4bd6;
  --brand-soft: #ebe8ff;
  --good: #1d9e75;
  --good-soft: #e1f5ee;
  --bad: #d85a30;
  --bad-soft: #fdece6;
  --warn: #ba7517;
  --warn-soft: #faeeda;
  --radius: 16px;
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { flex: 1; font-weight: 800; font-size: 20px; color: var(--brand); }
.tag { font-size: 12px; font-weight: 700; color: var(--warn); background: var(--warn-soft); padding: 2px 8px; border-radius: 99px; vertical-align: middle; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 20px; }
main { max-width: 860px; margin: 0 auto; padding: 16px; padding-bottom: 48px; outline: none; }
h1 { font-size: 26px; margin: 8px 0 4px; }
h2 { font-size: 21px; margin: 8px 0; }
p { margin: 6px 0 12px; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.btn {
  min-height: 52px; padding: 10px 22px; border-radius: 14px; border: 2px solid var(--brand);
  background: var(--card); color: var(--brand); font-weight: 800; font-size: 18px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
input[type=text] {
  width: 100%; min-height: 52px; font: inherit; padding: 10px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card);
}
input[type=text]:focus { border-color: var(--brand); outline: none; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choice {
  border: 2px solid var(--line); background: var(--card); border-radius: var(--radius);
  padding: 14px; text-align: center; font-weight: 800; min-height: 64px;
}
.choice[aria-pressed=true] { border-color: var(--brand); background: var(--brand-soft); }
.choice small { display: block; font-weight: 600; color: var(--muted); }
.error { color: var(--bad); font-size: 15px; min-height: 20px; }

/* World map */
.worlds { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.world {
  position: relative; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card);
  padding: 14px; text-align: left; min-height: 150px; display: flex; flex-direction: column; gap: 4px;
}
.world .emoji { font-size: 38px; line-height: 1; }
.world .name { font-weight: 800; }
.world .blurb { font-size: 14px; color: var(--muted); }
.world .stars { font-size: 14px; color: var(--warn); font-weight: 800; margin-top: auto; }
.world.locked { opacity: .55; }
.world.locked .stars { color: var(--muted); }

/* Puzzle screen */
.puzzle-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.level-pill { font-size: 13px; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.progress { font-size: 14px; color: var(--muted); font-weight: 700; }
.prompt { font-size: 20px; font-weight: 700; margin: 4px 0 12px; }
.stage { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.hintbox { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); color: #633806; font-weight: 600; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 14px; font-weight: 800; }
.feedback.good { background: var(--good-soft); color: #085041; }
.feedback.bad { background: var(--bad-soft); color: #712b13; }
.why { margin-top: 12px; padding: 14px; border-radius: 14px; background: var(--brand-soft); }
.why h3 { margin: 0 0 6px; font-size: 18px; }
.why ol, .why ul { margin: 6px 0; padding-left: 22px; }
.why li { margin: 4px 0; }

/* Guess the rule */
.gr-wrap { display: grid; gap: 12px; }
.tokens { display: flex; flex-wrap: wrap; gap: 8px; }
.token {
  width: 64px; height: 64px; border-radius: 14px; border: 2px solid var(--line); background: #fff;
  display: grid; place-items: center; padding: 0; position: relative;
}
.token svg { width: 52px; height: 52px; }
.token.yes { border-color: var(--good); background: var(--good-soft); }
.token.no { border-color: var(--bad); background: var(--bad-soft); }
.token .mark { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; font-size: 14px; font-weight: 900; color: #fff; display: grid; place-items: center; }
.token.yes .mark { background: var(--good); }
.token.no .mark { background: var(--bad); }
.token[aria-pressed=true] { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px var(--brand-soft); }
.basket { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.basket > div { border-radius: 14px; padding: 10px; min-height: 90px; }
.basket .in { background: var(--good-soft); }
.basket .out { background: var(--bad-soft); }
.basket h4 { margin: 0 0 6px; font-size: 15px; }
.basket .tokens .token { width: 48px; height: 48px; }
.basket .tokens .token svg { width: 38px; height: 38px; }
.referee { display: flex; gap: 10px; align-items: center; font-weight: 700; }
.referee .face { font-size: 40px; }

/* Chat */
.phone { max-width: 440px; margin: 0 auto; background: #ece5dd; border-radius: 22px; padding: 10px; border: 6px solid #2c2c2a; }
.phone .chat-title { background: #075e54; color: #fff; border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 16px; margin-bottom: 8px; }
.msg { max-width: 82%; margin: 6px 0; padding: 7px 10px 4px; border-radius: 12px; background: #fff; font-size: 16px; }
.msg .who { font-size: 13px; font-weight: 800; }
.msg .time { font-size: 11px; color: #888; text-align: right; }
.avatars { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.avatar { border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 10px 6px; text-align: center; font-weight: 800; }
.avatar .dot { width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 4px; display: grid; place-items: center; color: #fff; font-size: 20px; }
.avatar[aria-pressed=true] { border-color: var(--brand); background: var(--brand-soft); }
.notes { margin-top: 12px; }
.notes table { border-collapse: collapse; width: 100%; font-size: 15px; }
.notes th, .notes td { border: 1px solid var(--line); text-align: center; padding: 0; }
.notes th { padding: 6px; background: #faf9ff; }
.notes td button { width: 100%; min-height: 40px; border: 0; background: transparent; font-size: 18px; font-weight: 900; }

/* Scene */
.scene svg { width: 100%; height: auto; display: block; border-radius: 12px; touch-action: manipulation; }
.scene .obj { cursor: pointer; }
.scene .found-ring { fill: none; stroke: var(--good); stroke-width: 5; }
.scene .miss-ring { fill: none; stroke: var(--bad); stroke-width: 4; stroke-dasharray: 8 6; }
.counter { font-weight: 800; color: var(--brand); }

/* Recipe */
.steps { display: grid; gap: 8px; }
.step {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 12px; min-height: 56px; font-weight: 700;
}
.step .ico { font-size: 26px; }
.step .num { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 15px; flex: none; }
.step.placed { border-color: var(--brand); }
.step.bad { border-color: var(--bad); background: var(--bad-soft); }
.slots-title { font-weight: 800; margin: 10px 0 6px; }
.empty-slot { border: 2px dashed var(--line); border-radius: 14px; min-height: 56px; display: grid; place-items: center; color: var(--muted); font-size: 15px; }

/* Grown-ups */
table.stats { border-collapse: collapse; width: 100%; font-size: 15px; background: #fff; }
table.stats th, table.stats td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
.like-row { display: flex; gap: 14px; justify-content: center; margin-top: 12px; }
.like-row .btn { font-size: 30px; min-width: 110px; }
@media (max-width: 480px) {
  body { font-size: 17px; }
  .token { width: 56px; height: 56px; }
  .token svg { width: 44px; height: 44px; }
}
