/* A mobile-only scene. The existing desktop band and audio clock stay intact. */
#mobileGame { display: none; }

@media (max-width: 767px) and (orientation: portrait) {
  body.game-mode #mobileGame {
    display: block; position: fixed; inset: 0; z-index: 5; isolation: isolate;
    overflow: hidden; background: var(--game-sky); color: var(--game-ink);
    -webkit-tap-highlight-color: transparent;
  }
  #mobileGame [hidden] { display: none !important; }
  #mobileCats {
    position: absolute; inset: 126px 0 calc(148px + var(--safe-bottom));
    display: grid; grid-template-rows: minmax(0, 1fr) 144px;
    min-width: 0; direction: ltr;
  }
  #mobileCats::before {
    content: ""; position: absolute; inset: -126px 0 auto; pointer-events: none;
    height: var(--game-sky-height, 300px); z-index: -1;
    background: url('./assets/stage/courtyard-sky.svg') center bottom / cover no-repeat;
  }
  #gameDock {
    position: absolute; inset: auto 0 0; height: calc(148px + var(--safe-bottom));
    background: url('./assets/stage/courtyard-deck.svg') center top / 100% 148px repeat-y;
  }
  .game-stage { position: relative; min-width: 0; min-height: 0; }
  .game-stage::before {
    content: ""; position: absolute; left: 0; right: 0;
    bottom: var(--game-stage-art-bottom, 0px); height: var(--game-stage-art-height, 342px);
    background: url('./assets/stage/courtyard-stage.svg') center bottom / 100% 100% no-repeat;
    pointer-events: none;
  }
  .game-tier {
    position: absolute; left: var(--game-row-inset); right: var(--game-row-inset);
    bottom: calc(var(--game-row-foot) - 20px);
    display: flex; justify-content: center; align-items: flex-end;
  }
  .game-tier-back { z-index: 1; }
  .game-tier-middle { z-index: 2; }
  .game-tier-front { z-index: 3; }
  .game-cat-slot { position: relative; flex: none; min-width: 0; }
  .game-cat {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 0;
    width: 100%; min-height: 44px; margin: 0; padding: 0; border: 0; border-radius: 12px;
    background: transparent; color: var(--game-ink); font: inherit;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    touch-action: manipulation; cursor: pointer;
  }
  .game-cat:focus-visible { outline: 2px solid var(--game-glow); outline-offset: 3px; z-index: 6; }
  .game-cat-figure {
    position: relative; display: block; flex: none; width: var(--game-cat-size); height: calc(var(--game-cat-size) * 280 / 240);
    border-radius: 16px; transition: opacity var(--dur-short), filter var(--dur-short);
  }
  .game-cat .cat-portrait { display: block; width: 100%; height: 100%; pointer-events: none; transform-origin: 50% 100%; }
  .game-cat .cat-portrait svg { max-width: none; pointer-events: none; }
  .game-cat-plaque {
    display: flex; justify-content: center; align-items: center; flex: none; gap: 4px;
    max-width: calc(100% - 4px); height: 20px; padding: 0 6px;
    color: var(--game-ink); font: 700 11px/1 var(--font-display); white-space: nowrap;
  }
  .game-cat-name { white-space: nowrap; }
  .game-cat-dot { flex: none; width: 7px; height: 7px; border: 1.5px solid var(--game-ink-dim); border-radius: 50%; }
  .game-cat[data-playing="true"] .game-cat-dot { background: var(--game-green); border-color: var(--game-green); }
  .game-cat-group { display: block; flex: none; width: 4px; height: 12px; border-radius: 2px; background: var(--group-color); }
  .game-cat[data-name-mode="dot"] .game-cat-name { display: none; }
  .game-cat[data-pending="off"] .game-cat-figure,
  .game-cat[data-pending="change"][data-on="true"] .game-cat-figure { outline: 2px dashed var(--game-pending); outline-offset: 3px; }
  .game-cat-flag {
    position: absolute; left: 50%; top: -12px; z-index: 2; transform: translateX(-50%);
    padding: 3px 8px; border-radius: var(--radius-pill); background: var(--game-pending);
    color: var(--game-stage); font: 700 11px/1.3 var(--font-display); white-space: nowrap;
    box-shadow: 0 2px 0 var(--game-shadow); pointer-events: none;
  }
  .game-cat-check {
    position: absolute; top: 0; right: 2px; z-index: 4; width: 22px; height: 22px;
    display: grid; place-items: center; border: 2px solid var(--game-ink-dim); border-radius: 50%;
    background: var(--game-stage); color: var(--game-paper-ink); font-weight: 800; font-size: 14px;
  }
  .game-cat.is-picked .game-cat-figure { outline: 2px solid var(--game-amber); outline-offset: 3px; }
  .game-cat.is-picked .game-cat-check { background: var(--game-amber); border-color: var(--game-amber); }
  .game-cat.is-landing .cat-portrait { animation: game-cat-land .7s cubic-bezier(.2, 1.35, .4, 1); }
  .game-stage-empty {
    position: absolute; z-index: 4; left: 40px; right: 40px; bottom: 25px; margin: 0;
    padding: 10px 14px; border-radius: 14px; background: var(--game-transport);
    color: var(--game-ink); text-align: center; font-size: 13px; line-height: 1.4;
  }
  .game-waiting {
    position: relative; min-width: 0; height: 144px; z-index: 4;
    background: url('./assets/stage/courtyard-waiting.svg') center / 100% 100% no-repeat;
  }
  .game-waiting-head { display: flex; align-items: center; gap: 8px; height: 24px; padding: 0 24px; }
  .game-waiting-title {
    padding: 3px 10px; border-radius: var(--radius-pill); background: var(--game-stone);
    color: var(--game-ink); font: 700 12px/1.3 var(--font-display); white-space: nowrap;
    box-shadow: inset 0 0 0 1px var(--game-stone-rule);
  }
  .game-waiting-count {
    display: grid; place-items: center; flex: none; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: var(--game-stone); color: var(--game-ink); font-size: 11px; font-weight: 700;
  }
  .game-waiting-count[data-pending="true"] { background: var(--game-pending); color: var(--game-stage); }
  .game-waiting-hint {
    margin-left: auto; padding: 3px 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border-radius: var(--radius-pill); background: var(--game-transport); color: var(--game-water-ink); font-size: 11px;
  }
  .game-waiting-cats {
    display: flex; align-items: flex-start; gap: 2px; overflow-x: auto; overflow-y: hidden;
    padding: 12px 22px 10px; height: 120px; scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x;
    mask-image: linear-gradient(90deg, var(--game-sky) calc(100% - 26px), transparent);
    -webkit-mask-image: linear-gradient(90deg, var(--game-sky) calc(100% - 26px), transparent);
  }
  .game-waiting-cats::-webkit-scrollbar { display: none; }
  .game-waiting .game-cat-slot { width: 72px; }
  .game-waiting .game-cat-slot.has-candidates { width: 112px; }
  .game-waiting .game-cat { padding: 0 0 2px; touch-action: pan-x; }
  .game-waiting .game-cat-figure { width: 64px; height: 46px; clip-path: inset(-40px -14px 0); }
  .game-waiting .cat-portrait { position: absolute; left: 5px; top: 5px; width: 54px; height: 63px; transition: top .3s; }
  .game-waiting .game-cat[data-on="false"] .cat-portrait { opacity: .9; filter: none; }
  .game-waiting .game-cat-plaque { max-width: 100%; height: auto; margin-top: 6px; padding: 0 2px; font-size: 11px; line-height: 1.25; }
  .game-waiting .game-cat-name { max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
  .game-waiting .game-cat-dot { display: none; }
  .game-cat-state { margin-top: 3px; color: var(--game-water-ink); font-size: 11px; line-height: 1.2; white-space: nowrap; }
  .game-cat-ripple { display: none; }
  .game-waiting .game-cat-ripple {
    display: block; position: absolute; left: -6px; right: -6px; bottom: -5px; height: 10px;
    border-radius: 50%; background: var(--game-water); border-top: 1.5px solid var(--game-water-rule); pointer-events: none;
  }
  .game-cat-slot[data-joining="true"] .cat-portrait { top: -12px; animation: game-cat-ready 1.4s ease-in-out infinite; }
  .game-cat-slot[data-joining="true"] .game-cat-ripple { border: 1.5px dashed var(--game-pending); background: var(--game-water-light); }
  .game-cat-slot[data-joining="true"] .game-cat-state { padding: 2px 7px; border-radius: var(--radius-pill); background: var(--game-pending); color: var(--game-stage); font-weight: 700; }
  .game-cat-slot[data-joining="true"] .cat-eyes-open { opacity: 1; }
  .game-cat-slot[data-joining="true"] .cat-eyes-rest { opacity: 0; }
  .game-stage-candidate {
    position: absolute; top: 3px; display: grid; place-items: center; width: 44px; height: 44px;
    padding: 0; border: 0; background: transparent; color: var(--game-ink); cursor: pointer; touch-action: manipulation;
  }
  .game-stage-candidate::before { content: ""; position: absolute; inset: 7px 9px; z-index: -1; border: 1px solid var(--game-wood-rule); border-radius: 9px; background: var(--game-transport); }
  .game-stage-candidate-previous { left: -6px; }
  .game-stage-candidate-next { right: -6px; }
  .game-stage-candidate:focus-visible { outline: 2px solid var(--game-glow); outline-offset: 0; border-radius: 12px; }
  .game-waiting-empty { margin: 0; padding: 25px 26px; color: var(--game-water-ink); font-size: 12px; line-height: 1.5; text-align: center; }
  .game-cat[data-filtered="true"] .game-cat-figure { opacity: .32; filter: saturate(.2); }
  .game-cat[data-filtered="true"] .game-cat-plaque, .game-cat[data-filtered="true"] .game-cat-state { opacity: .42; }
  #mobileCats[data-monitoring="true"] .game-cat[data-on="true"][data-filtered="false"] .game-cat-figure { filter: drop-shadow(0 0 5px var(--game-amber)); }
  #mobileCats[data-recording="true"] .game-cat-figure { transform: rotate(-7deg) translateY(-2px); }
  #mobileCats[data-playing="false"] .game-stage .cat-portrait { opacity: .82; }
  [dir="rtl"] .game-cat-plaque, [dir="rtl"] .game-cat-state, [dir="rtl"] .game-stage-empty, [dir="rtl"] .game-waiting-empty { direction: rtl; }

  /* No idle beat simulation: only Strudel's real .is-hit events animate limbs. */
  .game-cat .cat-body, .game-cat .cat-tail { animation: none; }
  .game-cat[data-on="true"]:not([data-mood="sleepy"]) .cat-eyes-open { animation: none; }
  @keyframes game-cat-land { 0% { transform: translateY(-70px) scale(.92); opacity: 0; } 65% { transform: translateY(3px) scale(1.03,.97); opacity: 1; } 100% { transform: none; opacity: 1; } }
  @keyframes game-cat-ready { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-3px); } }
  @media (prefers-reduced-motion: reduce) {
    .game-cat *, .game-cat::before, .game-cat::after { animation: none !important; transition: none !important; }
    .game-cat.is-hit .game-cat-figure { filter: brightness(1.12); }
    #mobileCats[data-recording="true"] .game-cat-figure { transform: none; }
  }
  @media (max-width: 350px) {
    .game-waiting-head { padding-inline: 16px; gap: 5px; }
    .game-waiting-hint { max-width: 145px; padding-inline: 5px; }
    .game-stage-empty { left: 24px; right: 24px; font-size: 12px; padding: 8px 10px; }
  }
}
