#game-screen{position:relative;width:100%;height:100%}
#handheld-controls{touch-action:none;user-select:none;-webkit-user-select:none}
@media(pointer:coarse) and (orientation:portrait){
  #world.handheld{--screen-top:env(safe-area-inset-top,0px);--screen-height:clamp(200px,52dvh,520px);--chat-height:clamp(80px,13dvh,108px);background:#11251f}
  #world.handheld #game-screen{position:absolute;left:0;top:var(--screen-top);width:100%;height:var(--screen-height);overflow:hidden;background:#11251f}
  #world.handheld #canvas,#world.handheld #nameplates,#world.handheld #map-speech{width:100%;height:100%}
  #world.handheld #hud{bottom:0}
  #world.handheld .topbar{position:absolute;left:12px;right:12px;top:calc(var(--screen-top) + 12px);padding:0;gap:6px}
  #world.handheld .identity{padding:5px 8px;border-radius:4px;min-width:0;gap:0}
  #world.handheld .identity strong{font-size:10px;color:#eff2dc}
  #world.handheld .identity .portrait,#world.handheld .identity small,#world.handheld .health,#world.handheld .mini-map,#world.handheld .zone-caption,#world.handheld .bottom-right,#world.handheld #menu-button{display:none}
  #world.handheld #chat-panel{position:absolute;left:0;top:calc(var(--screen-top) + var(--screen-height) + 1px);bottom:auto;width:100%;height:var(--chat-height);border:0;border-top:1px solid #65715a;border-bottom:1px solid #344c3b;box-shadow:none}
  #world.handheld .chat-titlebar{height:18px;font-size:8px;padding:0 5px}
  #world.handheld .chat-titlebar span{padding:1px 4px}
  #world.handheld #chat-messages{font-size:10px;padding:2px 7px}
  #world.handheld #chat-form{padding:3px 5px;gap:4px}
  #world.handheld #chat-input{padding:2px 5px;font-size:16px}
  #world.handheld #chat-send{padding:5px 7px;font-size:9px}
  #world.handheld #handheld-controls{position:absolute;left:0;right:0;top:calc(var(--screen-top) + var(--screen-height) + var(--chat-height) + 14px);bottom:env(safe-area-inset-bottom);pointer-events:auto}
  #world.handheld #handheld-controls #joystick{display:block;left:24px;top:16px;bottom:auto}
  .handheld-actions{position:absolute;right:24px;top:38px;display:flex;flex-direction:column;gap:12px}
  .handheld-actions button,.handheld-system button{border:1px solid #52715b;background:#213d30;color:#d4dfc5;border-radius:8px;min-height:44px;padding:10px 18px;font-size:12px;font-weight:600;touch-action:manipulation}
  .handheld-actions button{min-width:94px}
  .handheld-actions button:active,.handheld-system button:active{background:#507450}
  .handheld-system{position:absolute;left:24px;right:24px;bottom:12px;display:flex;justify-content:center;gap:12px}
  .handheld-system button{min-height:36px;padding:7px 14px;font-size:10px;background:transparent;color:#a4bb9b;border-color:#375440}
  #world.handheld #menu-panel{left:16px;right:16px;top:calc(var(--screen-top) + 16px);width:auto;max-height:calc(var(--screen-height) - 32px);z-index:6;padding:14px 18px;color:#f6f2de}
  #world.handheld #menu-panel h2{font-size:22px;margin:6px 0}
  #world.handheld #menu-panel dl{margin:7px 0}
  #world.handheld #menu-panel dl>div{padding:7px 0}
  #world.handheld #toast{bottom:12px;color:#e3e7c9;font-size:10px}
  #world.handheld:has(#chat-input:focus){--screen-height:min(clamp(140px,32dvh,290px),calc(100dvh - var(--keyboard-inset) - var(--chat-height) - 24px))}
}
@media(pointer:coarse) and (orientation:portrait) and (max-height:680px){
  #world.handheld{--screen-height:46dvh;--chat-height:80px}
  #world.handheld #handheld-controls #joystick{top:8px}.handheld-actions{top:28px}.handheld-system{bottom:8px}
}
