/* speed-match · fullscreen fit — everything is scoped under html:is(.pip-immersive,.pip-native), so the normal page is
   untouched. Sizes come from js/fullscreen-fit.js (--fs-w / --fs-h / --fs-side on the stage). */
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; overflow-x: hidden; overflow-y: auto; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit > * { flex-shrink: 0; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit > * { max-width: 100%; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit #speed-play-area { width: var(--fs-w) !important; height: var(--fs-h) !important; max-width: none !important; max-height: none !important; margin: 0 !important; flex: none; }

html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit > .hud { width: var(--fs-w); max-width: 100%; margin: 0; padding-top: 4px; padding-bottom: 4px; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit > [role="status"]:empty, html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit > #status:empty { display: none; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit > [role="status"], html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit > #status { margin: 0; min-height: 0; padding: 2px 8px; width: var(--fs-w); text-align: center; font-size: .85rem; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit #speed-play-area:not([hidden]) { display: flex; flex-direction: column; gap: 8px; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit #speed-play-area .speed-arena { flex: 1 1 auto; min-height: 0; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit #speed-play-area .speed-controls { flex: none; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit .speed-timer-bar-wrap, html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit .speed-hud, html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit .speed-start-card, html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit .speed-result { width: var(--fs-w); max-width: 100%; }
@media (max-height: 520px) { html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit #status, html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit .speed-hud { margin: 0; } html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit #status { display: none; } html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit .speed-hud { padding: 2px 0; } }
/* wide: board left, HUD/controls right */
html:is(.pip-immersive,.pip-native) .game-wrap.fs-wide { display: grid; grid-template-columns: var(--fs-w) var(--fs-side); justify-content: center; align-content: center; column-gap: 16px; row-gap: 8px; grid-auto-rows: min-content; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-wide #speed-play-area { grid-column: 1; grid-row: 1 / span 12; align-self: center; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-wide > :not(#speed-play-area) { grid-column: 2; width: auto; margin: 0; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-wide > .hud { width: auto; }
html:is(.pip-immersive,.pip-native) .game-wrap.fs-wide .speed-replay, html:is(.pip-immersive,.pip-native) .game-wrap.fs-wide .speed-key-hint { display: none !important; }

/* pass 3: compact full screen (no scroll, safe areas, 44px+ controls) */
html:is(.pip-immersive,.pip-native) .game-wrap.fs-fit { overflow: hidden; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); padding-bottom: max(8px, env(safe-area-inset-bottom)); justify-content: center; }
html:is(.pip-immersive,.pip-native) .game-wrap .speed-intro,
html:is(.pip-immersive,.pip-native) .game-wrap .speed-key-hint,
html:is(.pip-immersive,.pip-native) .game-wrap .speed-replay,
html:is(.pip-immersive,.pip-native) .game-wrap .speed-lab,
html:is(.pip-immersive,.pip-native) .game-wrap #speed-memory-root,
html:is(.pip-immersive,.pip-native) .game-wrap .speed-start-card > p,
html:is(.pip-immersive,.pip-native) .game-wrap .pip-actions { display: none !important; }
html:is(.pip-immersive,.pip-native) .game-wrap .speed-start-card { padding: 1rem; overflow: hidden; }
html:is(.pip-immersive,.pip-native) .game-wrap .sm-goals { margin: .5rem 0; padding: .5rem; }
html:is(.pip-immersive,.pip-native) .game-wrap .btn-choice { min-height: 64px; }
html:is(.pip-immersive,.pip-native) .game-wrap .speed-symbol { width: min(26vw, 22vh, 140px); height: min(26vw, 22vh, 140px); }
html:is(.pip-immersive,.pip-native) .game-wrap .speed-result { overflow: hidden; padding: .75rem; }
@media (orientation: landscape) and (max-height: 520px) {
  html:is(.pip-immersive,.pip-native) .game-wrap .speed-start-card h2 { font-size: 1.05rem; margin-bottom: .25rem; }
  html:is(.pip-immersive,.pip-native) .game-wrap .sm-goals { display: none; }
  html:is(.pip-immersive,.pip-native) .game-wrap .speed-symbol { width: min(18vw, 30vh, 110px); height: min(18vw, 30vh, 110px); }
}
