.mobile-chat-dismiss{display:none}
@media (max-width:700px), (max-width:950px) and (max-height:500px), (max-width:1100px) and (pointer:coarse), (max-width:1600px) and (max-height:700px) and (any-pointer:coarse) {
  .mobile-chat-dismiss{display:block;min-width:44px}
  html,body{height:100%;height:var(--mobile-vh,100dvh);overflow:hidden;overscroll-behavior:none}
  body{display:grid;grid-template-rows:44px minmax(0,1fr);min-height:0}
  body.embedded{grid-template-rows:minmax(0,1fr)}
  body.embedded .page-bar,.page-footer{display:none}
  .page-bar{height:44px;padding:0 max(6px,env(safe-area-inset-right)) 0 max(6px,env(safe-area-inset-left));gap:4px}
  .page-bar>span{display:block;letter-spacing:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;min-width:0;margin-right:auto}.page-bar>a{display:flex;align-items:center;min-height:44px;flex-shrink:0;font-size:12px}
  .page-bar #quality{display:none}
  button,input,select{min-height:44px}button{touch-action:manipulation}
  input,select{font-size:16px!important}button{font-size:12px}
  .page-bar button{min-width:44px;font-size:11px;padding:6px}
  #viewport{display:grid;grid-template-rows:minmax(0,1fr) 96px;gap:4px;min-height:0;height:100%;padding:4px max(4px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(4px,env(safe-area-inset-left));overflow:hidden;align-items:stretch}
  #screen-wrap{width:100%!important;height:100%!important;min-height:0;min-width:0}
  #screen{width:100%;height:100%;position:relative;transform:none!important;box-shadow:none}
  #world{width:100%;height:calc(100% - 88px);touch-action:none;user-select:none}
  .region-heading{left:6px;right:6px;top:5px;font-size:11px}.region-heading>span{max-width:65%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding:4px}
  #connection{font-size:10px}#battle-status{top:34px;left:50%;transform:translateX(-50%);width:auto;max-width:75%;padding:4px;font-size:11px}
  #city-facilities,#unit-rail{display:none}
  #hud{top:auto;bottom:0;width:100%;height:88px;background-image:none;border-top:1px solid #59694b}
  #commander-status{left:5px;right:88px;top:4px;width:auto;height:78px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px;align-content:center;padding:4px;font-size:11px}
  #commander-status>b{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#commander-rank{font-size:10px;text-align:right}
  #commander-sheet{grid-column:2;grid-row:2/4;min-width:70px;font-size:11px!important}#wallet{grid-row:2/4;align-self:center}
  #order-bar,#location-label,#focus{display:none}
  #mini{left:auto;right:5px;top:5px;width:76px;height:76px}
  .mobile-orders{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));grid-template-rows:44px 44px;gap:4px;width:100%;margin:0;align-content:center}
  .mobile-orders button{min-width:0;min-height:44px;padding:4px 2px;line-height:1.2;font-size:11px}
  #chat-form,#chat-log{display:none}
  .mobile-chat-open #chat-form{position:fixed;display:flex;z-index:60;left:8px;right:8px;top:auto;bottom:104px;width:auto;padding:5px;background:#071107f5;border:1px solid #81956b;gap:5px}
  .mobile-chat-open #chat-input{height:44px;padding:8px;min-width:0;flex:1}
  .mobile-chat-open #chat-form button{min-width:48px;font-size:12px}
  .mobile-chat-open #chat-log{display:block;position:fixed;left:8px;right:8px;width:auto;top:auto;bottom:163px;height:96px;z-index:59;font-size:13px;background:#020902ec;padding:6px}
  dialog{max-height:calc(var(--mobile-vh,100dvh) - 16px);overflow:auto;padding:18px;width:calc(100% - 24px)}
  dialog h1{font-size:22px}dialog p{font-size:13px}dialog label{font-size:13px}
  #mobile-menu-dialog{padding:14px}#mobile-menu-dialog h2{font-size:18px;margin:0 0 16px;padding-right:52px;min-height:36px;display:flex;align-items:center}
  .mobile-menu-close{position:absolute;right:8px;top:8px;min-width:48px}.mobile-menu-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.mobile-menu-grid button{min-height:44px;font-size:14px}
  body>#panel{height:var(--mobile-vh,100dvh);padding-top:0;overscroll-behavior:contain}
  body>#panel #panel-close{top:4px!important;right:6px;width:48px;height:44px!important;min-height:44px}
  body>#panel #panel-title{top:8px;left:8px;height:36px;font-size:13px}
  body>#panel #panel-content{margin:58px 8px 16px;min-height:0}
  body>#panel button{min-height:44px;touch-action:manipulation}
  body>#panel .panel-tabs{overflow-x:auto}.panel-tabs button{min-width:64px}
  #loading{max-width:100%;padding:20px}#loading h1{font-size:24px;letter-spacing:2px}#loading progress{max-width:90%}#toast{left:8px;right:8px;width:auto;top:40px;font-size:13px}
  body.mobile-keyboard #viewport{grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr)}
  body.mobile-keyboard .mobile-orders,body.mobile-keyboard #hud>:not(#chat-form):not(#chat-log){display:none}
  body.mobile-keyboard #hud{height:0;border:0;background:none;pointer-events:none}
  body.mobile-keyboard #world{height:100%}
  body.mobile-keyboard.mobile-chat-open #chat-form{bottom:calc(8px + var(--mobile-keyboard-inset,0px));left:8px;right:8px;z-index:120;pointer-events:auto}
  body.mobile-keyboard.mobile-chat-open #chat-log{bottom:calc(68px + var(--mobile-keyboard-inset,0px));left:8px;right:8px;height:64px;z-index:119;pointer-events:auto}
}
@media (min-width:480px) and (max-width:950px) and (max-height:500px) and (orientation:landscape) {
  #viewport{grid-template-columns:minmax(0,1fr) 184px;grid-template-rows:minmax(0,1fr);gap:5px}
  #world{height:calc(100% - 68px)}#hud{height:68px}#commander-status{height:60px;right:72px;font-size:11px}
  #mini{width:58px;height:58px}.mobile-orders{height:100%;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(4,minmax(44px,1fr));gap:4px}
  .mobile-orders button{font-size:11px}
  .mobile-chat-open #chat-form{bottom:8px;right:196px}.mobile-chat-open #chat-log{bottom:68px;right:196px;height:78px}
}
