/* Modo celular (body.mobile): botões grandes, joystick flutuante, barra de habilidades compacta */
html.mobile, body.mobile { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.mobile #m-zone { position: fixed; left: calc(64px + env(safe-area-inset-left, 0px)); bottom: calc(40px + env(safe-area-inset-bottom, 0px)); width: 108px; height: 108px; border-radius: 50%; border: 1.5px solid rgba(240, 210, 139, .28); background: radial-gradient(circle, rgba(10, 24, 24, .10), rgba(10, 24, 24, .24)); box-shadow: inset 0 0 14px rgba(0, 0, 0, .25); z-index: 33; touch-action: none; }
body.mobile #m-knob { position: absolute; left: 31px; top: 31px; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(246, 226, 168, .55), rgba(184, 138, 58, .45)); border: 1.5px solid rgba(240, 210, 139, .45); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); pointer-events: none; transition: transform .07s ease-out; }
body.mobile #m-full { position: fixed; right: calc(8px + env(safe-area-inset-right, 0px)); top: calc(8px + env(safe-area-inset-top, 0px)); z-index: 40; width: 40px; height: 40px; border-radius: 10px; border: 1px solid #c1a267; background: #0d1a1acc; color: #f0d28b; font-size: 22px; line-height: 1; padding: 0; }
body.mobile #m-full[hidden] { display: none; }

body.mobile #attack, body.mobile #potion, body.mobile #interact, body.mobile #return-town, body.mobile #dodge {
    display: grid !important; place-items: center; position: fixed !important; z-index: 32; translate: none !important; transform: none !important; margin: 0 !important;
    left: auto !important; top: auto !important; border-radius: 50% !important; padding: 0 !important; font-size: 13px !important; line-height: 1.1; touch-action: none;
}
body.mobile #attack small, body.mobile #potion small, body.mobile #interact small { display: none; }
body.mobile #attack { width: 76px !important; height: 76px !important; right: calc(16px + env(safe-area-inset-right, 0px)) !important; bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important; }
body.mobile #potion { width: 46px !important; height: 46px !important; right: calc(100px + env(safe-area-inset-right, 0px)) !important; bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important; }
body.mobile #interact { width: 46px !important; height: 46px !important; right: calc(100px + env(safe-area-inset-right, 0px)) !important; bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important; }
body.mobile #dodge { width: 44px !important; height: 44px !important; right: calc(30px + env(safe-area-inset-right, 0px)) !important; bottom: calc(98px + env(safe-area-inset-bottom, 0px)) !important; }
body.mobile #return-town { width: 38px !important; height: 38px !important; right: calc(104px + env(safe-area-inset-right, 0px)) !important; bottom: calc(118px + env(safe-area-inset-bottom, 0px)) !important; }

/* barra de habilidades: toda a barra (F1–F12 + 1–9) à esquerda dos botões */
body.mobile #hotbar { --hs: 42px; left: calc(100vw - 586px); top: auto; right: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: auto !important; padding: 4px 5px; z-index: 31; touch-action: none; }
body.mobile #hotbar .hb-head { display: flex; height: 18px; margin-bottom: 2px; }
body.mobile #hotbar .hb-gear, body.mobile #hotbar .hb-info { display: none; }
body.mobile #hotbar .hb-handle { width: 100%; text-align: center; font-size: 16px; line-height: 18px; }
body.mobile #hotbar .hb-slot { touch-action: none; }
body.mobile #hotbar .hb-rows .hb-row:first-child, body.mobile #hotbar .hb-page, body.mobile #hotbar .hb-tray { display: none !important; }
body.mobile #hotbar .hb-row .hb-slot:nth-child(n+9) { display: none !important; }
body.mobile #hotbar .hb-slot { width: var(--hs); height: var(--hs); }
body.mobile #hotbar .hb-key { font-size: 8px; }

/* retrato: barra ocupa a largura, botões sobem */
@media (orientation: portrait) {
    body.mobile #hotbar { --hs: 42px; left: calc(100vw - 586px); top: auto; right: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: auto !important; padding: 4px 5px; z-index: 31; touch-action: none; }
    body.mobile #m-zone { position: fixed; left: calc(64px + env(safe-area-inset-left, 0px)); bottom: calc(40px + env(safe-area-inset-bottom, 0px)); width: 108px; height: 108px; border-radius: 50%; border: 1.5px solid rgba(240, 210, 139, .28); background: radial-gradient(circle, rgba(10, 24, 24, .10), rgba(10, 24, 24, .24)); box-shadow: inset 0 0 14px rgba(0, 0, 0, .25); z-index: 33; touch-action: none; }
}

/* painel esquerdo compacto, sem tomar toque do joystick */
@media (orientation: landscape) {
    body.mobile header { transform: scale(.75); transform-origin: top left; pointer-events: none; }
    body.mobile #hero { scale: .78 !important; transform-origin: top left !important; top: 46px !important; pointer-events: none; }
    body.mobile aside:has(#quest) { scale: .72 !important; transform-origin: top left !important; top: 122px !important; pointer-events: none; }
    body.mobile #minimap-frame { transform: scale(1); transform-origin: top right; }
    body.mobile #dock { left: calc(6px + env(safe-area-inset-left, 0px)) !important; right: auto !important; bottom: auto !important; top: 140px !important; height: 100px; width: 38px; grid-template-columns: 28px; grid-auto-rows: 28px; gap: 4px; padding: 4px; overflow-y: auto; overflow-x: hidden; align-content: start; touch-action: pan-y; z-index: 34; scrollbar-width: none; }
    body.mobile #dock .dk { width: 28px; height: 28px; }
    body.mobile #dock .dk .dk-img { width: 23px; height: 23px; }
    body.mobile #dock-menu { bottom: auto !important; top: 140px; left: 56px; right: auto; max-height: calc(100dvh - 150px); overflow: auto; z-index: 36; }
    body.mobile #dock-world { display: none !important; }
    body.mobile #zoom-controls { z-index: 40; top: 8px !important; bottom: auto !important; left: auto !important; right: calc(270px + env(safe-area-inset-right, 0px)) !important; width: auto !important; height: auto !important; display: flex !important; flex-direction: row !important; align-items: center; gap: 4px; }
    body.mobile #zoom-controls button { width: 34px !important; height: 34px !important; margin: 0 !important; }
    body.mobile #zoom-out { order: 1; } body.mobile #zoom-in { order: 3; } body.mobile #view-toggle { order: 4; }
    body.mobile #zoom-value { order: 2; min-width: 38px; text-align: center; }
}
/* chat recolhido: botão abre/fecha */
body.mobile #activity-feed { display: none; }
body.mobile.m-chat #activity-feed { display: block; left: 60px !important; bottom: 108px !important; width: min(300px, 40vw); z-index: 34; }
body.mobile #m-chat { position: fixed; left: calc(8px + env(safe-area-inset-left, 0px)); top: 8px; left: auto; right: calc(446px + env(safe-area-inset-right, 0px)); z-index: 40; width: 40px; height: 32px; border-radius: 8px; border: 1px solid #c1a267; background: #0d1a1acc; color: #f0d28b; font: 700 11px/1 system-ui, sans-serif; padding: 0; }

/* janelas menores */
body.mobile :is(#char-panel,#inventory-panel,#skills-panel,#class-panel,#world-atlas,#online-panel,#dock-panel,#world-boss-panel,#hebrom-map,#jerusalem-map) { scale: .85 !important; transform-origin: top left !important; left: calc(52px + env(safe-area-inset-left, 0px)) !important; top: 6px !important; right: auto !important; bottom: auto !important; max-height: calc((100dvh - 14px) / .85) !important; max-width: calc((100vw - 60px) / .85) !important; overflow: auto !important; -webkit-overflow-scrolling: touch; }
body.mobile :is(#char-panel,#inventory-panel,#skills-panel,#class-panel,#world-atlas,#online-panel,#dock-panel) button[aria-label="Fechar"], body.mobile #dock-panel .dp-x { min-width: 44px; min-height: 44px; }

/* botões com área demarcada: disco translúcido + anel dourado */
body.mobile :is(#attack, #potion, #interact, #return-town, #dodge, #m-sound) {
    background: radial-gradient(circle at 50% 32%, rgba(52, 74, 70, .66), rgba(10, 20, 20, .70) 72%) !important;
    border: 2px solid rgba(214, 174, 92, .9) !important; color: #f6e2a8 !important;
    box-shadow: 0 0 0 3px rgba(8, 16, 16, .5), inset 0 0 0 2px rgba(255, 236, 170, .16), inset 0 -10px 16px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .55) !important;
}
body.mobile #attack { background: radial-gradient(circle at 50% 30%, rgba(150, 82, 34, .72), rgba(42, 16, 8, .78) 74%) !important; border-color: rgba(240, 178, 84, .95) !important; box-shadow: 0 0 0 4px rgba(8, 16, 16, .5), 0 0 16px rgba(240, 150, 60, .25), inset 0 0 0 2px rgba(255, 220, 150, .22), inset 0 -12px 18px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .6) !important; }
body.mobile #potion { background: radial-gradient(circle at 50% 30%, rgba(150, 44, 52, .62), rgba(34, 10, 14, .74) 74%) !important; }
body.mobile :is(#attack, #potion, #interact, #return-town, #dodge):active { filter: brightness(1.35); }
body.mobile #m-sound { position: fixed; top: 8px; right: calc(494px + env(safe-area-inset-right, 0px)); z-index: 40; width: 34px; height: 34px; border-radius: 50%; padding: 0; display: grid; place-items: center; }
body.mobile #m-sound svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.mobile #m-sound.off { opacity: .6; }
body.mobile #m-sound .x { display: none; }
body.mobile #m-sound.off .x { display: block; }

/* ===== arte dos controles (assets/mobile) ===== */
body.mobile :is(#attack, #potion, #interact, #return-town, #dodge, #m-sound) {
    background-color: transparent !important; background-repeat: no-repeat !important; background-position: center !important; background-size: 100% 100% !important;
    border: 0 !important; border-radius: 50% !important; box-shadow: none !important; color: transparent !important; font-size: 0 !important; text-shadow: none !important;
}
body.mobile :is(#attack, #potion, #interact, #return-town, #dodge, #m-sound) > :not(.icon-badge) { visibility: hidden; }
body.mobile #attack { background-image: url(assets/mobile/btn-attack.png) !important; }
body.mobile #potion { background-image: url(assets/mobile/btn-potion.png) !important; }
body.mobile #interact { background-image: url(assets/mobile/btn-interact.png) !important; }
body.mobile #return-town { background-image: url(assets/mobile/btn-return.png) !important; }
body.mobile #dodge { background-image: url(assets/mobile/btn-dodge.png) !important; }
body.mobile #m-sound { background-image: url(assets/mobile/btn-sound.png) !important; position: fixed; }
body.mobile #m-sound svg { display: none; }
body.mobile #m-sound.off { opacity: .55; filter: grayscale(.8); }
body.mobile :is(#attack, #potion, #interact, #return-town, #dodge, #m-sound):active { filter: brightness(1.3); }
body.mobile #return-town.cooldown, body.mobile #potion[disabled] { opacity: .5; }
body.mobile :is(#potion, #attack, #interact)::after { font-size: 13px; }

/* joystick com arte */
body.mobile #m-zone { width: 104px; height: 104px; border: 0 !important; box-shadow: none !important; background: url(assets/mobile/joy-base.png) center / 100% 100% no-repeat, radial-gradient(circle, rgba(10, 24, 24, .06) 55%, rgba(10, 24, 24, .22) 100%) !important; opacity: .82; }
body.mobile #m-knob { left: 31px; top: 31px; width: 42px; height: 42px; border: 0 !important; background: url(assets/mobile/joy-knob.png) center / 100% 100% no-repeat !important; box-shadow: none !important; opacity: .9; }

/* barra de skills com moldura de arte: 8 encaixes alinhados com a imagem */
body.mobile #hotbar { --bw: 340px; position: fixed; left: calc(100vw - 500px); width: var(--bw) !important; height: calc(var(--bw) * .1682) !important; padding: calc(var(--bw) * .0338) 0 0 calc(var(--bw) * .0522) !important; box-sizing: border-box; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: url(assets/mobile/bar.png) center / 100% 100% no-repeat !important; }
body.mobile #hotbar .hb-head { position: absolute; left: 50%; top: 0; width: calc(var(--bw) * .22); height: calc(var(--bw) * .034); margin: 0 0 0 calc(var(--bw) * -.11); display: block; }
body.mobile #hotbar .hb-handle { display: block; width: 100%; height: 100%; color: transparent !important; font-size: 0; padding: 0; }
body.mobile #hotbar .hb-grid, body.mobile #hotbar .hb-rows { gap: 0; padding: 0; margin: 0; }
body.mobile #hotbar .hb-row { gap: calc(var(--bw) * .0133); margin: 0; }
body.mobile #hotbar .hb-gap { margin-left: 0 !important; }
body.mobile #hotbar .hb-slot { --hs: calc(var(--bw) * .1006); width: var(--hs) !important; height: var(--hs) !important; border: 0 !important; background: transparent !important; border-radius: 8px; }
body.mobile #hotbar .hb-slot.empty { border: 0 !important; }
body.mobile #hotbar .hb-slot img { inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); }
@media (orientation: portrait) { body.mobile #hotbar { --bw: calc(100vw - 12px); left: 6px; } }
body.mobile :is(#potion, #attack, #interact) .icon-badge { visibility: visible; font-size: 13px !important; color: #fff !important; position: absolute; right: 2px; bottom: 2px; min-width: 18px; padding: 1px 4px; border-radius: 9px; background: #0d1a1acc; border: 1px solid #d6ae5c; text-shadow: none; }

/* quadro do alvo menor */
body.mobile #target-frame { scale: .55; transform-origin: top center; top: 40px; }

/* zoom compacto e mensagens no chat (nada no meio da tela) */
@media (orientation: landscape) { body.mobile #zoom-controls { scale: .85; transform-origin: top right; top: 6px !important; right: calc(292px + env(safe-area-inset-right, 0px)) !important; } }
body.mobile #toast { display: none !important; }
body.mobile #m-chat.new { animation: mchat 1s ease-in-out infinite alternate; }
@keyframes mchat { to { background: #5a4318; box-shadow: 0 0 10px #f0d28b; } }

body.mobile #m-floats { position: fixed; left: 50%; top: 30%; transform: translateX(-50%); z-index: 38; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; width: min(70vw, 420px); }
body.mobile .m-float { padding: 3px 10px; border-radius: 10px; background: rgba(10, 20, 20, .55); color: #ffe9a8; font: 700 11px/1.2 system-ui, sans-serif; text-align: center; text-shadow: 0 1px 2px #000; animation: mfloat 1.6s ease-out forwards; }
@keyframes mfloat { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: translateY(0); } 60% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px); } }

/* Janela de drops (alvo): mesma redução das outras janelas */
body.mobile #l2-drops { position: fixed !important; scale: .85; transform-origin: top left; transform: none !important; left: calc(52px + env(safe-area-inset-left, 0px)) !important; top: 6px !important; right: auto !important; bottom: auto !important; width: min(340px, calc((100vw - 60px) / .85)); }
body.mobile #l2-drops .dr-body { max-height: calc((100dvh - 14px) / .85 - 40px); }

/* ===== Mapa mundial no celular: tela cheia, toque amplia, +/- e arrastar ===== */
body.mobile #world-atlas { scale: 1 !important; left: 0 !important; top: 0 !important; margin: 0 !important; width: 100vw !important; max-width: 100vw !important; height: 100dvh !important; max-height: 100dvh !important; padding: 6px 8px !important; box-sizing: border-box; overflow: hidden !important; }
body.mobile #world-atlas .atlas-heading { margin-bottom: 4px; }
body.mobile #world-atlas .atlas-heading h2 { font-size: 18px; margin: 0; }
body.mobile #world-atlas .atlas-heading small, body.mobile #world-atlas .atlas-footnote, body.mobile #world-atlas .atlas-map-help, body.mobile #world-atlas .atlas-key { display: none; }
body.mobile #world-atlas #atlas-resume { min-height: 38px; padding: 4px 12px; font-size: 14px; }
body.mobile #world-atlas .atlas-layout { display: block; position: relative; }
body.mobile #world-atlas .atlas-map-pane { position: relative; }
body.mobile #world-atlas .atlas-scroll { width: 100% !important; height: calc(100dvh - 58px); overflow: auto !important; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
body.mobile #world-atlas .atlas-board { min-width: 0; margin: 0 auto; }
body.mobile #world-atlas .atlas-legend { display: none; position: absolute !important; right: 6px; top: 6px; width: min(290px, 46vw) !important; max-height: calc(100dvh - 70px) !important; overflow: auto; z-index: 6; background: #142b2bf2; border: 1px solid #c3a362; border-radius: 8px; }
body.mobile #world-atlas.m-list .atlas-legend { display: block; }
body.mobile #world-atlas .m-az { position: absolute; left: 10px; bottom: 12px; z-index: 7; display: flex; gap: 8px; }
body.mobile #world-atlas .m-az button { min-width: 52px; height: 52px; border-radius: 12px; border: 1px solid #c1a267; background: #0d1a1aee; color: #f6e2a8; font-size: 26px; line-height: 1; padding: 0 12px; }
body.mobile #world-atlas .m-az button[data-z=list] { font-size: 15px; }


/* ===== Mapa do mundo aberto (Mapa / Bosses) no celular: tela cheia + zoom ===== */
body.mobile #world-open-map { width: 100vw !important; max-width: 100vw !important; height: 100dvh !important; max-height: 100dvh !important; margin: 0 !important; border-radius: 0 !important; }
body.mobile #world-open-map[open] { display: flex; flex-direction: column; }
body.mobile #world-open-map .wm-bar { flex: none; height: 30px; font-size: 14px; line-height: 30px; white-space: nowrap; overflow: hidden; }
body.mobile #world-open-map .wm-bar span { overflow: hidden; text-overflow: ellipsis; }
body.mobile #world-open-map .wm-tabs { flex: none; margin: 4px 8px 0; }
body.mobile #world-open-map .wm-tabs button { padding: 6px 14px; font-size: 14px; }
body.mobile #world-open-map .m-wv { flex: 1 1 auto; min-height: 0; margin: 4px 0 0; overflow: auto; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; background: #0b0f16; }
body.mobile #world-open-map .m-wv canvas { width: 100%; margin: 0 auto; border: 0; }
body.mobile #world-open-map .wm-list { position: absolute; left: 70px; right: 8px; bottom: 8px; z-index: 6; margin: 0; max-height: 45dvh; background: #0e131cf2; }
body.mobile #world-open-map .wm-note { display: none; }
body.mobile #world-open-map #world-open-plan { flex: none; margin: 4px 8px; padding: 6px 12px; font-size: 14px; }
body.mobile #world-open-map .m-az { position: absolute; left: 12px; top: 74px; z-index: 7; display: flex; flex-direction: column; gap: 8px; }
body.mobile #world-open-map .m-az button { min-width: 48px; height: 48px; border-radius: 12px; border: 1px solid #c1a267; background: #0d1a1aee; color: #f6e2a8; font-size: 26px; line-height: 1; padding: 0 12px; }

/* Guardião dos Chefes: texto à esquerda, lista rolável à direita */
body.mobile #dialog[data-bm]{width:min(760px,calc(100vw - 16px));max-height:calc(100dvh - 12px);overflow:hidden;padding:0 0 8px;display:grid;grid-template-columns:42% 1fr;grid-template-rows:auto auto auto minmax(0,1fr);column-gap:6px}
body.mobile #dialog[data-bm][open]{display:grid}
body.mobile #dialog[data-bm]>.l2-bar{grid-column:1/-1;grid-row:1}
body.mobile #dialog[data-bm] #speaker{grid-column:1;grid-row:2;margin:6px 10px 0;font-size:13px}
body.mobile #dialog[data-bm] #title{grid-column:1;grid-row:3;margin:1px 10px 0;font-size:11px}
body.mobile #dialog[data-bm] #text{grid-column:1;grid-row:4;margin:6px 10px;font-size:11px;line-height:1.35;overflow:auto;min-height:0}
body.mobile #dialog[data-bm] #choices{grid-column:2;grid-row:2/5;max-height:none;min-height:0;margin:6px 10px 0 0;padding-right:4px;gap:2px;overflow-y:auto;align-self:stretch}
body.mobile #dialog[data-bm] #choices button{font-size:12px;line-height:1.3;padding:5px 0;width:100%}
