/* A single mobile layout owns the available space. Scene height must never
   depend on subtracting the keyboard from an already shortened scene. */
@media (max-width:900px), (any-pointer:coarse) and (max-width:1200px) {
  body:has(#game:not([hidden])) { margin:0; overflow:hidden; }
  .app:has(#game:not([hidden])) {
    height:100svh; height:100dvh; min-height:0; padding:0;
    display:grid; grid-template-rows:52px minmax(0,1fr);
    padding-top:env(safe-area-inset-top); padding-bottom:env(safe-area-inset-bottom);
    background:#071a18;
  }
  .app:has(#game:not([hidden])) .masthead {
    position:relative; inset:auto; display:flex; flex-direction:row;
    justify-content:space-between; align-items:center; min-height:0;
    padding:3px 8px; gap:8px; width:100%;
  }
  .app:has(#game:not([hidden])) .masthead .game-title { width:125px; height:46px; flex:none; }
  .app:has(#game:not([hidden])) .game-title img { width:100%; height:100%; object-fit:contain; }
  .app:has(#game:not([hidden])) .title-spider,
  .app:has(#game:not([hidden])) .game-brand { display:none; }
  .app:has(#game:not([hidden])) .masthead .header-actions {
    position:static; display:flex; gap:5px; padding:0; margin:0;
  }
  .app:has(#game:not([hidden])) .header-actions .outline {
    width:44px; height:44px; min-height:44px; padding:3px; font-size:0;
  }
  .app:has(#game:not([hidden])) #pauseButton { width:62px; font:700 12px system-ui; padding:3px; }
  .app:has(#game:not([hidden])) .header-actions kbd { display:none; }
  .app:has(#game:not([hidden])) #musicButton::before { content:'♫'; font-size:21px; }
  .app:has(#game:not([hidden])) #helpButton::before { content:'?'; font-size:21px; }
  .app:has(#game:not([hidden])) main { min-height:0; height:auto; }
  .app #game.game-screen {
    display:grid; grid-template-columns:minmax(0,1fr);
    grid-template-rows:auto minmax(0,1fr) auto; height:100%; min-height:0; padding:0;
  }
  .app #game .hud {
    position:relative; inset:auto; transform:none; grid-row:1;
    width:auto; margin:0; padding:4px 12px 7px;
    display:grid; grid-template-columns:minmax(0,1fr) auto; gap:5px 12px;
    background:#071a18; border:0; border-radius:0; box-shadow:none; backdrop-filter:none;
  }
  .app #game .chapter { flex-direction:row; flex-wrap:wrap; align-items:center; gap:4px 8px; }
  .app #game .player-label { display:none; }
  .app #game .chapter .eyebrow { margin:0; font-size:10px; }
  .app #game .chapter strong,.app #game .play-stats strong { font:700 12px/1.2 system-ui; }
  .app #game .play-stats { gap:12px; }
  .app #game .play-stats span { font-size:8px; }
  .app #game .web-status { grid-column:1/-1; grid-row:2; gap:3px; width:100%; }
  .app #game .web-label,.app #game .pressure-label { font-size:8px; }
  .app #game .web-label strong,.app #game .pressure-label strong { font-size:11px; }
  .app #game .web-meter { height:10px; }
  .app #game .pressure-status .web-meter { height:6px; }
  .app #game #scene {
    position:relative; inset:auto; grid-row:2; width:100%; height:100%; min-height:0;
    overflow:hidden; border:0; border-radius:0;
  }
  .app #game .scene-art { background-size:cover; background-position:center 57%; }
  .app #game .scene-shade { background:linear-gradient(0deg,#03150f70,transparent 60%); }
  .app #game #scene .scene-svg {
    position:absolute; inset:0; margin:auto; transform:none;
    width:min(64%,240px); height:96%; max-height:300px; overflow:visible;
  }
  .app #game #childWebFrame,.app #game #childFullWeb { transform:none; }
  .app #game .spell-panel {
    position:relative; inset:auto; transform:none; grid-row:3; width:100%; margin:0;
    padding:5px 7px 6px; border:0; border-top:1px solid #67bfa675;
    border-radius:0; background:#071c18; box-shadow:none; backdrop-filter:none;
  }
  .app #game .prompt-row,.app #game .answer-heading { display:none; }
  .app #game .tangle { font-size:clamp(20px,5.5vw,26px); line-height:1.2; min-height:30px; padding:2px 0 4px; }
  .app #game #answer { height:42px; font:600 18px/1.2 system-ui; padding:6px 9px; border-width:2px; }
  .app #game .answer-bottom { height:0; min-height:0; margin:0; }
  .app #game #feedback { position:absolute; right:8px; bottom:100%; background:#071c18dd; }
  .app #game .touch-keyboard { width:100%; max-width:none; margin:4px 0 0; }
  .app #game .key-row { gap:4px; margin:4px 0 0; }
  .app #game .key-row button,.app #game .key-row.special button {
    height:clamp(34px,5.8dvh,44px); min-height:34px; max-width:none;
    font-size:17px; padding:0; border-radius:6px;
  }
  .app #game .key-row.special [data-key='space'] { font-size:13px; }
  .app #game .defense-panel { width:calc(100% - 16px); max-height:75%; overflow:auto; bottom:8px; padding:12px; }
  .app #game .defense-panel h2 { font-size:25px; }
  .app #game .defense-panel .eyebrow { display:none; }
  .app #game.defending { grid-template-rows:auto minmax(0,1fr); }
  .app #game .defense-cue { top:10%; font-size:22px; }
  .app #game .child-cry,.app #game .cutscene-help { max-width:80%; font-size:16px; white-space:normal; }
}
@media (orientation:landscape) and (max-height:600px) and (max-width:900px), (orientation:landscape) and (max-height:600px) and (any-pointer:coarse) and (max-width:1200px) {
  .app:has(#game:not([hidden])) { grid-template-rows:46px minmax(0,1fr); }
  .app:has(#game:not([hidden])) .masthead .game-title { height:40px; width:120px; }
  .app #game.game-screen { grid-template-columns:43% minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); }
  .app #game .hud { grid-column:1; grid-row:1; padding:3px 8px; gap:3px; }
  .app #game #scene { grid-column:1; grid-row:2; }
  .app #game .spell-panel { grid-column:2; grid-row:1/3; align-self:end; border-top:0; border-left:1px solid #67bfa675; }
  .app #game .tangle { font-size:22px; min-height:28px; }
  .app #game #answer { height:38px; font-size:17px; }
  .app #game .key-row button,.app #game .key-row.special button { height:clamp(30px,9dvh,42px); min-height:30px; }
  .app #game.defending #scene { grid-column:1/-1; }
}
