/* TD2 Level 4 finding: the in-game options panel is substantially larger
   than needed on desktop. Scope every rule to the <details id="hudMenu"> menu.
   Do NOT alter the five-tower arsenal, action bar, canvas or frame cadence. */
#hudMenu .hud-menu-panel{
  box-sizing:border-box;
  width:min(244px,calc(100vw - 24px));
  min-width:0;
  grid-template-columns:repeat(2,minmax(0,1fr));
  grid-auto-flow:row;
  align-items:stretch;
  gap:5px;
  padding:7px;
  max-height:min(55dvh,290px);
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior:contain;
}
#hudMenu .hud-menu-panel > button{
  box-sizing:border-box;
  min-width:0;
  width:100%;
  border-radius:4px;
  white-space:normal;
  overflow-wrap:break-word;
  text-align:center;
}
#hudMenu .hud-menu-panel #telemetryBtn{grid-column:auto!important}
#hudMenu .hud-menu-panel #fullscreenBtn{grid-column:1/-1}
@media (hover:hover) and (pointer:fine){
  #hudMenu .hud-menu-panel{
    top:calc(100% + 6px);
    right:0;
    min-width:0;
  }
  #hudMenu .hud-menu-panel > button{
    min-height:38px;
    padding:6px 5px;
    font-size:11px;
    line-height:1.15;
    letter-spacing:0;
  }
  #hudMenu .hud-menu-panel #inventoryBtn{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:4px;
    font-size:11px;
  }
  #hudMenu .hud-menu-panel #inventoryBtn kbd{display:none}
  #hudMenu .hud-menu-panel #inventoryCount{
    font-size:10px;
    white-space:nowrap;
  }
}
@media (pointer:coarse){
  #hudMenu .hud-menu-panel{
    width:min(278px,calc(100vw - 24px));
    max-height:min(50dvh,320px);
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:5px;
    padding:7px;
  }
  #hudMenu .hud-menu-panel > button{
    min-height:48px;
    padding:6px 5px;
    font-size:11px;
    line-height:1.15;
    touch-action:manipulation;
  }
}
/* Narrow landscape: preserve every option, scroll within safe-area height. */
@media (max-height:540px){
  #hudMenu .hud-menu-panel{
    max-height:calc(100dvh - 85px - env(safe-area-inset-bottom,0px));
  }
}
