/*
 * game.css — Times Tables Galaxy. Everything lives on a 390px-wide logical
 * stage that main.js scales to fit the window; positions below are stage px.
 */

:root {
  --ink: #1b1747;
  --card: #fffaf0;
  --gold: #ffc83d;
  --gold-dark: #c99a1a;
  --mint: #2fd39a;
  --coral: #ff6b6b;
  --sky: #5fd0ff;
  --violet: #8f7bff;
  --font: "Baloo 2", ui-rounded, "Nunito", "Segoe UI", system-ui, sans-serif;
}

html, body {
  margin: 0; height: 100%; overflow: hidden; background: #07061a;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; font-family: var(--font);
}

#stage {
  position: absolute; left: 50%; top: 50%; overflow: hidden; color: #fff;
  /* pastel cartoon sky: deep violet at the top (so the HUD reads), then
     lavender, pink and a warm peach glow over the desert horizon */
  background:
    radial-gradient(300px 220px at 85% 12%, rgba(255,214,250,.25), transparent 70%),
    linear-gradient(180deg, #3b2a86 0%, #6a4fc4 22%, #a77fdc 42%, #e59ac9 62%, #ffb8b0 78%, #ffd6ac 100%);
}

button { font-family: var(--font); -webkit-tap-highlight-color: transparent; }

/* ---- stars ----------------------------------------------------------- */

.stars { position: absolute; inset: 0; pointer-events: none; }
.star { position: absolute; border-radius: 50%; background: #fff; animation: twinkle var(--d, 3s) ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .25; } to { opacity: 1; } }

/* ---- living background (ambient.js) ------------------------------------ */

.ambient { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ambient > * { position: absolute; left: 0; top: 0; }
.rim-planet { width: 300px; height: 300px; margin: -150px 0 0 -150px; animation: breathe 9s ease-in-out infinite; }
.rim-planet svg { width: 100%; height: 100%; }
@keyframes breathe { 50% { opacity: .75; transform: scale(1.02); } }
.flare {
  width: 240px; height: 3px; margin: -1.5px 0 0 -120px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,236,200,.9) 50%, transparent);
  animation: flare 5s ease-in-out infinite;
}
.flare::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: #fff; box-shadow: 0 0 14px 6px rgba(255,220,170,.8);
}
@keyframes flare { 0%, 100% { opacity: .35; transform: scaleX(.6); } 50% { opacity: 1; transform: scaleX(1.15); } }
.dust { width: 2px; height: 2px; border-radius: 50%; background: #d8d0ff; animation: dust linear infinite; }
@keyframes dust { to { transform: translateX(var(--dx)); } }
.drift-rock svg, .far-saucer svg { width: 100%; height: 100%; display: block; }
.far-saucer { width: 44px; height: 30px; }
.shoot {
  height: 2px; transform-origin: 0 50%; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.95));
  box-shadow: 0 0 6px rgba(255,240,200,.8);
}
.glint { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
.glint::before, .glint::after {
  content: ""; position: absolute; left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px;
  background: linear-gradient(180deg, transparent, #fff, transparent);
}
.glint::after { transform: rotate(90deg); }

.layer { position: absolute; inset: 0; }
.layer > * { position: absolute; }

/* ---- HUD ------------------------------------------------------------- */

.hud {
  position: absolute; top: 0; left: 0; right: 0; height: 52px; z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
}
.hud[hidden] { display: none; }
.shields { display: flex; gap: 4px; }
.shields svg { width: 24px; height: 28px; transition: opacity .3s, transform .3s; }
.shields svg.lost { opacity: .2; transform: scale(.8); }
.score { margin-left: auto; font-size: 24px; font-weight: 800; min-width: 60px; text-align: right; }
.boost {
  font-size: 15px; font-weight: 800; color: var(--ink); background: var(--gold);
  border-radius: 999px; padding: 2px 10px 0; opacity: 0; transform: scale(.6); transition: .25s;
}
.boost.on { opacity: 1; transform: scale(1); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.12); color: #fff; font-size: 17px; line-height: 36px; padding: 0;
}

/* ---- shared pieces --------------------------------------------------- */

.qcard {
  left: 45px; top: 62px; width: 300px; z-index: 10; padding: 0 12px;
  background: var(--card); color: var(--ink); border-radius: 22px;
  font-size: 42px; font-weight: 800; text-align: center; line-height: 1.05; height: 64px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 #c9b98f, 0 12px 24px rgba(0,0,0,.35);
}

/* stacked fractions in questions and answers */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .6em; line-height: 1; margin: 0 .08em; }
.frac i { font-style: normal; padding: 0 .1em; }
.frac i:first-child { border-bottom: .09em solid currentColor; }
.ans { display: block; transform-origin: center; white-space: nowrap; }
.ans.s2 { transform: scale(.78); }
.ans.s3 { transform: scale(.58); }
.ans.s4 { transform: scale(.44); white-space: normal; line-height: 1.1; }
.progress { left: 0; right: 0; top: 140px; display: flex; justify-content: center; gap: 8px; z-index: 10; }
.progress i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.22); transition: .3s; }
.progress i.done { background: var(--gold); }
.progress i.now { box-shadow: 0 0 0 2px #fff; }

.btn {
  font-size: 26px; font-weight: 800; color: var(--ink); background: var(--gold);
  border: 0; border-radius: 999px; padding: 12px 38px 8px; cursor: pointer;
  box-shadow: 0 6px 0 var(--gold-dark); transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--gold-dark); }
.btn.ghost { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); font-size: 20px; }

.spark { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; z-index: 15; pointer-events: none; }
.float-text {
  position: absolute; z-index: 16; pointer-events: none; transform: translateX(-50%);
  font-size: 26px; font-weight: 800; white-space: nowrap; text-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.float-text.good { color: var(--gold); }
.float-text.bad { color: #ffd0d0; font-size: 22px; }
.laser {
  position: absolute; height: 5px; margin-top: -2.5px; transform-origin: 0 50%; z-index: 9; pointer-events: none;
  border-radius: 3px; background: linear-gradient(90deg, #fff, var(--sky)); box-shadow: 0 0 12px var(--sky);
}

/* ---- screens --------------------------------------------------------- */

.screen {
  inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 0 28px; gap: 10px;
}
.screen h1 { margin: 0; font-size: 46px; line-height: .95; font-weight: 800; }
.screen h1 b { display: block; font-size: 64px; color: var(--gold); }
.screen h1.custom-title { font-size: 40px; line-height: 1.05; color: var(--gold); overflow-wrap: anywhere; }
.screen h2 { margin: 0; font-size: 34px; font-weight: 800; }
.screen p { margin: 0; font-size: 18px; color: #dcd6ff; line-height: 1.35; }
.screen .brand { position: absolute; bottom: 22px; left: 0; right: 0; font-size: 14px; color: var(--gold); opacity: .85; }
.title-rocket { width: 110px; height: 190px; animation: hover 3s ease-in-out infinite; }
.title-rocket svg { width: 100%; height: 100%; }
@keyframes hover { 50% { transform: translateY(-14px); } }
.screen .btn { margin-top: 14px; }

.round-big { font-size: 72px !important; color: var(--gold); line-height: 1 !important; }
.lineup { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; width: 100%; }
.lineup div {
  display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.08);
  border-radius: 16px; padding: 8px 14px; font-size: 20px; font-weight: 700; text-align: left;
}
.lineup svg { width: 42px; height: 42px; flex: none; }

.banner {
  left: 20px; right: 20px; top: 50%; transform: translateY(-50%); z-index: 30;
  background: var(--card); color: var(--ink); border-radius: 26px; padding: 22px 20px 20px; text-align: center;
  box-shadow: 0 10px 0 #c9b98f, 0 20px 40px rgba(0,0,0,.5);
}
.banner h2 { margin: 0 0 4px; font-size: 32px; font-weight: 800; color: #5b3fd9; }
.banner p { margin: 0; font-size: 18px; line-height: 1.3; }

.found-planet { width: 170px; height: 170px; animation: spin-in .9s cubic-bezier(.34,1.56,.64,1); }
.found-planet svg { width: 100%; height: 100%; }
@keyframes spin-in { from { transform: scale(0) rotate(-90deg); } }
.planet-name { font-size: 30px; font-weight: 800; color: var(--gold); }
.shelf { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 6px; max-width: 300px; }
.shelf svg { width: 34px; height: 34px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 10px 0 4px; }
.stats div { background: rgba(255,255,255,.08); border-radius: 16px; padding: 10px 6px 6px; }
.stats b { display: block; font-size: 30px; line-height: 1; }
.stats span { font-size: 14px; color: #bfb6ff; }
.new-best { color: var(--ink); background: var(--gold); border-radius: 999px; padding: 2px 14px 0; font-weight: 800; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.lesson-link { color: #bfb6ff; font-size: 16px; font-weight: 700; margin-top: 6px; }

/* ---- Meteor Blaster -------------------------------------------------- */

.surface {
  left: -60px; right: -60px; height: 220px; border-radius: 50% 50% 0 0 / 60px 60px 0 0;
  background: radial-gradient(circle at 30% 30%, #4a3a9a, #2a1f66 70%);
  box-shadow: inset 0 8px 0 rgba(255,255,255,.08);
}
.surface::before, .surface::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(0,0,0,.18);
}
.surface::before { width: 60px; height: 18px; left: 90px; top: 60px; }
.surface::after { width: 40px; height: 12px; right: 110px; top: 100px; }
.shield {
  left: 0; right: 0; height: 14px; margin-top: -7px; z-index: 5; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(95,208,255,.55) 50%, transparent);
  box-shadow: 0 0 18px rgba(95,208,255,.6);
}
.shield.hit { animation: shield-hit .5s; }
@keyframes shield-hit { 30% { background: linear-gradient(180deg, transparent, rgba(255,107,107,.9) 50%, transparent); } }
.cannon { width: 64px; height: 112px; margin: -112px 0 0 -32px; z-index: 6; }
.cannon svg { width: 100%; height: 100%; }

.meteor {
  width: 92px; height: 92px; margin: -46px 0 0 -46px; padding: 0; border: 0; background: none;
  cursor: pointer; z-index: 7;
}
.meteor svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.meteor > span {
  position: absolute; left: 0; right: 0; top: 34px; font-size: 32px; font-weight: 800; color: #fff; line-height: 1;
  text-shadow: 0 2px 0 #3a2410, 0 0 6px #000, 0 0 2px #000;
}
.meteor.bad svg { filter: sepia(1) saturate(4) hue-rotate(-30deg); }
.meteor.good { filter: drop-shadow(0 0 14px var(--mint)); }

/* ---- Planet Hop ------------------------------------------------------ */

.world { inset: 0; }
.world > * { position: absolute; }
.planet {
  width: 110px; height: 110px; margin: -55px 0 0 -55px; padding: 0; border: 0; background: none; cursor: pointer;
}
.planet .bob { position: absolute; inset: 0; animation: bob 2.6s ease-in-out infinite; }
.planet .bob svg { width: 100%; height: 100%; }
.planet > span {
  position: absolute; left: 0; right: 0; top: 36px; font-size: 34px; font-weight: 800; color: #fff; line-height: 1;
  text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 8px rgba(0,0,0,.5);
}
.planet.bad .bob { filter: grayscale(1) brightness(.7); }
.planet.good .bob { filter: drop-shadow(0 0 16px var(--mint)); }
.planet.base { cursor: default; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.astro { width: 54px; height: 72px; margin: -72px 0 0 -27px; z-index: 8; pointer-events: none; }
.astro svg { width: 100%; height: 100%; }
.station { width: 170px; height: 96px; margin: -48px 0 0 -85px; }
.station svg { width: 100%; height: 100%; }

/* ---- Docking Bay ----------------------------------------------------- */

.ship { width: 120px; height: 80px; margin: -40px 0 0 -60px; z-index: 8; pointer-events: none; }
.ship .bob { width: 100%; height: 100%; animation: bob 2s ease-in-out infinite; }
.ship svg { width: 100%; height: 100%; }
.beam {
  width: 90px; height: 0; margin-left: -45px; z-index: 4; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,200,61,.35), transparent);
  clip-path: polygon(35% 0, 65% 0, 100% 100%, 0 100%);
}
/* UFO Beam-Up critters: a bouncing character with its answer on a sign */
.critter {
  width: 84px; height: 118px; margin: -59px 0 0 -42px; padding: 0; border: 0; background: none; cursor: pointer; z-index: 6;
  -webkit-tap-highlight-color: transparent;
}
.critter .hop { position: absolute; left: 4px; top: 0; width: 76px; height: 76px; animation: critter-hop 1.6s ease-in-out infinite; animation-delay: var(--d, 0s); transform-origin: 50% 100%; }
.critter svg { width: 100%; height: 100%; display: block; overflow: visible; }
.critter .sign {
  position: absolute; left: 6px; right: 6px; bottom: 0; height: 40px; display: flex; align-items: center; justify-content: center;
  background: #fffaf0; border: 3px solid #fff; border-radius: 14px; box-shadow: 0 4px 0 #c9b98f;
  color: var(--ink, #1b1747);
}
.critter .sign > span { font-size: 28px; font-weight: 800; line-height: 1; }
.critter:active .hop { transform: scale(.92); }
.critter.lifted .hop { animation: none; }
.critter.lifted { filter: drop-shadow(0 0 12px rgba(255,200,61,.9)); z-index: 7; }
.critter.good { filter: drop-shadow(0 0 14px var(--mint)); }
.critter.good .sign { background: var(--mint); color: #fff; box-shadow: 0 4px 0 #1f9c70; }
.critter.bad .sign { background: var(--coral); color: #fff; box-shadow: 0 4px 0 #c94a4a; }
.critter.bad .hop { filter: grayscale(.6); }
@keyframes critter-hop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.08, .9); }
  40% { transform: translateY(-12px) scale(.96, 1.05); }
  65% { transform: translateY(0) scale(1.05, .94); }
}
.port {
  width: 84px; height: 104px; margin: -52px 0 0 -42px; padding: 0; border: 0; background: none; cursor: pointer; z-index: 6;
}
.port svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.port > span {
  position: absolute; left: 0; right: 0; top: 46px; font-size: 34px; font-weight: 800; color: #fff; line-height: 1;
  text-shadow: 0 2px 0 rgba(0,0,0,.5);
}
.port.good .light { fill: var(--mint); }
.port.bad .light { fill: var(--coral); }
.port.good { filter: drop-shadow(0 0 14px var(--mint)); }
/* ---- Star Express ---------------------------------------------------- */

.rails {
  left: 0; right: 0; height: 16px; margin-top: -2px;
  border-top: 4px solid #c9c3e8; border-bottom: 4px solid #c9c3e8;
  background: repeating-linear-gradient(90deg, #6b5cc0 0 8px, transparent 8px 30px);
}
.rails.moving { animation: rails .3s linear infinite; }
@keyframes rails { to { background-position-x: -30px; } }
.train { display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 2px; z-index: 6; }
.loco { width: 104px; height: 80px; flex: none; }
.loco svg, .car svg { width: 100%; height: 100%; display: block; }
.car { position: relative; width: 72px; height: 62px; flex: none; margin-bottom: 4px; }
.car > span { position: absolute; left: 0; right: 4px; top: 12px; text-align: center; font-size: 24px; font-weight: 800; color: #fff; }
.car.faded { opacity: .5; }
.puff { width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: rgba(255,255,255,.7); z-index: 7; pointer-events: none; }
.step-sign {
  transform: translateX(-50%); padding: 4px 16px 2px; border-radius: 12px; font-size: 18px; font-weight: 800;
  background: rgba(255,255,255,.12); color: var(--gold); white-space: nowrap;
}
.ticket, .pad {
  width: 100px; height: 74px; margin: -37px 0 0 -50px; padding: 0; cursor: pointer; z-index: 8;
  border: 3px dashed #c9b98f; border-radius: 18px; background: var(--card); color: var(--ink);
  box-shadow: 0 5px 0 #c9b98f; font-size: 34px; font-weight: 800;
}
.pad { border-style: solid; border-color: #fff; background: #ffe9b8; box-shadow: 0 5px 0 #c99a1a; }
.ticket.good, .pad.good { background: var(--mint); color: #fff; border-color: #fff; box-shadow: 0 5px 0 #1f9c70; }
.ticket.bad, .pad.bad { background: var(--coral); color: #fff; border-color: #fff; box-shadow: 0 5px 0 #c94a4a; }

/* ---- Starburst Show -------------------------------------------------- */

.hills {
  left: -40px; right: -40px; height: 160px; border-radius: 50% 50% 0 0 / 50px 50px 0 0;
  background: linear-gradient(180deg, #2a1f66, #150f3f);
}
.shell { width: 8px; height: 22px; margin: -11px 0 0 -4px; border-radius: 4px; z-index: 6;
  background: linear-gradient(0deg, transparent, #ffc83d); box-shadow: 0 0 10px #ffc83d; }
.burst { width: 124px; height: 124px; margin: -62px 0 0 -62px; padding: 0; border: 0; background: none; cursor: pointer; z-index: 7; }
.burst svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.burst .rays { transform-origin: center; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.burst > span { position: absolute; left: 0; right: 0; top: 44px; font-size: 32px; font-weight: 800; color: #fff; line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.burst.bad svg { filter: grayscale(1) brightness(.6); }

/* ---- Cosmic Catch ---------------------------------------------------- */

.nebula {
  inset: 0; pointer-events: none;
  background: radial-gradient(220px 160px at 30% 70%, rgba(47,211,154,.16), transparent 70%),
              radial-gradient(200px 160px at 75% 55%, rgba(95,208,255,.14), transparent 70%);
}
.tractor {
  width: 90px; height: 0; margin-left: -45px; z-index: 5; pointer-events: none; opacity: 0;
  background: linear-gradient(180deg, rgba(255,200,61,.65), rgba(255,200,61,.08));
  clip-path: polygon(38% 0, 62% 0, 100% 100%, 0 100%); transition: opacity .2s;
}
.tractor.on { opacity: 1; }
.jelly { width: 80px; height: 88px; margin: -44px 0 0 -40px; padding: 0; border: 0; background: none; cursor: pointer; z-index: 6; }
.jelly .bob { position: absolute; inset: 0; animation: bob 2.2s ease-in-out infinite; transform: rotate(var(--tilt, 0deg)); }
.jelly svg { width: 100%; height: 100%; }
.jelly > span { position: absolute; left: 0; right: 0; top: 12px; font-size: 26px; font-weight: 800; color: #fff; line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
.jelly .tent { animation: sway 1.4s ease-in-out infinite alternate; transform-origin: top; }
.jelly .t1, .jelly .t3 { animation-delay: -.7s; }
@keyframes sway { to { transform: skewX(12deg); } }
.jelly.bad .bob { filter: grayscale(1) brightness(.7); }
.jelly.good { filter: drop-shadow(0 0 14px var(--mint)); }

/* ---- Robot Rumble ---------------------------------------------------- */

.ring {
  left: 10px; right: 10px; height: 70px; border-radius: 12px;
  background: linear-gradient(180deg, #3a3480, #241e5c);
  box-shadow: 0 -10px 0 -4px #ff6b6b, 0 -22px 0 -8px #ffc83d;
}
.robot { width: 126px; height: 128px; margin: -64px 0 0 -63px; z-index: 6; pointer-events: none; }
.robot svg { width: 100%; height: 100%; }
.robot.alien svg { transform: scaleX(-1); }
.robot.hit svg { filter: brightness(1.8) saturate(.4); }
.hp { left: 40px; right: 40px; top: 140px; display: flex; align-items: center; gap: 6px; z-index: 10; }
.hp b { font-size: 14px; color: #ffd0d0; margin-right: 4px; }
.hp i { flex: 1; height: 14px; border-radius: 7px; background: var(--coral); transition: .3s; }
.hp i.gone { background: rgba(255,255,255,.15); }
.charge { width: 100px; height: 10px; margin-left: -50px; border-radius: 5px; background: rgba(255,255,255,.15); overflow: hidden; z-index: 7; }
.charge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--coral)); }
.ko { font-size: 64px; font-weight: 800; color: var(--gold); text-shadow: 0 4px 0 #c94a4a; z-index: 12; transform: translateX(-50%); }

.deck {
  left: -20px; right: -20px; height: 120px; border-radius: 18px 18px 0 0;
  background: linear-gradient(180deg, #3a3480, #241e5c);
  box-shadow: inset 0 6px 0 rgba(255,255,255,.08);
}

/* ---- student login: who is playing, and whether the score was saved ---- */
.screen .player { font-size: 15px; font-weight: 700; color: #ffd76a; margin-top: 4px; }
.screen .save-note { font-size: 14px; font-weight: 700; color: #cfc8ff; margin: 2px 0 6px; }
.screen .save-note.ok { color: #6ff0be; }
.screen .save-note.bad { color: #ff9b9b; }
.screen .save-note a { color: #ffd76a; }

/* ---- critters in every mission (pickup.js) ------------------------------ */
.pickup-ship { z-index: 12; }
.layer > .tractor { z-index: 9; }
.rider { position: absolute; width: 52px; height: 52px; left: 50%; top: -38px; margin-left: -26px; z-index: 2; pointer-events: none; }
.rider svg { width: 100%; height: 100%; display: block; overflow: visible; animation: critter-hop 1.6s ease-in-out infinite; animation-delay: var(--d, 0s); transform-origin: 50% 100%; }
.rider.lifted svg { animation: none; }
.rider.lifted { filter: drop-shadow(0 0 10px rgba(255,200,61,.9)); }
.car .rider { width: 40px; height: 40px; top: -30px; margin-left: -22px; }
.car .rider svg { animation-duration: 2.2s; }

/* Meteor Rescue: the critter sits on a falling meteor with a fiery tail */
.critter.on-meteor { height: 128px; margin-top: -74px; z-index: 6; }
.critter.on-meteor .ride { position: absolute; left: 50%; top: 30px; width: 70px; height: 70px; margin-left: -35px; z-index: -1; }
.critter.on-meteor .ride svg { width: 100%; height: 100%; }
.critter.on-meteor::before {
  content: ""; position: absolute; left: 50%; top: -40px; width: 34px; height: 90px; margin-left: -17px; z-index: -2;
  background: linear-gradient(0deg, rgba(255,140,60,.7), rgba(255,200,61,0)); border-radius: 50%; filter: blur(4px);
}
.critter.on-meteor .hop { top: -6px; }
.critter.on-meteor .sign { bottom: 0; }

/* Starburst: the critter pops out of the firework */
.critter.pop { position: absolute; left: 50%; top: 50%; z-index: 1; pointer-events: none; }
.burst.bad svg { filter: grayscale(1) brightness(.6); }

/* Cosmic Catch: critters drift in bubble helmets */
.critter.swim .hop::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, rgba(255,255,255,.55) 0 8%, rgba(255,255,255,.08) 9% 62%, rgba(143,227,255,.35) 63% 70%, transparent 71%);
  border: 2px solid rgba(255,255,255,.55);
}

/* ---- pastel cartoon-space theme (ambient.js sceneSVG) -------------------- */
.scene { position: absolute !important; inset: 0; }
.scene svg { width: 100%; height: 100%; display: block; }
.twinkle-star { transform-box: fill-box; transform-origin: center; animation: star-twinkle 2.6s ease-in-out infinite; }
@keyframes star-twinkle { 50% { transform: scale(.7) rotate(18deg); opacity: .7; } }
.dust { background: #fff; box-shadow: 0 0 4px #fff; }
.star { box-shadow: 0 0 3px #fff; }
.far-saucer { opacity: .8; }

/* text on the brighter sky gets a soft shadow; panels get a violet glass */
.screen h1, .screen h2, .screen p, .planet-name, .round-big, .score { text-shadow: 0 2px 0 rgba(59,42,134,.55), 0 0 12px rgba(59,42,134,.45); }
.screen p { color: #fff; }
.lineup div, .stats div { background: rgba(59,42,134,.55); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); }
.stats span { color: #f3e9ff; }
.lesson-link { color: #fff; text-shadow: 0 1px 0 rgba(59,42,134,.6); }
.progress i { background: rgba(255,255,255,.45); }
.icon-btn { background: rgba(59,42,134,.45); }

/* mission floors become sandy desert dunes */
.surface, .deck {
  background: linear-gradient(180deg, #ffd2a8 0%, #f4ad8b 55%, #e38f7e 100%);
  box-shadow: inset 0 6px 0 rgba(255,255,255,.35);
}
.surface::before, .surface::after { background: rgba(190,110,100,.3); }
.hills { background: linear-gradient(180deg, #e9a3c0, #c97ca8); box-shadow: inset 0 6px 0 rgba(255,255,255,.25); }
.ring { background: linear-gradient(180deg, #6a4fc4, #4b3596); }
.rails { border-color: #fff3e0; background: repeating-linear-gradient(90deg, #8a5fb8 0 8px, transparent 8px 30px); }
.step-sign { background: rgba(59,42,134,.55); }
.shield { background: linear-gradient(180deg, transparent, rgba(95,208,255,.7) 50%, transparent); }
/* the lower screen sits on sand: darker violet text there */
.screen .brand { color: #5b2fa8; opacity: 1; text-shadow: 0 1px 0 rgba(255,255,255,.6); font-weight: 800; }
.screen .player { color: #fff; background: rgba(59,42,134,.6); border-radius: 999px; padding: 3px 14px 1px; text-shadow: none; }
.screen .save-note { background: rgba(59,42,134,.6); border-radius: 12px; padding: 4px 12px 2px; text-shadow: none; }

/* title screen: big UFO, green beam, two aliens and the astronaut */
.title-scene { position: relative; width: 250px; height: 250px; margin-bottom: -6px; }
.title-scene > svg { width: 100%; height: 100%; overflow: visible; }
.title-scene .ufo-body { animation: ufo-hover 3s ease-in-out infinite; }
.title-scene .ufo-beam { animation: beam-glow 2.4s ease-in-out infinite; transform-origin: 50% 0; transform-box: fill-box; }
.title-scene .ufo-light { animation: ufo-blink 1.2s steps(1) infinite; }
.ts-astro { position: absolute; right: -6px; bottom: 6px; width: 46px; height: 62px; animation: hover 3.4s ease-in-out infinite; }
.ts-astro svg { width: 100%; height: 100%; }
@keyframes ufo-hover { 50% { transform: translateY(-8px); } }
@keyframes beam-glow { 50% { opacity: .7; transform: scaleX(1.06); } }
@keyframes ufo-blink { 50% { fill: #fff; } }

/* the owner's monster sprites (img/aliens) in every answer slot */
.critter .hop img.sprite, .rider img.sprite {
  width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(20,10,50,.35));
}
.critter .hop { left: -2px; width: 88px; height: 82px; top: -6px; }
.rider img.sprite { animation: critter-hop 1.6s ease-in-out infinite; animation-delay: var(--d, 0s); transform-origin: 50% 100%; }
.rider.lifted img.sprite { animation: none; }
.critter.bad .hop img.sprite { filter: grayscale(.7) drop-shadow(0 4px 4px rgba(20,10,50,.35)); }

/* ---- the owner's background pictures (img/bg-play.*, img/bg-menu.*) ------ */
#stage.photo-bg { background: #0b0930 var(--bg-play) center / cover no-repeat; transition: background-image .4s; }
#stage.photo-bg.menu { background-image: var(--bg-menu); }
#stage.photo-bg .scene { display: none; }
#stage.photo-bg .drift-rock { display: none; }   /* the pictures already have their own asteroids */
/* mission floors become a soft dark glass so the picture shows through */
#stage.photo-bg .surface, #stage.photo-bg .deck, #stage.photo-bg .hills {
  background: linear-gradient(180deg, rgba(20,16,60,.15), rgba(10,8,30,.7)); box-shadow: inset 0 3px 0 rgba(255,255,255,.18);
}
#stage.photo-bg .surface::before, #stage.photo-bg .surface::after { background: rgba(255,255,255,.08); }
#stage.photo-bg .screen .brand { color: var(--gold); text-shadow: 0 1px 2px rgba(0,0,0,.7); }

/* ---- dark theme: drawn nebula (missions) + neon chalk (menus) ------------ */
#stage.dark-theme { background: #05081a; }
#stage .scene-menu { display: none; }
#stage.menu .scene-menu { display: block; }
#stage.menu .scene-play { display: none; }
#stage.photo-bg .scene-play, #stage.photo-bg .scene-menu { display: none; }
#stage.dark-theme .drift-rock { display: none; }
#stage.dark-theme .surface, #stage.dark-theme .deck, #stage.dark-theme .hills {
  background: linear-gradient(180deg, rgba(20,16,60,.1), rgba(6,6,24,.75)); box-shadow: inset 0 3px 0 rgba(255,255,255,.16);
}
#stage.dark-theme .surface::before, #stage.dark-theme .surface::after { background: rgba(255,255,255,.07); }
#stage.dark-theme .screen p { color: #e8e4ff; }
#stage.dark-theme .screen h1, #stage.dark-theme .screen h2, #stage.dark-theme .screen p, #stage.dark-theme .score { text-shadow: 0 2px 6px rgba(0,0,0,.75); }
#stage.dark-theme .screen .brand { color: var(--gold); text-shadow: 0 1px 2px rgba(0,0,0,.8); }
#stage.dark-theme .lineup div, #stage.dark-theme .stats div { background: rgba(12,10,40,.7); }
#stage.dark-theme .progress i { background: rgba(255,255,255,.3); }
#stage.dark-theme .rails { border-color: #c9c3e8; }

/* menus over the monster poster: the picture already shows the whole cast,
   so the drawn UFO scene steps aside and a soft dark glow sits behind the text */
#stage.photo-bg .title-scene { display: none; }
#stage.photo-bg.menu .screen {
  background: radial-gradient(ellipse 78% 34% at 50% 50%, rgba(5,8,26,.82), rgba(5,8,26,.45) 65%, transparent 100%);
}
#stage.photo-bg.menu .screen h1 { text-shadow: 0 3px 0 rgba(0,0,0,.5), 0 0 18px rgba(0,0,0,.8); }
/* the owner's pictures win over the dark theme's plain colour */
#stage.dark-theme.photo-bg { background: #05081a var(--bg-play) center / cover no-repeat; }
#stage.dark-theme.photo-bg.menu { background-image: var(--bg-menu); }
