/*
 * Word Rangers - one space theme, "sticker" look to match the artwork:
 * thick ink outlines, hard offset shadows, one corner-radius family.
 * Letters use Andika (made for early readers: clear b/d, I/l, single-storey a and g).
 */
@font-face { font-family: "Andika"; src: url("../assets/fonts/andika-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Andika"; src: url("../assets/fonts/andika-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("../assets/fonts/baloo-2-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("../assets/fonts/baloo-2-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --ink: #0a1136;
  --space: #101a52;
  --space-2: #1b2a7a;
  --paper: #fffbf0;
  --yellow: #ffc933;
  --orange: #ff7a3d;
  --cyan: #2cc6f5;
  --lime: #86e04a;
  --red: #ff5468;
  --accent: var(--yellow);
  --r: 22px;          /* panels, cards, buttons */
  --r-sm: 14px;       /* keys, slots, chips */
  --edge: 4px solid var(--ink);
  --drop: 0 6px 0 var(--ink);
  --display: "Baloo 2", "Andika", system-ui, sans-serif;
  --read: "Andika", system-ui, sans-serif;
}
.c-yellow { --accent: var(--yellow); }
.c-cyan { --accent: var(--cyan); }
.c-orange { --accent: var(--orange); }
.c-lime { --accent: var(--lime); }
.c-red { --accent: var(--red); }

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--read); color: #fff; background: var(--space);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
/* Starfield: two tiled dot layers over a deep-space glow. */
body::before, body::after { content: ""; position: fixed; inset: 0; pointer-events: none; }
body::before {
  background:
    radial-gradient(120% 80% at 15% 0%, #2a3fae 0%, transparent 55%),
    radial-gradient(90% 70% at 100% 100%, #0d4d86 0%, transparent 60%),
    linear-gradient(#111c5a, #0b1240);
}
body::after {
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 110px 90px, #cfe6ff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 170px 20px, #ffe9a8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 70px 150px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 210px 170px, #bfe9ff 50%, transparent 51%);
  background-size: 240px 220px; opacity: .75;
}
#app { position: fixed; inset: 0; z-index: 1; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
h1, h2 { font-family: var(--display); font-weight: 800; line-height: 1.05; }

.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  animation: screen-in .28s ease-out both;
}
@keyframes screen-in { from { opacity: 0; transform: scale(.985); } }

/* ---------- shared pieces ---------- */
.sprite { display: block; aspect-ratio: 1; }
.sprite img, .pic img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.pic { position: relative; aspect-ratio: 1; }
.pic.noimg { border: 4px dashed rgba(10, 17, 54, .3); border-radius: var(--r); }
.pic.noimg::after { content: "?"; position: absolute; inset: 0; display: grid; place-items: center; font: 800 3em var(--display); color: rgba(10, 17, 54, .35); }
.pic-badge {
  position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
  font: 800 clamp(22px, 4.4vmin, 40px) var(--display); color: var(--ink);
}
/* Simple shapes used only until a picture file exists. */
.fb { border: var(--edge); border-radius: 50%; background: radial-gradient(circle at 32% 30%, #fff 0 9%, transparent 10%), var(--accent); }
.fb-ship { border-radius: 50% 50% 22% 22% / 70% 70% 22% 22%; background: linear-gradient(#fff 0 38%, var(--red) 38%); }
.fb-alien { background: radial-gradient(circle at 50% 38%, var(--ink) 0 9%, #fff 10% 24%, transparent 25%), var(--lime); }
.fb-robot { border-radius: 26%; background: radial-gradient(circle at 34% 42%, var(--ink) 0 7%, transparent 8%), radial-gradient(circle at 66% 42%, var(--ink) 0 7%, transparent 8%), var(--cyan); }
.fb-trophy, .fb-star { background: var(--yellow); }

.btn {
  font: 800 clamp(18px, 2.6vmin, 24px) var(--display); color: var(--ink); line-height: 1;
  padding: .6em 1.1em; min-height: 54px; border: var(--edge); border-radius: var(--r); box-shadow: var(--drop);
  background: var(--paper); display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  transition: transform .08s, box-shadow .08s;
}
.btn:active, .btn-round:active, .key:active, .tile:active, .chip:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn svg { width: 1.3em; height: 1.3em; }
.btn-yellow { background: var(--yellow); }
.btn-blue { background: var(--cyan); }
.btn-red { background: var(--red); }
.btn-big { font-size: clamp(22px, 3.4vmin, 32px); padding: .55em 1.5em; min-height: 66px; }
.btn.rec.on { background: var(--red); animation: pulse 1s infinite; }
.btn-round {
  width: 56px; height: 56px; flex: none; border: var(--edge); border-radius: 50%; box-shadow: var(--drop);
  background: var(--paper); color: var(--ink); display: grid; place-items: center; transition: transform .08s, box-shadow .08s;
}
.btn-round svg { width: 30px; height: 30px; }

.ministar, .bigstar, .pip {
  display: inline-block; aspect-ratio: 1; background: rgba(255, 255, 255, .22);
  clip-path: polygon(50% 0, 62% 35%, 98% 37%, 69% 59%, 80% 95%, 50% 74%, 20% 95%, 31% 59%, 2% 37%, 38% 35%);
}
.ministar { width: 1.05em; vertical-align: -.12em; }
.ministar.on, .pip.done { background: var(--yellow); }
.starcount {
  display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 12px; border: var(--edge); border-radius: 999px;
  background: var(--ink); font: 800 26px var(--display);
}
.starcount .ministar { width: 28px; }

.hud { display: flex; align-items: center; gap: 14px; flex: none; min-height: 62px; padding-bottom: 8px; }
.pips { flex: 1; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pip { width: 28px; transition: background .2s, transform .2s; }
.pip.cur { background: #fff; transform: scale(1.25); }
.play { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; position: relative; }

.overlay {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(8, 13, 46, .82); animation: fade .2s both;
}
@keyframes fade { from { opacity: 0; } }
.panel {
  width: min(520px, 100%); background: var(--paper); color: var(--ink); border: var(--edge); border-radius: var(--r);
  box-shadow: 0 10px 0 var(--ink); padding: 26px; display: flex; flex-direction: column; gap: 14px; text-align: center;
  animation: pop-in .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
.panel h2 { font-size: clamp(30px, 5vmin, 44px); }
.panel p { font-size: 18px; line-height: 1.4; }
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } }

.bubble-say {
  position: relative; background: var(--paper); color: var(--ink); border: var(--edge); border-radius: var(--r);
  box-shadow: var(--drop); padding: 14px 20px;
}
.bubble-say h2 { font-size: clamp(26px, 4.4vmin, 38px); margin-bottom: 4px; }
.bubble-say p { font-size: clamp(20px, 3vmin, 28px); font-weight: 700; line-height: 1.3; }

.intro-box { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(560px, 100%); animation: pop-in .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.intro-bot { width: clamp(110px, 22vmin, 170px); }
.intro-bot .sprite { animation: bob 2.4s ease-in-out infinite; }
.intro .bubble-say { text-align: center; width: 100%; }

.result-art { width: clamp(110px, 22vmin, 170px); margin: -70px auto 0; }
.result-art .sprite { animation: bob 2.4s ease-in-out infinite; }
.bigstars { display: flex; justify-content: center; gap: 12px; }
.bigstar { width: clamp(60px, 13vmin, 96px); background: #d9d3c2; }
.bigstar.on { background: var(--yellow); animation: star-in .5s var(--d) cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes star-in { from { transform: scale(0) rotate(-140deg); } }
.result-btns { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.spark { position: fixed; z-index: 50; width: 14px; height: 14px; margin: -7px; pointer-events: none;
  clip-path: polygon(50% 0, 62% 35%, 98% 37%, 69% 59%, 80% 95%, 50% 74%, 20% 95%, 31% 59%, 2% 37%, 38% 35%);
  animation: spark .65s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) rotate(200deg) scale(.3); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes shake { 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes pulse { 50% { transform: scale(1.06); } }
.shake { animation: shake .4s; }

/* ---------- home ---------- */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; }
.hero { width: clamp(72px, 13vmin, 110px); }
.hero .sprite { animation: bob 3s ease-in-out infinite; }
.brand h1 { font-size: clamp(30px, 6vmin, 54px); color: var(--yellow); text-shadow: 0 4px 0 var(--ink); }
.rank { font: 700 clamp(15px, 2.4vmin, 20px) var(--display); color: #bfe9ff; }
.home-tools { display: flex; align-items: center; gap: 12px; }
.planets {
  flex: 1; min-height: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: clamp(8px, 2vmin, 22px); overflow-y: auto; padding: 14px 0 26px;
}
.planet { width: clamp(140px, 17vw, 220px); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.planet .sprite { width: 100%; animation: bob 3.2s ease-in-out infinite; transition: transform .15s; }
.planet:nth-child(2n) .sprite { animation-delay: -1.3s; }
.planet:nth-child(3n) .sprite { animation-delay: -2.2s; }
.planet:active .sprite { transform: scale(.94); }
.planet-name { font: 800 clamp(20px, 2.9vmin, 27px) var(--display); color: var(--accent); text-shadow: 0 3px 0 var(--ink); line-height: 1.1; }
.planet-sub { font-size: 16px; color: #d7e4ff; }
.planet-stars { margin-top: 4px; font: 800 18px var(--display); background: var(--ink); border-radius: 999px; padding: 2px 14px 2px 10px; }
@media (min-width: 900px) { .planet:nth-child(2n) { transform: translateY(34px); } }
@media (max-width: 900px) { .planet { width: 30vw; } }
@media (max-width: 560px) { .planet { width: 42vw; } }

/* ---------- planet level path ---------- */
.planet-title { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.planet-title .sprite { width: 62px; flex: none; }
.planet-title h1 { font-size: clamp(24px, 4.4vmin, 38px); color: var(--accent); text-shadow: 0 3px 0 var(--ink); }
.planet-title p { font-size: 16px; color: #d7e4ff; }
.path {
  flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: center; justify-content: center;
  grid-template-columns: repeat(auto-fit, minmax(150px, 180px)); gap: 26px 12px; padding: 18px 0 30px;
}
.node { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.node:nth-child(2n) { transform: translateY(18px); }
.node-disc {
  width: 86px; height: 86px; border: var(--edge); border-radius: 50%; box-shadow: var(--drop); background: var(--accent);
  color: var(--ink); font: 800 40px var(--display); display: grid; place-items: center; transition: transform .08s, box-shadow .08s;
}
.node:active .node-disc { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.node.boss .node-disc { border-radius: var(--r); background: var(--red); }
.node.next .node-disc { animation: pulse 1.2s ease-in-out infinite; outline: 4px solid #fff; outline-offset: 4px; }
.node.locked .node-disc { background: #5a6599; color: #232c5c; box-shadow: 0 6px 0 #070c28; }
.node.locked .node-disc svg { width: 36px; }
.node-kind { margin-top: 8px; font: 800 14px var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.node-title { font-size: 17px; font-weight: 700; text-align: center; line-height: 1.15; }
.node.locked .node-kind, .node.locked .node-title { opacity: .5; }
.node-stars { font-size: 20px; }

/* ---------- letter slots (shared by Catch and Type) ---------- */
.slot-holder {
  flex: none; align-self: center; max-width: 100%; background: var(--paper); border: var(--edge); border-radius: var(--r);
  box-shadow: var(--drop); padding: 10px 18px 12px;
}
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 0; font: 700 clamp(28px, 5.4vmin, 46px)/1.25 var(--read); color: transparent; }
.slots.long { font-size: clamp(22px, 3.9vmin, 34px); }
.slot-word { display: inline-flex; gap: 4px; white-space: nowrap; }
.slot-gap { width: .65em; }
.slot { width: 1.15em; height: 1.45em; display: grid; place-items: center; border-bottom: 5px solid #b9c0de; border-radius: 8px 8px 0 0; transition: background .15s; }
.slot.punct { width: .45em; border-bottom-color: transparent; color: var(--ink); }
.slot.given { color: var(--ink); border-bottom-color: transparent; }
.slots.ghost .slot, .slot.hint { color: rgba(10, 17, 54, .28); }
.slot.hint { color: var(--orange); }
.slot.cur { border-bottom-color: var(--orange); background: #ffe7c7; animation: cur 1s ease-in-out infinite; }
.slot.filled { color: var(--ink); background: var(--yellow); border-bottom-color: var(--ink); animation: letter-in .3s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes cur { 50% { transform: translateY(-3px); } }
@keyframes letter-in { from { transform: scale(1.7) rotate(-8deg); } }
.slots.cheer .slot-word { animation: cheer .45s ease-in-out 2; }
@keyframes cheer { 50% { transform: translateY(-10px); } }

/* ---------- Letter Catch ---------- */
.word-top { flex: none; display: flex; align-items: center; justify-content: center; gap: 14px; }
.pic-holder { width: clamp(84px, 17vmin, 132px); flex: none; background: var(--paper); border: var(--edge); border-radius: var(--r); box-shadow: var(--drop); padding: 4px; }
.sky { flex: 1; min-height: 0; position: relative; overflow: hidden; border-radius: var(--r); touch-action: none;
  background: linear-gradient(rgba(255, 255, 255, .04), rgba(255, 255, 255, .1)); border: 3px dashed rgba(255, 255, 255, .18); }
.bubble {
  position: absolute; left: 0; top: 0; width: 72px; height: 72px; margin-left: -36px; will-change: transform;
  border: var(--edge); border-radius: 50%; background: radial-gradient(circle at 30% 26%, #fff 0 12%, transparent 13%), var(--cyan);
  color: var(--ink); font: 700 44px/1 var(--read); display: grid; place-items: center; padding-bottom: 6px;
}
.bubble.miss { background: var(--red); opacity: .2; transition: opacity .3s; }
.ship-wrap { position: absolute; left: 0; bottom: 4px; width: 104px; margin-left: -52px; transform: translateX(var(--x, 0)); will-change: transform; }
.ship-wrap.shake .sprite { animation: shake .4s; }
.ship-wrap.zoom .sprite { animation: zoom .9s ease-in-out; }
@keyframes zoom { 40% { transform: translateY(-70px) rotate(360deg) scale(1.15); } }

/* ---------- Type Blaster ---------- */
.bl-sky { flex: 1; min-height: 110px; position: relative; overflow: hidden; }
.invader { position: absolute; left: 50%; top: 0; display: flex; align-items: flex-end; gap: 6px; transform: translate(-50%, var(--y, 0)); will-change: transform; }
.inv-alien { width: clamp(84px, 16vmin, 132px); }
.inv-alien .sprite { animation: bob 1.8s ease-in-out infinite; }
.inv-pic { width: clamp(92px, 18vmin, 150px); background: var(--paper); border: var(--edge); border-radius: var(--r); box-shadow: var(--drop); padding: 4px; }
.inv-alien, .inv-pic { transition: transform .35s cubic-bezier(.5, -0.6, .7, 1), opacity .35s; }
.invader.boom .inv-alien { transform: scale(0) rotate(160deg); opacity: 0; }
.invader.boom .inv-pic { transform: scale(1.12); }
.invader.hit .inv-alien { filter: brightness(1.8); }
.laser { position: absolute; left: 50%; width: 8px; margin-left: -4px; border-radius: 4px; background: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 201, 51, .35); opacity: 0; }
.laser.fire { animation: fire .18s; }
@keyframes fire { from { opacity: 1; } to { opacity: 0; } }
.bl-ship { position: absolute; left: 50%; bottom: 0; width: clamp(60px, 11vmin, 92px); transform: translateX(-50%); }

.kb { flex: none; display: flex; flex-direction: column; gap: 7px; align-items: center; padding-top: 4px; }
.kb-row { display: flex; gap: 6px; justify-content: center; width: 100%; }
.key {
  flex: 1; max-width: 82px; height: clamp(46px, 8.2vmin, 64px); border: 3px solid var(--ink); border-radius: var(--r-sm);
  box-shadow: 0 5px 0 var(--ink); background: var(--paper); color: var(--ink); font: 700 clamp(22px, 4vmin, 32px)/1 var(--read);
  transition: transform .06s, box-shadow .06s;
}
.key.right { background: var(--lime); }
.key.wrong { background: var(--red); animation: shake .35s; }
.key.glow { background: var(--yellow); animation: pulse .5s ease-in-out 3; }

/* ---------- Grammar Gates ---------- */
.g-card { flex: none; background: var(--paper); color: var(--ink); border: var(--edge); border-radius: var(--r); box-shadow: var(--drop); padding: 14px 20px; text-align: center; }
.g-sent { font: 700 clamp(24px, 4.6vmin, 40px)/1.35 var(--read); }
.gap { display: inline-block; min-width: 2.6em; padding: 0 .3em; border-radius: var(--r-sm); border: 3px dashed var(--orange); color: var(--orange); background: #ffe7c7; }
.gap.filled { border-style: solid; border-color: var(--ink); color: var(--ink); background: var(--yellow); animation: letter-in .3s cubic-bezier(.2, 1.6, .4, 1); }
.g-road { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.g-gates { position: absolute; left: 0; right: 0; top: 6%; height: 46%; display: flex; gap: clamp(10px, 3vw, 28px); padding: 0 clamp(6px, 3vw, 40px); }
.g-gates.arrive { animation: arrive .8s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes arrive { from { transform: translateY(-80%) scale(.6); opacity: 0; } }
.gate {
  flex: 1; border: 6px solid var(--ink); border-radius: 60px 60px var(--r) var(--r); box-shadow: 0 8px 0 var(--ink);
  background: linear-gradient(var(--cyan), #1b8fd0); display: grid; place-items: center; transition: transform .1s, opacity .3s, background .2s;
}
.gate span { background: var(--paper); color: var(--ink); border: var(--edge); border-radius: var(--r-sm); padding: .1em .5em; font: 700 clamp(26px, 5.4vmin, 46px)/1.3 var(--read); }
.gate:active { transform: translateY(4px); }
.gate.ok { background: var(--lime); }
.gate.no { background: var(--red); opacity: .45; animation: shake .4s; }
.g-ship { position: absolute; bottom: 4px; left: 50%; width: clamp(80px, 15vmin, 120px); transform: translateX(-50%); transition: left .35s cubic-bezier(.3, 1.3, .5, 1); }
.g-ship .sprite { transition: transform .6s ease-in, opacity .5s .15s; }
.g-ship.fly .sprite { transform: translateY(-260%) scale(.5); opacity: 0; }
.g-ship.bump .sprite { animation: bump .45s; transition: none; }
@keyframes bump { 30% { transform: translateY(-60px); } 55% { transform: translateY(10px) rotate(-12deg); } }

/* ---------- Sentence Rocket ---------- */
.t-prompt { flex: none; display: flex; align-items: center; justify-content: center; gap: 12px; }
.t-who { width: clamp(64px, 12vmin, 100px); flex: none; }
.t-who .sprite { animation: bob 2.2s ease-in-out infinite; }
.t-prompt .bubble-say { flex: 0 1 auto; }
.t-pic { width: clamp(72px, 14vmin, 116px); flex: none; background: var(--paper); border: var(--edge); border-radius: var(--r); box-shadow: var(--drop); padding: 4px; }
.t-pic:empty { display: none; }
.t-track { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.t-train { display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; transition: transform .8s cubic-bezier(.6, 0, .9, .4); }
.t-train.go { transform: translateX(130vw); }
.t-cars { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 8px; }
.t-engine { width: clamp(60px, 11vmin, 92px); flex: none; }
.t-engine .sprite { transform: rotate(90deg); }
.car, .tile {
  font: 700 clamp(22px, 4vmin, 34px)/1.2 var(--read); color: var(--ink); border-radius: var(--r-sm); padding: .32em .5em; text-align: center;
}
.car { min-height: 1.9em; border: 4px dashed rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .08); }
.car.cur { border-color: var(--yellow); background: rgba(255, 201, 51, .22); }
.car.full { border: var(--edge); background: var(--yellow); box-shadow: 0 5px 0 var(--ink); animation: letter-in .3s cubic-bezier(.2, 1.6, .4, 1); }
.t-yard { flex: none; min-height: 150px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 14px 12px; padding: 8px 0 12px; }
.tile { border: var(--edge); background: var(--paper); box-shadow: var(--drop); transition: transform .08s, box-shadow .08s; }
.tile.used { visibility: hidden; }
.tile.wrong { background: var(--red); animation: shake .4s; }
.say-box { display: flex; flex-direction: column; align-items: center; gap: 12px; animation: pop-in .3s both; }
.say-label { font: 800 clamp(24px, 4vmin, 34px) var(--display); color: var(--yellow); }
.say-btns, .talk-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ---------- Science Sorter ---------- */
.s-zone { flex: 1; min-height: 0; display: grid; place-items: center; }
.s-card {
  width: clamp(170px, 34vmin, 270px); background: var(--paper); color: var(--ink); border: var(--edge); border-radius: var(--r);
  box-shadow: var(--drop); padding: 10px 12px 12px; text-align: center; touch-action: none; cursor: grab;
}
.s-label { font: 700 clamp(22px, 3.8vmin, 32px)/1.15 var(--read); }
.s-card.drop-in { animation: drop-in .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes drop-in { from { transform: translateY(-120%) rotate(-10deg); opacity: 0; } }
.s-card.to-0, .s-card.to-1 { transition: transform .5s ease-in, opacity .5s ease-in; opacity: 0; }
.s-card.to-0 { transform: translate(-34vw, 34vh) scale(.2) rotate(-30deg) !important; }
.s-card.to-1 { transform: translate(34vw, 34vh) scale(.2) rotate(30deg) !important; }
.s-bins { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; height: clamp(120px, 26vh, 200px); }
.bin {
  position: relative; border: 5px solid var(--ink); border-radius: var(--r-sm) var(--r-sm) 46px 46px; box-shadow: 0 8px 0 var(--ink);
  color: var(--ink); display: grid; place-items: center; font: 700 clamp(24px, 5vmin, 44px) var(--read); transition: transform .1s;
}
.bin-0 { background: var(--cyan); }
.bin-1 { background: var(--orange); }
.bin:active { transform: translateY(4px); }
.bin-count { position: absolute; top: 8px; right: 14px; min-width: 40px; padding: 0 8px; border-radius: 999px; background: var(--ink); color: #fff; font: 800 22px/1.6 var(--display); }
.bin.gulp { animation: gulp .5s; }
.bin.no { animation: shake .4s; }
@keyframes gulp { 40% { transform: scale(1.06, .92); } 70% { transform: scale(.97, 1.05); } }

/* ---------- Listen and Find ---------- */
.l-ask { flex: none; display: flex; justify-content: center; }
.l-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 6px 0 10px; align-content: center; justify-content: center; }
@media (min-aspect-ratio: 5/4) { .l-grid { grid-template-columns: repeat(4, minmax(0, 230px)); } }
@media (max-aspect-ratio: 5/4) { .l-grid { grid-template-columns: repeat(2, minmax(0, 300px)); } }
.l-card {
  background: var(--paper); color: var(--ink); border: var(--edge); border-radius: var(--r); box-shadow: var(--drop); padding: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 0;
  animation: pop-in .35s calc(var(--i) * .06s) cubic-bezier(.2, 1.4, .4, 1) both; transition: transform .1s, opacity .25s;
}
.l-card .pic { width: 100%; max-width: min(200px, 26vh); }
.l-card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.l-cap { font: 700 clamp(18px, 3.2vmin, 26px)/1.2 var(--read); visibility: hidden; }
.l-word { font: 700 clamp(26px, 5vmin, 42px) var(--read); padding: .8em 0; }
.l-card.ok { background: var(--lime); transform: scale(1.05); }
.l-card.ok .l-cap { visibility: visible; }
.l-card.no { opacity: .35; animation: shake .4s; }

/* ---------- Short Talk Builder ---------- */
.talk-paper { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--paper); color: var(--ink); border: var(--edge); border-radius: var(--r); box-shadow: var(--drop); padding: 16px 22px; }
.talk-paper h2 { font-size: clamp(24px, 4vmin, 34px); margin-bottom: 8px; }
.talk-lines { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.talk-line { font: 700 clamp(20px, 3.3vmin, 28px)/1.6 var(--read); padding: 4px 10px; border-radius: var(--r-sm); animation: pop-in .3s both; }
.talk-line.cur { background: #ffeecb; }
.talk-line.speaking { background: var(--yellow); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 8px; vertical-align: middle; margin: 2px 4px; }
.chip { font: inherit; color: var(--ink); background: var(--cyan); border: 3px solid var(--ink); border-radius: var(--r-sm); box-shadow: 0 4px 0 var(--ink); padding: 0 .55em; transition: transform .08s, box-shadow .08s; }
.chip-ok { background: var(--yellow); }
.chosen { background: var(--yellow); border-radius: 8px; padding: 0 .25em; }
.talk-in { display: inline-flex; gap: 8px; vertical-align: middle; margin: 2px 4px; }
.talk-in input { font: inherit; color: var(--ink); width: 9.5em; padding: 0 .4em; border: 3px solid var(--ink); border-radius: var(--r-sm); background: #fff; -webkit-user-select: text; user-select: text; }
.talk-actions { flex: none; min-height: 70px; padding-bottom: 6px; }

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

/* A missing picture in Listen and Find falls back to the written word, so the level stays playable. */
.l-card .pic.noimg { display: none; }
.l-card .pic.noimg + .l-cap { visibility: visible; font-size: clamp(24px, 4.4vmin, 36px); padding: .8em 0; }
