.touch-keys{display:none}

@media (any-pointer:coarse),(max-width:650px){
  #game{
    --safe-top:max(8px,env(safe-area-inset-top));
    --safe-right:max(10px,env(safe-area-inset-right));
    --safe-bottom:max(12px,env(safe-area-inset-bottom));
    --safe-left:max(10px,env(safe-area-inset-left));
  }
  #hud{inset:var(--safe-top) var(--safe-right) auto var(--safe-left)}
  .mission{max-width:calc(100% - 102px)}
  #radar{width:88px;height:auto}
  .pause{min-width:48px;min-height:48px;touch-action:manipulation}
  #touch{display:flex;inset:auto var(--safe-right) var(--safe-bottom) var(--safe-left)}
  #touch button{min-width:48px;min-height:48px;font-size:.79rem;touch-action:none}
  .pad{grid-template-columns:repeat(3,48px);gap:4px}
  .pad button{font-size:1rem!important}
  #touch.driving .pad{grid-template-columns:repeat(2,48px)}
  .pedals{grid-template-columns:repeat(2,54px)}
  .pedals [data-key=brake]{grid-column:1/-1}
  #touch #act{min-width:76px}
  #pulseControls button{min-width:65px}
  #hint{bottom:calc(var(--safe-bottom) + 112px);max-width:calc(100% - var(--safe-left) - var(--safe-right))}
  #vehicle{right:var(--safe-right);bottom:calc(var(--safe-bottom) + 154px)}
  .overlay{justify-items:center;align-items:safe center;padding:max(12px,var(--safe-top)) max(12px,var(--safe-right)) max(14px,var(--safe-bottom)) max(12px,var(--safe-left))}
  .actions button{min-height:48px;touch-action:manipulation}
  #keys{display:none}
  #keys:not([hidden]) + .touch-keys{display:block}
}

/* Put the driving and firing controls at the right thumb in landscape. */
@media (any-pointer:coarse) and (orientation:landscape),(max-width:650px) and (orientation:landscape){
  .mission{max-width:min(440px,calc(100% - 110px));padding:6px 9px}
  #dispatch{font-size:.74rem}
  .pedals{grid-template-columns:repeat(3,minmax(52px,auto))}
  .pedals [data-key=brake]{grid-column:auto}
  #touch #act{margin-inline-start:auto}
  #hint{bottom:calc(var(--safe-bottom) + 59px)}
  #vehicle{bottom:calc(var(--safe-bottom) + 61px)}
  .sheet{max-width:490px}
  .sheet .actions{margin:8px 0}
}

@media (max-width:350px){
  #touch{gap:4px}
  #touch #act{min-width:69px}
  .pedals{grid-template-columns:repeat(2,50px)}
  .pedals [data-key=brake]{grid-column:1/-1}
  .mission{max-width:calc(100% - 90px)}
  #radar{width:76px}
}

/* Keep the readout and the contextual hint apart while driving. */
@media (any-pointer:coarse) and (orientation:landscape),(max-width:650px) and (orientation:landscape){
  #vehicle:not([hidden]) + #hint{left:var(--safe-left);transform:none;max-width:calc(100% - 190px)}
}
