/**
 * Two Baskets — two-baskets.css
 * A task-switching game: things fall, Ponoki carries them, and the rule for
 * which basket is correct keeps changing. Unlike firefly-catch (a real-time
 * chase) or star-weaver (a still sky you read), this one is a running loop
 * with a single fixed banner at the top that is the whole source of truth.
 *
 * The visual hierarchy is deliberate and load bearing: the rule bar is the
 * brightest thing on the screen and it never moves, sitting directly under
 * the app header so it is in the same place on every device. Everything else,
 * the sky, the hill, the baskets, is quiet, so the eye returns to the bar.
 *
 * A rule has a colour (amber / violet / teal). That accent flows through the
 * whole screen at once via --rule, so a switch is felt peripherally even if
 * you were looking at the falling object rather than the banner.
 */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg-deep:    hsl(230, 35%, 7%);
  --color-bg-surface: hsl(230, 28%, 10%);
  --color-bg-card:    hsl(230, 25%, 13%);
  --color-line:       hsl(230, 22%, 20%);

  --color-text-primary: hsl(220, 20%, 92%);
  --color-text-muted:   hsl(220, 15%, 55%);
  --color-text-dim:     hsl(220, 12%, 35%);

  /* Ponoki's rig, matching shared/companion-stage/companion-stage.css. */
  --pk-body:   hsl(28, 66%, 80%);
  --pk-accent: hsl(248, 38%, 72%);
  --pk-band:   hsl(250, 44%, 81%);
  --pk-cheek:  hsl(8, 66%, 72%);
  --pk-eye:    hsl(24, 34%, 19%);

  /* One accent per sorting rule. --rule is swapped by JS on every change. */
  --rule-colour: hsl(33, 86%, 62%);
  --rule-shape:  hsl(258, 80%, 78%);
  --rule-size:   hsl(184, 64%, 58%);
  --rule: var(--rule-colour);

  /* Sky, restated per level by JS so the evening moves on as you climb. */
  --sky-a: hsl(230, 35%, 7%);
  --sky-b: hsl(230, 30%, 15%);

  --text-xs:  clamp(0.65rem, 1.5vw, 0.75rem);
  --text-sm:  clamp(0.8rem, 2vw, 0.875rem);
  --text-md:  clamp(1rem, 3vw, 1.125rem);
  --text-lg:  clamp(1.1rem, 3.5vw, 1.375rem);
  --text-xl:  clamp(1.3rem, 4vw, 1.75rem);
  --text-2xl: clamp(1.6rem, 5vw, 2.25rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --radius-full: 9999px;

  --ease-bounce:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  --nav-h: 56px;
  --rule-h: 62px;
  --pk-w: clamp(94px, 27vw, 116px);
  --bk-w: clamp(74px, 22vw, 94px);
  --item-w: clamp(56px, 17vw, 68px);
}

html, body {
  height: 100%; width: 100%; overflow: hidden;
  background: var(--color-bg-deep);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}

/* ── Screen system ──
   Both screens are fixed and full-viewport. The start screen scrolls when a
   short window cannot hold the column (this is what used to clip Ponoki's
   feet); the play screen never scrolls, because its layout is the game. */
.screen {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-screen, 320ms) var(--ease-out-expo);
}
.screen.is-active { opacity: 1; pointer-events: auto; }
#screen-start { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
#screen-play  { overflow: hidden; }

/* ── Ambient background (behind both screens) ── */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(110px); opacity: 0.11; animation: blobDrift 24s ease-in-out infinite alternate; }
.blob-a { width: 440px; height: 440px; background: hsl(33, 70%, 45%); top: -150px; left: -110px; animation-duration: 27s; }
.blob-b { width: 340px; height: 340px; background: hsl(258, 60%, 50%); bottom: -120px; right: -90px; animation-duration: 21s; animation-delay: -7s; }
@keyframes blobDrift { from { transform: translate(0, 0) scale(1); } to { transform: translate(26px, 18px) scale(1.06); } }

/* ═══════════════════════════════════════════
   START SCREEN
   margin:auto inside the scrolling flex column centres the card when there is
   room and lets it scroll when there is not, so nothing is ever cut off.
═══════════════════════════════════════════ */
.start-inner {
  margin: auto;
  width: 100%;
  max-width: 30rem;
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-4);
  text-align: center;
  padding:
    calc(env(safe-area-inset-top) + var(--space-8)) var(--space-5)
    calc(env(safe-area-inset-bottom) + var(--space-6));
}

.scr-header {
  position: absolute;
  top: calc(env(safe-area-inset-top) + var(--space-3));
  left: calc(env(safe-area-inset-left) + var(--space-3));
  z-index: 4;
}
.nav-back {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--color-line);
  background: var(--color-bg-card);
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
}
.nav-back:focus-visible { outline: 2px solid var(--rule); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .nav-back:hover { color: var(--color-text-primary); border-color: var(--rule); }
}

.start-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.start-best {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
}

/* Ponoki greets you in. The mount point is sized by companion-stage.css. */
.pk-greet { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.pk-say {
  max-width: 30ch;
  font-size: var(--text-sm);
  line-height: 1.65;
  color: hsl(220, 18%, 78%);
}
.pk-say b { color: var(--rule); font-weight: 600; }

.start-length { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.length-label {
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 500;
}
.length-row { display: flex; gap: var(--space-2); }
.length-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: var(--color-bg-card);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-full);
  padding: 0.7rem 1.1rem;
  min-height: 44px;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.length-btn.is-selected {
  color: var(--color-text-primary);
  border-color: var(--rule);
  background: color-mix(in srgb, var(--rule) 16%, var(--color-bg-card));
}
.length-btn:focus-visible { outline: 2px solid var(--rule); outline-offset: 2px; }

.begin-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  color: hsl(230, 40%, 8%);
  background: var(--rule);
  border: none;
  border-radius: var(--radius-full);
  padding: 0.95rem 2rem;
  min-height: 52px;
  display: inline-flex; align-items: center; gap: var(--space-2);
  cursor: pointer;
  transition: transform 160ms var(--ease-bounce), filter 160ms ease;
}
.begin-btn:active { transform: scale(0.96); }
.begin-btn:focus-visible { outline: 2px solid var(--color-text-primary); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) { .begin-btn:hover { filter: brightness(1.08); } }

/* ═══════════════════════════════════════════
   PLAY SCREEN — header, rule bar, field, hint
═══════════════════════════════════════════ */
.play-header {
  flex: 0 0 auto;
  min-height: var(--nav-h);
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: var(--space-2);
  padding-inline: var(--space-3);
  background: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-line);
  position: relative; z-index: 6;
}
.hud-btn {
  width: 44px; height: 44px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--color-line);
  background: var(--color-bg-card);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 0;
}
.hud-btn:focus-visible { outline: 2px solid var(--rule); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .hud-btn:hover { color: var(--color-text-primary); } }
.hud-spacer { flex: 1 1 auto; }
.hud-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  color: var(--rule);
  transition: color 500ms ease;
}
.hud-score.is-pop { animation: scorePop 340ms var(--ease-bounce); }
@keyframes scorePop { 0% { transform: scale(1); } 40% { transform: scale(1.2); } 100% { transform: scale(1); } }

.timer-ring { position: relative; width: 38px; height: 38px; flex: 0 0 auto; }
.timer-svg { width: 38px; height: 38px; transform: rotate(-90deg); }
.timer-svg circle { fill: none; stroke-width: 3; stroke-linecap: round; }
.timer-track { stroke: hsl(230, 20%, 22%); }
.timer-arc { stroke: var(--rule); transition: stroke 500ms ease; }
.timer-num {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  letter-spacing: -0.02em;
}

/* ── The rule. One fixed place, always directly under the header. ── */
.rulebar {
  flex: 0 0 var(--rule-h);
  position: relative; z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-3);
  background: linear-gradient(180deg, color-mix(in srgb, var(--rule) 16%, var(--color-bg-surface)) 0%, var(--color-bg-surface) 100%);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 35%, var(--color-line));
  transition: background 450ms ease, border-color 450ms ease;
  overflow: hidden;
}
.rulebar::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 140% at 50% 0%, color-mix(in srgb, var(--rule) 40%, transparent), transparent 60%);
  opacity: 0;
  pointer-events: none;
}
.rulebar.is-switching::after { animation: ruleFlash 700ms ease-out; }
@keyframes ruleFlash { 0% { opacity: 0.9; } 100% { opacity: 0; } }

.rule-side { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.rule-side.r { justify-content: flex-end; }
.rule-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  white-space: nowrap;
}
.rule-arrow { color: var(--rule); font-size: var(--text-xs); }
.rule-center { text-align: center; }
.rule-eyebrow {
  display: block;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  line-height: 1;
}
.rule-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: var(--rule);
  transition: color 450ms ease;
}
.rulebar.is-switching .rule-name { animation: ruleSwap 620ms var(--ease-bounce); }
.rulebar.is-switching .rule-word { animation: ruleSwap 620ms var(--ease-bounce) 60ms both; }
@keyframes ruleSwap {
  0%   { transform: translateY(-120%); opacity: 0; }
  60%  { transform: translateY(6%);    opacity: 1; }
  100% { transform: translateY(0);     opacity: 1; }
}
/* The swap twist slides the two values past each other, so it never reads as
   an ordinary rule change. */
.rulebar.is-swapping .rule-side.l .rule-word { animation: slideFromR 640ms var(--ease-bounce); }
.rulebar.is-swapping .rule-side.r .rule-word { animation: slideFromL 640ms var(--ease-bounce); }
@keyframes slideFromR { 0% { transform: translateX(150px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes slideFromL { 0% { transform: translateX(-150px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ── Field ── */
.field {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(90% 60% at 50% 108%, var(--sky-b) 0%, transparent 70%),
    radial-gradient(70% 40% at 50% -6%, color-mix(in srgb, var(--rule) 12%, transparent) 0%, transparent 70%),
    var(--sky-a);
  transition: background 1400ms ease;
}
.sky { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.moon {
  position: absolute;
  right: 13%; top: 7%;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, hsl(48, 44%, 92%), hsl(45, 30%, 78%));
  box-shadow: 0 0 40px hsla(48, 60%, 85%, 0.22);
}
.moon::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 62% 44%, hsla(230, 30%, 60%, 0.3) 0 5px, transparent 6px),
              radial-gradient(circle at 38% 66%, hsla(230, 30%, 60%, 0.25) 0 4px, transparent 5px);
}
.ridge { position: absolute; left: -12%; right: -12%; border-radius: 50% 50% 0 0 / 30% 30% 0 0; transition: background 1400ms ease; }
.ridge-far  { bottom: 26%; height: 16%; background: color-mix(in srgb, var(--sky-b) 62%, var(--sky-a)); }
.ridge-near { bottom: 22%; height: 13%; background: color-mix(in srgb, var(--sky-b) 80%, var(--sky-a)); }
.chute {
  position: absolute;
  left: 50%; top: 0;
  width: 132px; margin-left: -66px;
  height: 72%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--rule) 26%, transparent), transparent 78%);
  opacity: 0.3;
  transition: background 600ms ease;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
}
.mote {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: hsl(220, 30%, 70%);
  opacity: 0.28;
  animation: drift linear infinite;
}
@keyframes drift {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(14px, -22px); }
  100% { transform: translate(0, 0); }
}
.hill {
  position: absolute;
  left: -8%; right: -8%; bottom: 0;
  height: 34%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--sky-b) 96%, var(--sky-a)), var(--sky-a));
  border-radius: 50% 50% 0 0 / 22% 22% 0 0;
  border-top: 1px solid hsl(230, 20%, 22%);
  transition: background 1400ms ease;
}
.grass { position: absolute; left: 0; right: 0; bottom: 0; height: 22%; pointer-events: none; }
.blade {
  position: absolute;
  bottom: 0;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, hsl(230, 22%, 26%));
  transform-origin: bottom center;
  animation: sway 4200ms ease-in-out infinite;
}
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg); } }

/* ── Input targets: the whole half of the field, so nothing needs aiming ── */
.side {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
}
.side.l { left: 0; }
.side.r { right: 0; }
.side:focus-visible { outline: 2px solid var(--rule); outline-offset: -6px; border-radius: var(--radius-md); }
.side::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(60% 50% at 50% 78%, color-mix(in srgb, var(--rule) 30%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity 200ms ease;
}
.side.is-hit::before { opacity: 1; transition: opacity 60ms ease; }

/* ── Baskets ── */
.basket {
  position: absolute;
  bottom: 9%;
  width: var(--bk-w);
  margin-left: calc(var(--bk-w) / -2);
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
.basket-chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 4px 9px 4px 5px;
  border-radius: var(--radius-full);
  background: var(--color-bg-card);
  border: 1px solid color-mix(in srgb, var(--rule) 38%, var(--color-line));
  margin-bottom: var(--space-2);
  transition: border-color 450ms ease;
}
.chip-glyph { width: 16px; height: 16px; display: block; }
.chip-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.08em;
}
.basket.is-swapping .basket-chip { animation: chipPop 520ms var(--ease-bounce); }
@keyframes chipPop { 0% { transform: scale(0.7) translateY(-6px); opacity: 0; } 100% { transform: none; opacity: 1; } }

.basket-body { position: relative; width: 100%; }
.basket-svg { display: block; width: 100%; height: auto; overflow: visible; }
.basket.is-catching .basket-svg { animation: bktCatch 380ms var(--ease-bounce); }
.basket.is-nope .basket-svg { animation: bktNope 420ms ease-out; }
.basket.is-full .basket-svg { animation: bktFull 700ms var(--ease-bounce); }
@keyframes bktCatch { 0% { transform: none; } 40% { transform: translateY(4px) scale(1.06, 0.9); } 100% { transform: none; } }
@keyframes bktNope { 0%, 100% { transform: none; } 25% { transform: translateX(-4px) rotate(-2deg); } 65% { transform: translateX(4px) rotate(2deg); } }
@keyframes bktFull { 0% { transform: none; } 30% { transform: translateY(-12px) scale(1.1); } 100% { transform: none; } }

/* The object drops behind the rim rather than fading out. This box ends
   exactly at the rim line and clips whatever descends through it. */
.basket-mouth {
  position: absolute;
  left: -6%; right: -6%;
  top: calc(var(--bk-w) * -0.88);
  height: calc(var(--bk-w) * 1.07);
  overflow: hidden;
  pointer-events: none;
}

/* ── Falling and carried objects ── */
.item {
  position: absolute;
  left: 50%; top: 0;
  width: var(--item-w); height: var(--item-w);
  margin: 0 0 0 calc(var(--item-w) / -2);
  z-index: 4;
  pointer-events: none;
  transform-origin: center bottom;
  will-change: transform;
}
.item svg { display: block; width: 100%; height: 100%; overflow: visible; }
.item.is-carried {
  position: static;
  margin: 0;
  animation: carryBob 420ms ease-in-out infinite alternate;
}
@keyframes carryBob {
  from { transform: scale(var(--s, 1)) translateY(0) rotate(-3deg); }
  to   { transform: scale(var(--s, 1)) translateY(-4px) rotate(3deg); }
}

/* ── Ponoki ── */
.ponoki {
  position: absolute;
  bottom: 11%;
  left: 0;
  width: var(--pk-w);
  margin-left: calc(var(--pk-w) / -2);
  z-index: 5;
  pointer-events: none;
  will-change: transform;
}
.pk-shadow {
  position: absolute;
  left: 50%; bottom: -6px;
  width: 58%; height: 12px;
  margin-left: -29%;
  border-radius: 50%;
  background: hsla(230, 60%, 2%, 0.55);
  filter: blur(3px);
}
/* The carry slot sits clear above the hat and objects grow upward from its
   bottom edge, so a big one never swells down into his face and its real
   size stays readable while he is holding it. */
.pk-carry {
  position: absolute;
  left: 50%;
  top: calc(var(--pk-w) * -0.59);
  width: var(--item-w); height: var(--item-w);
  margin-left: calc(var(--item-w) / -2);
  display: grid;
  place-items: end center;
  z-index: 2;
}
.pk-carry::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -9px;
  width: 46px; height: 12px;
  margin-left: -23px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--rule) 60%, transparent), transparent 72%);
  opacity: 0;
  transition: opacity 220ms ease;
}
.ponoki.is-carrying .pk-carry::after,
.ponoki.is-winding .pk-carry::after { opacity: 0.85; }

.pk-rig {
  display: block;
  width: 100%; height: auto;
  overflow: visible;
  transform: scaleX(var(--flip, 1)) rotate(var(--tilt, 0deg));
  transition: transform 190ms var(--ease-bounce);
}
.pk-body-g {
  transform-origin: 100px 174px;
  animation: tbBreathe 3400ms ease-in-out infinite;
  transition: transform 180ms var(--ease-bounce);
}
@keyframes tbBreathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.025); } }

.ponoki.is-running .pk-body-g { animation: tbRunBob 250ms ease-in-out infinite; }
@keyframes tbRunBob { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-5px) scaleY(0.985); } }
.ponoki.is-running .pk-foot-l { animation: tbStepA 250ms ease-in-out infinite; }
.ponoki.is-running .pk-foot-r { animation: tbStepB 250ms ease-in-out infinite; }
@keyframes tbStepA { 0%, 100% { transform: translate(-6px, 0); } 50% { transform: translate(8px, -9px); } }
@keyframes tbStepB { 0%, 100% { transform: translate(8px, -9px); } 50% { transform: translate(-6px, 0); } }

/* The rig has no arms, only paw dots, so a paw lifted clear of the silhouette
   reads as a floating blob. These poses keep both paws overlapping the hat. */
.pk-hand-l, .pk-hand-r { transition: transform 230ms var(--ease-bounce); }
.ponoki.is-carrying .pk-hand-l { transform: translate(24px, -78px); }
.ponoki.is-carrying .pk-hand-r { transform: translate(-24px, -78px); }
.ponoki.is-winding  .pk-hand-l { transform: translate(18px, -58px); }
.ponoki.is-winding  .pk-hand-r { transform: translate(-18px, -58px); }
.ponoki.is-throwing .pk-hand-l { transform: translate(30px, -94px); }
.ponoki.is-throwing .pk-hand-r { transform: translate(-30px, -94px); }
.ponoki.is-winding  .pk-body-g { transform: translateY(5px) scaleY(0.94); }
.ponoki.is-throwing .pk-body-g { transform: translateY(-4px) scaleY(1.04); }

/* Every keyframe name in this file carries a `tb` prefix, and must keep it.
   @keyframes names are global across every stylesheet on the page, and the
   last declaration of a name wins. This page also loads companion-stage.css,
   which owns `pkHop` and `pkBreathe` and is linked after this file, so the
   game's identically named animations were silently replaced by the
   companion's. That is what sent Ponoki off the left edge on every combo:
   the companion's `pkHop` animates `transform`, which overrode the inline
   `transform: translateX(...)` that holds his place in the field.

   Hops ride the independent `translate` property, never `transform`.
   His position along the field is an inline `transform: translateX(...)`
   written every frame by placePonoki(). A keyframe that also sets `transform`
   overrides that inline value for the whole animation, and `var(--px)` inside
   a keyframe does not resolve back to it, so it fell to the 0px fallback and
   he snapped to the left edge mid-cheer. `translate` is applied before
   `transform` and composes with it, so the hop is purely vertical and his
   horizontal position is left entirely to placePonoki(). */
.ponoki.is-hop { animation: tbHop 520ms var(--ease-bounce); }
@keyframes tbHop {
  0%, 100% { translate: 0 0; }
  40%      { translate: 0 -26px; }
}

/* The every-correct-landing version: the same move, smaller and quicker, so
   a good sort is felt without competing with the combo cheer above. */
.ponoki.is-hop-sm { animation: tbHopSm 300ms var(--ease-bounce); }
@keyframes tbHopSm {
  0%, 100% { translate: 0 0; }
  45%      { translate: 0 -9px; }
}

@media (prefers-reduced-motion: reduce) {
  .ponoki.is-hop, .ponoki.is-hop-sm { animation: none; }
}

.pk-eyes-happy, .pk-eyes-wide { opacity: 0; }
.ponoki.exp-happy .pk-eyes-open { opacity: 0; }
.ponoki.exp-happy .pk-eyes-happy { opacity: 1; }
.ponoki.exp-wide .pk-eyes-open { opacity: 0; }
.ponoki.exp-wide .pk-eyes-wide { opacity: 1; }
.pk-m-big { opacity: 0; }
.ponoki.exp-happy .pk-m-smile { opacity: 0; }
.ponoki.exp-happy .pk-m-big { opacity: 1; }

/* ── In-field HUD ── */
.streak {
  position: absolute;
  left: var(--space-3); top: var(--space-3);
  z-index: 6;
  display: flex; align-items: center; gap: var(--space-1);
  padding: 5px 11px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--rule) 20%, var(--color-bg-card));
  border: 1px solid color-mix(in srgb, var(--rule) 45%, transparent);
  font-size: var(--text-xs);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
.streak.is-on { opacity: 1; }
.streak b { font-family: var(--font-display); font-weight: 800; font-variant-numeric: tabular-nums; }

.levelup {
  position: absolute;
  left: 50%; top: 20%;
  transform: translate(-50%, 0) scale(0.86);
  z-index: 7;
  padding: 11px 20px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--rule) 16%, var(--color-bg-card));
  border: 1px solid color-mix(in srgb, var(--rule) 50%, transparent);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 340ms ease, transform 340ms var(--ease-bounce);
}
.levelup.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.levelup b {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-md);
  letter-spacing: 0.02em;
  color: var(--rule);
}
.levelup span { display: block; font-size: var(--text-xs); color: hsl(220, 18%, 78%); margin-top: 2px; }

.floater {
  position: absolute;
  z-index: 7;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--rule);
  pointer-events: none;
  white-space: nowrap;
}
.petal { position: absolute; width: 9px; height: 9px; border-radius: 50% 50% 50% 0; z-index: 6; pointer-events: none; }

.play-hint {
  flex: 0 0 auto;
  padding: var(--space-2) var(--space-4) calc(env(safe-area-inset-bottom) + var(--space-2));
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-dim);
  background: var(--color-bg-surface);
  border-top: 1px solid var(--color-line);
}

/* ═══════════════════════════════════════════
   SESSION OVERLAY
═══════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
  opacity: 0; pointer-events: none;
  transition: opacity 340ms var(--ease-out-expo);
  overflow-y: auto;
}
.overlay.is-visible { opacity: 1; pointer-events: auto; }
.overlay-bg { position: absolute; inset: 0; background: hsla(230, 38%, 5%, 0.93); backdrop-filter: blur(4px); }
.overlay-card {
  position: relative;
  margin: auto;
  width: 100%;
  max-width: 24rem;
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6) var(--space-5);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px hsla(230, 50%, 2%, 0.6);
}
.overlay-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.overlay-msg { font-size: var(--text-sm); line-height: 1.6; color: hsl(220, 18%, 78%); max-width: 30ch; }
.final-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--rule);
}
.new-record-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(230, 40%, 8%);
  background: var(--rule);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  display: none;
}
.new-record-badge.is-visible { display: block; }
.prev-best-line { font-size: var(--text-xs); color: var(--color-text-muted); min-height: 1em; font-variant-numeric: tabular-nums; }

.final-stats { display: flex; gap: 7px; width: 100%; }
.final-stat {
  flex: 1 1 0;
  min-width: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  padding: var(--space-2) 6px;
}
.final-val {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}
.final-label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.next-suggestion { font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.5; min-height: 1em; }

.overlay-actions { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; align-items: center; }
.btn-primary {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  color: hsl(230, 40%, 8%);
  background: var(--rule);
  border: none;
  border-radius: var(--radius-full);
  padding: 0.9rem 2rem;
  min-height: 48px;
  cursor: pointer;
  transition: transform 160ms var(--ease-bounce), filter 160ms ease;
}
.btn-primary:active { transform: scale(0.96); }
.btn-ghost {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: none;
  border: none;
  padding: var(--space-2) var(--space-4);
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--rule); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-ghost:hover { color: var(--color-text-primary); }
}

/* ── Short screens: the play column stays whole, the chrome gives up room ── */
@media (max-height: 620px) {
  /* Chrome gives up room before the play column does, but never below the
     44px touch-target floor, so --nav-h stops at 52. */
  :root { --nav-h: 52px; --rule-h: 54px; }
  .play-hint { display: none; }
}

/* Landscape and other short viewports. The game is portrait-first, but the
   start screen still has to fit rather than hide its own button. */
@media (max-height: 480px) {
  .start-inner {
    gap: var(--space-2);
    padding-top: calc(env(safe-area-inset-top) + var(--space-4));
    padding-bottom: calc(env(safe-area-inset-bottom) + var(--space-4));
  }
  .start-title { font-size: var(--text-lg); }
  .start-best { font-size: var(--text-xs); }
  .pk-greet { flex-direction: row; align-items: center; gap: var(--space-4); }
  .pk-say { font-size: var(--text-xs); line-height: 1.5; max-width: 46ch; text-align: left; }
  .length-label { display: none; }
  .start-length { gap: var(--space-2); }
  .begin-btn { padding: 0.7rem 1.6rem; min-height: 46px; }
}

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