/* Phone layouts keep the game and its primary action close at hand. */
@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
  body { overscroll-behavior: none; }
  button, select, input { touch-action: manipulation; }
  canvas { touch-action: none; }
  dialog { max-height: calc(100dvh - 24px); overflow: auto; }
  body[data-game="patchwork-parade"] .shell,
  body[data-game="puddle-engineers"] .shell,
  body[data-game="picnic-pairs"] .shell,
  body[data-game="mosaic-courtyard"] .shell,
  body[data-game="pantry-shuffle"] .shell { width: 100%; padding: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  body[data-game] .shell > header { min-height: 52px; }
  body[data-game] .shell > .footnote, body[data-game] .shell > footer { display: none; }
  body[data-game]:not([data-game="lantern-links"]) .game-menu { min-height: 0; gap: 12px; padding: 12px 0; }
  body[data-game]:not([data-game="lantern-links"]) .menu-art { display: none; }
  body[data-game]:not([data-game="lantern-links"]) .menu-copy { padding: 12px; }
  body[data-game]:not([data-game="lantern-links"]) .menu-copy h1 { font-size: clamp(28px, 8vw, 40px); }
  body[data-game]:not([data-game="lantern-links"]) .play-top { padding: 6px 0; gap: 8px; }
  body[data-game]:not([data-game="lantern-links"]) .scene-caption { min-height: 0; padding: 8px; }
  body[data-game]:not([data-game="lantern-links"]) .sidebar { position: static; padding: 6px; }
  body[data-game="lantern-links"] .shell { width: 100%; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  body[data-game="lantern-links"] #menuArt { display: none; }
  body[data-game="lantern-links"] .menu { min-height: 0; padding-block: 12px; }
  body[data-ug-game="find-the-animal"] .hero-art,
  body[data-ug-game="photon"] .orbit-art { display: none; }
  body[data-ug-game="find-the-animal"] .hero-card,
  body[data-ug-game="photon"] .home-layout { min-height: 0; }
  body[data-ug-game="swipe"] #gameCanvas,
  body[data-ug-game="pearls"] #game { touch-action: none; user-select: none; }
}

@media (max-width: 800px), (max-height: 560px) and (pointer: coarse) {
  .game-shell { width: 100%; padding: 0; }
  .masthead { position: absolute; z-index: 4; top: env(safe-area-inset-top); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); min-height: 48px; pointer-events: none; }
  .masthead > * { pointer-events: auto; }
  .game-shell:has(#hud:not([hidden])) .masthead { display: none; }
  .ocean-frame { width: 100%; height: 100dvh; min-height: 0; max-height: none; aspect-ratio: auto; border: 0; border-radius: 0; box-shadow: none; }
  .footer { display: none; }
  .screen { padding: calc(56px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .screen:not(.menu-screen) { padding-top: max(12px, env(safe-area-inset-top)); }
  .screen.menu-screen { align-items: center; }
  .hero-title { font-size: clamp(42px, 12vw, 70px); margin: 8px 0 12px; }
  .hero-copy { margin-bottom: 14px; line-height: 1.45; }
  .menu-links { margin-top: 10px; }
  .menu-footnote { margin-top: 8px; }
  .hud { top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); }
  .touch-controls { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .ship-panel { padding-right: 52px; }
  .ship-panel .icon-button { width: 44px; height: 44px; }
}

/* Edge-to-edge game presentation, on phones and larger screens. */

body[data-ug-game] .game-shell { width:100%; max-width:none; padding:0; }
body[data-ug-game] .ocean-frame { height:100dvh; min-height:0; max-height:none; aspect-ratio:auto; border:0; border-radius:0; box-shadow:none; }
body[data-ug-game] .footer { display:none; }
body[data-ug-game] .masthead { position:absolute; z-index:4; top:env(safe-area-inset-top); left:max(8px,env(safe-area-inset-left)); right:max(8px,env(safe-area-inset-right)); min-height:48px; }
body[data-ug-game]:has(#hud:not([hidden])) .masthead { display:none; }
body[data-ug-game] .screen.menu-screen { justify-content:center; padding-top:calc(56px + env(safe-area-inset-top)); }
body[data-ug-game] .menu-content { text-align:center; }
body[data-ug-game] .menu-content .button-row, body[data-ug-game] .menu-links { justify-content:center; }
body[data-ug-game] .hero-copy { margin-inline:auto; }
