@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(../fonts/nunito-latin.woff2) format('woff2');
}

:root {
  color-scheme: dark;
  --sky1: #141a3d;
  --sky2: #2c2363;
  --night-ink: #f4f1ff;
  --night-muted: #c4bfe6;
  --paper: #fffaf0;
  --ink: #1f2430;
  --muted: #676b78;
  --line: #e8dcc8;
  --gold: #ffd23f;
  --gold-deep: #f0a500;
  --good: #1f9d55;
  --good-soft: #dcfce7;
  --bad: #d64545;
  --bad-soft: #fee2e2;
  --try: #b45309;
  --try-soft: #fff1d6;
  --answer: #2f6fd8;
  --pond: #cdeefd;
  --protractor: #fff3c4;
  --glass: rgba(220, 240, 255, 0.55);
  --glass-line: #7a8fb3;
  --radius: 22px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 10px 30px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: linear-gradient(180deg, var(--sky1), var(--sky2)) fixed var(--sky2);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Nunito, system-ui, sans-serif;
  font-size: 19px;
  line-height: 1.4;
  color: var(--night-ink);
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 72%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 9%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 33%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 81% 14%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 91% 58%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 7% 88%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 92%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 74% 81%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 44%, #fff 50%, transparent 51%);
  opacity: 0.7;
  animation: twinkle 5s ease-in-out infinite alternate;
}

@keyframes twinkle { to { opacity: 0.35; } }

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.loading { text-align: center; padding: 40vh 0; }

h1, h2, h3 { margin: 0.2em 0 0.4em; line-height: 1.15; font-weight: 900; }

h2 { font-size: 1.25rem; }

a { color: inherit; }

.muted { color: var(--muted); }

button { font: inherit; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 22px;
  border: 0;
  border-radius: 16px;
  background: var(--gold);
  color: #2a1d00;
  font-weight: 900;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--gold-deep);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}

.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-deep); }

.btn:disabled { opacity: 0.45; cursor: default; }

.btn.big { min-height: 56px; font-size: 1.2rem; padding: 12px 28px; }

.btn.small { min-height: 42px; padding: 6px 14px; font-size: 1rem; }

.btn.secondary { background: #ece7ff; color: #3b2f8a; box-shadow: 0 4px 0 #c5bbf2; }

.btn.secondary:active:not(:disabled) { box-shadow: 0 1px 0 #c5bbf2; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  font-size: 1.3rem;
  text-decoration: none;
  cursor: pointer;
}

.row-center {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.link-quiet { color: var(--night-muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------- header */

.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  backdrop-filter: blur(6px);
}

.top h1 { flex: 1; font-size: 1.4rem; margin: 0; }

.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.logo { font-size: 1.7rem; letter-spacing: 0.01em; }

.sparks {
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(255, 210, 63, 0.18);
  color: var(--gold);
  font-weight: 800;
  white-space: nowrap;
}

.sparks .spark-n { color: #fff; }

.stars { color: #6a6790; letter-spacing: 2px; font-size: 1.1em; }

.stars .on { color: var(--gold); text-shadow: 0 0 8px rgba(255, 210, 63, 0.6); }

/* ---------------------------------------------------------------- pet bubble */

.pet-says { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 14px; }

.pet-face { font-size: 2.4rem; line-height: 1; display: inline-block; }

.pet-face.pop { animation: pop 0.5s; }

@keyframes pop { 40% { transform: scale(1.35) rotate(-8deg); } }

.bubble {
  position: relative;
  margin: 0;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 4px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 700;
}

/* ---------------------------------------------------------------- start */

.start { text-align: center; padding-top: 1vh; }

.start .lead { font-size: 1.15rem; max-width: 34em; margin: 0 auto 22px; color: var(--night-muted); }

.pet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 520px;
  margin: 0 auto 18px;
}

.pet-pick {
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 12px 6px;
  border: 3px solid transparent;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-weight: 800;
  cursor: pointer;
}

.pet-pick.on { border-color: var(--gold); background: rgba(255, 210, 63, 0.16); }

.pet-big { font-size: 3rem; line-height: 1.1; }

.name-label { display: block; margin: 0 auto 22px; font-weight: 700; }

.name-input {
  display: block;
  margin: 8px auto 0;
  width: min(280px, 100%);
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font: inherit;
  text-align: center;
}

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

.isle-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.isle-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
  transition: transform 0.15s;
}

.isle-card:not(.locked):hover { transform: translateY(-3px); border-color: var(--grass); }

.isle-card.done { border-color: var(--gold); box-shadow: 0 0 24px rgba(255, 210, 63, 0.25); }

.isle-card.locked { opacity: 0.55; filter: grayscale(0.7); }

.isle-card .lock { position: absolute; top: 12px; right: 14px; font-size: 1.4rem; }

.isle-art { width: 100%; max-width: 240px; animation: bob 4s ease-in-out infinite; }

.isle-glow { filter: blur(14px); }

.isle-card:nth-child(2n) .isle-art { animation-delay: -2s; }

@keyframes bob { 50% { transform: translateY(-6px); } }

.isle-info { text-align: center; }

.isle-info b { display: block; font-size: 1.25rem; }

.isle-info span { color: var(--night-muted); font-size: 0.95rem; }

.bottom-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; gap: 12px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- island */

.island-wrap { display: flex; justify-content: center; }

.island-svg { width: 100%; max-width: 520px; max-height: calc(100dvh - 170px); overflow: visible; }

.island-ground { fill: var(--grass); stroke: var(--rock); stroke-width: 14; opacity: 0.92; }

.trail { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 6; stroke-dasharray: 2 14; stroke-linecap: round; }

.node { cursor: pointer; outline: none; }

.node.closed { cursor: default; }

.node-glow { fill: var(--gold); opacity: 0; }

.node.lit .node-glow { opacity: 0.35; animation: glow 2.4s ease-in-out infinite; }

@keyframes glow { 50% { opacity: 0.6; } }

.node-disc { fill: #fffaf0; stroke: #3b2f8a; stroke-width: 4; transition: transform 0.15s; }

.node.closed .node-disc { fill: #b9b6cc; stroke: #6b6890; }

.node.lit .node-disc { fill: #ffe58a; stroke: var(--gold-deep); }

.node.beast .node-disc { fill: #d8d4ee; stroke: #4a4e69; }

.node.beast.lit .node-disc { fill: #fff3b0; }

.node:focus-visible .node-disc, .node:not(.closed):hover .node-disc { stroke: #ff7a59; }

.node-stars { fill: var(--gold); font-size: 16px; font-weight: 900; stroke: #3b2f8a; stroke-width: 0.6px; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(560px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  animation: rise 0.2s ease-out;
}

.sheet p { margin: 0.3em 0; }

.sheet .stars { color: #cfc9b8; }

@keyframes rise { from { transform: translate(-50%, 30px); opacity: 0; } }

/* ---------------------------------------------------------------- play */

.play-top { flex-wrap: wrap; }

.play-title { flex: 1; font-weight: 900; font-size: 1.15rem; min-width: 8em; }

.dots { display: flex; gap: 6px; }

.dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }

.dot.now { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3); }

.dot.good { background: #4ade80; }

.dot.ok { background: var(--gold); }

.dot.miss { background: #f87171; }

.dots.big { justify-content: center; margin: 12px 0; }

.dots.big .dot { width: 18px; height: 18px; }

.hearts { font-size: 1.3rem; letter-spacing: 2px; }

.beast-bar { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; font-weight: 800; }

.beast-bar .hp { flex: 1; height: 14px; border-radius: 99px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }

.beast-bar .hp i { display: block; height: 100%; background: linear-gradient(90deg, #8e8aa8, #d7d3ea); transition: width 0.5s; }

.prompt-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  font-weight: 700;
}

.prompt { flex: 1; }

.prompt b { color: #3b2f8a; font-weight: 900; }

.prompt-card .icon-btn { background: #ece7ff; color: #3b2f8a; }

.fill-sentence { display: block; margin-top: 8px; font-weight: 600; }

.blank { display: inline-block; min-width: 3.5em; border-bottom: 3px solid #3b2f8a; text-align: center; color: #3b2f8a; }

.stage {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.stage svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }

.feedback:empty { display: none; }

.feedback {
  position: sticky;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  animation: rise-in 0.2s ease-out;
}

@keyframes rise-in { from { transform: translateY(12px); opacity: 0; } }

.feedback.good { background: var(--good-soft); border: 3px solid var(--good); }

.feedback.try { background: var(--try-soft); border: 3px solid var(--try); }

.feedback.miss { background: #eef3ff; border: 3px solid var(--answer); }

.feedback p { margin: 0.15em 0; }

.fb-row { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 240px; }

.feedback .explain { font-weight: 600; }

.streak { color: #c2410c; font-weight: 900; }

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1.05;
  font-size: 0.88em;
  margin: 0 2px;
}

.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

.chip { padding: 3px 10px; border-radius: 99px; font-weight: 800; background: #eee; }

.chip.good { background: var(--good-soft); color: var(--good); }

.chip.bad { background: var(--bad-soft); color: var(--bad); }

.choice {
  padding: 12px 16px;
  min-height: 52px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.choice:hover:not(:disabled) { border-color: #8f86d9; }

.choice.right, .answer.choice { border-color: var(--good); background: var(--good-soft); }

.choice.wrong-pick { border-color: var(--bad); background: var(--bad-soft); }

.choice:disabled { opacity: 0.6; }

/* tiles shared by forge, bridge and the number machine */

.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

.tile {
  min-width: 56px;
  min-height: 56px;
  padding: 6px 14px;
  border: 0;
  border-radius: 14px;
  background: #3b2f8a;
  color: #fff;
  font-weight: 900;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #241c5c;
  transition: transform 0.1s, opacity 0.2s;
}

.tile.word { font-size: 1.15rem; }

.tile small { display: block; font-size: 0.65rem; font-weight: 700; opacity: 0.85; }

.tile:disabled { opacity: 0.25; cursor: default; }

.tile.gone { transform: scale(0.85); }

.slot {
  min-width: 56px;
  min-height: 60px;
  padding: 6px 10px;
  border: 3px dashed #8f86d9;
  border-radius: 14px;
  background: #f3f0ff;
  color: #3b2f8a;
  font-weight: 900;
  font-size: 1.35rem;
  cursor: pointer;
}

.slot.filled { border-style: solid; background: #fff; }

.slot small { display: block; font-size: 0.65rem; font-weight: 700; }

.slot.answer, .answer .slot { border-color: var(--answer); background: #eef3ff; }

/* ---------------------------------------------------------------- frog */

.frog-svg { color: #234; }

.frog { transition: none; }

.frog-pad.answer ellipse { stroke: var(--answer); stroke-width: 5; }

.ripple { fill: none; stroke: #4dabf7; stroke-width: 4; animation: ripple 0.8s ease-out forwards; }

@keyframes ripple { to { r: 46; opacity: 0; } }

.frog-readout, .garden-readout, .potion-amount, .cannon-readout, .balloon-score, .sort-score { font-weight: 800; color: var(--muted); min-width: 8em; text-align: center; }

/* ---------------------------------------------------------------- potion */

.bottles { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 18px; }

.bottle-wrap { display: grid; justify-items: center; gap: 4px; transition: transform 0.2s; }

.stage svg.bottle { width: 130px; height: auto; }

.stage .bottle-wrap.small svg.bottle { width: 92px; }

.bottle.tappable { cursor: pointer; }

.bottle .cell { transition: fill 0.2s; }

.bottle-label { font-weight: 900; font-size: 1.3rem; }

.bottle-wrap.picked { transform: translateY(-6px); }

.bottle-wrap.picked .bottle { filter: drop-shadow(0 0 8px #8f86d9); }

.bottle-wrap.answer .bottle { filter: drop-shadow(0 0 10px var(--answer)); }

.btn.picked { outline: 3px solid #8f86d9; }

.btn.answer { outline: 3px solid var(--answer); }

/* ---------------------------------------------------------------- cannon */

.cannon-svg { color: #2a2340; max-height: 52vh; }

.barrel { transition: transform 0.08s; }

.balloon { transition: opacity 0.3s, transform 0.3s; }

.balloon.popped { opacity: 0; }

.balloon.answer ellipse:nth-of-type(1) { stroke: var(--answer); stroke-width: 6; }

.cannon-readout { color: #3b2f8a; font-size: 1.15rem; }

/* ---------------------------------------------------------------- garden */

.garden-svg { max-height: 56vh; }

.garden-soil { fill: #f3e2c7; }

.grid-line { stroke: #d6c09c; stroke-width: 2; }

.garden-plot { fill: rgba(105, 219, 124, 0.55); stroke: #8b5a2b; stroke-width: 7; stroke-dasharray: 14 6; }

.garden-plot.answer { stroke: var(--answer); }

.garden-label { font-size: 26px; font-weight: 900; fill: #3b2f8a; }

/* ---------------------------------------------------------------- balloons */

.balloon-sky {
  position: relative;
  height: min(440px, 55vh);
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(#bfe6ff, #eaf7ff);
}

.float-balloon {
  position: absolute;
  bottom: -90px;
  width: 74px;
  height: 88px;
  margin-left: -37px;
  border: 0;
  border-radius: 50% 50% 46% 46%;
  background: var(--c);
  color: #fff;
  font-weight: 900;
  font-size: 1.45rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  animation: float-up linear forwards;
  touch-action: manipulation;
}

.float-balloon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 26px;
  background: #556;
}

@keyframes float-up { to { transform: translateY(calc(-1 * min(440px, 55vh) - 120px)); } }

.float-balloon.pop-good, .float-balloon.pop-bad { animation-play-state: paused; transition: transform 0.35s, opacity 0.35s; transform: scale(1.6) !important; opacity: 0; }

.float-balloon.pop-bad { background: #555; }

.missed-tag {
  position: absolute;
  top: 6px;
  margin-left: -40px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bad-soft);
  color: var(--bad);
  font-weight: 800;
  font-size: 0.85rem;
  animation: fade 2s forwards;
}

@keyframes fade { 70% { opacity: 1; } to { opacity: 0; } }

.balloon-summary, .sort-summary { padding: 18px; text-align: center; }

/* ---------------------------------------------------------------- number machine */

.machine {
  position: relative;
  padding: 18px 12px 12px;
  border-radius: 18px;
  background: linear-gradient(#56607a, #3d4459);
  overflow-x: auto;
}

.machine .slots { display: flex; justify-content: center; align-items: flex-start; gap: 6px; }

.slot-col { display: grid; justify-items: center; gap: 4px; width: 64px; }

.slot-label { color: #e5e7f0; font-size: 0.68rem; font-weight: 700; text-align: center; line-height: 1.1; }

.comma { color: #fff; font-size: 2rem; font-weight: 900; align-self: center; margin-top: -18px; }

.gears { position: absolute; top: -6px; right: 10px; font-size: 1.5rem; letter-spacing: -6px; }

.gears.spin { animation: spin 0.7s linear; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- treasure */

.treasure-game { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 24px; }

.chest { position: relative; font-size: 6rem; line-height: 1; }

.chest-lock { position: absolute; left: 50%; bottom: 0.25em; transform: translateX(-50%); font-size: 0.45em; }

.chest.opened .chest-body { animation: pop 0.5s; }

.chest.opened::after { content: '💰✨'; position: absolute; left: 50%; top: -0.2em; transform: translateX(-50%); font-size: 0.4em; animation: rise-in 0.4s; }

.chest.shake, .anvil.shake, .bridge-scene.wobble { animation: shake 0.4s; }

@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

.pad { width: min(320px, 100%); }

.pad-screen {
  min-height: 60px;
  padding: 8px 14px;
  border-radius: 14px;
  background: #22223b;
  color: #9ef0b0;
  font-size: 2rem;
  font-weight: 900;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pad-screen.answer { color: #9ec5ff; }

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }

.key {
  min-height: 58px;
  border: 0;
  border-radius: 14px;
  background: #ece7ff;
  color: #3b2f8a;
  font-weight: 900;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 3px 0 #c5bbf2;
}

.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #c5bbf2; }

.key.back { background: #ffe1d6; color: #9a3412; box-shadow: 0 3px 0 #f4b8a2; }

.key-open { min-height: 58px; padding: 6px; font-size: 1.1rem; box-shadow: 0 3px 0 var(--gold-deep); }

/* ---------------------------------------------------------------- forge */

.anvil {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px 10px;
  border-radius: 18px;
  background: linear-gradient(#5b5f73, #3c3f52);
  transition: box-shadow 0.3s;
}

.anvil .slots { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }

.plus { color: #fff; font-weight: 900; font-size: 1.4rem; }

.forge-word { min-height: 1.6em; color: #ffd23f; font-size: 1.6rem; font-weight: 900; letter-spacing: 0.02em; }

.anvil.glow { box-shadow: 0 0 0 4px var(--gold), 0 0 30px rgba(255, 210, 63, 0.8); }

.anvil.answer .slot { border-color: var(--answer); }

/* ---------------------------------------------------------------- sentence doctor */

.patient { display: flex; gap: 12px; align-items: flex-start; }

.doc-icon { font-size: 2rem; }

.doctor-sentence { margin: 0; font-size: 1.45rem; line-height: 2.1; font-weight: 700; }

.word-btn {
  padding: 2px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  border-bottom: 3px dotted #c9c1ef;
}

.word-btn:hover:not(:disabled) { background: #f0edff; }

.word-btn:disabled { cursor: default; border-bottom-color: transparent; }

.word-btn.wrong-pick { background: var(--bad-soft); color: var(--bad); }

.error-unit.found .word-btn { background: #ffe8a3; }

.error-unit.fixed { padding: 2px 8px; border-radius: 8px; background: var(--good-soft); color: var(--good); font-weight: 900; }

.error-unit.answer { background: #eef3ff; color: var(--answer); }

.fix-ask { margin: 14px 0 6px; font-weight: 800; }

.fix-choices { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------------------------------------------------------- word sort */

.chute {
  position: relative;
  height: min(340px, 42vh);
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(#e9f2ff, #fdf6ff);
}

.falling-card {
  position: absolute;
  left: 50%;
  top: -70px;
  max-width: 90%;
  padding: 12px 18px;
  border-radius: 14px;
  background: #fff;
  border: 3px solid #3b2f8a;
  font-weight: 900;
  font-size: 1.3rem;
  text-align: center;
  transform: translateX(-50%);
  animation: fall linear forwards;
}

@keyframes fall { to { top: calc(100% - 64px); } }

.falling-card.sorted-good, .falling-card.sorted-bad { animation-play-state: paused; transition: opacity 0.35s; opacity: 0; }

.falling-card.sorted-good { border-color: var(--good); background: var(--good-soft); }

.falling-card.sorted-bad, .falling-card.landed { border-color: var(--bad); background: var(--bad-soft); }

.bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }

.bin {
  position: relative;
  min-height: 70px;
  padding: 10px;
  border: 0;
  border-radius: 16px;
  background: var(--c);
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.bin:disabled { opacity: 0.6; }

.bin.flash { animation: pop 0.45s; }

.bin-key { position: absolute; top: 4px; left: 8px; font-size: 0.75rem; opacity: 0.75; }

.sort-summary { display: grid; gap: 12px; }

.sum-bin b { color: var(--c); }

/* ---------------------------------------------------------------- bridge */

.bridge-scene {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 150px;
  padding-top: 52px;
  border-radius: 16px;
  background: linear-gradient(#bfe6ff 60%, #6fb7e8);
  overflow: hidden;
}

.cliff { flex: none; width: 34px; height: 92px; background: #8b6b4a; border-top: 8px solid #6fcf73; }

.cliff.left { border-radius: 0 10px 0 0; }

.cliff.right { border-radius: 10px 0 0 0; }

.bridge {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 52px;
  padding: 6px 4px;
  border-bottom: 6px solid #8b5a2b;
}

.bridge.story { flex-direction: column; flex-wrap: nowrap; align-items: stretch; margin-bottom: 8px; border-bottom: 0; }

.lead { font-weight: 900; font-size: 1.15rem; color: #3b2f8a; padding: 0 4px; }

.plank { min-width: 64px; min-height: 48px; font-size: 1.05rem; background: #f6e3c4; border-color: #b07d48; color: #4a2f12; }

.plank.filled { background: #e8c48f; }

.plank.story { width: 100%; min-height: 44px; text-align: left; font-size: 1rem; }

.tiles.story { flex-direction: column; align-items: stretch; }

.tiles.story .tile { text-align: left; font-size: 1rem; }

.walker { position: absolute; left: 2px; bottom: 96px; font-size: 2.4rem; }

.bridge-scene:has(.bridge.story) { padding-top: 56px; }

.bridge-scene:has(.bridge.story) .walker { top: 6px; bottom: auto; }

.bridge-scene.crossed .walker { animation: walk 1.6s ease-in-out forwards; }

@keyframes walk { to { left: calc(100% - 46px); } }

.bridge.answer .slot { border-color: var(--answer); }

/* ---------------------------------------------------------------- clue */

.case-file { position: relative; padding: 22px 16px 14px; border-radius: 16px; background: #fdf3d7; border: 2px solid #e6cf91; }

.case-tag { position: absolute; top: -12px; left: 14px; padding: 1px 10px; border-radius: 6px; background: #b45309; color: #fff; font-weight: 900; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }

.case-text { margin: 0; font-size: 1.3rem; line-height: 1.6; font-weight: 600; }

mark.mystery { padding: 0 4px; border-radius: 6px; background: #ffe066; color: inherit; font-weight: 900; }

.clue-hl { text-decoration: underline wavy #2f6fd8 2px; text-underline-offset: 4px; }

.clue-cards { display: grid; gap: 10px; margin-top: 14px; }

.clue-card { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; }

.lens { font-size: 1.3rem; }

/* ---------------------------------------------------------------- results */

.result { padding-top: 6vh; text-align: center; }

.result h1 { font-size: 2rem; }

.result .stars { font-size: 2.6rem; }

.big-lantern { font-size: 5rem; filter: grayscale(1) brightness(0.7); }

.big-lantern.on { filter: drop-shadow(0 0 24px rgba(255, 210, 63, 0.9)); animation: pop 0.8s; }

.earned { color: var(--gold); font-weight: 900; font-size: 1.2rem; }

/* ---------------------------------------------------------------- my isle */

.isle-board { position: relative; display: flex; justify-content: center; }

.isle-grid {
  display: grid;
  grid-template-columns: repeat(var(--w), minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 640px);
  padding: 22px 18px 34px;
  border-radius: 36px;
  background: radial-gradient(ellipse at 50% 35%, #7ee8a1, #3fbf7f 70%);
  box-shadow: 0 18px 0 #7a5b45, var(--shadow);
}

.cell {
  aspect-ratio: 1;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: transparent;
  font-size: clamp(1.2rem, 5vw, 2.1rem);
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.cell.has { border-color: transparent; }

.isle-pet { position: absolute; bottom: -8px; right: 8%; font-size: 2.6rem; }

.isle-help { color: var(--night-muted); text-align: center; margin-top: 26px; }

.inventory, .shop { display: flex; flex-wrap: wrap; gap: 10px; }

.inv-item, .shop-item {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 82px;
  padding: 8px 10px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-weight: 800;
  cursor: pointer;
}

.inv-item.on { border-color: var(--gold); background: rgba(255, 210, 63, 0.16); }

.inv-item:disabled, .shop-item:disabled { opacity: 0.45; cursor: default; }

.inv-icon { font-size: 2rem; line-height: 1.1; }

.shop-item small { color: var(--gold); }

/* ---------------------------------------------------------------- grown-ups */

.card, .stage, .sheet, .prompt-card, .feedback { color-scheme: light; }

.card { padding: 18px; border-radius: var(--radius); background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }

.card .stars { color: #cfc9b8; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }

th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }

td.num { text-align: right; font-variant-numeric: tabular-nums; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 700; }

.check input { width: 22px; height: 22px; }

.lvl { display: inline-grid; place-items: center; width: 36px; height: 36px; margin: 2px; border-radius: 10px; background: #ece7ff; color: #3b2f8a; font-weight: 900; text-decoration: none; }

.sync-state { font-weight: 800; }

.sync-state.offline, .sync-state.nokey { color: var(--try); }

[hidden] { display: none !important; }

.link-warning { margin: 4px 0 10px; padding: 10px 14px; border-radius: 14px; background: var(--try-soft); color: var(--try); font-weight: 800; }

.link-warning a { color: inherit; }

.confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .prompt-card { font-size: 1.05rem; }
  .doctor-sentence, .case-text { font-size: 1.15rem; }
  .stage svg.bottle { width: 100px; }
  .chest { font-size: 4.2rem; }
  .slot-col { width: 50px; }
  .slot, .tile { min-width: 46px; font-size: 1.15rem; }
  .play-title { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .float-balloon, .falling-card { animation-duration: inherit !important; }
}
