/* Shared phone frame. Mission text scrolls; controls keep their own stable rows. */
:root{
 --hq-safe-top:env(safe-area-inset-top,0px);
 --hq-safe-right:env(safe-area-inset-right,0px);
 --hq-safe-bottom:env(safe-area-inset-bottom,0px);
 --hq-safe-left:env(safe-area-inset-left,0px);
}
#hq-control-dock{display:contents}
/* Color only: keep the portalled controls' geometry and typography unchanged. */
#levels-dialog #hq-control-dock #campaign-launch{background:linear-gradient(110deg,#d5983c,#f3c66b 60%,#d59739);color:#192d30;border-color:#f9d88e}
#levels-dialog #hq-control-dock .hq-difficulty button{background:#1b3440;color:#acbfc4;border-color:#4d6873}
#levels-dialog #hq-control-dock .hq-difficulty button.is-selected{background:#4a412b;color:#f5cf89;border-color:#ba9654}
@media(max-width:700px),(max-width:1024px) and (max-height:500px){
 #levels-dialog.hq-screen[open]{
  display:flex;flex-direction:column;max-width:540px;overflow:hidden;padding:0;
 }
 #levels-dialog .hq-shell{
  flex:1 1 auto;height:auto;min-height:0;min-width:0;box-sizing:border-box;
  grid-template-columns:minmax(0,1fr);
  grid-template-areas:'head' 'modes' 'chapter' 'map' 'prep';
  grid-template-rows:repeat(5,max-content);
  align-content:start;overflow-x:hidden;overflow-y:auto;
  overscroll-behavior-y:contain;touch-action:pan-y;
  padding:calc(8px + var(--hq-safe-top)) max(10px,var(--hq-safe-right)) 12px max(10px,var(--hq-safe-left));
  gap:5px;
 }
 #levels-dialog .hq-shell>.desktop-toolbar,
 #levels-dialog .hq-settings:not([open]){display:none}
 #levels-dialog .campaign-selection>:is(#hq-armory-status,#hq-return-note,#local-playtest-notice){grid-column:1/-1;min-width:0;overflow-wrap:anywhere}
 #levels-dialog .campaign-map-group{grid-template-columns:minmax(0,1fr);height:auto;align-self:start}
 #levels-dialog .campaign-map-group>.campaign-map{width:100%;height:auto;min-height:0;max-height:none;aspect-ratio:4/3}
 #hq-control-dock{
  position:relative;flex:0 0 auto;z-index:8;display:grid;grid-template-columns:minmax(0,1fr);
  margin:0 max(10px,var(--hq-safe-right)) 0 max(10px,var(--hq-safe-left));width:auto;min-width:0;
  gap:6px;padding:6px 0 max(8px,var(--hq-safe-bottom));background:#142e38;
 }
 #hq-control-dock #hq-config-buttons,
 #hq-control-dock .hq-difficulty,
 #hq-control-dock #hq-launch-actions{
  position:static;inset:auto;grid-area:auto;min-width:0;width:auto;margin:0;padding:0;
 }
 #hq-control-dock #hq-config-buttons{grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
 #hq-control-dock #hq-config-buttons button{min-width:0;max-width:100%;overflow-wrap:anywhere}
 #levels-dialog #hq-control-dock #hq-config-buttons .hq-entry{flex-direction:column;gap:1px;min-height:calc(40px + 2.3em + 8px);padding:2px 3px 3px}
 #hq-control-dock #hq-config-buttons .hq-entry>span{display:block;min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}
 #hq-control-dock .hq-difficulty{display:flex;gap:5px}
 #hq-control-dock .hq-difficulty button{min-height:35px;flex:1;min-width:0;white-space:normal;overflow-wrap:anywhere}
 #hq-control-dock #campaign-launch{width:100%;min-height:44px;margin:0}

 /* All preparation panels share the same visible viewport, including browser bars. */
 :is(#hq-loadout-panel,#hq-supply-dialog,#hq-arsenal-panel,#hq-points-dialog,#hq-stars-dialog,#premium-dialog,#territories-dialog){
  position:fixed;top:var(--hq-viewport-top,0px);bottom:auto;left:0;right:0;
  width:min(100%,540px);height:var(--hq-viewport-height,100dvh);
  min-width:0;min-height:0;max-width:540px;max-height:var(--hq-viewport-height,100dvh);
  margin:0 auto;border-radius:0;box-sizing:border-box;overflow-x:hidden;overflow-y:auto;
 }
 .hq-screen-masthead{padding-top:calc(12px + var(--hq-safe-top))}
 .wallet-panel{padding-top:var(--hq-safe-top);padding-bottom:var(--hq-safe-bottom)}
 #territories-dialog .territories-header{padding-top:calc(11px + var(--hq-safe-top))}
 #levels-dialog .hq-settings[open]{
  position:fixed;inset:calc(var(--hq-viewport-top,0px) + var(--hq-safe-top) + 10px) max(10px,var(--hq-safe-right)) calc(var(--hq-viewport-bottom,0px) + var(--hq-safe-bottom) + 10px) max(10px,var(--hq-safe-left));
  z-index:40;overflow:auto;background:#132f3b;padding:12px;margin:0;
 }
}
