/* Perspecta: phone first, light and dark. */
:root {
  /* Light theme: bright, high contrast, white space, bold colour accents (see docs/design-research.md). */
  --bg: #f6f7fb; --card: #ffffff; --ink: #1d2533; --muted: #5b6577; --line: #e2e6ef; --press: #cfd5e2;
  --brand: #2f6fe4; --brand-ink: #ffffff; --brand-dark: #1f4fb0; --accent: #ffb020; --accent-dark: #c98200;
  --good: #1a9a5b; --bad: #d93a3a; --info: #7c5cff;
  --good-bg: #e4f7ec; --bad-bg: #fde8e8; --info-bg: #efeaff; --sea: #d9ecff; --xp: #9a6400; --hero: linear-gradient(135deg, #2f6fe4, #12a4c9);
  --f-head: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
/* Dark theme: follows the phone setting unless the student picks Light or Dark on the Me page. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) { --bg: #0d1a27; --card: #15263a; --ink: #e7eef5; --muted: #9db0c3; --line: #2a3f57; --press: #0a1520;
    --brand: #4aa3e8; --brand-ink: #071522; --brand-dark: #2b78b5; --accent: #f2a516; --accent-dark: #b57a0c; --good: #4cc47e; --bad: #f07067; --info: #b49cf0;
    --good-bg: #133524; --bad-bg: #3a1a18; --info-bg: #261d3d; --sea: #12324a; --xp: var(--accent); --hero: linear-gradient(135deg, #123a5c, #1d6b8f); color-scheme: dark; }
}
:root[data-theme=dark] { --bg: #0d1a27; --card: #15263a; --ink: #e7eef5; --muted: #9db0c3; --line: #2a3f57; --press: #0a1520;
    --brand: #4aa3e8; --brand-ink: #071522; --brand-dark: #2b78b5; --accent: #f2a516; --accent-dark: #b57a0c; --good: #4cc47e; --bad: #f07067; --info: #b49cf0;
    --good-bg: #133524; --bad-bg: #3a1a18; --info-bg: #261d3d; --sea: #12324a; --xp: var(--accent); --hero: linear-gradient(135deg, #123a5c, #1d6b8f); color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: 16px; }
html.big-text { font-size: 19px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
body.teacher main { padding-bottom: 48px; }
button, a, input, label { touch-action: manipulation; }
.runner { scroll-margin-top: 64px; } .fb > * { scroll-margin-bottom: 84px; }
main.wide { max-width: 1100px; }
h1, h2, h3, h4 { font-family: var(--f-head); line-height: 1.2; margin: .4em 0; }
h1 { font-size: 1.8rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
a { color: var(--brand); }
.small, small { color: var(--muted); font-size: .85rem; }
.kicker { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 700; color: var(--muted); margin: 0 0 4px; }
.lead { font-size: 1.05rem; }
.note { background: var(--info-bg); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.code { font-size: .72rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.sec { margin-top: 20px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); max-width: 100%; }
.me-chip { display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); margin-right: auto; min-width: 0; }
.me-chip b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av { font-size: 1.5rem; } .av.big { font-size: 3rem; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.chip.xp { color: var(--xp); }
.icon { background: none; border: 0; font-size: 1.25rem; cursor: pointer; padding: 6px; border-radius: 8px; color: inherit; }
.back { display: inline-block; margin: 4px 0 8px; text-decoration: none; font-weight: 600; }

/* cards, buttons, bars */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px; margin: 12px 0; box-shadow: 0 1px 2px rgb(0 0 0 / .04); }
.btn { display: inline-block; border: 0; border-radius: 12px; padding: 12px 18px; margin: 6px 6px 0 0; background: var(--brand); color: var(--brand-ink);
  font: 700 1rem var(--f-head); text-decoration: none; cursor: pointer; min-height: 44px; }
.btn { box-shadow: 0 4px 0 var(--brand-dark); transition: transform .06s, box-shadow .06s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand); border: 2px solid var(--brand); box-shadow: 0 4px 0 var(--line); }
.btn.big { width: 100%; font-size: 1.15rem; padding: 14px; }
.btn:disabled { background: var(--line); color: var(--muted); box-shadow: none; cursor: default; transform: none; }
.btn:focus-visible, .opt:focus-visible, .gl:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--brand); text-decoration: underline; cursor: pointer; padding: 4px 0; font: inherit; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .6s; }
.bar.health i, .bar.full i { background: var(--good); }

/* sign in */
.signin h1 { font-size: 2.2rem; margin-top: 24px; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input:not([type]), textarea { width: 100%; font: inherit; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
input.err { border-color: var(--bad); }
.label { font-weight: 600; margin: 16px 0 6px; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.av-pick { font-size: 1.8rem; padding: 6px 0; border-radius: 12px; border: 2px solid var(--line); background: var(--card); cursor: pointer; }
.av-pick.on { border-color: var(--brand); background: var(--info-bg); }
.levels { display: grid; gap: 8px; }
.lv { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; align-items: start; margin: 0; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); font-weight: 400; cursor: pointer; }
.lv input { grid-row: span 2; margin-top: 4px; width: 20px; height: 20px; }
.lv span { color: var(--muted); font-size: .85rem; }
.lv:has(input:checked) { border-color: var(--brand); }

/* home */
.hero { background: var(--hero); color: #fff; border: 0; }
.hero .kicker { color: #bfe0f2; } .hero .bar { background: rgb(255 255 255 / .25); } .hero .bar i { background: var(--accent); }
.hero .btn { background: var(--accent); color: #1e1400; box-shadow: 0 4px 0 var(--accent-dark); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.tile span { font-size: 1.6rem; } .tile small { line-height: 1.3; }
.islands { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; border-radius: 20px;
  background: radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--sea) 60%, white 10%), var(--sea)); }
.island { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 16px; background: var(--card); text-decoration: none; color: var(--ink); border: 2px solid transparent; }
a.island { border-color: var(--good); }
.island .ic { font-size: 1.8rem; } .island small { line-height: 1.3; }
.island.locked { opacity: .65; filter: grayscale(.6); }
.lock { font-weight: 600; }

/* mission */
.phases { display: flex; gap: 6px; padding: 0; margin: 0 0 8px; list-style: none; overflow-x: auto; }
.phases li { flex: 1; min-width: 70px; text-align: center; font-size: .78rem; font-weight: 700; padding: 6px 4px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.phases li.done { background: var(--good-bg); color: var(--good); border-color: transparent; }
.phases li.now { border: 2px solid var(--brand); color: var(--ink); }
.brief { border-left: 5px solid var(--accent); }
.done h2 { margin-top: 0; }
.bring { background: var(--good-bg); border-radius: 12px; padding: 10px 12px; }

/* questions */
.dots { display: flex; gap: 5px; margin: 4px 0 8px; }
.dots i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.dots i.ok { background: var(--good); } .dots i.mid { background: var(--accent); } .dots i.no { background: var(--bad); } .dots i.now { background: var(--brand); }
.source { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--info); border-radius: 14px; padding: 12px 14px; margin: 8px 0; }
.source header { display: flex; align-items: center; gap: 10px; }
.source header div { display: flex; flex-direction: column; margin-right: auto; }
.source header small { line-height: 1.3; }
.sic { font-size: 1.8rem; }
.source p { margin: 8px 0 0; }
.q { position: relative; }
.q .say { position: absolute; top: 8px; right: 8px; }
.stem { font-weight: 700; font-size: 1.05rem; margin: 0 32px 10px 0; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; font: inherit; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--card); color: var(--ink); cursor: pointer; min-height: 48px; transition: transform .06s; }
.opt:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt.right { border-color: var(--good); background: var(--good-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); text-decoration: line-through; opacity: .8; }
.opt:disabled { cursor: default; }
.fb p { margin: 10px 0 0; }
.good { color: var(--good); font-weight: 700; }
.fb .bad, .sec .bad { color: var(--bad); font-weight: 600; }
.sec .opt.wrong { cursor: default; }
.info { background: var(--info-bg); border-radius: 10px; padding: 8px 10px; }
.skilltag { font-size: .85rem; font-weight: 600; color: var(--muted); }
.gl { font: inherit; font-weight: 700; color: var(--info); background: var(--info-bg); border: 0; border-bottom: 2px dotted var(--info); border-radius: 4px; padding: 0 3px; cursor: pointer; }
.pop-def { display: inline-block; margin: 2px 4px; padding: 2px 8px; border-radius: 8px; background: var(--info); color: #fff; font-size: .85rem; }
.wordbox { margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--info-bg); font-size: .85rem; display: grid; gap: 4px; }
.wordbox div { display: flex; gap: 6px; } .wordbox dt { font-weight: 700; } .wordbox dd { margin: 0; }
.refl b { display: block; } .refl small { display: block; font-weight: 400; margin-bottom: 4px; }

/* game */
.arena { padding: 12px; background: linear-gradient(160deg, #1b2c4a, #26467a); color: #fff; min-height: 260px; }
.gcard { background: rgb(255 255 255 / .08); border-radius: 14px; padding: 14px; }
.gt { font-size: 1.1rem; font-weight: 700; min-height: 3em; }
.tb { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tb .btn { margin: 0; } .btn.trust { background: #2e9d5b; color: #fff; box-shadow: 0 4px 0 #1d6b3d; } .btn.bust { background: #d2493f; color: #fff; box-shadow: 0 4px 0 #8f2a23; }
.gwhy { min-height: 1.5em; color: #d8e6f5; }
.arena h2 { color: #fff; }

/* leaderboards and Agent ID */
.lb { list-style: none; padding: 0; margin: 0; }
.lb li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.lb li span:nth-child(2) { margin-right: auto; }
.lb li.me { background: var(--info-bg); border-radius: 10px; font-weight: 700; }
.pos { width: 1.6em; text-align: center; font-weight: 800; color: var(--muted); }
.idcard { display: flex; gap: 14px; align-items: center; } .idcard h2 { margin: 0; } .idcard p { margin: 0; }
.skills { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .skills { grid-template-columns: 1fr 1fr; } }
.skill h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rank { margin-left: auto; font-size: .78rem; background: var(--accent); color: #1e1400; padding: 2px 8px; border-radius: 999px; }
.blk { font-size: .88rem; } .blk .bar { margin: 4px 0 10px; height: 8px; }
.stamps { display: flex; gap: 8px; flex-wrap: wrap; }
.stamp { font-size: 1.6rem; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; border: 2px dashed var(--line); filter: grayscale(1); opacity: .45; }
.stamp.got { filter: none; opacity: 1; border: 3px solid var(--bad); transform: rotate(-8deg); }

/* teacher */
.scroll { overflow-x: auto; }
.heat { border-collapse: collapse; font-size: .85rem; min-width: 640px; width: 100%; }
.heat th, .heat td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.heat td.cell { color: #fff; text-align: center; font-weight: 700; width: 44px; }
.heat tr.me td:first-child { font-weight: 800; }
.toggles { display: grid; gap: 4px; } .toggles label { font-weight: 400; margin: 4px 0; }

@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }

/* bottom tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding: 4px max(4px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0; min-height: 52px; border-radius: 12px;
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 700; }
.tabs a span { font-size: 1.35rem; line-height: 1.2; }
.tabs a.on { color: var(--brand); background: var(--info-bg); }
@media (min-width: 700px) { .tabs { left: 50%; right: auto; width: 640px; translate: -50% 0; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; } }
/* first-run card, segmented control */
.intro { border: 2px solid var(--accent); } .intro ol { padding-left: 1.2em; margin: 6px 0; } .intro li { margin: 4px 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg.three { grid-template-columns: 1fr 1fr 1fr; }
.segb { font: 700 1rem var(--f-head); padding: 12px; border-radius: 12px; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--card); color: var(--ink); cursor: pointer; min-height: 48px; }
.segb.on { border-color: var(--brand); background: var(--info-bg); }

/* ---------------- the walking agent ---------------- */
  background: linear-gradient(to bottom, var(--sea) 0 38%, color-mix(in srgb, var(--good) 22%, var(--card)) 38% 100%); border: 2px solid var(--line); }
  transform-origin: left center; transition: transform .45s ease, background .2s; position: relative; }
.agent { position: absolute; transform: translate(-50%, -50%); font-size: 2.2rem; line-height: 1; transition: left .4s ease, top .4s ease; z-index: 2; cursor: grab;
  filter: drop-shadow(0 4px 2px rgb(0 0 0 / .25)); }
.agent .bob { display: inline-block; }
.agent.walking .bob { animation: walk .2s infinite alternate; }
.agent.flip .bob { transform: scaleX(-1); }
.agent.through { transition: top .5s ease, opacity .5s; top: 14% !important; opacity: 0; }
.walkbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pad { display: grid; grid-template-columns: repeat(4, 44px); gap: 6px; }
.padb { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-size: 1rem; cursor: pointer; }
.padb:active { background: var(--press); }
.walkbar .enter { flex: 1; min-width: 0; margin: 0; }
@keyframes walk { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-5px) rotate(6deg); } }

/* ---------------- the island: 3D ground and the walking agent ---------------- */
.hero .btn.ghost.light { background: transparent; color: #fff; border: 2px solid rgb(255 255 255 / .7); box-shadow: none; }
.world { position: relative; height: min(60vh, 440px); margin: 6px 0 10px; border-radius: 20px; overflow: hidden; perspective: 900px; perspective-origin: 50% 50%;
  background: linear-gradient(to bottom, #9fd8f5 0%, #cdeefa 10%, #4fb3d9 11%, #2a8fbf 100%); border: 2px solid var(--line); touch-action: manipulation; cursor: pointer; user-select: none; }
:root[data-theme=dark] .world { background: linear-gradient(to bottom, #1d3550 0%, #2b4a6b 10%, #17557a 11%, #0f3f5c 100%); }
.ground { position: absolute; left: 0; right: 0; top: -35%; bottom: -35%; transform: rotateX(52deg); transform-origin: 50% 50%; pointer-events: none; }
.ground span { position: absolute; border-radius: 50%; }
.ground .beach { inset: 2% 3%; background: #e9d49a; box-shadow: 0 0 0 10px rgb(255 255 255 / .35); }
.ground .grass { inset: 7% 8%; background: radial-gradient(circle at 30% 30%, #8fd67f 0 25%, transparent 26%), radial-gradient(circle at 70% 70%, #7cc96e 0 22%, transparent 23%), #6dbb6a; }
.ground .path { inset: 30% 30%; border: 10px dashed rgb(240 225 180 / .9); }
.layer { position: absolute; inset: 0; pointer-events: none; }
.layer > * { position: absolute; left: 0; top: 0; pointer-events: auto; will-change: transform; }
.place { display: grid; justify-items: center; gap: 2px; border: 0; background: none; padding: 0; cursor: pointer; transform-origin: 50% 100%; }
.place .pi { font-size: 2.3rem; line-height: 1; filter: drop-shadow(0 6px 3px rgb(0 0 0 / .3)); transition: transform .2s; }
.place small { color: #1d2a1d; font-weight: 700; font-size: .7rem; line-height: 1.1; background: rgb(255 255 255 / .9); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.place.here .pi { transform: translateY(-6px) scale(1.15); }
.place.here small { background: var(--accent); color: #1e1400; }
.place.done small::before { content: "✔ "; color: var(--good); }
.place.next .pi { animation: beckon 1.2s ease-in-out infinite; }
@keyframes beckon { 50% { transform: translateY(-8px); } }

.agent3d { width: 64px; height: 64px; transform-origin: 50% 100%; pointer-events: none !important; }
.a-shadow { position: absolute; left: 12px; right: 12px; bottom: -4px; height: 10px; border-radius: 50%; background: rgb(0 0 0 / .25); }
.a-body { position: absolute; inset: 0; transform: rotateY(calc((1 - var(--face, 1)) * 90deg)); transition: transform .3s ease; transform-style: preserve-3d; }
.a-whole { position: absolute; left: 50%; bottom: 0; translate: -50% 0; font-size: 50px; line-height: 1; transform-origin: 50% 100%; filter: drop-shadow(0 2px 0 rgb(0 0 0 / .12)); }

/* four-legged cuties (fox, panda, tiger): big head in front, a round body, stubby legs and a tail */
.k-trot .a-head { position: absolute; left: 0; top: 2px; font-size: 40px; line-height: 1; z-index: 4; }
.q-torso { position: absolute; left: 18px; top: 26px; width: 38px; height: 24px; border-radius: 14px 16px 12px 12px; background: var(--fur); box-shadow: inset -5px -4px 0 rgb(0 0 0 / .1); z-index: 2; }
.panda .q-torso { background: linear-gradient(90deg, #f4f4f4 0 18%, #222 18% 40%, #f4f4f4 40%); }
.panda .q-tail { left: 53px; top: 28px; width: 9px; height: 9px; border-radius: 50%; background: #f4f4f4; box-shadow: inset -1px -1px 0 rgb(0 0 0 / .15); transform: none; animation: none !important; }
.stripes .q-torso { background: repeating-linear-gradient(100deg, var(--fur) 0 6px, #2a2a2a 6px 8px); }
.q-leg { position: absolute; top: 44px; width: 9px; height: 14px; border-radius: 4px 4px 5px 5px; background: var(--leg); transform-origin: 50% 2px; }
.q-leg::after { content: ""; position: absolute; bottom: -2px; left: -1px; width: 11px; height: 6px; border-radius: 5px; background: var(--leg); filter: brightness(.8); }
.q-leg.f1 { left: 22px; z-index: 3; } .q-leg.f2 { left: 28px; z-index: 1; } .q-leg.b1 { left: 44px; z-index: 3; } .q-leg.b2 { left: 49px; z-index: 1; }
.q-tail { position: absolute; left: 50px; top: 14px; width: 14px; height: 24px; border-radius: 50% 50% 40% 40%; background: linear-gradient(to top, var(--tail) 60%, var(--tip) 60%); transform-origin: 30% 100%; transform: rotate(35deg); z-index: 1; }
.k-trot.walking .q-leg.f1, .k-trot.walking .q-leg.b2 { animation: a-swing .28s ease-in-out infinite alternate; }
.k-trot.walking .q-leg.f2, .k-trot.walking .q-leg.b1 { animation: a-swing .28s ease-in-out infinite alternate-reverse; }
.k-trot.walking .a-body { animation: a-bob .28s ease-in-out infinite alternate; }
.k-trot .q-tail { animation: wag 1.4s ease-in-out infinite alternate; }
.k-trot.walking .q-tail { animation-duration: .3s; }
.k-trot.away .a-head { filter: brightness(.8); }

/* whole animals, each with its own way of moving */
.agent3d .a-whole { animation: breathe 2.4s ease-in-out infinite; }
.k-plod.walking .a-whole { animation: plod .7s ease-in-out infinite alternate; }
.k-hop.walking .a-whole { animation: hop .4s ease-in-out infinite; }
.k-swim .a-whole { bottom: 8px; }
/* sea animals swim through a little patch of water that travels with them */
.k-swim .a-shadow { left: 2px; right: 2px; bottom: -6px; height: 18px; background: radial-gradient(ellipse at center, #7fd3f7 0 45%, #3aa6dc 46% 62%, rgb(58 166 220 / 0) 64%); animation: ripple 1.2s ease-in-out infinite alternate; }
@keyframes ripple { from { scale: 1 1; } to { scale: 1.12 .9; } }
.k-swim.walking .a-whole { animation: swim .7s ease-in-out infinite alternate; }
.k-flutter .a-whole { bottom: 16px; animation: float 1.6s ease-in-out infinite alternate; }
.k-flutter .a-whole, .k-flutter.walking .a-whole { animation: float 1.6s ease-in-out infinite alternate, flap .18s linear infinite alternate; }
.k-squish.walking .a-whole { animation: squish .45s ease-in-out infinite alternate; }
.k-scurry.walking .a-whole { animation: hop .2s ease-in-out infinite; }
.k-wiggle.walking .a-whole { animation: wiggle .22s ease-in-out infinite alternate; }

@keyframes a-swing { from { transform: rotate(32deg); } to { transform: rotate(-32deg); } }
@keyframes a-bob { from { translate: 0 0; } to { translate: 0 -3px; } }
@keyframes wag { from { transform: rotate(20deg); } to { transform: rotate(50deg); } }
@keyframes breathe { 50% { scale: 1.03 0.97; } }
@keyframes plod { from { rotate: -5deg; translate: -50% 0; } to { rotate: 5deg; translate: -50% -2px; } }
@keyframes hop { 0%, 100% { translate: -50% 0; scale: 1.05 .92; } 50% { translate: -50% -14px; scale: .95 1.05; } }
@keyframes swim { from { rotate: -14deg; translate: -50% 0; } to { rotate: 10deg; translate: -50% -10px; } }
@keyframes float { from { translate: -50% 0; } to { translate: -50% -10px; } }
@keyframes flap { from { scale: 1 1; } to { scale: .55 1; } }
@keyframes squish { from { scale: 1.15 .82; rotate: -4deg; } to { scale: .9 1.12; rotate: 4deg; } }
@keyframes wiggle { from { rotate: -12deg; } to { rotate: 12deg; } }
.isle-go { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 52px; }
.isle-go p { margin: 0; flex: 1 1 160px; }
@media (prefers-reduced-motion: reduce) { .agent3d *, .place.next .pi { animation: none !important; } .a-body { transition: none; } }

.gcard .gd { margin: 8px 0 14px; font-size: 1rem; font-weight: 600; color: #dbe6f5; }
.gcard .gd::before { content: "🔎 "; }
.source .byline { margin: 8px 0 0; padding-top: 6px; border-top: 1px dashed var(--line); font-size: .9rem; color: var(--muted); font-weight: 600; }

/* ---------------- archipelago: open islands are buttons ---------------- */
button.island { font: inherit; text-align: left; cursor: pointer; border-color: var(--good); }
.island.here { box-shadow: 0 0 0 3px var(--brand); }

/* ---------------- Signal Point: a rockier, cooler island ---------------- */
.isle-signal .ground .beach { background: #d9d2c0; }
.isle-signal .ground .grass { background: radial-gradient(circle at 30% 30%, #9cc8a0 0 25%, transparent 26%), radial-gradient(circle at 70% 70%, #86b98d 0 22%, transparent 23%), #79a983; }

/* ---------------- sentence jumble ---------------- */
.jumble .j-order { list-style: none; counter-reset: j; margin: 10px 0; padding: 0; display: grid; gap: 6px; }
.jumble .j-order li { counter-increment: j; display: flex; gap: 8px; align-items: stretch; }
.jumble .j-order li::before { content: counter(j); flex: 0 0 28px; display: grid; place-items: center; border-radius: 50%; height: 28px; margin-top: 8px; background: var(--line); font-weight: 700; color: var(--ink); }
.jumble .j-empty { min-height: 44px; }
.jumble .j-empty::after { content: ""; flex: 1; border: 2px dashed var(--press); border-radius: 12px; }
.jumble .j-pool { display: grid; gap: 8px; margin: 8px 0 12px; }
.jpart { font: inherit; text-align: left; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--press); background: var(--card); color: var(--ink); cursor: pointer; line-height: 1.35; }
.jpart.placed { border-color: var(--brand); background: var(--sea); }
.jpart:disabled { cursor: default; opacity: .9; }

/* ---------------- Debate Dojo ---------------- */
.tile.wide { grid-column: 1 / -1; }
.dojo-blocks { display: grid; gap: 8px; margin: 10px 0; }

/* ---------------- tap feedback: shake on wrong, pop on right, snap when a sentence is placed ---------------- */
@keyframes shake { 0%, 100% { translate: 0 0; } 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }
@keyframes pop { 0% { scale: 1; } 40% { scale: 1.05; } 100% { scale: 1; } }
@keyframes snap { from { opacity: .3; translate: 0 14px; scale: .97; } to { opacity: 1; translate: 0 0; scale: 1; } }
.shake { animation: shake .35s ease-in-out; }
.pop { animation: pop .3s ease-out; }
.jpart.snap { animation: snap .18s ease-out; }
.j-order.solved .jpart { border-color: var(--good); background: var(--good-bg); animation: pop .3s ease-out; }
.jpart.shake { border-color: var(--bad); }
@media (prefers-reduced-motion: reduce) { .shake, .pop, .jpart.snap, .j-order.solved .jpart { animation: none; } }
