/* UNFIRE mobile HUD guard — an opt-in music drawer, not a second game UI.
   Small screen controls remain usable in case, story, multiplayer and roaming.
   Added on an isolated branch; desktop/Y2K styling and game state untouched. */
#unfireMixToggle{display:none}
@media (pointer:coarse), (max-width:720px){
  #mix.on{
    box-sizing:border-box!important;position:fixed!important;
    left:max(8px,env(safe-area-inset-left))!important;right:auto!important;
    top:calc(env(safe-area-inset-top) + 59px)!important;
    bottom:auto!important;transform:none!important;transform-origin:top left!important;
    z-index:85!important;width:max-content!important;
    max-width:calc(100vw - 16px)!important;
    min-width:0!important;padding:4px!important;gap:4px!important;
    border-radius:20px!important;
  }
  #mix.on:not(.unfire-expanded)>.row{display:none!important}
  #mix.on #unfireMixToggle{
    display:block!important;box-sizing:border-box!important;
    border-radius:999px!important;min-height:39px!important;
    width:auto!important;max-width:100%!important;
    padding:8px 13px!important;white-space:normal!important;
    font:800 11px/1.25 system-ui,sans-serif!important;
    letter-spacing:.02em!important;touch-action:manipulation;
  }
  #mix.on.unfire-expanded{
    left:max(8px,env(safe-area-inset-left))!important;
    right:max(8px,env(safe-area-inset-right))!important;
    top:calc(env(safe-area-inset-top) + 56px)!important;
    bottom:auto!important;width:auto!important;
    max-width:none!important;max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 67px)!important;
    overflow-y:auto!important;overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    padding:10px!important;gap:8px!important;
    border-radius:17px!important;
    box-shadow:0 12px 44px #000c!important;
  }
  #mix.on.unfire-expanded>.row{
    display:flex!important;min-width:0!important;max-width:100%!important;
    flex-wrap:wrap!important;gap:5px!important;
    white-space:normal!important;overflow-wrap:anywhere!important;
  }
  #mix.on.unfire-expanded b{
    flex:1 1 110px!important;min-width:0!important;
    max-width:100%!important;font:800 12px/1.3 system-ui,sans-serif!important;
    white-space:normal!important;overflow-wrap:anywhere!important;
  }
  #mix.on.unfire-expanded button{
    box-sizing:border-box!important;min-width:35px!important;min-height:36px!important;
    padding:7px 9px!important;
    font:750 10px/1.3 system-ui,sans-serif!important;
    white-space:normal!important;overflow-wrap:anywhere!important;
  }
  #mix.on.unfire-expanded>.row:nth-of-type(2) button{flex:1 1 95px!important}
  #mix.on.unfire-expanded select{
    box-sizing:border-box!important;min-width:0!important;
    flex:1 1 95px!important;max-width:100%!important;
    min-height:36px!important;font:500 12px system-ui,sans-serif!important;
  }
  /* Music/radio editors are mutually exclusive with the movement rail and
     foreground prompts; they stay in the DOM with their original handlers. */
  body.unfire-mix-open #ctlDock,body.unfire-mix-open #wradio,
  body.unfire-mix-open #buy,body.unfire-mix-open #cfgB,
  body.unfire-mix-open #tip,body.unfire-mix-open #storyHud,
  body.unfire-mix-open #onlHud,body.unfire-mix-open #minimap,
  body.unfire-mix-open .hud{
    visibility:hidden!important;pointer-events:none!important;
  }
  body.storyOn #mix,body.unfire-roaming #mix{display:none!important}
  /* Radio sits in the left lane. A centred bar collided with PASEAR on 375px. */
  #wradio{
    left:max(8px,env(safe-area-inset-left))!important;
    right:auto!important;transform:none!important;
    top:calc(env(safe-area-inset-top) + 112px)!important;
    width:max-content!important;max-width:min(51vw,195px)!important;
    box-sizing:border-box!important;flex-wrap:wrap!important;
  }
  #wradio button{flex-shrink:0!important}
  #wradio.expanded{
    left:max(8px,env(safe-area-inset-left))!important;
    right:max(8px,env(safe-area-inset-right))!important;
    top:calc(env(safe-area-inset-top) + 56px)!important;
    width:auto!important;max-width:none!important;
    max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 68px)!important;
    overflow-y:auto!important;overflow-x:hidden!important;
    justify-content:center!important;
  }
  body:has(#wradio.expanded) #mix,
  body:has(#wradio.expanded) #ctlDock,
  body:has(#wradio.expanded) #cfgB,
  body:has(#wradio.expanded) #tip,
  body:has(#wradio.expanded) #buy,
  body:has(#wradio.expanded) #minimap{
    visibility:hidden!important;pointer-events:none!important;
  }
  /* Allow safe scrolling for long translated dialogue and online menus. */
  #storyMenu,#onl .b,#onl.workshop .b,#howto{
    box-sizing:border-box!important;max-width:calc(100vw - 16px)!important;
    max-height:calc(100dvh - 16px)!important;
    overflow:auto!important;overscroll-behavior:contain;
  }
}
@media (pointer:coarse) and (orientation:landscape), (max-width:720px) and (orientation:landscape){
  #mix.on{top:calc(env(safe-area-inset-top) + 8px)!important}
  #mix.on.unfire-expanded{
    top:calc(env(safe-area-inset-top) + 50px)!important;
    max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 59px)!important;
  }
  #wradio{top:calc(env(safe-area-inset-top) + 57px)!important;max-width:min(45vw,195px)!important}
  #wradio.expanded{top:calc(env(safe-area-inset-top) + 50px)!important;
    max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 60px)!important}
}
@media (prefers-reduced-motion:reduce){
  #mix,#wradio,#unfireMixToggle{transition:none!important;animation:none!important}
}
