/* =====================================================================
 * mobile_v20.css — PIXEL F v20: เลย์เอาต์มือถือ / แท็บเล็ต (iPhone • iPad • Android)
 *  หน่วย: --ui = สเกลตามด้านสั้นของจอ, --mu = --ui × ขนาดปุ่มที่ผู้เล่นตั้ง
 *  Safe area: --sat/--sar/--sab/--sal (รอยบาก / Dynamic Island / แถบโฮม)
 * ===================================================================== */
:root { --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); }
body.m-mobile { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body.m-mobile #ui-layer button { touch-action: manipulation; }
#mobile-ui { --mu: calc(var(--ui, 1) * var(--mscale, 1)); }

/* ============================ สถานะ (มุมซ้ายบน) ============================ */
body.m-mobile #hud.hx { left: calc(var(--sal) + 8px); top: calc(var(--sat) + 6px); right: auto; bottom: auto; width: 232px; height: auto; display: block; padding: 7px 9px 11px 7px;
  border-radius: 16px; background: rgba(10, 8, 22, .58); border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transform: scale(var(--ui)); transform-origin: 0 0; z-index: 6; }
body.m-mobile #hud.hx .hx-skill, body.m-mobile #hud.hx .hx-content { display: none !important; }
body.m-mobile #hud.hx .hx-stat { padding: 0; gap: 8px; width: 100%; }
body.m-mobile #hud.hx .hx-stat::before { display: none; }
body.m-mobile #hud.hx .hud-lv { width: 42px; height: 42px; border-radius: 12px; flex: none; }
body.m-mobile #hud.hx .hx-idbars { flex: 1; min-width: 0; }
body.m-mobile #hud.hx .hud-id { display: block; font-size: 10.5px; line-height: 1.1; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.m-mobile #hud.hx .track { height: 14px; } body.m-mobile #hud.hx .track span { line-height: 14px; font-size: 9.5px; }
body.m-mobile #hud.hx .exp-bar { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 3px; border-radius: 2px; overflow: hidden; }
body.m-mobile #hud.hx .exp-bar span, body.m-mobile #hud.hx .exp-bar b, body.m-mobile #hud.hx .exp-bar i { font-size: 0; }

/* บัฟ • ปาร์ตี้ • มินิแมพ (คอลัมน์ซ้าย ใต้การ์ดสถานะ) */
body.m-mobile #buffs { left: calc(var(--sal) + 10px); right: auto; top: calc(var(--sat) + 6px + 74px * var(--ui)); bottom: auto; flex-direction: row; transform-origin: 0 0; max-width: 60vw; flex-wrap: wrap; }
body.m-mobile #minimap { display: none; left: calc(var(--sal) + 8px); top: calc(var(--sat) + 6px + 102px * var(--ui)); transform: scale(calc(.82 * var(--ui))); transform-origin: 0 0; }
body.m-mobile.mm-on #minimap { display: block; }
body.m-mobile #pt-hud { left: calc(var(--sal) + 8px); top: calc(var(--sat) + 6px + 102px * var(--ui)); width: 158px; }
body.m-mobile.mm-on #pt-hud { top: calc(var(--sat) + 6px + 232px * var(--ui)); }
body.m-mobile #pxp-fab { display: none !important; }

/* ============================ แถบปุ่มขวาบน ============================ */
body.m-mobile #mobile-ui .mtop { right: calc(var(--sar) + 8px); top: calc(var(--sat) + 6px); gap: calc(6px * var(--ui)); transform: none; }
body.m-mobile #mobile-ui .mtop .mt { position: relative; min-width: 0; width: calc(42px * var(--ui)); height: calc(42px * var(--ui)); padding: 0; border-radius: calc(13px * var(--ui)); font-size: calc(19px * var(--ui)); line-height: 1;
  background: rgba(10, 8, 22, .55); border: 1px solid rgba(255, 255, 255, .22); color: #fff; opacity: 1; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }
body.m-mobile #mobile-ui .mtop .mt:active { transform: scale(.92); }
body.m-mobile #mobile-ui .mtop [data-act=up], body.m-mobile #mobile-ui .mtop [data-act=home] { display: none; }
body.m-mobile #mobile-ui .mtop .m20-ev { background: linear-gradient(160deg, #ffb300, #ff4f6d 55%, #7b2cff); border-color: rgba(255, 255, 255, .4); }
body.m-mobile #mobile-ui .mtop .mt.on { background: linear-gradient(135deg, #00d68f, #00a3ff); border-color: #fff; }
.m20-dot { position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; background: #ff3355; border: 2px solid #120c24; font: 800 9px/12px system-ui, sans-serif; color: #fff; }
.m20-dot.hidden, .ml-dot.hidden { display: none; }
/* จอแคบ (iPhone SE/mini แนวนอน): เก็บปุ่มรองไว้ใน ☰ */
@media (max-width: 760px) { body.m-mobile #mobile-ui .mtop .m20-sec { display: none; } }
body.m-mobile.dv-phone:not(.mm-on) #mobile-ui .mtop [data-m20=mm] { opacity: .7; }

/* สภาพอากาศ / เควส (ขวา ใต้แถบปุ่ม) */
body.m-mobile #wx-hud { right: calc(var(--sar) + 8px); top: calc(var(--sat) + 10px + 46px * var(--ui)); transform: scale(calc(.8 * var(--ui))); transform-origin: 100% 0; }
body.m-mobile #qtrack { right: calc(var(--sar) + 8px); top: calc(var(--sat) + 10px + 96px * var(--ui)); bottom: auto; width: 200px; transform: scale(calc(.8 * var(--ui))); transform-origin: 100% 0; }
body.m-mobile.dv-phone #qtrack { max-height: 120px; overflow: hidden; }

/* แชท: ด้านบนกลางจอ แคบ ไม่บัง */
body.m-mobile #chat:not(.cx-moved) { top: calc(var(--sat) + 6px); width: calc(min(30vw, 300px) / var(--ui)); }
body.m-mobile.dv-tablet #chat:not(.cx-moved) { width: calc(min(34vw, 380px) / var(--ui)); }
body.m-mobile #chat-fab { left: 50%; top: calc(var(--sat) + 6px); bottom: auto; transform: translateX(-50%); }
/* ลอกข้อความ EXP / ของที่เก็บ: ซ้ายกลาง เหนือจอย */
body.m-mobile #log { left: calc(var(--sal) + 10px); right: auto; bottom: calc(var(--sab) + 172px * var(--ui)); align-items: flex-start; transform-origin: 0 100%; }

/* ============================ จอย (ซ้ายล่าง) ============================ */
body.m-mobile #mobile-ui .joy2:not([data-lay]):not(.act) { left: calc(var(--sal) + 14px + 70px * (var(--mu) - 1)); bottom: calc(var(--sab) + 14px + 70px * (var(--mu) - 1)); }
body.m-mobile #mobile-ui .joy2 { width: 140px; height: 140px; transform: scale(var(--mu)); transform-origin: 50% 50%; }
body.m-mobile #joy-zone { top: 30%; bottom: 0; width: 42%; left: 0; }

/* ============================ ปุ่มแอ็กชัน (ขวาล่าง) ============================ */
body.m-mobile #mobile-ui .mbtns { right: calc(var(--sar) + 12px); bottom: calc(var(--sab) + 12px); width: calc(280px * var(--mu)); height: calc(230px * var(--mu)); transform: none !important; pointer-events: none; }
body.m-mobile #mobile-ui .mb { transform: none !important; padding: 0; display: grid; place-items: center; line-height: 1; }
body.m-mobile #mobile-ui .mb.on { transform: scale(.9) !important; }
body.m-mobile #mobile-ui .mb.sk img, body.m-mobile #mobile-ui .mb.pot img { width: calc(30px * var(--mu)); height: calc(30px * var(--mu)); }
body.m-mobile #mobile-ui .mb.sk b { font-size: calc(9px * var(--mu)); right: 22%; bottom: 6%; }
body.m-mobile #mobile-ui .mb.pot span { font-size: calc(9px * var(--mu)); }
body.m-mobile #mobile-ui .mb.up { font-size: calc(20px * var(--mu)); background: rgba(14, 12, 26, .38); border: 1.5px solid rgba(255, 255, 255, .45); color: #fff; opacity: var(--mop); backdrop-filter: blur(3px); }
/* ขนาด */
body.m-mobile #mobile-ui .mb.atk { width: calc(86px * var(--mu)); height: calc(86px * var(--mu)); font-size: calc(34px * var(--mu)); }
body.m-mobile #mobile-ui .mb.jump { width: calc(62px * var(--mu)); height: calc(62px * var(--mu)); font-size: calc(24px * var(--mu)); }
body.m-mobile #mobile-ui .mb.sk { width: calc(50px * var(--mu)); height: calc(50px * var(--mu)); }
body.m-mobile #mobile-ui .mb.pot { width: calc(42px * var(--mu)); height: calc(42px * var(--mu)); }
body.m-mobile #mobile-ui .mb.pick { width: calc(44px * var(--mu)); height: calc(44px * var(--mu)); font-size: calc(11px * var(--mu)); }
body.m-mobile #mobile-ui .mb.up { width: calc(44px * var(--mu)); height: calc(44px * var(--mu)); }
/* ◯ วงกลม / ✥ อิสระ (ค่าเริ่มต้น): สกิลเรียงโค้งรอบปุ่มโจมตี รับนิ้วโป้ง */
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).atk { right: 0; bottom: 0; }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).jump { right: calc(100px * var(--mu)); bottom: 0; }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).s0 { right: calc(18px * var(--mu)); bottom: calc(122px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).s1 { right: calc(72px * var(--mu)); bottom: calc(107px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).s2 { right: calc(110px * var(--mu)); bottom: calc(67px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).s3 { right: calc(40px * var(--mu)); bottom: calc(176px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).s4 { right: calc(107px * var(--mu)); bottom: calc(151px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).s5 { right: calc(157px * var(--mu)); bottom: calc(98px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).p0 { right: calc(179px * var(--mu)); bottom: calc(5px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).p1 { right: calc(184px * var(--mu)); bottom: calc(51px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).pick { right: calc(230px * var(--mu)); bottom: calc(4px * var(--mu)); }
body.m-mobile #mobile-ui:not(.ms-square) .mb:not([data-lay]).up { right: calc(174px * var(--mu)); bottom: calc(156px * var(--mu)); }
/* ▢ สี่เหลี่ยม: กริดเป็นระเบียบ */
body.m-mobile #mobile-ui.ms-square .mb.atk { right: 0; bottom: 0; border-radius: calc(22px * var(--mu)); }
body.m-mobile #mobile-ui.ms-square .mb.jump { right: calc(94px * var(--mu)); bottom: 0; }
body.m-mobile #mobile-ui.ms-square .mb.s0 { right: 0; bottom: calc(94px * var(--mu)); } body.m-mobile #mobile-ui.ms-square .mb.s1 { right: calc(58px * var(--mu)); bottom: calc(94px * var(--mu)); } body.m-mobile #mobile-ui.ms-square .mb.s2 { right: calc(116px * var(--mu)); bottom: calc(94px * var(--mu)); }
body.m-mobile #mobile-ui.ms-square .mb.s3 { right: 0; bottom: calc(152px * var(--mu)); } body.m-mobile #mobile-ui.ms-square .mb.s4 { right: calc(58px * var(--mu)); bottom: calc(152px * var(--mu)); } body.m-mobile #mobile-ui.ms-square .mb.s5 { right: calc(116px * var(--mu)); bottom: calc(152px * var(--mu)); }
body.m-mobile #mobile-ui.ms-square .mb.p0 { right: calc(174px * var(--mu)); bottom: calc(58px * var(--mu)); } body.m-mobile #mobile-ui.ms-square .mb.p1 { right: calc(174px * var(--mu)); bottom: calc(106px * var(--mu)); }
body.m-mobile #mobile-ui.ms-square .mb.pick { right: calc(164px * var(--mu)); bottom: 0; } body.m-mobile #mobile-ui.ms-square .mb.up { right: calc(174px * var(--mu)); bottom: calc(154px * var(--mu)); }
body.m-mobile #mobile-ui.ms-square .mb.up { border-radius: calc(12px * var(--mu)); }

/* ============================ หน้าต่างบนมือถือ ============================ */
body.m-mobile .win { max-height: calc((100vh - var(--sat) - var(--sab) - 16px) / var(--ui)) !important; max-width: calc((100vw - var(--sal) - var(--sar) - 16px) / var(--ui)) !important; }
body.m-mobile .win-head { min-height: 38px; } body.m-mobile .win-close, body.m-mobile .win-head button { min-width: 36px; min-height: 32px; }

/* ============================ LAUNCHER (☰) ============================ */
#m-launch { position: absolute; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: calc(var(--sat) + 10px) calc(var(--sar) + 10px) calc(var(--sab) + 10px) calc(var(--sal) + 10px); background: rgba(4, 3, 10, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: auto; animation: mlIn .16s ease-out; }
#m-launch.hidden { display: none; }
@keyframes mlIn { from { opacity: 0; transform: scale(1.03); } }
.ml-box { width: min(760px, 100%); max-height: 100%; display: flex; flex-direction: column; border-radius: 20px; background: linear-gradient(160deg, rgba(40, 24, 70, .92), rgba(12, 9, 26, .95)); border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); color: #fff; overflow: hidden; }
.ml-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, .1); } .ml-head b { font-size: 16px; } .ml-head small { flex: 1; font-size: 10.5px; color: rgba(255, 255, 255, .5); }
.ml-x { width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: #fff; font-size: 18px; }
.ml-body { overflow-y: auto; padding: 8px 14px 14px; -webkit-overflow-scrolling: touch; }
.ml-t { font-size: 11px; font-weight: 800; letter-spacing: .8px; color: #ff9ecb; margin: 8px 2px 6px; }
.ml-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ml-it { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 72px; padding: 8px 4px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06); color: #fff; font: inherit; }
.ml-it:active { transform: scale(.94); background: rgba(255, 79, 163, .25); }
.ml-it i { font-style: normal; font-size: 26px; line-height: 1; } .ml-it span { font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.15; }
.ml-dot { position: absolute; top: 6px; right: 8px; min-width: 16px; height: 16px; border-radius: 8px; background: #ff3355; font: 800 9px/16px system-ui, sans-serif; text-align: center; }
body.dv-tablet .ml-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); } body.dv-tablet .ml-it { min-height: 88px; } body.dv-tablet .ml-it i { font-size: 32px; } body.dv-tablet .ml-it span { font-size: 13px; }

/* ============================ SHEET / ROTATE ============================ */
.m-sheet, #m-rotate { position: absolute; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(4, 3, 10, .7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: auto; color: #fff; }
.m-sheet-box { width: min(460px, 100%); max-height: 100%; overflow-y: auto; padding: 16px 18px; border-radius: 18px; background: linear-gradient(160deg, #2a1a48, #120c22); border: 1px solid rgba(255, 255, 255, .15); font-size: 13px; line-height: 1.5; }
.m-sheet-t { font-size: 17px; } .m-sheet-box p { color: rgba(255, 255, 255, .75); margin: 6px 0; } .m-sheet-box ol { padding-left: 20px; margin: 6px 0 12px; } .m-sheet-box li { margin: 6px 0; }
.m-sheet-box kbd { padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, .15); font-family: inherit; }
.m-sheet-ok, #m-rotate button { width: 100%; height: 46px; border-radius: 12px; border: 0; background: linear-gradient(135deg, #ff4fa3, #7b2cff); color: #fff; font: 800 15px/1 inherit; }
#m-rotate > div { text-align: center; max-width: 320px; } #m-rotate i { font-style: normal; font-size: 64px; display: block; animation: mRot 1.8s ease-in-out infinite; }
#m-rotate b { display: block; font-size: 20px; margin: 10px 0 6px; } #m-rotate p { color: rgba(255, 255, 255, .7); font-size: 13px; margin: 0 0 16px; }
@keyframes mRot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ============================ แท็บเล็ต ============================ */
body.m-mobile.dv-tablet #hud.hx { width: 250px; }
body.m-mobile.dv-tablet #qtrack { max-height: none; }
/* แจ้งเตือนกลางจอ: ต่ำกว่าแชทบนมือถือ */
body.m-mobile #notices { top: calc(var(--sat) + 112px * var(--ui)); }
body.m-mobile.dv-phone #ui-layer #chat #chat-log { max-height: 50px; height: auto; font-size: 10.5px; }
body.m-mobile.dv-phone #ui-layer #chat.cx-open #chat-log { height: 50px; }
