/* SparkGlee — game styles, batch C: times, world, science, unscramble, codebot, sudoku, balance, echo.
 * Every rule is scoped under its game's .g-<id> root. */

/* =========================================================== Times Turbo */
.g-times {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
  min-height: 210px; padding: 12px; overflow: hidden;
  background: linear-gradient(180deg, #7fd3ff 0%, #bdeaff 38%, #7ed957 38%, #4fb83a 100%);
}
.g-times .sky { position: absolute; inset: 0 0 62% 0; pointer-events: none; }
.g-times .cloud { position: absolute; font-size: 34px; opacity: .9; animation: gt-drift 18s linear infinite; }
.g-times .cloud.c1 { top: 8%; left: -10%; }
.g-times .cloud.c2 { top: 26%; left: -10%; font-size: 24px; animation-duration: 26s; animation-delay: -12s; }
@keyframes gt-drift { to { transform: translateX(120vw); } }
.g-times .track {
  position: relative; height: clamp(120px, 24vh, 180px); border-radius: 18px;
  background:
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(255,255,255,.08) 34px 36px),
    linear-gradient(180deg, #4a4f5c, #2f333d);
  box-shadow: inset 0 6px 0 #ff4d4d, inset 0 -6px 0 #ff4d4d, inset 0 9px 0 #fff, inset 0 -9px 0 #fff, 0 10px 24px rgba(0,0,0,.25);
  overflow: hidden;
}
.g-times .lane { position: absolute; left: 0; right: 0; height: 50%; }
.g-times .lane-rival { top: 0; border-bottom: 4px dashed rgba(255,255,255,.55); }
.g-times .lane-me { bottom: 0; }
.g-times .finish {
  position: absolute; top: 0; bottom: 0; right: 8%; width: 22px;
  background: conic-gradient(#fff 25%, #111 0 50%, #fff 0 75%, #111 0) 0 0 / 11px 11px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.4);
}
.g-times .flag { position: absolute; right: calc(8% - 6px); top: -2px; font-size: 30px; transform-origin: bottom left; animation: gt-wave 1s ease-in-out infinite alternate; z-index: 3; }
@keyframes gt-wave { to { transform: rotate(-10deg); } }
.g-times .car {
  position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: clamp(40px, 9vw, 64px);
  transition: left .7s cubic-bezier(.2, .9, .3, 1.1); z-index: 2; line-height: 1;
}
/* .me is also the global profile-chip class (style.css): undo its pill background/padding on the kid's car. */
.g-times .car.me { display: block; background: none; box-shadow: none; padding: 0; border-radius: 0; min-width: 0; gap: 0; }
.g-times .car .body { display: inline-block; transform: scaleX(-1); filter: drop-shadow(0 6px 4px rgba(0,0,0,.35)); animation: gt-rumble .18s linear infinite alternate; }
.g-times .car.rival .body { opacity: .92; }
@keyframes gt-rumble { to { transform: scaleX(-1) translateY(-2px); } }
.g-times .car .flame {
  position: absolute; left: -22px; top: 50%; width: 26px; height: 12px; margin-top: -2px; border-radius: 50%;
  background: radial-gradient(circle at 80% 50%, #fff6a8, #ffb300 40%, #ff4d00 70%, transparent 72%);
  opacity: 0; transform: scaleX(.3); transform-origin: right center; transition: opacity .2s, transform .2s;
}
.g-times .car.zoom .flame { opacity: 1; transform: scaleX(1.4); }
.g-times .car.zoom::before {
  content: ''; position: absolute; right: 100%; top: 20%; width: 90px; height: 60%;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.75) 0 3px, transparent 3px 10px);
  -webkit-mask: linear-gradient(90deg, transparent, #000); mask: linear-gradient(90deg, transparent, #000);
  animation: gt-lines .5s ease-out forwards;
}
@keyframes gt-lines { from { opacity: 1; } to { opacity: 0; transform: translateX(-30px); } }
.g-times .car.sputter .body { animation: gt-sputter .45s ease; }
@keyframes gt-sputter { 0%,100% { transform: scaleX(-1); } 25% { transform: scaleX(-1) rotate(-8deg) translateX(-4px); } 60% { transform: scaleX(-1) rotate(6deg); } }
.g-times .car.sputter::after { content: '💨'; position: absolute; left: -26px; top: 0; font-size: 26px; animation: gt-puff .6s ease-out forwards; }
@keyframes gt-puff { to { opacity: 0; transform: translate(-16px, -10px) scale(1.4); } }
.g-times .problem {
  align-self: center; position: relative; z-index: 2;
  padding: 8px 26px; border-radius: 999px; font-weight: 700; font-size: clamp(30px, 7vw, 48px); color: #2b2d42;
  background: linear-gradient(180deg, #fff, #ffe9a8); box-shadow: 0 6px 0 #e0a800, 0 12px 20px rgba(0,0,0,.2);
}
.g-times .problem b { color: #ff5f6d; }
.g-times.won .car.me .body { animation: gt-jump .5s ease 3; }
@keyframes gt-jump { 50% { transform: scaleX(-1) translateY(-18px) rotate(-8deg); } }
.g-times.won .flag { animation: gt-wave .25s ease-in-out infinite alternate; font-size: 40px; }

/* =========================================================== World Explorer */
.g-world {
  display: flex; align-items: center; justify-content: center; min-height: 190px; padding: 14px; overflow: hidden;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.35), transparent 55%), linear-gradient(160deg, #7ee8fa 0%, #3fa7e0 100%);
}
.g-world .globe-bg { position: absolute; right: -40px; bottom: -50px; font-size: 220px; opacity: .14; animation: gw-spin 40s linear infinite; pointer-events: none; }
@keyframes gw-spin { to { transform: rotate(360deg); } }
.g-world .dots { position: absolute; inset: 0; background: radial-gradient(rgba(255,255,255,.35) 1.5px, transparent 2px) 0 0 / 22px 22px; pointer-events: none; }
.g-world .postcard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 28px 14px; min-width: min(78%, 300px); border-radius: 22px; transform: rotate(-2deg);
  background: linear-gradient(180deg, #fffdf6, #fff3d6);
  box-shadow: 0 0 0 6px #fff, 0 0 0 9px #ffcf5c, 0 14px 30px rgba(0,0,0,.22);
}
.g-world .stamp {
  position: absolute; top: -14px; right: -12px; width: 50px; height: 50px; display: grid; place-items: center; font-size: 26px;
  background: #ff7a7a; border-radius: 8px; transform: rotate(12deg); box-shadow: 0 0 0 4px #fff, 0 4px 8px rgba(0,0,0,.2);
  outline: 3px dotted #fff; outline-offset: -8px;
}
.g-world .pic { font-size: clamp(70px, 17vw, 120px); line-height: 1.1; filter: drop-shadow(0 8px 8px rgba(0,0,0,.18)); }
.g-world .pic.flag { font-size: clamp(84px, 21vw, 140px); }
.g-world .cap { font-weight: 700; font-size: clamp(16px, 3.8vw, 22px); color: #2d5f8a; text-align: center; }
.g-world .cap::first-letter { text-transform: uppercase; }
.g-world ~ .choices .wx-ico { font-size: 1.25em; margin-right: 4px; vertical-align: -2px; }

/* =========================================================== Science Sparks */
.g-science {
  display: flex; align-items: center; justify-content: center; min-height: 190px; padding: 14px; overflow: hidden;
  background: radial-gradient(circle at 50% 110%, #b7fff1 0%, transparent 60%), linear-gradient(160deg, #3b2f8f 0%, #5a48d6 55%, #18a999 100%);
}
.g-science .bubbles i {
  position: absolute; bottom: -20px; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, rgba(255,255,255,.2)); opacity: .55;
  animation: gs-rise 5s ease-in infinite;
}
.g-science .bubbles i:nth-child(even) { width: 9px; height: 9px; animation-duration: 6.5s; }
@keyframes gs-rise { to { transform: translateY(-110vh) translateX(20px); opacity: 0; } }
.g-science .flask {
  position: relative; width: clamp(130px, 34vw, 190px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.9), rgba(255,255,255,.25) 45%, rgba(140,255,230,.25) 70%);
  box-shadow: 0 0 0 6px rgba(255,255,255,.35), 0 0 40px rgba(140,255,230,.55), inset 0 -16px 30px rgba(0,180,160,.35);
  animation: gs-glow 2.4s ease-in-out infinite alternate;
}
@keyframes gs-glow { to { box-shadow: 0 0 0 9px rgba(255,255,255,.25), 0 0 60px rgba(255,140,220,.6), inset 0 -16px 30px rgba(0,180,160,.35); } }
.g-science .pic { font-size: clamp(64px, 16vw, 100px); filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); }
.g-science .fact {
  position: absolute; left: 50%; bottom: 12px; width: min(92%, 520px); transform: translate(-50%, 140%);
  display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: 18px; cursor: pointer;
  background: linear-gradient(180deg, #fffbe0, #ffe98a); color: #4a3b00; font-size: clamp(15px, 3.6vw, 19px); line-height: 1.3;
  box-shadow: 0 10px 24px rgba(0,0,0,.3), 0 0 0 4px rgba(255,255,255,.6);
  transition: transform .45s cubic-bezier(.2, 1.4, .4, 1); z-index: 3; text-align: center;
}
.g-science .fact b { color: #d97a00; font-size: 1.05em; }
.g-science.show-fact .fact { transform: translate(-50%, 0); }
.g-science.show-fact .flask { animation: gs-pop .6s ease; }
@keyframes gs-pop { 40% { transform: scale(1.12) rotate(-4deg); } }

/* =========================================================== Word Wizard */
.g-unscramble {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2.4vh, 20px);
  padding: 14px 10px; min-height: 260px; overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.5) 1.5px, transparent 2px) 0 0 / 46px 46px,
    radial-gradient(circle at 70% 60%, rgba(255,230,140,.6) 1.5px, transparent 2px) 0 0 / 60px 60px,
    linear-gradient(170deg, #2a1b5e 0%, #5b2a9c 60%, #a8418f 100%);
}
.g-unscramble .wizard { display: flex; align-items: center; gap: 8px; color: #ffe9a8; font-weight: 600; }
.g-unscramble .count { padding: 4px 12px; border-radius: 999px; background: rgba(255,255,255,.15); font-size: 15px; }
.g-unscramble .slots, .g-unscramble .pool {
  --sz: min(74px, calc((100vw - 56px) / var(--n) - 6px));
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%;
}
.g-unscramble .slot, .g-unscramble .tile {
  width: var(--sz); height: calc(var(--sz) * 1.1); border-radius: 14px; border: 0; padding: 0;
  font: 700 calc(var(--sz) * .55) 'Fredoka', system-ui, sans-serif; display: grid; place-items: center; cursor: pointer;
}
.g-unscramble .slot.empty { background: rgba(255,255,255,.12); box-shadow: inset 0 -4px 0 rgba(255,255,255,.25); border: 2px dashed rgba(255,255,255,.4); cursor: default; }
.g-unscramble .slot.filled {
  color: #4a2a00; background: linear-gradient(180deg, #fff6c9, #ffd45c); box-shadow: 0 5px 0 #d99a00, 0 8px 14px rgba(0,0,0,.25);
  animation: gu-drop .25s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes gu-drop { from { transform: translateY(-14px) scale(.8); } }
.g-unscramble .tile {
  color: #fff; background: linear-gradient(180deg, #8ec5ff, #4d7cff); box-shadow: 0 6px 0 #2f4fc4, 0 10px 16px rgba(0,0,0,.3);
  animation: gu-in .4s cubic-bezier(.3, 1.6, .5, 1) backwards; transition: transform .15s, opacity .2s;
}
.g-unscramble .tile:active { transform: translateY(4px); box-shadow: 0 2px 0 #2f4fc4; }
.g-unscramble .tile.used { opacity: .18; transform: scale(.85); pointer-events: none; }
.g-unscramble .tile.pop { animation: gu-in .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes gu-in { from { transform: scale(.2) rotate(-30deg); opacity: 0; } }
.g-unscramble .slots.solved .slot { background: linear-gradient(180deg, #d9ffd1, #6be08a); box-shadow: 0 5px 0 #2fa652, 0 0 22px rgba(160,255,170,.8); animation: gu-win .6s ease both; }
.g-unscramble .slots.solved .slot:nth-child(2n) { animation-delay: .08s; }
.g-unscramble .slots.solved .slot:nth-child(3n) { animation-delay: .16s; }
@keyframes gu-win { 50% { transform: translateY(-12px) rotate(6deg); } }
.g-unscramble .shuffle {
  border: 0; border-radius: 999px; padding: 10px 22px; min-height: 48px; cursor: pointer;
  font: 600 18px 'Fredoka', system-ui, sans-serif; color: #5b2a9c; background: linear-gradient(180deg, #fff, #e9dcff);
  box-shadow: 0 5px 0 #b69bf0, 0 8px 14px rgba(0,0,0,.25);
}
.g-unscramble .shuffle:active { transform: translateY(3px); box-shadow: 0 2px 0 #b69bf0; }

/* =========================================================== Code Bot */
.g-codebot {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 10px; min-height: 0;
  background: linear-gradient(180deg, #1d2b64 0%, #2a4d9b 100%);
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(180deg, #1d2b64 0%, #2a4d9b 100%);
  background-size: 24px 24px, 24px 24px, auto;
}
.g-codebot .board-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.g-codebot .board {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr);
  gap: 4px; padding: 6px; aspect-ratio: 1; width: min(100%, 44vh, 420px); max-height: 100%;
  border-radius: 18px; background: #0f1a3d; box-shadow: 0 0 0 4px #4fd1ff, 0 0 30px rgba(79,209,255,.45), 0 12px 24px rgba(0,0,0,.35);
}
.g-codebot .cell {
  border-radius: 10px; display: grid; place-items: center; font-size: calc(min(100vw, 44vh, 420px) / var(--n) * .5);
  background: linear-gradient(180deg, #8be28b, #5cc46a); box-shadow: inset 0 -4px 0 rgba(0,0,0,.12);
}
.g-codebot .cell.alt { background: linear-gradient(180deg, #9cec96, #6fd17a); }
.g-codebot .cell.rock { background: linear-gradient(180deg, #b49a7d, #8a7058); }
.g-codebot .cell.water { background: linear-gradient(180deg, #6ec8ff, #2f8ae0); animation: gc-water 2s ease-in-out infinite alternate; }
@keyframes gc-water { to { filter: brightness(1.15); } }
.g-codebot .piece {
  position: absolute; display: grid; place-items: center; pointer-events: none;
  width: calc((100% - 12px - (var(--n) - 1) * 4px) / var(--n)); aspect-ratio: 1;
  left: calc(6px + var(--c) * ((100% - 12px - (var(--n) - 1) * 4px) / var(--n) + 4px));
  top: calc(6px + var(--r) * ((100% - 12px - (var(--n) - 1) * 4px) / var(--n) + 4px));
  font-size: calc(min(100vw, 44vh, 420px) / var(--n) * .62);
}
.g-codebot .bot { transition: left .36s cubic-bezier(.4, 1.5, .5, 1), top .36s cubic-bezier(.4, 1.5, .5, 1); z-index: 2; }
.g-codebot .bot span { filter: drop-shadow(0 4px 4px rgba(0,0,0,.35)); animation: gc-hover 1.4s ease-in-out infinite alternate; }
@keyframes gc-hover { to { transform: translateY(-4px); } }
.g-codebot .bot.bump span { animation: gc-bump .5s ease; }
@keyframes gc-bump { 35% { transform: translate(calc(var(--dx, 0) * 22%), calc(var(--dy, 0) * 22%)) rotate(-12deg); } 70% { transform: rotate(8deg); } }
.g-codebot .bot.win span { animation: gc-win .5s ease 3; }
@keyframes gc-win { 50% { transform: translateY(-30%) rotate(360deg) scale(1.2); } }
.g-codebot .gem span { animation: gc-gem 1.2s ease-in-out infinite alternate; filter: drop-shadow(0 0 8px rgba(120,220,255,.9)); }
@keyframes gc-gem { to { transform: scale(1.12) rotate(8deg); } }
.g-codebot .gem.got span { animation: gc-got .45s ease forwards; }
@keyframes gc-got { to { transform: translateY(-60%) scale(1.6); opacity: 0; } }
.g-codebot .prog {
  display: flex; align-items: center; gap: 8px; width: min(100%, 560px); min-height: 56px; padding: 6px 10px; border-radius: 16px;
  background: rgba(0,0,0,.25); box-shadow: inset 0 2px 8px rgba(0,0,0,.35);
}
.g-codebot .queue { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; min-height: 40px; }
.g-codebot .queue .empty { color: rgba(255,255,255,.5); font-size: 22px; }
.g-codebot .chip {
  position: relative; min-width: 40px; height: 40px; border: 0; border-radius: 10px; cursor: pointer; padding: 0 6px;
  font: 700 22px 'Fredoka', system-ui, sans-serif; color: #fff; background: linear-gradient(180deg, #ffb347, #ff7b39);
  box-shadow: 0 3px 0 #c4521a; animation: gu-in .25s cubic-bezier(.3, 1.6, .5, 1);
}
.g-codebot .chip.twice { background: linear-gradient(180deg, #ff7ad9, #c84bff); box-shadow: 0 3px 0 #8a2bbf; }
.g-codebot .chip sup { font-size: 12px; margin-left: 1px; }
.g-codebot .chip.now { outline: 3px solid #fff; transform: translateY(-4px) scale(1.1); box-shadow: 0 0 16px #fff58a; }
.g-codebot .counter { color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; }
.g-codebot .counter:empty { display: none; }
.g-codebot .counter.full { color: #ffd45c; }
.g-codebot .pad { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: min(100%, 560px); }
.g-codebot .cmd, .g-codebot .run {
  min-width: 64px; height: 64px; border: 0; border-radius: 18px; cursor: pointer;
  font: 700 30px 'Fredoka', system-ui, sans-serif; color: #fff;
  background: linear-gradient(180deg, #5ee7df, #22a6c9); box-shadow: 0 6px 0 #167a96, 0 10px 16px rgba(0,0,0,.3);
  transition: transform .08s;
}
.g-codebot .cmd:active, .g-codebot .run:active { transform: translateY(4px); box-shadow: 0 2px 0 #167a96; }
.g-codebot .cmd.x2 { font-size: 24px; background: linear-gradient(180deg, #ff9be6, #c84bff); box-shadow: 0 6px 0 #8a2bbf; }
.g-codebot .cmd.x2.on { outline: 4px solid #fff58a; transform: scale(1.08); }
.g-codebot .cmd.clear { font-size: 20px; padding: 0 14px; background: linear-gradient(180deg, #ced6e6, #8f9bb6); box-shadow: 0 6px 0 #5f6a85; }
.g-codebot .run { padding: 0 20px; font-size: 24px; background: linear-gradient(180deg, #7cf29c, #1fbf5b); box-shadow: 0 6px 0 #148a40, 0 10px 16px rgba(0,0,0,.3); }
.g-codebot.running .pad { opacity: .55; pointer-events: none; }
@media (max-width: 420px) {
  .g-codebot .cmd, .g-codebot .run { min-width: 56px; height: 56px; font-size: 26px; }
  .g-codebot .run { font-size: 20px; padding: 0 14px; }
}

/* =========================================================== Puzzle Pals (mini sudoku) */
.g-sudoku {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px 10px;
  background: radial-gradient(circle at 20% 15%, rgba(255,255,255,.45), transparent 50%), linear-gradient(160deg, #ffe29f 0%, #ffa99f 60%, #ff719a 100%);
}
.g-sudoku .sgrid-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.g-sudoku .sgrid {
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; padding: 8px; aspect-ratio: 1;
  width: min(100%, 46vh, 420px); border-radius: 20px; background: #6b3fa0;
  box-shadow: 0 0 0 5px #fff, 0 14px 30px rgba(107,63,160,.4);
}
.g-sudoku .scell {
  border: 0; border-radius: 10px; padding: 0; display: grid; place-items: center; cursor: pointer;
  font: 700 calc(min(100vw, 46vh, 420px) / var(--n) * .42) 'Fredoka', system-ui, sans-serif; color: #4b2a7a;
  background: #fff; box-shadow: inset 0 -4px 0 rgba(107,63,160,.15); animation: gu-in .35s ease backwards;
  transition: background .15s, transform .15s;
}
.g-sudoku .sgrid.fruit .scell { font-size: calc(min(100vw, 46vh, 420px) / var(--n) * .5); }
.g-sudoku .scell.given { background: linear-gradient(180deg, #f3eaff, #e2d2ff); cursor: default; }
.g-sudoku .scell.blank { background: #fff; }
/* Boxes alternate tint so kids can see them. */
.g-sudoku .scell.given.alt { background: linear-gradient(180deg, #d9f1ff, #bfe3ff); }
.g-sudoku .scell.blank.alt { background: #f1f9ff; }
.g-sudoku .scell.blank.peer, .g-sudoku .scell.peer { background: #fff4d6; }
.g-sudoku .scell.blank.sel { background: #ffe066; transform: scale(1.06); box-shadow: 0 0 0 3px #ff9f1c, 0 6px 12px rgba(0,0,0,.2); z-index: 1; }
.g-sudoku .scell.blank.filled { color: #1f9d55; background: linear-gradient(180deg, #e6ffe9, #c3f5cc); animation: gs-fill .35s cubic-bezier(.3, 1.6, .5, 1); }
.g-sudoku .scell.blank.wrong { color: #e63946; background: #ffe0e3; }
@keyframes gs-fill { from { transform: scale(.6); } }
.g-sudoku .sgrid.solved .scell { animation: gs-wave .7s ease; }
.g-sudoku .sgrid.solved .scell:nth-child(odd) { animation-delay: .1s; }
@keyframes gs-wave { 50% { transform: translateY(-8px) scale(1.06); background: #fff6a8; } }
.g-sudoku .palette { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; width: min(100%, 520px); }
.g-sudoku .sym {
  width: clamp(46px, calc((100vw - 80px) / var(--n) - 8px), 76px); aspect-ratio: 1; /* 6 fit on one row at 390px */ border: 0; border-radius: 18px; cursor: pointer;
  font: 700 clamp(26px, 7vw, 38px) 'Fredoka', system-ui, sans-serif; color: #fff;
  background: linear-gradient(180deg, #b388ff, #7c4dff); box-shadow: 0 6px 0 #5530c4, 0 10px 16px rgba(0,0,0,.2);
}
.g-sudoku .sym.fruit { background: linear-gradient(180deg, #fff, #ffe6f0); box-shadow: 0 6px 0 #f5a3c4, 0 10px 16px rgba(0,0,0,.2); }
.g-sudoku .sym:active { transform: translateY(4px); box-shadow: 0 2px 0 #5530c4; }

/* =========================================================== Balance Bridge */
.g-balance {
  --tilt: 0deg;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-height: 230px; padding: 10px; overflow: hidden;
  background: linear-gradient(180deg, #b8f3ff 0%, #e8fbff 60%, #c6f1d6 60%, #8fd9a8 100%);
}
.g-balance .hills { position: absolute; left: -10%; right: -10%; bottom: 0; height: 46%; background: radial-gradient(ellipse at 30% 100%, #6fcf8f 0 45%, transparent 46%), radial-gradient(ellipse at 80% 100%, #5bbf7d 0 40%, transparent 41%); pointer-events: none; }
.g-balance .scale { position: relative; width: min(94%, 520px); height: clamp(190px, 34vh, 280px); }
/* stand = illustrated picture (prop/scale-stand) sized so its golden knob's centre sits on the beam's pivot (28% down) */
.g-balance .gb-stand { position: absolute; left: 50%; bottom: 0; height: 78.8%; width: auto; transform: translateX(-50%); z-index: 1; pointer-events: none;
  filter: drop-shadow(0 8px 8px rgba(0,0,0,.18)); }
.g-balance .beam {
  position: absolute; left: 4%; right: 4%; top: 28%; height: 14px; margin-top: -7px; border-radius: 7px;
  background: linear-gradient(180deg, #ffd86b, #e69b00); box-shadow: 0 4px 8px rgba(0,0,0,.2);
  transform: rotate(var(--tilt)); transition: transform 1s cubic-bezier(.3, 1.7, .5, 1); z-index: 2;
}
.g-balance .hanger {
  position: absolute; top: 7px; width: 0; display: flex; flex-direction: column; align-items: center;
  transform: rotate(calc(var(--tilt) * -1)); transform-origin: top center; transition: transform 1s cubic-bezier(.3, 1.7, .5, 1);
}
.g-balance .hanger.hl { left: 10%; }
.g-balance .hanger.hr { right: 10%; }
.g-balance .rope { display: block; width: 3px; height: clamp(34px, 7vh, 56px); background: #8a6d3b; }
.g-balance .pan {
  position: relative; display: flex; justify-content: center; align-items: flex-end; min-width: clamp(110px, 30vw, 170px); height: 64px; margin-top: -2px;
}
.g-balance .pan::after { /* illustrated dish (prop/scale-pan): its rim sits at the weight's foot */
  content: ''; position: absolute; left: 0; right: 0; top: calc(100% - 20px); aspect-ratio: 520 / 241;
  background: url(../img/art/props/scale-pan.webp) center / contain no-repeat; filter: drop-shadow(0 6px 6px rgba(0,0,0,.15));
}
.g-balance .weight {
  position: relative; z-index: 1; margin-bottom: 4px; padding: 8px 14px; border-radius: 14px; white-space: nowrap;
  font-weight: 700; font-size: clamp(22px, 5.4vw, 32px); color: #fff;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.18), 0 6px 10px rgba(0,0,0,.18);
}
.g-balance .lw { background: linear-gradient(180deg, #ff8a65, #ff5252); }
.g-balance .rw { background: linear-gradient(180deg, #64b5ff, #3d7bff); }
.g-balance .weight .q { display: inline-grid; place-items: center; min-width: 1.4em; padding: 0 4px; border-radius: 8px; background: #fff; color: #ff5252; animation: gb-blink 1s ease-in-out infinite alternate; }
.g-balance .weight .try { display: inline-block; min-width: 1.2em; padding: 0 4px; border-radius: 8px; background: #fff7c2; color: #c2410c; }
.g-balance .weight i { font-style: italic; }
@keyframes gb-blink { to { transform: scale(1.12); } }
.g-balance.balanced .weight { box-shadow: 0 0 0 4px #fff, 0 0 24px rgba(255,240,120,.95); }
.g-balance.balanced .weight .try { background: #c8ffd0; color: #138a36; }
.g-balance.balanced .gb-stand { animation: gb-shine .8s ease 2; }
@keyframes gb-shine { 50% { filter: drop-shadow(0 0 14px #fff58a) drop-shadow(0 0 6px #fff); } }

/* =========================================================== Echo Birds */
.g-echo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 240px; padding: 12px; overflow: hidden;
  background: linear-gradient(180deg, #8fd3ff 0%, #c9f0ff 55%, #e9fff3 100%);
}
.g-echo .sun { position: absolute; top: 14px; left: 18px; width: 62px; height: 62px; border-radius: 50%; background: radial-gradient(circle, #fff7b0, #ffd23f 60%); box-shadow: 0 0 40px 14px rgba(255,214,70,.55); animation: ge-sun 4s ease-in-out infinite alternate; }
@keyframes ge-sun { to { transform: scale(1.08); } }
.g-echo .cloud { position: absolute; width: 90px; height: 30px; border-radius: 30px; background: #fff; opacity: .9; animation: gt-drift 30s linear infinite; }
.g-echo .cloud::before, .g-echo .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.g-echo .cloud::before { width: 40px; height: 40px; left: 14px; top: -20px; }
.g-echo .cloud::after { width: 30px; height: 30px; left: 44px; top: -12px; }
.g-echo .cloud.c1 { top: 16%; left: -20%; }
.g-echo .cloud.c2 { top: 34%; left: -20%; transform: scale(.7); animation-duration: 42s; animation-delay: -20s; }
.g-echo .progress { display: flex; gap: 8px; z-index: 1; }
.g-echo .progress i { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.7); box-shadow: inset 0 2px 3px rgba(0,0,0,.15); transition: background .2s, transform .2s; }
.g-echo .progress i.on { background: #ffcc33; transform: scale(1.2); box-shadow: 0 0 10px #ffcc33; }
.g-echo .branch {
  --bw: min(94vw, 640px);
  position: relative; display: flex; justify-content: space-around; align-items: flex-end;
  width: var(--bw); padding: 0 4px 20px;
}
.g-echo .wood {
  position: absolute; left: -6%; right: -6%; bottom: 0; height: 22px; border-radius: 12px;
  background: linear-gradient(180deg, #a0673a, #6d4123); box-shadow: 0 6px 10px rgba(0,0,0,.2); transform: rotate(-1.5deg);
}
.g-echo .leaf { position: absolute; width: 28px; height: 16px; border-radius: 0 100% 0 100%; background: linear-gradient(135deg, #7be07b, #2fa84f); }
.g-echo .leaf.l1 { left: 4%; top: -12px; transform: rotate(-20deg); }
.g-echo .leaf.l2 { right: 12%; bottom: -10px; transform: rotate(30deg); }
.g-echo .leaf.l3 { left: 52%; bottom: -12px; transform: rotate(160deg); }
.g-echo .bird {
  --s: calc(var(--bw) / 5.2);
  position: relative; width: var(--s); height: calc(var(--s) * 1.05); min-width: 72px; min-height: 76px; max-width: 120px; max-height: 126px;
  border: 0; padding: 0; background: none; cursor: pointer; animation: ge-in .5s cubic-bezier(.3, 1.6, .5, 1) backwards;
  transform-origin: bottom center; -webkit-tap-highlight-color: transparent;
}
.g-echo .branch.n6 .bird { --s: calc(var(--bw) / 7.4); min-width: 50px; min-height: 54px; }
@keyframes ge-in { from { transform: translateY(-60px) scale(.4); opacity: 0; } }
.g-echo .bird .body {
  position: absolute; left: 8%; right: 8%; top: 10%; bottom: 10%; border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 35% 28%, var(--c2), var(--c1) 70%); box-shadow: inset 0 -6px 0 rgba(0,0,0,.12), 0 6px 10px rgba(0,0,0,.18);
}
.g-echo .bird .belly { position: absolute; left: 24%; right: 24%; bottom: 6%; height: 44%; border-radius: 50%; background: rgba(255,255,255,.75); }
.g-echo .bird .wing { position: absolute; left: -6%; top: 40%; width: 40%; height: 34%; border-radius: 50% 10% 50% 50%; background: var(--c1); filter: brightness(.88); transform-origin: right top; }
.g-echo .bird .eye { position: absolute; left: 28%; top: 26%; width: 16%; aspect-ratio: 1; border-radius: 50%; background: #222; box-shadow: calc(var(--s) * .26) 0 0 #222; }
.g-echo .bird .eye::after { content: ''; position: absolute; left: 20%; top: 15%; width: 35%; height: 35%; border-radius: 50%; background: #fff; }
.g-echo .bird .cheek { position: absolute; left: 18%; top: 44%; width: 14%; height: 9%; border-radius: 50%; background: rgba(255,120,150,.55); box-shadow: calc(var(--s) * .38) 0 0 rgba(255,120,150,.55); }
.g-echo .bird .beak {
  position: absolute; left: 50%; top: 40%; width: 0; height: 0; transform: translateX(-50%);
  border-left: calc(var(--s) * .08) solid transparent; border-right: calc(var(--s) * .08) solid transparent;
  border-top: calc(var(--s) * .12) solid #ff9f1c; transition: transform .1s;
}
.g-echo .bird .tuft { position: absolute; left: 44%; top: -10%; width: 12%; height: 18%; border-radius: 50% 50% 0 50%; background: var(--c1); transform: rotate(20deg); }
.g-echo .bird .tail { position: absolute; right: 0; bottom: 18%; width: 24%; height: 24%; border-radius: 0 50% 50% 0; background: var(--c1); filter: brightness(.8); transform: rotate(-25deg); }
.g-echo .bird .feet { position: absolute; left: 34%; right: 34%; bottom: 2%; height: 10%; border-left: 3px solid #e07b00; border-right: 3px solid #e07b00; }
.g-echo .bird .note { position: absolute; left: 50%; top: -6%; font-size: calc(var(--s) * .3); color: var(--c1); font-weight: 700; opacity: 0; pointer-events: none; text-shadow: 0 2px 0 #fff; }
.g-echo .bird.sing { animation: ge-sing .42s cubic-bezier(.3, 1.6, .5, 1); }
.g-echo .bird.sing .body { filter: brightness(1.15) saturate(1.2); box-shadow: 0 0 0 4px #fff, 0 0 26px 6px var(--c2); }
.g-echo .bird.sing .beak { transform: translateX(-50%) scaleY(1.5); border-top-color: #ff6b00; }
.g-echo .bird.sing .wing { animation: ge-flap .14s ease-in-out 3 alternate; }
.g-echo .bird.sing .note { animation: ge-note .8s ease-out forwards; }
@keyframes ge-sing { 0% { transform: scale(1); } 40% { transform: translateY(-18%) scale(1.12, .94); } 100% { transform: scale(1); } }
@keyframes ge-flap { to { transform: rotate(-35deg); } }
@keyframes ge-note { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(10%, -120%) rotate(15deg); } }
.g-echo.your-turn .bird:not(.sing) { animation: ge-ready 1.6s ease-in-out infinite; }
.g-echo.your-turn .bird:nth-child(odd):not(.sing) { animation-delay: .4s; }
@keyframes ge-ready { 50% { transform: rotate(-4deg); } }

/* Hint glow (own keyframes so it wins over each element's entrance animation). */
.g-unscramble .tile.hint, .g-unscramble .slot.hint, .g-codebot .cmd.hint, .g-codebot .chip.hint, .g-codebot .run.hint,
.g-sudoku .sym.hint, .g-echo .bird.hint, .g-echo.your-turn .bird.hint:not(.sing) {
  animation: gc-hint .9s ease-in-out infinite; outline: 4px solid #fff58a; outline-offset: 3px;
}
.g-echo .bird.hint { outline: none; filter: drop-shadow(0 0 12px #fff58a) drop-shadow(0 0 4px #fff); }
@keyframes gc-hint { 50% { transform: scale(1.12); } }

@media (prefers-reduced-motion: reduce) {
  .g-times *, .g-world *, .g-science *, .g-unscramble *, .g-codebot *, .g-sudoku *, .g-balance *, .g-echo * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* =========================================================== v2: Rival Pip (Times Turbo) */
.g-times .car.rival { display: flex; align-items: flex-end; }
.g-times .car.rival .gt-pip {
  position: absolute; left: 50%; bottom: 38%; width: .5em; height: .5em; transform: translateX(-30%);
  pointer-events: none; z-index: 1; animation: gt-pip-bob .5s ease-in-out infinite alternate;
}
.g-times .gt-pip .pip-body, .g-times .gt-pip .pip-body svg { width: 100%; height: 100%; display: block; }
@keyframes gt-pip-bob { to { transform: translateX(-30%) translateY(-3px) rotate(-6deg); } }
.g-times .car.rival.finished .gt-pip { animation: gt-pip-cheer .4s ease-in-out 4 alternate; }
@keyframes gt-pip-cheer { to { transform: translateX(-30%) translateY(-12px) scale(1.15); } }
.g-times-demo span { display: inline-grid; place-items: center; min-width: 1.6em; padding: 4px 12px; border-radius: 14px; background: #fff; color: #2b2d42; font-weight: 800; }
.g-times-fingers { gap: 2px !important; font-size: clamp(26px, 6vw, 40px); }
.g-times-fingers span.fold { filter: drop-shadow(0 0 6px #ffcf3a); }
.g-times-fingers b { font-size: 1.3em; color: #ff5f6d; padding: 0 10px; }

/* =========================================================== v2: trick demos (batch C) */
.g-world-demo span, .g-science-demo span, .g-science-demo s, .g-unscramble-demo span, .g-balance-demo span {
  display: inline-grid; place-items: center; min-width: 1.6em; padding: 6px 12px; border-radius: 14px;
  background: #fff; color: #2b2d42; font-weight: 800; box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.g-world-demo span.demo-arrow { background: none; box-shadow: none; }
.g-science-demo s { opacity: .45; text-decoration-thickness: 4px; text-decoration-color: #ff4f6d; }
.g-unscramble-demo { gap: 6px !important; }
.g-unscramble-demo span { min-width: 1.4em; background: linear-gradient(180deg, #fff, #efe6ff); color: #5a2fd1; }
.g-codebot-demo, .g-sudoku-demo {
  --n: 3; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; width: min(60vmin, 230px); margin: 0 auto;
  padding: 6px; border-radius: 16px; background: rgba(0,0,0,.12);
}
.g-codebot-demo span, .g-sudoku-demo span {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; background: #fff; font-size: clamp(20px, 5vw, 30px); font-weight: 800; color: #2b2d42;
}
.g-codebot-demo span.path { background: #b9f6ca; box-shadow: inset 0 0 0 3px #21c87a; }
.g-sudoku-demo span.hl { background: #fff3b0; }
.g-sudoku-demo span.q { background: #ffd6e0; box-shadow: inset 0 0 0 3px #ff4f6d; }
.g-sudoku-demo span.q:empty::after { content: '?'; color: #ff4f6d; }
.demo-eq .q, .g-balance-demo .q { color: #ff4f6d; }
.g-echo-demo { align-items: center; flex-wrap: wrap; }
.ge-demo-bird { display: inline-flex; flex-direction: column; align-items: center; padding: 4px 8px; border-radius: 16px; background: var(--c1); box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.ge-demo-bird b { font-size: 14px; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.35); min-height: 1em; }
.ge-chunk { display: inline-flex; gap: 6px; padding: 6px; border-radius: 18px; border: 3px dashed rgba(0,0,0,.25); }

/* =========================================================== v2: Echo Birds — Pip the band leader, modes, colour-safe */
.g-echo .ge-leader { position: absolute; right: 12px; top: 10px; width: 64px; height: 64px; z-index: 2; pointer-events: none; }
.g-echo .ge-leader .ge-pip { width: 100%; height: 100%; }
.g-echo .ge-leader .pip-body, .g-echo .ge-leader .pip-body svg { width: 100%; height: 100%; display: block; }
/* The baton's handle tucks against Pip's side (handle end = pivot), so it reads as held, not floating beside him. */
.g-echo .ge-baton { position: absolute; left: -9px; bottom: 16px; font-size: 28px; line-height: 1; transform-origin: 85% 85%; transform: rotate(-10deg); z-index: -1; }
.g-echo .ge-baton > * { display: block; width: 1em; height: 1em; margin: 0; transform: scaleX(-1); } /* handle end toward Pip */
.g-echo .ge-leader.wave .ge-baton { animation: ge-baton .3s ease-out; }
@keyframes ge-baton { 50% { transform: rotate(-45deg); } }
.g-echo .ge-mode {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 2; padding: 2px 16px; border-radius: 999px;
  font-size: 20px; font-weight: 700; color: #2b1b4f; white-space: nowrap; background: rgba(255,255,255,.9); box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
/* The drop-in plays once; without this it restarted every time a bird stopped singing (bird vanished and fell in again). */
.g-echo:not(.your-turn) .bird.entered:not(.sing):not(.hint) { animation: none; }
/* Ears-only round: the birds hide (dark silhouettes) while Pip plays the tune. */
.g-echo.mode-ears.playing .bird { filter: brightness(.25) saturate(0); opacity: .55; }
/* Deaf mode: a stronger, longer light-up so the tune is easy to follow without sound. */
.g-echo.deaf .bird.sing .body { box-shadow: 0 0 0 6px #fff, 0 0 36px 12px var(--c2), 0 0 0 10px var(--c1); }
.g-echo.deaf .bird.sing .note { font-size: calc(var(--s) * .42); }
/* Colour-safe: a symbol on each bird's belly, so birds never differ by colour alone. */
.g-echo .ge-sym { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--s) * .26); color: #222; line-height: 1; }

/* Calm mode: no shaking, sputtering or bumping in these games. */
body.a11y-calm .g-times .car.sputter .body, body.a11y-calm .g-times .car.sputter::after, body.a11y-calm .g-times.won .car.me .body,
body.a11y-calm .g-codebot .bot.bump span, body.a11y-calm .g-times .gt-pip,
body.a11y-calm .g-times .shake, body.a11y-calm .g-world .shake, body.a11y-calm .g-science .shake, body.a11y-calm .g-unscramble .shake,
body.a11y-calm .g-codebot .shake, body.a11y-calm .g-sudoku .shake, body.a11y-calm .g-balance .shake, body.a11y-calm .g-echo .shake { animation: none !important; }

/* SVG flags (flag emoji don't render on Windows) */
.flag-img { display: inline-block; width: 1.5em; height: 1.125em; object-fit: cover; border-radius: 3px; vertical-align: -0.2em;
  box-shadow: 0 0 0 1px rgba(0,0,0,.18), 0 2px 4px rgba(0,0,0,.15); }
.g-world .pic .flag-img.wx-big { width: clamp(150px, 38vw, 230px); height: auto; aspect-ratio: 4 / 3; border-radius: 8px; vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2), 0 10px 20px rgba(0,0,0,.25); }
.g-world ~ .choices .flag-img.wx-flag { width: 1.7em; height: 1.275em; margin-right: 6px; }
.choices.g-world-flags .flag-img.wx-opt { width: clamp(96px, 26vw, 150px); height: auto; aspect-ratio: 4 / 3; border-radius: 6px; vertical-align: middle; }
.demo-row .flag-img { width: 1.6em; height: 1.2em; margin: 0 .12em; }
.wa-flag .flag-img { width: 1.5em; height: 1.125em; }
.g-world .wx-mystery { display: grid; place-items: center; width: clamp(150px, 38vw, 230px); aspect-ratio: 4 / 3; border-radius: 8px;
  font-size: .7em; font-weight: 800; color: #7a8fa6; background: repeating-linear-gradient(135deg, #eef3f8 0 14px, #e1e9f2 14px 28px);
  border: 3px dashed #aebdcc; }
.g-world .stamp.stamped { background: #fff; animation: wx-stamp .45s cubic-bezier(.3,1.6,.5,1); }
.g-world .stamp .flag-img.wx-stamp { width: 40px; height: 30px; border-radius: 3px; }
@keyframes wx-stamp { 0% { transform: rotate(12deg) scale(2.2); opacity: 0; } 100% { transform: rotate(12deg) scale(1); opacity: 1; } }
.g-world .wx-ans { font-weight: 800; color: #1f9d55; font-size: clamp(16px, 3.8vw, 22px); }
