/* A phone has a separate thumb-control area, leaving the world unobstructed. */
#pauseMain button[hidden],#pauseMain.hidden { display:none; }
@media (pointer:coarse) and (max-width:1100px) {
  #gameWrap { --touch-dock:calc(164px + env(safe-area-inset-bottom)); }
  #game { height:calc(100% - var(--touch-dock)); }
  #touch { position:absolute;left:0;right:0;bottom:0;height:var(--touch-dock);display:block;background:linear-gradient(#304d63,#233b50);border-top:3px solid #92aebf;z-index:35;touch-action:none; }
  #dpad { left:12px;bottom:calc(8px + env(safe-area-inset-bottom));grid-template-columns:repeat(3,48px);grid-template-rows:repeat(3,48px);gap:2px;touch-action:none; }
  #dpad .db { font-size:17px;min-width:0;min-height:0; }
  #dpad .held { background:#ffdf9c;outline:2px solid #f7c463;outline-offset:-4px;box-shadow:inset 0 2px 0 #b67b3c; }
  #abtns { display:grid;grid-template-columns:48px 60px;grid-template-rows:46px 62px;gap:8px 12px;right:14px;bottom:calc(16px + env(safe-area-inset-bottom)); }
  #btnMenuT,#btnRun { position:static;min-width:44px;min-height:44px;width:48px;height:44px;padding:0;font-size:13px; }
  #btnMenuT { font-size:23px; }
  #btnA { width:60px;height:60px;font-size:23px; }
  #btnB { width:48px;height:48px;align-self:end;font-size:20px; }
  #btnRun.on { background:#ffdf9c;color:#28454c;box-shadow:inset 0 2px 0 #b67b3c; }
  #advMobile { display:none; }
  #dlg { bottom:calc(var(--touch-dock) + 9px);left:50%;transform:translateX(-50%);width:calc(100% - 18px);max-height:calc(100% - var(--touch-dock) - 76px);overflow:auto;padding:10px;gap:8px; }
  #dlgText { font-size:14px;line-height:1.45; }
  #dlgHint { font-size:12px; }
  body.in-recovery #dlg { display:block; }
  #recoveryChoices { position:static;width:100%;display:flex;gap:8px;margin-top:10px;padding:0;border:0;background:none;box-shadow:none; }
  #recoveryChoices button { width:auto;flex:1;min-height:44px; }
  #recoveryControls button { min-height:44px; }
  #choice { bottom:calc(var(--touch-dock) + 12px);max-height:calc(100% - var(--touch-dock) - 76px);overflow:auto; }
  #chBtns button { min-height:44px; }
  #advPrompt { bottom:calc(var(--touch-dock) + 8px);max-width:calc(100% - 20px);white-space:normal;text-align:center;font-size:13px; }
  #advLocation,#advLocation.show { top:122px;bottom:auto;left:50%;right:auto;transform:translateX(-50%);width:max-content;max-width:calc(100% - 24px);padding:7px 12px;text-align:center; }
  #advLocation strong { font-size:15px; } #advLocation span { font-size:12px; }
  #mini { display:none; }
  #tracker { top:68px;left:10px;max-width:calc(100% - 20px);font-size:12px;padding:6px 9px; }
  #hud .hbtn,#hud #quick .q { min-width:40px;min-height:44px; }
  #hud #btnMe { width:40px;height:44px; }
  #hud #btnDex,#hud #btnBadge { min-height:44px; }
  #hudInfo { max-width:120px; }
  #pause .pcard { max-height:calc(100dvh - 24px);overflow-y:auto;overscroll-behavior:contain; }
  #pauseMain { display:grid;grid-template-columns:1fr 1fr;gap:8px; }
  #pauseMain button { font:700 13px/1.4 'Courier New',monospace;min-height:48px;padding:9px; }
  #pauseMain button[data-p="resume"] { grid-column:1/-1; }
  .dexFoot button,.blinks a,.blinks button,.guide-links a { min-height:44px;display:inline-flex;align-items:center;justify-content:center; }
  .dexFoot { padding-bottom:max(8px,env(safe-area-inset-bottom)); }
  #nqName { font-size:16px; }
  .adv-head h2 { min-width:0;overflow-wrap:anywhere; }
  .adv-head button { flex:none;white-space:nowrap;min-height:44px; }

  body.in-adventure-battle #touch { display:none!important; }
  #battle { --arena-min:clamp(190px,35dvh,290px); }
  #bField { flex:1;min-height:var(--arena-min); }
  #bUI { min-height:0;max-height:calc(100% - var(--arena-min));padding:8px 10px max(10px,env(safe-area-inset-bottom));gap:7px;scroll-padding-top:44px;touch-action:pan-y; }
  #bText { height:96px;min-height:96px;max-height:96px;overflow-y:auto;overscroll-behavior:contain;font:700 14px/1.4 'Courier New',monospace;padding:9px 12px; }
  .battle-command-heading { position:sticky;top:-8px;z-index:7;background:#35495c;padding:4px 0;min-height:36px; }
  #battleTrainerPortrait { width:30px;height:30px; }
  #battleTrainerIdentity { gap:7px; }
  #bHint { display:none; }
  #advTactics { font-size:11px;line-height:1.35; }
  #bMenu,#bMoves,#bParty { gap:6px; }
  #bMenu button,#bMoves button,#bParty button { min-height:46px;padding:8px;font-size:14px;touch-action:manipulation; }
  #bMoves button[data-type] { min-height:76px;padding:7px;gap:2px 4px; }
  #bMoves .move-name { font-size:14px;line-height:1.2; }
  #bMoves .move-type,#bMoves .move-detail { font-size:10px;line-height:1.25; }
  #bMoves .move-code { display:none; }
  #bMoves .move-power { grid-row:3;font-size:11px;line-height:1.3; }
  #bMoves .battle-item { min-height:76px; }
  #bParty { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #bParty button { min-width:0;padding:7px;font-size:13px;line-height:1.3; }
  #bParty .party-types,#bParty .party-matchup { font-size:11px;line-height:1.3;margin:2px 0; }
  #bParty .mhp { height:6px;margin-top:3px; }
  #bParty .mhn { font-size:11px; }
  #bParty button.back { grid-column:1/-1;min-height:44px; }
  #bContinue { min-height:44px; }
}
@media (pointer:coarse) and (max-width:360px) {
  #hudInfo { max-width:92px; }
  #hud #btnBadge { display:none; }
  #hud #quick { gap:3px; }
  #bText { height:88px;min-height:88px;max-height:88px; }
}
@media (pointer:coarse) and (max-width:639px) and (max-height:620px) {
  #battle { --arena-min:170px;--bugTop:4px;--meBot:4px;--spr:72px; }
  #bText { height:72px;min-height:72px;max-height:72px; }
  #advTactics { display:none; }
}
/* In landscape, the thumbs sit beside the map instead of covering its edges. */
@media (pointer:coarse) and (min-width:640px) and (max-width:1100px) and (max-height:560px) {
  #layout { padding:0;min-height:0; }
  #gameWrap { --touch-dock:0px;--touch-left:calc(162px + env(safe-area-inset-left));--touch-right:calc(144px + env(safe-area-inset-right));border:0;border-radius:0; }
  #game { left:var(--touch-left);right:var(--touch-right);width:calc(100% - var(--touch-left) - var(--touch-right));height:100%; }
  #touch { inset:58px 0 0;height:auto;background:none;border:0;pointer-events:none; }
  #touch::before,#touch::after { content:'';position:absolute;top:0;bottom:0;background:#263f54;z-index:-1; }
  #touch::before { left:0;width:var(--touch-left);border-right:2px solid #6e8d9e; }
  #touch::after { right:0;width:var(--touch-right);border-left:2px solid #6e8d9e; }
  #dpad { pointer-events:auto;left:calc(8px + env(safe-area-inset-left));bottom:max(8px,calc((100% - 148px)/2)); }
  #abtns { pointer-events:auto;right:calc(12px + env(safe-area-inset-right));bottom:max(8px,calc((100% - 116px)/2)); }
  #dlg,#choice { left:var(--touch-left);transform:none;bottom:10px;width:calc(100% - var(--touch-left) - var(--touch-right));max-height:calc(100% - 74px); }
  #dlgPort { display:none; }
  #tracker { left:calc(var(--touch-left) + 6px);max-width:calc(100% - var(--touch-left) - var(--touch-right) - 12px);top:64px; }
  #wxChip { display:none; }
  #advPrompt { bottom:9px;max-width:calc(100% - var(--touch-left) - var(--touch-right));left:calc(var(--touch-left) + (100% - var(--touch-left) - var(--touch-right))/2); }
  #advLocation { top:110px;max-width:calc(100% - var(--touch-left) - var(--touch-right));left:calc(var(--touch-left) + (100% - var(--touch-left) - var(--touch-right))/2); }
  #battle { --arena-min:0px; }
  #bField { min-height:0; }
  #bUI { max-height:100%;padding:6px 9px max(8px,env(safe-area-inset-bottom)); }
  #bText { height:84px;min-height:84px;max-height:84px; }
  .battle-command-heading { top:-6px; }
}
@media (pointer:coarse) and (min-width:640px) and (max-height:360px) {
  /* Move cards already show type, accuracy and outcome; keep all four within reach. */
  #battle[data-phase="moves"] #bText,#battle[data-phase="menu"] #bText { display:none; }
  #advTactics { display:none; }
}
