/* =====================================================================
 * mobile_v10.css — จอยสติ๊ก/ปุ่มมือถือแบบมินิมอล (3 รูปแบบ) + แชท Pop-up
 * ===================================================================== */
#mobile-ui { --mop: .85; --pm-acc: #ff4fa3; }

/* ---------------------------- JOYSTICK ---------------------------- */
#mobile-ui .joy2 { width: 140px; height: 140px; background: none; opacity: calc(var(--mop) * .75); transition: opacity .15s; }
#mobile-ui .joy2.act { opacity: var(--mop); }
#mobile-ui .joy2 .joy-ring, #mobile-ui .joy2 > .joy-knob { display: none; }
.j-base { position: absolute; inset: 12px; border-radius: 50%; background: rgba(255, 255, 255, .06); border: 1.5px solid rgba(255, 255, 255, .3); box-shadow: inset 0 0 18px rgba(255, 255, 255, .06); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); transition: border-color .15s, background .15s; }
.joy2.act .j-base { border-color: rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .1); }
.j-knob { position: absolute; left: calc(50% - 22px); top: calc(50% - 22px); width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .88); box-shadow: 0 2px 8px rgba(0, 0, 0, .35); transition: transform .06s linear, width .1s, height .1s; }
.joy2.act .j-knob { background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .15), 0 2px 10px rgba(0, 0, 0, .4); }
.j-ar { position: absolute; width: 0; height: 0; border: 6px solid transparent; opacity: .45; transition: opacity .1s, border-color .1s; }
.j-ar[data-k=ArrowUp] { left: calc(50% - 6px); top: 6px; border-bottom-color: #fff; border-top-width: 0; }
.j-ar[data-k=ArrowDown] { left: calc(50% - 6px); bottom: 6px; border-top-color: #fff; border-bottom-width: 0; }
.j-ar[data-k=ArrowLeft] { top: calc(50% - 6px); left: 6px; border-right-color: #fff; border-left-width: 0; }
.j-ar[data-k=ArrowRight] { top: calc(50% - 6px); right: 6px; border-left-color: #fff; border-right-width: 0; }
.j-ar.on { opacity: 1; filter: drop-shadow(0 0 4px var(--pm-acc)); }
.j-ar[data-k=ArrowUp].on { border-bottom-color: var(--pm-acc); } .j-ar[data-k=ArrowDown].on { border-top-color: var(--pm-acc); }
.j-ar[data-k=ArrowLeft].on { border-right-color: var(--pm-acc); } .j-ar[data-k=ArrowRight].on { border-left-color: var(--pm-acc); }
/* ระดับ 1: สี่เหลี่ยม */
#mobile-ui.ms-square .j-base { border-radius: 22px; }
#mobile-ui.ms-square .j-knob { border-radius: 14px; }
/* ระดับ 3: อิสระ (จอยลอย) */
#joy-zone { position: absolute; left: 0; top: 28%; width: 44%; bottom: 70px; pointer-events: none; touch-action: none; }
#mobile-ui.ms-free #joy-zone { pointer-events: auto; }
#mobile-ui.ms-free .joy2:not(.act) { opacity: calc(var(--mop) * .4); }
#mobile-ui.ms-free .joy2:not(.act) .j-base { border-style: dashed; }

/* ---------------------------- BUTTONS (มินิมอล) ---------------------------- */
#mobile-ui .mb { background: rgba(14, 12, 26, .38); border: 1.5px solid rgba(255, 255, 255, .34); box-shadow: none; color: #fff; opacity: var(--mop); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); font-weight: 700; }
#mobile-ui .mb.on { background: rgba(255, 255, 255, .28); filter: none; border-color: #fff; }
#mobile-ui .mb.atk { background: rgba(255, 79, 163, .22); border: 2px solid rgba(255, 79, 163, .85); color: #fff; font-size: 34px; }
#mobile-ui .mb.atk.on { background: rgba(255, 79, 163, .5); }
#mobile-ui .mb.jump { background: rgba(14, 12, 26, .38); border-color: rgba(255, 255, 255, .55); font-size: 24px; }
#mobile-ui .mb.pick { font-size: 11px; }
#mobile-ui .mb.sk b { opacity: .7; font-weight: 600; }
#mobile-ui .mb .mcd { border-radius: inherit; }
#mobile-ui .mt { background: rgba(14, 12, 26, .45); border: 1.5px solid rgba(255, 255, 255, .28); border-radius: 12px; opacity: var(--mop); backdrop-filter: blur(3px); }
#mobile-ui .mt.on { background: var(--pm-acc); color: #fff; border-color: var(--pm-acc); box-shadow: 0 0 10px rgba(255, 79, 163, .5); }
/* ระดับ 1: สี่เหลี่ยม — ปุ่มสี่เหลี่ยมมุมมน เรียงกริด */
#mobile-ui.ms-square .mb { border-radius: 14px; }
#mobile-ui.ms-square .mb.atk { right: 0; bottom: 0; width: 88px; height: 88px; border-radius: 22px; }
#mobile-ui.ms-square .mb.jump { right: 96px; bottom: 0; width: 64px; height: 64px; }
#mobile-ui.ms-square .mb.pick { right: 168px; bottom: 0; width: 48px; height: 48px; }
#mobile-ui.ms-square .mb.sk { width: 56px; height: 56px; }
#mobile-ui.ms-square .mb.s0 { right: 0; bottom: 96px; } #mobile-ui.ms-square .mb.s1 { right: 64px; bottom: 96px; } #mobile-ui.ms-square .mb.s2 { right: 128px; bottom: 96px; }
#mobile-ui.ms-square .mb.s3 { right: 0; bottom: 160px; } #mobile-ui.ms-square .mb.s4 { right: 64px; bottom: 160px; } #mobile-ui.ms-square .mb.s5 { right: 128px; bottom: 160px; }
#mobile-ui.ms-square .mb.pot { width: 44px; height: 44px; } #mobile-ui.ms-square .mb.p0 { right: 196px; bottom: 64px; } #mobile-ui.ms-square .mb.p1 { right: 196px; bottom: 114px; }
/* ระดับ 2 & 3: วงกลม */
#mobile-ui.ms-circle .mb, #mobile-ui.ms-free .mb { border-radius: 50%; }

/* ---------------------------- หน้าตั้งค่า ---------------------------- */
.mc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mc-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .15); background: rgba(255, 255, 255, .04); color: #fff; cursor: pointer; font: inherit; }
.mc-card.on { border-color: #ff4fa3; background: rgba(255, 79, 163, .14); box-shadow: 0 0 12px rgba(255, 79, 163, .35); }
.mc-card b { font-size: 12px; } .mc-card small { font-size: 10.5px; opacity: .7; text-align: center; line-height: 1.3; }
.mc-prev { position: relative; width: 100%; max-width: 120px; height: 58px; border-radius: 8px; background: linear-gradient(#2a3a5a, #1a2438); overflow: hidden; }
.mc-prev .pj { position: absolute; left: 8px; bottom: 8px; width: 30px; height: 30px; border: 1.5px solid rgba(255, 255, 255, .6); border-radius: 50%; }
.mc-prev .pj::after { content: ""; position: absolute; left: 9px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.mc-prev .pb { position: absolute; width: 13px; height: 13px; border: 1.5px solid rgba(255, 255, 255, .6); border-radius: 50%; }
.mc-prev .b1 { right: 8px; bottom: 8px; width: 20px; height: 20px; border-color: #ff4fa3; } .mc-prev .b2 { right: 32px; bottom: 8px; } .mc-prev .b3 { right: 10px; bottom: 32px; } .mc-prev .b4 { right: 30px; bottom: 26px; }
.mc-square .pj, .mc-square .pj::after { border-radius: 7px; } .mc-square .pb { border-radius: 3px; }
.mc-square .b3 { right: 8px; bottom: 32px; } .mc-square .b4 { right: 28px; bottom: 32px; }
.mc-free .pj { left: 30px; bottom: 14px; border-style: dashed; } .mc-free .b3 { right: 46px; bottom: 34px; } .mc-free .b4 { right: 6px; bottom: 36px; }
.mc-free em { position: absolute; left: 44px; bottom: 2px; font-style: normal; font-size: 14px; }
.mc-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; } .mc-row span { width: 70px; } .mc-row input { flex: 1; } .mc-row b { width: 40px; text-align: right; }

/* ---------------------------- มือถือ: จัด HUD ไม่ให้ทับกัน ---------------------------- */
body.m-mobile #wx-hud { top: calc(56px * var(--ui, 1)); right: 8px; transform: scale(.85); transform-origin: 100% 0; }

/* =====================================================================
 * CHAT POP-UP
 * ===================================================================== */
.cx-head { display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 4px; font-size: 12px; color: #fff; user-select: none; touch-action: none; cursor: move; pointer-events: auto; }
.cx-head b { font-weight: 700; letter-spacing: .3px; } .cx-sp { flex: 1; }
.cx-grip { opacity: .45; font-size: 10px; letter-spacing: -2px; }
.cx-b { width: 24px; height: 22px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .06); color: #fff; font-size: 12px; line-height: 1; padding: 0; cursor: pointer; }
.cx-b:hover { background: rgba(255, 255, 255, .18); }
#ui-layer #chat.cx-open [data-cx=open], #ui-layer #chat.cx-mini [data-cx=mini] { display: none; }
/* เปิด */
#ui-layer #chat.cx-open { background: rgba(10, 8, 22, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border-radius: 10px; border: 1px solid rgba(255, 255, 255, .14); overflow: hidden; }
body.m-mobile #ui-layer #chat.cx-open { width: min(440px, 56vw); }
body.m-mobile #ui-layer #chat.cx-open #chat-log { height: min(30vh, 150px); font-size: 11.5px; }
/* หุบ: ไม่มีพื้นหลัง แตะทะลุได้ */
#ui-layer #chat.cx-mini { background: transparent !important; border-color: transparent !important; box-shadow: none !important; backdrop-filter: none; pointer-events: none; opacity: 1; }
#ui-layer #chat.cx-mini .chat-tabs, #ui-layer #chat.cx-mini .chat-input { display: none !important; }
#ui-layer #chat.cx-mini .cx-head { width: max-content; background: rgba(10, 8, 22, .45); border-radius: 12px; padding: 2px 6px; cursor: pointer; }
#ui-layer #chat.cx-mini .cx-grip { display: none; }
#ui-layer #chat.cx-mini #chat-log { height: auto !important; max-height: none; overflow: hidden; pointer-events: none; background: none; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
#ui-layer #chat.cx-mini #chat-log > .cm:not(:nth-last-child(-n+3)) { display: none; }
/* ปิด */
#ui-layer #chat.cx-closed { display: none !important; }
#ui-layer #chat.cx-moved { right: auto !important; bottom: auto !important; transform: scale(var(--ui, 1)) !important; transform-origin: 0 0 !important; }
#chat-fab { display: none; position: absolute; left: 8px; bottom: calc(92px * var(--ui, 1)); z-index: 21; align-items: center; justify-content: center; gap: 4px; height: 38px; min-width: 44px; padding: 0 10px; border-radius: 20px; border: 1.5px solid rgba(255, 255, 255, .3); background: rgba(10, 8, 22, .55); backdrop-filter: blur(4px); color: #fff; font-size: 18px; cursor: pointer; pointer-events: auto; }
body.cx-is-closed #chat-fab { display: flex; }
body.m-mobile #chat-fab { left: 50%; bottom: auto; top: 8px; transform: translateX(-50%); }
.cx-badge { min-width: 18px; height: 18px; border-radius: 9px; background: #ff4fa3; color: #fff; font-size: 11px; font-style: normal; font-weight: 700; display: inline-grid; place-items: center; padding: 0 5px; }
#chat-peek { position: absolute; left: 62px; bottom: calc(96px * var(--ui, 1)); z-index: 21; max-width: min(360px, 60vw); padding: 6px 10px; border-radius: 10px; background: rgba(10, 8, 22, .6); color: #fff; font-size: 12px; pointer-events: none; opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-peek.on { opacity: 1; transform: none; }
body.m-mobile #chat-peek { left: 50%; bottom: auto; top: 52px; transform: translate(-50%, -6px); }
body.m-mobile #chat-peek.on { transform: translate(-50%, 0); }
/* ปุ่มที่ลากวางเอง (position:fixed) ต้องอ้างอิงหน้าจอ — ห้ามมี transform ที่คอนเทนเนอร์ */
#mobile-ui .mbtns { transform: none !important; }
@media (max-height: 460px) {
  #mobile-ui .mb { transform: scale(calc(var(--mscale, 1) * var(--ui, 1) * .85)); }
  #mobile-ui .mb.on { transform: scale(calc(var(--mscale, 1) * var(--ui, 1) * .78)); }
  #mobile-ui .mbtns { bottom: 64px; }
}
/* v15: ป้ายปาร์ตี้หน้าชื่อในแชท */
.cm-pt { display: inline-block; margin-right: 4px; padding: 0 5px; border-radius: 6px; background: rgba(255, 158, 196, .22); color: #ffb3d4; font-size: .9em; font-weight: 700; }
#chat .cm.pt b { color: #ffb3d4; }
