body.mobile { --mobile-safe-left:env(safe-area-inset-left); --mobile-safe-right:env(safe-area-inset-right); --mobile-safe-top:env(safe-area-inset-top); --mobile-safe-bottom:env(safe-area-inset-bottom); }
/* Mobile touch layout: stable thumb zones, readable slots, safe screen edges. */
body.mobile { --touch-edge: 10px; --skill-size: 48px; --skill-step: 54px; }
body.mobile #mSkills { width: 216px; height: 254px; right: max(10px, var(--mobile-safe-right)); bottom: max(18px, var(--mobile-safe-bottom)); transform: none; }
body.mobile #mSkills .m-skill { width: var(--skill-size); height: var(--skill-size); left: calc(var(--col) * var(--skill-step)); top: calc(148px + var(--row) * var(--skill-step)); right: auto; bottom: auto; border-radius: 12px; border: 1px solid #cfad66; box-shadow: 0 3px 8px #0009; }
body.mobile #mSkills .m-skill .cd { border-radius: 11px; font-size: 19px; }
body.mobile .m-slot-number { position: absolute; bottom: 1px; right: 4px; color: #fff1c6; font: 600 11px var(--head); text-shadow: 0 1px 3px #000, 0 0 4px #000; pointer-events: none; }
body.mobile .m-skill.auto-on::after { left: 4px; top: 3px; transform: none; font-size: 9px; }
body.mobile #mSkills .m-atk { width: 76px; height: 76px; right: 4px; bottom: 120px; }
body.mobile .m-atk-label { position: absolute; bottom: 12px; left: 0; right: 0; color: #ffecaf; font: 500 12px var(--head); text-shadow: 0 1px 4px #000; }
body.mobile #mSkills .m-tgt { width: 48px; height: 48px; right: 90px; bottom: 132px; }
body.mobile #mSkills .m-potrow { right: 4px; bottom: 208px; gap: 6px; }
body.mobile #mSkills .m-potrow button { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 12px; }
body.mobile #joy { width: 124px; height: 124px; left: max(12px, var(--mobile-safe-left)); bottom: max(24px, var(--mobile-safe-bottom)); transform: none; opacity: .88; }
body.mobile .joy-arrow { display: none; }
body.mobile .joy-knob { width: 54px; height: 54px; margin: -27px; }
body.mobile #mChatBtn { width: 46px; height: 46px; left: max(14px, var(--mobile-safe-left)); bottom: max(166px, calc(var(--mobile-safe-bottom) + 142px)); border-radius: 14px; }
body.mobile #chat { display: none; }
body.mobile #chat.chat-open { display: flex; left: max(10px, var(--mobile-safe-left)); right: max(10px, var(--mobile-safe-right)); top: 84px; bottom: auto; width: auto; height: min(300px, calc(100dvh - 100px)); transform: none; z-index: 45; background: #140f0bf2; }
body.mobile #chat.chat-open .chat-input input { font-size: 16px; min-height: 44px; }
body.mobile #chat .chat-tabs button { min-height: 44px; }
body.mobile #playerFrame { top: max(8px, var(--mobile-safe-top)); left: max(10px, var(--mobile-safe-left)); width: 222px; transform: none; gap: 7px; }
body.mobile #portrait { width: 54px; height: 54px; border-width: 2px; }
body.mobile .pf-name { font-size: 15px; }
body.mobile .pf-title { font-size: 11px; margin-bottom: 2px; }
body.mobile .pf-lv { font-size: 10px; padding: 0 6px; }
body.mobile .bar { height: 17px; }
body.mobile .bar span { font-size: 11px; line-height: 15px; }
body.mobile #minimap { top: max(8px, var(--mobile-safe-top)); right: max(8px, var(--mobile-safe-right)); width: 148px; padding: 3px 5px; }
body.mobile #mmCanvas { width: 136px; height: 82px; }
body.mobile #mmFold { min-width: 44px; min-height: 44px; font-size: 18px; }
body.mobile #clock { top: 66px; right: 12px; transform: none; font-size: 11px; }
body.mobile #clock .ck-date, body.mobile #clock .ck-icon { display: none; }
body.mobile #topMenu { top: max(8px, var(--mobile-safe-top)); left: 246px; right: 166px; overflow-x: auto; overflow-y: hidden; gap: 4px; scrollbar-width: none; touch-action: pan-x; }
body.mobile .menu-btn { flex: 0 0 48px; width: 48px; min-height: 52px; }
body.mobile .menu-btn img { width: 30px; height: 30px; }
body.mobile .menu-btn span { display: block; font-size: 10px; white-space: nowrap; }
body.mobile #deviceToggle, body.mobile #fsToggle { top: 78px; height: 36px; }
body.mobile #deviceToggle { left: 10px; }
body.mobile #fsToggle { left: 92px; }
body.mobile #actions { top: 122px; left: 10px; transform: none; gap: 5px; }
body.mobile .act-btn { width: 44px; }
body.mobile .act-btn img, body.mobile .act-btn .act-emoji { width: 40px; height: 40px; }
body.mobile #lootFeed { top: 122px; right: 12px; max-width: 40vw; pointer-events: none; }
body.mobile #hotbarWrap { bottom: max(2px, var(--mobile-safe-bottom)); width: min(260px, 36vw); pointer-events: none; }
body.mobile .win { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
body.mobile .win-x, body.mobile .win-z { min-width: 44px; min-height: 44px; }
body.mobile .win-body { overflow: auto; overscroll-behavior: contain; font-size: 14px; }
body.mobile .win input, body.mobile .win select { font-size: 16px; min-height: 40px; }
body.mobile .win .btn { min-height: 44px; }
body.mobile #targetFrame { top: 80px; transform: translateX(-50%) scale(.8); }
body.mobile #mSkills button:active, body.mobile #mChatBtn:active { filter: brightness(1.35); }
@media (max-width: 600px) {
  body.mobile { --skill-size: 46px; --skill-step: 51px; }
  body.mobile #mSkills { width: 200px; right: max(8px, var(--mobile-safe-right)); }
  body.mobile #joy { width: 112px; height: 112px; left: 8px; }
  body.mobile #playerFrame { width: calc(100vw - 146px); }
  body.mobile #minimap { width: 128px; }
  body.mobile #mmCanvas { width: 116px; }
  body.mobile #topMenu { top: 90px; left: 8px; right: 8px; padding: 4px 6px; border: 1px solid #9a783c66; border-radius: 12px; background: #100c08b8; }
  body.mobile #deviceToggle, body.mobile #fsToggle { top: 154px; }
  body.mobile #actions { top: 196px; }
  body.mobile #targetFrame { top: 260px; }
  body.mobile #lootFeed { top: 202px; max-width: 44vw; }
  body.mobile #chat.chat-open { top: 154px; height: min(330px, calc(100dvh - 350px)); }
  body.mobile #hotbarWrap { width: 90vw; }
}
@media (max-height: 360px) and (min-width: 601px) {
  body.mobile #mSkills { bottom: 8px; }
  body.mobile #actions { top: 112px; }
}
body.mobile .pf-info { min-width: 0; }
body.mobile .pf-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.mobile .act-btn span { white-space: nowrap; font-size: 10px; }
body.mobile #mmIn, body.mobile #mmOut { min-width: 44px; min-height: 44px; }
@media (max-width: 359px) {
  body.mobile { --skill-size: 44px; --skill-step: 48px; }
  body.mobile #mSkills { width: 188px; right: 6px; }
  body.mobile #joy { width: 100px; height: 100px; }
  body.mobile #playerFrame { gap: 4px; }
  body.mobile #portrait { width: 42px; height: 42px; }
}
body.mobile #topMenu { background-color: #100c08b8; border-radius: 12px; }
body.mobile #potionCfg { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
body.mobile .pc-slot { min-height: 44px; }
body.mobile #clock { top: calc(66px + var(--mobile-safe-top)); }
body.mobile #deviceToggle, body.mobile #fsToggle { top: calc(78px + var(--mobile-safe-top)); }
body.mobile #actions { top: calc(122px + var(--mobile-safe-top)); }
@media (max-width: 600px) {
  body.mobile #topMenu { top: calc(90px + var(--mobile-safe-top)); }
  body.mobile #deviceToggle, body.mobile #fsToggle { top: calc(154px + var(--mobile-safe-top)); }
  body.mobile #actions { top: calc(196px + var(--mobile-safe-top)); }
}
body.mobile .pc-head { position: sticky; top: 0; z-index: 1; background: #181009; }
body.mobile .pc-head button { min-width: 44px; min-height: 44px; font-size: 20px; }
body.mobile .pc-line select { font-size: 16px; min-height: 44px; }

/* Requested revision: familiar two arcs around the attack button. */
body.mobile #mSkills { width: 270px; height: 306px; }
body.mobile #mSkills .m-skill { --rad: 180px; width: 48px; height: 48px; left: auto; top: auto; right: calc(18px + cos(var(--ang)) * var(--rad)); bottom: calc(18px + sin(var(--ang)) * var(--rad)); border-radius: 50%; }
body.mobile #mSkills .m-skill[style*="--n:0"],
body.mobile #mSkills .m-skill[style*="--n:1"],
body.mobile #mSkills .m-skill[style*="--n:2"] { --rad: 94px; }
body.mobile #mSkills .m-skill .cd { border-radius: 50%; }
body.mobile #mSkills .m-atk { width: 84px; height: 84px; right: 0; bottom: 0; }
body.mobile #mSkills .m-tgt { right: 204px; bottom: 116px; }
body.mobile #mSkills .m-potrow { right: 0; bottom: 258px; }
body.mobile .m-slot-number { right: 8px; bottom: 2px; }
body.mobile .m-skill.auto-on::after { left: 50%; transform: translateX(-50%); }
@media (max-width: 600px) {
  body.mobile #mSkills { width: 260px; }
  body.mobile #mSkills .m-skill { --rad: clamp(162px, calc(60vw - 54px), 180px); width: 46px; height: 46px; }
  body.mobile #mSkills .m-tgt { right: 190px; bottom: 116px; }
}
@media (max-width: 359px) {
  body.mobile #mSkills .m-skill { width: 44px; height: 44px; --rad: 162px; }
  body.mobile #joy { width: 80px; height: 80px; }
  body.mobile #mSkills .m-tgt { right: 178px; bottom: 112px; }
}
body.mobile #mSkills .m-tgt { right: 160px; bottom: 206px; }
@media (min-width: 601px) and (max-height: 460px) {
  body.mobile #mSkills .m-potrow { right: 280px; bottom: 0; }
}

/* Compact combat: four skills per arc, secondary actions on demand. */
#mActionsToggle { display: none; }
body.mobile #mActionsToggle { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; color: var(--gold); }
body.mobile #mActionsToggle b { font-size: 20px; line-height: 30px; }
body.mobile #actions:not(.actions-open) .act-btn:not(#act-auto):not(#act-party):not(#mActionsToggle) { display: none; }
body.mobile #mSkills { width: 210px; height: 250px; }
body.mobile #mSkills .m-skill { --rad: 126px !important; width: 46px; height: 46px; }
body.mobile #mSkills .m-skill[style*="--n:0"] { --ang: 0deg; }
body.mobile #mSkills .m-skill[style*="--n:1"] { --ang: 30deg; }
body.mobile #mSkills .m-skill[style*="--n:2"] { --ang: 60deg; }
body.mobile #mSkills .m-skill[style*="--n:3"] { --ang: 90deg; }
body.mobile #mSkills .m-tgt { right: 0; bottom: 198px; width: 44px; height: 44px; }
body.mobile #mSkills .m-potrow { right: 54px; bottom: 198px; gap: 4px; }
body.mobile #mSkills .m-potrow button { width: 44px; height: 44px; flex-basis: 44px; }
body.mobile #mSkills .m-atk { width: 84px; height: 84px; }
@media (max-width: 600px) {
  body.mobile #mSkills .m-potrow { right: 0; bottom: 250px; }
  body.mobile #mSkills .m-tgt { right: 0; bottom: 198px; }
}
@media (max-width: 359px) { body.mobile #joy { width: 100px; height: 100px; } }


/* Dedicated mobile housing presentation. Shared actions live in ui/home/shared.js. */
body.mobile .home-panel .cx-tabs { flex-wrap:nowrap; overflow-x:auto; overscroll-behavior:contain; padding:4px 0 8px; scrollbar-width:thin; }
body.mobile .home-panel .cx-tabs button { flex:0 0 auto; }
body.mobile .home-hero { padding:12px; gap:10px; }
body.mobile .home-hero img { width:82px; height:90px; }
body.mobile .home-hero h3 { font-size:17px; }
body.mobile .home-cards { grid-template-columns:1fr; }
body.mobile #win-home { width:calc(100vw - 16px)!important; }
body.mobile .home-head small { display:block; color:#cbb98c; }
/* Dedicated bag / skill / quest views: list first, one detail at a time. */
body.mobile :is(#win-bag,#win-skill,#win-quest) { width:calc(100vw - 16px)!important; }
body.mobile .mobile-window { font-size:14px; overflow-x:hidden; }
body.mobile .mobile-window :is(button,input,select,summary) { min-height:44px; font:inherit; }
body.mobile .mw-summary { padding:10px 0; color:#efd39e; }
body.mobile .mw-filters { display:grid; grid-template-columns:1fr; gap:8px; margin-bottom:12px; }
body.mobile .mw-filters :is(input,select),body.mobile .mw-bind select { width:100%; min-width:0; box-sizing:border-box; background:#241b13; color:#f3e3c6; border:1px solid #80663c; border-radius:8px; padding:10px; }
body.mobile .mw-list { display:grid; gap:8px; }
body.mobile .mw-row { display:flex; align-items:center; gap:10px; padding:10px; width:100%; min-width:0; text-align:left; border:1px solid #685334; border-radius:10px; background:#251d14; color:#f3e3c6; cursor:pointer; }
body.mobile .mw-row img { width:44px; height:44px; object-fit:contain; flex:none; }
body.mobile .mw-row>span:first-of-type { flex:1; min-width:0; }
body.mobile .mw-row b,body.mobile .mw-row small { display:block; overflow-wrap:anywhere; }
body.mobile .mw-row small { color:#c6b18d; margin-top:4px; font-size:12px; }
body.mobile .mw-actions,body.mobile .mw-tabs { display:flex; flex-wrap:wrap; gap:8px; margin:10px 0; }
body.mobile .mw-actions button,body.mobile .mw-tabs button { flex:1; }
body.mobile .mw-back { width:100%; margin-bottom:12px; }
body.mobile :is(.mw-item-detail,.mw-skill-detail,.mw-quest-detail) { min-width:0; overflow-wrap:anywhere; }
body.mobile .mw-bind { padding:12px 0; display:grid; gap:8px; }
body.mobile .mw-bind label { display:grid; gap:8px; }
body.mobile .mw-overflow,body.mobile .mw-preview { margin:12px 0; }
body.mobile .mw-overflow button { display:block; width:100%; margin:6px 0; }
body.mobile .mw-quest-detail .q-actions { display:grid; gap:12px; }
body.mobile .mw-quest-detail .danger { margin-top:16px; }
body.mobile .mw-skill-detail .sk-prev-box { max-width:100%; }
body.mobile .ctx-menu { max-width:calc(100vw - 24px); max-height:70dvh; overflow:auto; }
body.mobile .ctx-menu button { min-height:44px; font-size:14px; }
body.mobile .mobile-window :focus-visible { outline:2px solid #f5d894; outline-offset:2px; }
body.mobile .mobile-window { background:#1b140d; }

/* Landscape-first: spend width on content, preserve the familiar combat arc. */
body.mobile #chat .chat-input { flex-wrap:wrap; }
body.mobile #chat .chat-input input { min-width:100px; flex:1; }
body.mobile #chat :is(.chat-input button,.chat-input select,.chat-item-tag) { min-height:44px; }
/* Utilities participate in menu flow instead of floating over HP/MP. */
body.mobile #topMenu :is(#deviceToggle,#fsToggle,#pfPlus) { position:static; inset:auto; transform:none; flex:0 0 52px; width:52px; min-width:52px; height:52px; min-height:52px; padding:4px; margin:0; }
body.mobile #topMenu #deviceToggle { flex-direction:column; justify-content:center; gap:0; font-size:10px; }
body.mobile #topMenu #deviceToggle .dt-ico img { width:26px; height:26px; }
body.mobile #topMenu #pfPlus { font-size:24px; }
body.mobile .pf-name { min-height:24px; }
body.mobile #buffs { flex-wrap:nowrap; overflow-x:auto; overflow-y:hidden; max-width:100%; scrollbar-width:none; }
body.mobile #buffs .buff { flex:0 0 26px; }
body.mobile .auto-box { max-height:calc(100dvh - 24px); overflow-y:auto; }
body.mobile .auto-box :is(button,select),body.mobile .auto-box label { min-height:44px; }
body.mobile :is(#chat,#potionCfg,#autoBox,.mobile-window) button { min-width:44px; min-height:44px; }
body.mobile .win :is(button,select) { min-width:44px; min-height:44px; }
body.mobile #win-home { width:calc(100vw - max(8px,var(--mobile-safe-left)) - max(8px,var(--mobile-safe-right)))!important; }
/* Expanded minimap is a focused panel, not a layer over combat controls. */
@media (orientation:landscape) and (min-width:480px) {
 body.mobile :is(#win-bag,#win-skill,#win-quest) { width:calc(100vw - max(12px,var(--mobile-safe-left)) - max(12px,var(--mobile-safe-right)))!important; height:calc(100dvh - 16px); border:1px solid #aa864c; border-radius:12px; box-shadow:0 8px 28px #0008; }
 body.mobile .mobile-window { padding:12px 16px; background:linear-gradient(110deg,#241b12,#19130d); }
 body.mobile .mw-summary { padding:0 0 8px; font-size:13px; }
 body.mobile .mw-filters { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-bottom:8px; }
 body.mobile #win-skill .mw-filters { grid-template-columns:1fr 1fr 1fr; }
 body.mobile .mw-list { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
 body.mobile .mw-row { padding:8px 12px; min-height:66px; background:#302317; border-color:#705534; }
 body.mobile .mw-row:active { background:#4a3620; }
 body.mobile .mw-tabs { margin:0 0 10px; }
 body.mobile .mw-back { width:auto; min-width:180px; margin-bottom:8px; }
 body.mobile .mw-actions { position:sticky; bottom:0; background:#21180f; padding:8px; border-top:1px solid #735936; }
 body.mobile .mw-bind { grid-template-columns:minmax(0,1fr) 160px; align-items:end; }
 body.mobile .mw-bind label { grid-template-columns:110px minmax(0,1fr); align-items:center; }
 body.mobile #chat.chat-open { top:8px; left:max(12px,var(--mobile-safe-left)); right:max(12px,var(--mobile-safe-right)); height:calc(100dvh - 76px); }
 body.mobile #chat .chat-tabs { overflow-x:auto; flex-shrink:0; }
 body.mobile #chat .chat-tabs button { flex:1; min-width:64px; }
 body.mobile #lootFeed { right:226px; top:130px; max-width:200px; }
 body.mobile #clock { top:62px; }

 body.mobile #playerFrame { width:222px; }
 body.mobile #topMenu { top:max(8px,var(--mobile-safe-top)); left:calc(max(10px,var(--mobile-safe-left)) + 236px); right:calc(max(8px,var(--mobile-safe-right)) + 158px); padding:0; border:0; }
 body.mobile #actions { left:max(10px,var(--mobile-safe-left)); top:calc(max(8px,var(--mobile-safe-top)) + 124px); }
 body.mobile #mSkills .m-potrow { right:54px; bottom:198px; }
 body.mobile #mSkills { bottom:max(8px,var(--mobile-safe-bottom)); }
 body.mobile #mChatBtn { left:calc(max(12px,var(--mobile-safe-left)) + 140px); bottom:max(18px,var(--mobile-safe-bottom)); }
 body.mobile #targetFrame { left:calc(50% - 48px); top:126px; width:220px; transform:translateX(-50%); padding:8px 52px 8px 8px; }
 body.mobile #targetFrame .tf-x { width:44px; height:44px; right:0; top:0; }
 body.mobile #targetFrame :is(.tf-name,.tf-sub) { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
 /* Keep the locked target visible while the extra action buttons are open. */
 body.mobile:has(#actions.actions-open) #targetFrame { top:72px; left:calc(50% + 56px); }
}
@media (orientation:landscape) and (min-width:480px) and (max-width:640px) {
 body.mobile #playerFrame { width:180px; }
 body.mobile #topMenu { left:calc(max(10px,var(--mobile-safe-left)) + 194px); right:calc(max(8px,var(--mobile-safe-right)) + 138px); }
 body.mobile #targetFrame { width:210px; }
}
@media (orientation:landscape) and (max-height:340px) {
 body.mobile #joy { width:100px; height:100px; bottom:max(12px,var(--mobile-safe-bottom)); }
 body.mobile #clock { display:none; }
}
/* Potion stock is a separate readable badge; it must not cover the bottle. */
body.mobile #mSkills .m-pot { position:relative; overflow:hidden; }
body.mobile #mSkills .m-pot img { width:30px; height:30px; margin:2px auto 10px; object-fit:contain; }
body.mobile #mSkills .m-pot b { right:2px; bottom:1px; min-width:20px; padding:0 3px; border-radius:4px; background:#140e08ed; color:#fff3cd; font:700 12px/15px system-ui; text-shadow:none; }

/* Folding keeps the navigation tabs available to reopen the panel. */
body.mobile #sidePanel.folded { display:block; }

@media (orientation:portrait) {
}

/* Keep tabs reachable and give social content its own scrolling area. */
body.mobile #sidePanel { display:flex; flex-direction:column; }
body.mobile #sidePanel.folded { display:flex; }
body.mobile #sidePanel .sp-tabs, body.mobile #sidePanel .panel-drag { flex-shrink:0; }
body.mobile #sidePanel:not(.folded) #spBody { display:block; min-height:64px; overflow-y:auto; }
body.mobile #targetFrame .tf-name { min-height:32px; }
@media (orientation:portrait) {
}

/* Mobile inventory: compact slots with persistent item details. */
body.mobile #win-bag { max-width:1080px!important; height:auto!important; max-height:calc(100dvh - 20px)!important; }
body.mobile #win-bag .win-body { min-height:0; }
body.mobile .mb-toolbar { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; }
body.mobile .mb-toolbar .mw-summary { padding:0; font-size:13px; }
body.mobile .mb-toolbar button { font-size:12px; }
body.mobile .mb-layout { display:grid; gap:14px; grid-template-columns:minmax(0,1fr); }
body.mobile .mb-inventory { min-width:0; }
body.mobile .mb-inventory .mw-filters { grid-template-columns:minmax(0,1fr) minmax(100px,.7fr); gap:6px; }
body.mobile .mb-inventory .mw-filters :is(input,select) { padding:8px; font-size:12px; }
body.mobile .mb-grid { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:7px; align-content:start; }
body.mobile .mb-slot { position:relative; display:grid; place-items:center; aspect-ratio:1; width:100%; min-width:0; padding:5px; border:1px solid var(--item-color,#55432d); border-radius:9px; background:radial-gradient(ellipse at top,#3c2e1c,#19130e); box-shadow:inset 0 1px 4px #0008; cursor:pointer; }
body.mobile .mb-slot img { width:100%; height:100%; object-fit:contain; max-height:70px; pointer-events:none; }
body.mobile .mb-slot.empty { opacity:.45; background:#17120e; cursor:default; }
body.mobile .mb-slot.selected { outline:2px solid #ffdc8c; outline-offset:2px; background:#60461f; }
body.mobile .mb-slot:focus-visible { outline:2px solid white; outline-offset:2px; }
body.mobile .mb-count,body.mobile .mb-refine { position:absolute; font-size:12px; line-height:17px; font-weight:bold; color:#fff0ce; text-shadow:0 1px 2px #000; background:#160e09cc; padding:0 4px; border-radius:4px; }
body.mobile .mb-count { right:3px; bottom:3px; }
body.mobile .mb-refine { left:3px; top:3px; color:#ffe294; }
body.mobile .mb-grid-hint { text-align:center; font-size:12px; color:#b6a17c; margin-top:12px; }
body.mobile .mb-detail { min-width:0; padding:14px; border:1px solid #655033; border-radius:10px; background:linear-gradient(145deg,#302316,#1b140e); }
body.mobile .mb-detail-icon { display:flex; justify-content:center; margin-bottom:12px; }
body.mobile .mb-detail-icon img { width:64px; height:64px; object-fit:contain; }
body.mobile .mb-detail .mw-back { min-height:36px; font-size:12px; margin-bottom:12px; }
body.mobile .mb-detail .mw-actions { position:static; display:grid; grid-template-columns:1fr 1fr; padding:12px 0 0; background:transparent; margin-bottom:0; }
body.mobile .mb-detail .mw-actions button { min-width:0; white-space:normal; padding:10px 6px; font-size:12px; }
body.mobile .mb-detail .mw-actions .gold { grid-column:1/-1; }
body.mobile .mb-empty-detail { text-align:center; color:#e4c795; padding:16px 0; }
body.mobile .mb-empty-detail small { display:block; color:#ab9879; margin-top:8px; font-size:12px; }
body.mobile .mb-no-results { grid-column:1/-1; color:#c9b18a; text-align:center; }
@media (orientation:landscape) and (min-width:640px) {
 body.mobile .mb-layout { grid-template-columns:minmax(0,1.35fr) minmax(230px,1fr); align-items:start; }
 body.mobile .mb-grid { grid-template-columns:repeat(6,minmax(0,1fr)); }
 body.mobile .mb-detail { position:sticky; top:0; }
 body.mobile .mb-slot { max-height:88px; }
}
body.mobile .mb-detail .mw-item-detail { margin-top:14px; }
@media (orientation:landscape) and (min-width:640px) {
 body.mobile .mb-detail,body.mobile .mb-inventory { max-height:calc(100dvh - 155px); overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; }
 body.mobile .mb-detail { position:static; box-sizing:border-box; }
 body.mobile .mb-grid { padding:4px; }
 body.mobile .mb-detail-icon img { width:48px; height:48px; }
}

/* หน้าเข้าเกมบนมือถือ: อ่านง่าย กดง่าย พอดีจอทั้งแนวตั้งและแนวนอน */
html[data-ui-page="mobile"] #screens .screen.login { justify-content: flex-start; gap: 10px; padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
html[data-ui-page="mobile"] #screens .login .logo-img { width: min(250px, 66vw); max-height: 20vh; object-fit: contain; margin: 0 auto; }
html[data-ui-page="mobile"] #screens .login .logo-sub { font-size: 11px; letter-spacing: 1px; margin-top: 0; }
html[data-ui-page="mobile"] #screens .login .story { display: none; }
html[data-ui-page="mobile"] #screens .login .login-box { width: min(440px, 100%); padding: 16px; border: 1px solid #8a6a3a; border-image: none; border-radius: 12px; background: rgba(14, 8, 5, .93); }
html[data-ui-page="mobile"] #screens .login .login-box label { margin-bottom: 10px; font-size: 14px; }
html[data-ui-page="mobile"] #screens .login .login-box input:not([type=checkbox]) { height: 46px; margin-top: 4px; padding: 0 12px !important; border: 1px solid #8a6a3a !important; border-image: none !important; border-radius: 8px !important; background: #120a06 !important; color: #f6e6c4; font-size: 16px !important; line-height: normal; }
html[data-ui-page="mobile"] #screens .login .login-box input:focus { border-color: #e8c46a !important; }
html[data-ui-page="mobile"] #screens .login .login-box input:-webkit-autofill { -webkit-text-fill-color: #f6e6c4; -webkit-box-shadow: inset 0 0 0 100px #120a06; caret-color: #f6e6c4; }
html[data-ui-page="mobile"] #screens .login .login-box .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
html[data-ui-page="mobile"] #screens .login .login-box .btn { width: 100%; min-width: 0; min-height: 46px; padding: 8px 6px; font-size: 15px; }
html[data-ui-page="mobile"] #screens .login .guest-row { display: grid; gap: 8px; }
html[data-ui-page="mobile"] #screens .login .hint { margin-top: 8px; font-size: 11px; }
html[data-ui-page="mobile"] #screens .login .wiki-link { display: flex; align-items: center; justify-content: center; min-height: 40px; margin-top: 4px; }
html[data-ui-page="mobile"] #screens .login .reg-terms { max-height: 26vh; }
html[data-ui-page="mobile"] #screens .login .login-box .err:empty { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  html[data-ui-page="mobile"] #screens .screen.login { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: center; justify-items: center; column-gap: 16px; }
  html[data-ui-page="mobile"] #screens .login .logo-img { width: min(100%, 300px); max-height: 56vh; }
  html[data-ui-page="mobile"] #screens .login .login-box { padding: 10px 14px; }
  html[data-ui-page="mobile"] #screens .login .login-box label { margin-bottom: 6px; }
  html[data-ui-page="mobile"] #screens .login .login-box input:not([type=checkbox]) { height: 42px; }
  html[data-ui-page="mobile"] #screens .login .login-box .btn { min-height: 44px; }
  html[data-ui-page="mobile"] #screens .login .hint { display: none; }
  html[data-ui-page="mobile"] #screens .login .guest-row { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); margin-top: 6px; padding-top: 6px; }
  html[data-ui-page="mobile"] #screens .login .wiki-link { min-height: 30px; margin-top: 2px; font-size: 12px; }
}

/* Mobile side content opens only when requested. */
body.mobile #sidePanel.folded { display:none !important; }
body:not(.mobile) #mSideToggle { display:none; }
body.mobile #mSideToggle { display:flex; }

/* Persistent PC-style minimap without blocking mobile controls. */
body.mobile #minimap:not(.folded) { position:fixed; left:auto; right:max(8px,var(--mobile-safe-right)); top:max(8px,var(--mobile-safe-top)); transform:none; width:148px; max-height:190px; overflow:hidden; z-index:25; }
body.mobile #minimap #mmCanvas { width:100%; height:92px; object-fit:contain; }
body.mobile #mSideToggle { display:flex!important; background:transparent!important; }
@media (orientation:portrait) { body.mobile #minimap:not(.folded) { top:100px; width:120px; } body.mobile #minimap #mmCanvas { height:76px; } }
body.mobile #actions { z-index:66; }


/* Compact movable quest panel; inline drag coordinates must win. */
body.mobile #sidePanel:not(.folded) {
 display:flex; position:fixed; top:220px; left:10px; right:auto; bottom:auto;
 width:min(360px,calc(100vw - 20px)); height:auto;
 max-height:calc(100dvh - 24px); overflow:hidden; transform:none; z-index:80;
 background:#160f09f5;
}
body.mobile #sidePanel .panel-drag { display:block; flex:0 0 28px; height:28px; line-height:28px; touch-action:none; cursor:grab; }
body.mobile #sidePanel .sp-tabs { flex:0 0 auto; }
body.mobile #sidePanel:not(.folded) #spBody {
 flex:0 1 auto; min-height:0; max-height:min(260px,calc(100dvh - 110px));
 overflow-y:auto; touch-action:pan-y; overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
}
body.mobile #sidePanel .sp-fold { min-width:40px; min-height:40px; }

/* Keep the page switch and potion controls left of the expanded minimap. */
@media (orientation: landscape) {
  body.mobile #mSkills .m-potrow { right:160px; }
}
