/* Mobile layout hardening: keep the game controls inside the safe viewport. */
html,body,#app{min-width:0;max-width:100%;overflow-x:hidden}
button,input,textarea,select{font:inherit}
dialog{max-width:calc(100vw - 24px);max-height:calc(100dvh - 24px);box-sizing:border-box}
dialog.account-pop,dialog.sc-dialog,dialog.debate-dialog,dialog.passes-dialog,dialog.over-dialog{width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow-y:auto}
.action-popover{max-width:calc(100vw - 20px);max-height:calc(100dvh - 130px);box-sizing:border-box}
@media (pointer:coarse),(max-width:760px){
  body:not(.playing) .topbar{padding-inline:max(12px,env(safe-area-inset-left)) max(12px,env(safe-area-inset-right));}
  body:not(.playing) .top-actions{gap:6px;min-width:0;flex-wrap:wrap;justify-content:flex-end}
  body:not(.playing) .top-actions .account-btn{min-height:42px;padding:9px 11px}
  body:not(.playing) .entry{width:100%;max-width:100%;padding:10px;box-sizing:border-box}
  body:not(.playing) .entry-card{width:100%;max-height:calc(100dvh - 92px);padding:18px 14px 0;border-radius:14px}
  body:not(.playing) .entry-scroll{padding:16px 12px 18px}
  body:not(.playing) .entry-card .entry-actions{grid-template-columns:1fr;padding:11px 14px;gap:8px}
  body:not(.playing) .entry-card .entry-actions .primary,.entry-card .entry-actions .spectate-entry{width:100%;min-height:48px}
  body:not(.playing) .account-box{align-items:flex-start;flex-wrap:wrap}
  body:not(.playing) .account-actions{width:100%;justify-content:flex-end}
  body:not(.playing) .account-actions .account-btn{flex:1;min-width:0;min-height:44px}
  body.playing nav.grouped-dock{max-width:calc(100vw - 16px);overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}
  body.playing nav.grouped-dock::-webkit-scrollbar{display:none}
  body.playing nav.grouped-dock>.action-category{flex:0 0 auto;min-width:110px;min-height:50px}
  body.playing nav.dock .action-utilities{flex:0 0 auto}
  body.playing nav.dock .action-popover{inset:auto 10px max(var(--mobile-bottom),72px) 10px;width:auto;max-width:none;max-height:calc(100dvh - 180px)}
  body.playing .chat-panel{max-width:calc(100vw - 20px);box-sizing:border-box}
  .mobile-sheet,.mobile-menu-grid{max-width:calc(100vw - 16px);box-sizing:border-box}
}
@media (max-width:420px){
  body:not(.playing) .entry-card .sides{grid-template-columns:1fr;}
  body:not(.playing) .entry-card .characters{grid-template-columns:repeat(2,minmax(0,1fr));}
  body:not(.playing) .login-row{justify-content:stretch}
  body:not(.playing) .login-row .account-btn{flex:1;min-width:0}
  .action-options{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* Keep the mobile navigation and its sheet above the canvas on touch devices. */
@media (pointer: coarse), (max-width: 760px) {
  body.mobile-hud.playing .mobile-nav {
    z-index: 2147483000 !important;
    pointer-events: auto !important;
    isolation: isolate;
  }
  body.mobile-hud.playing .mobile-nav-button,
  body.mobile-hud.playing .mobile-sheet,
  body.mobile-hud.playing .mobile-sheet button,
  body.mobile-hud.playing .mobile-menu-action,
  body.mobile-hud.playing .mobile-vehicle {
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  body.mobile-hud.playing .mobile-sheet {
    z-index: 2147483001 !important;
  }
}

@media (pointer: coarse), (max-width: 760px) {
  body.mobile-hud.playing .mobile-jump {
    display: grid;
    place-items: center;
    pointer-events: auto !important;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    width: 72px;
    height: 72px;
    margin: 0;
    padding: 8px 4px;
    border: 2px solid #e9d68d88;
    border-radius: 22px;
    background: #1d392fe8;
    color: #fff3c5;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
  }
  body.mobile-hud.playing .mobile-jump:active,
  body.mobile-hud.playing .mobile-jump.held {
    background: #ecd680;
    border-color: #fff2bf;
    color: #14291f;
    transform: scale(.96);
  }
  body.mobile-hud.playing[data-mobile-mode="vehicle"] .mobile-jump,
  body.mobile-hud.playing[data-mobile-mode="passenger"] .mobile-jump,
  body.mobile-hud.playing[data-mobile-mode="mount"] .mobile-jump,
  body.mobile-hud.playing[data-mobile-mode="spectator"] .mobile-jump {
    display: none;
  }
}
