/* ธีม UI: กระจกเขียวอมฟ้า (teal glass) โทนน่ารักแบบ RO */
:root {
  --panel: rgba(16, 38, 42, .88);
  --panel2: rgba(10, 26, 30, .9);
  --line: rgba(140, 220, 205, .28);
  --line2: rgba(140, 220, 205, .5);
  --cream: #f6ebcc;
  --mint: #8ce8cf;
  --gold: #ffd36a;
  --txt: #e6f2ee;
  --dim: #8fb0aa;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1a1a; color: var(--txt);
  font-family: Tahoma, "Leelawadee UI", "Noto Sans Thai", sans-serif; font-size: 13px; user-select: none; }
canvas#view { position: fixed; left: 0; top: 0; display: block; }
canvas#labels { position: fixed; inset: 0; display: block; }
button { font-family: inherit; cursor: pointer; }
.dim { color: var(--dim); }
.good { color: #8f8; } .bad { color: #ff8a8a; }
.rare { color: var(--gold) !important; }
i.px { display: inline-block; image-rendering: pixelated; vertical-align: middle; flex-shrink: 0; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50; overflow: auto; padding: 16px;
  background: linear-gradient(#8fd4f0 0%, #c8ecf4 45%, #7cc860 46%, #4f9a3c 100%); }
#title::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 20% 30%, rgba(255,255,255,.7) 0 6%, transparent 7%), radial-gradient(ellipse at 75% 18%, rgba(255,255,255,.6) 0 5%, transparent 6%),
              repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 2px, transparent 2px 6px); }
#title .panel { position: relative; width: min(760px, 100%); background: var(--panel); backdrop-filter: blur(6px); border: 1px solid var(--line2); border-radius: 16px; padding: 24px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,30,30,.45); }
#title h1 { margin: 0; font-size: 48px; color: var(--cream); letter-spacing: 2px;
  text-shadow: 0 3px 0 #e0709a, 0 6px 0 #6a2a4a, 0 0 24px rgba(255,190,220,.45); }
#title h1 span { color: var(--mint); font-size: 26px; text-shadow: 0 2px 0 #1a5a4a; }
#title .sub { color: var(--dim); margin: 8px 0 16px; }
#title h3 { color: var(--cream); margin: 18px 0 8px; }
#pname-in { width: 260px; padding: 9px 12px; font: inherit; font-size: 15px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); color: #fff; text-align: center; outline: none; }
#pname-in:focus { border-color: var(--mint); }
#classes { display: flex; gap: 12px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.cls { width: 200px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.04); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: .15s; }
.cls:hover { border-color: var(--line2); transform: translateY(-2px); }
.cls.sel { border-color: var(--mint); background: rgba(140,232,207,.12); box-shadow: 0 0 16px rgba(140,232,207,.3); }
.cls canvas { width: 144px; height: 144px; image-rendering: pixelated; background: radial-gradient(ellipse at 50% 85%, rgba(120,200,90,.35), transparent 60%); }
.cls b { font-size: 16px; color: var(--cream); }
.cls small { color: #b8d0ca; min-height: 34px; }
.cstats { font-size: 11px; color: var(--mint); }
button.big { padding: 11px 32px; font-size: 16px; font-weight: bold; border-radius: 999px; border: none; color: #2a1a20;
  background: linear-gradient(#ffe6a0, #ffb878); box-shadow: 0 3px 0 #b86a40, 0 6px 14px rgba(0,0,0,.25); margin: 6px; }
button.big:hover { filter: brightness(1.06); transform: translateY(-1px); }
button.big:active { transform: translateY(2px); box-shadow: 0 1px 0 #b86a40; }

/* ---------- HUD ---------- */
.glass { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(4px); }
#hud { position: fixed; left: 12px; top: 12px; display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 8px; }
.lvbox { width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--mint); display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--panel2); line-height: 1; box-shadow: inset 0 0 10px rgba(140,232,207,.25); }
.lvbox small { color: var(--mint); font-size: 10px; } .lvbox b { font-size: 20px; color: var(--cream); }
.bars { width: 220px; }
#pname { font-weight: bold; margin-bottom: 3px; color: var(--cream); }
.barw { position: relative; height: 14px; background: #0a1414; border: 1px solid #000; border-radius: 999px; overflow: hidden; margin-top: 3px; }
.barw > div { height: 100%; transition: width .15s; border-radius: 999px; }
.barw span { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 13px; text-shadow: 0 1px 2px #000; }
.hp > div { background: linear-gradient(#ff9a9a, #e04848 60%, #b02a3a); }
.mp > div { background: linear-gradient(#9ad0ff, #4a8ae8 60%, #2a5ab0); }
.exp > div { background: linear-gradient(#ffe6a0, #f0b040 60%, #c07a20); }
.tg > div { background: linear-gradient(#ff9a9a, #e04848 60%, #b02a3a); }
#buffs { position: fixed; left: 12px; top: 92px; display: flex; gap: 4px; }
.buff { position: relative; width: 30px; height: 30px; background: var(--panel); border: 1px solid var(--mint); border-radius: 8px; text-align: center; line-height: 28px; font-size: 16px; }
.buff span { position: absolute; right: 1px; bottom: -2px; font-size: 10px; line-height: 1; text-shadow: 0 0 2px #000; }
#target { display: none; position: fixed; left: 50%; top: 12px; transform: translateX(-50%); width: 240px; padding: 6px 12px; text-align: center; color: #ffd0d0; }

#mapbox { position: fixed; right: 12px; top: 12px; padding: 6px; text-align: center; }
#mapname { font-weight: bold; color: var(--cream); margin-bottom: 4px; }
#minimap { display: block; border-radius: 8px; border: 1px solid var(--line); image-rendering: pixelated; }
#coords { font-size: 11px; color: var(--dim); margin-top: 2px; }
#maptitle { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; white-space: nowrap; }
#maptitle.show { animation: banner 3s ease forwards; }
#maptitle .n { font-size: 36px; font-weight: bold; color: var(--cream); text-shadow: 0 3px 0 #2a5a50, 0 0 18px rgba(140,232,207,.6), 0 2px 8px #000; }
#maptitle .l { color: var(--mint); text-shadow: 0 1px 4px #000; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

#log { position: fixed; left: 12px; bottom: 100px; width: 400px; max-width: calc(100vw - 24px); height: 140px; overflow-y: auto; background: rgba(8,22,24,.55); border-radius: 10px; padding: 6px 10px; font-size: 12px; border: 1px solid rgba(140,220,205,.15); }
#log .msg { margin: 1px 0; text-shadow: 0 1px 1px #000; }
#log .good { color: #9f9; } #log .bad { color: #f99; } #log .warn { color: #ffe08a; } #log .quest { color: var(--mint); } #log .rare { color: var(--gold); font-weight: bold; }
#log::-webkit-scrollbar, .wb::-webkit-scrollbar { width: 6px; } #log::-webkit-scrollbar-thumb, .wb::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }

#bottom { position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%); width: min(740px, calc(100vw - 16px)); }
#bottom .exp { height: 11px; margin-bottom: 5px; } #bottom .exp span { font-size: 9px; line-height: 10px; }
#bottom .row { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 6px; flex-wrap: wrap; }
#hotbar { display: flex; gap: 4px; }
#goldbox { padding: 0 8px; color: var(--gold); white-space: nowrap; display: flex; align-items: center; gap: 2px; }
#menubar { display: flex; gap: 4px; }
#menubar button { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.05); }
#menubar button:hover { background: rgba(140,232,207,.18); border-color: var(--mint); }
#menubar button.flash { animation: flash 1s infinite; }
@keyframes flash { 50% { background: rgba(255,211,106,.4); border-color: var(--gold); } }

.slot { position: relative; width: 40px; height: 40px; background: rgba(0,10,12,.55); border: 1px solid var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.slot:hover { border-color: var(--mint); background: rgba(140,232,207,.08); }
.slot .key { position: absolute; left: 3px; top: 0; font-size: 10px; color: var(--dim); }
.slot .ic { display: flex; }
.slot .qty { position: absolute; right: 2px; bottom: 0; font-size: 11px; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.slot .plus { position: absolute; left: 2px; top: 0; font-size: 10px; color: var(--mint); font-weight: bold; text-shadow: 0 0 2px #000; }
.slot .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); pointer-events: none; border-radius: 0 0 8px 8px; }
.slot.hb { cursor: pointer; }
.slot.empty-item .ic { opacity: .3; }
.slot.rare { border-color: #e0b050; box-shadow: inset 0 0 10px rgba(255,200,80,.3); }
.slot.sel { border-color: var(--mint); box-shadow: 0 0 10px var(--mint); }

/* ---------- windows ---------- */
.win { position: fixed; width: 360px; background: var(--panel); backdrop-filter: blur(6px); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.5); display: none; }
#win-inv { width: 390px; } #win-shop { width: 410px; }
.wh { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: move; color: var(--cream); font-weight: bold; }
.wh::before { content: "✦"; color: var(--mint); margin-right: 6px; font-size: 11px; }
.wh .wt { flex: 1; }
.wh .x { background: rgba(255,255,255,.06); border: 1px solid var(--line); color: #cde; font-size: 11px; width: 24px; height: 24px; border-radius: 50%; }
.wh .x:hover { color: #fff; background: #c04a5a; }
.wb { padding: 10px 12px 12px; max-height: 70vh; overflow-y: auto; }
.wb button { background: rgba(140,232,207,.12); color: var(--txt); border: 1px solid var(--line2); border-radius: 999px; padding: 4px 12px; }
.wb button:hover:not(:disabled) { background: rgba(140,232,207,.28); }
.wb button:disabled { opacity: .3; cursor: default; }
.equip { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.eqrow { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.grid { display: grid; grid-template-columns: repeat(8, 40px); gap: 4px; justify-content: center; }
.invfoot { margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--gold); }
.charhead { font-size: 15px; margin-bottom: 8px; color: var(--cream); }
.stats .st { display: grid; grid-template-columns: 1fr 70px 30px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.stats em { color: var(--mint); font-style: normal; font-size: 11px; }
.stats button { padding: 1px 0; }
.pts { margin: 8px 0; }
.derived { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 12px; background: rgba(0,0,0,.25); padding: 8px 10px; border-radius: 10px; }
.derived b { color: var(--cream); }
.skrow { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.skrow.locked .slot { opacity: .4; }
.skinfo { flex: 1; }
.npctext { line-height: 1.7; margin-bottom: 10px; background: rgba(0,0,0,.25); padding: 10px 12px; border-radius: 10px; border-left: 3px solid var(--mint); }
.opts { display: flex; flex-direction: column; gap: 5px; }
.opts button { text-align: left; padding: 7px 14px; }
.shoprow { display: flex; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.shoprow .si { flex: 1; font-size: 12px; }
.shoprow .price { color: var(--gold); width: 70px; text-align: right; font-size: 12px; }
.shoprow .btns { display: flex; gap: 3px; }
.upbox { text-align: center; padding: 12px; background: rgba(0,0,0,.25); border-radius: 10px; }
.slot.big { width: 64px; height: 64px; margin: 0 auto 6px; }
.upbox button { margin-top: 6px; padding: 8px 26px; font-size: 15px; background: linear-gradient(#ffe6a0, #ffb878); color: #2a1a20; border: none; font-weight: bold; box-shadow: 0 3px 0 #b86a40; }
.help p { margin: 5px 0; }

#tooltip { position: fixed; display: none; z-index: 100; max-width: 250px; background: rgba(10,26,30,.97); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; font-size: 12px; pointer-events: none; line-height: 1.5; }
.tt-name { font-weight: bold; font-size: 13px; color: var(--cream); display: flex; align-items: center; gap: 6px; }

#death { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(40,0,10,.4); pointer-events: none; }
#death.show { display: flex; }
#death div { font-size: 34px; color: #ffb0b8; text-shadow: 0 2px 8px #000; text-align: center; }
#death small { display: block; font-size: 15px; color: #ddd; }

@media (max-width: 700px) {
  #log { height: 90px; width: calc(100vw - 24px); bottom: 150px; }
  #mapbox { transform: scale(.7); transform-origin: top right; }
  .bars { width: 150px; }
}

/* ---------- ออร่าไอเท็ม / แอดมิน ---------- */
.slot[data-aura="rainbow"] { animation: rainbow 2s linear infinite; }
@keyframes rainbow { 0% { box-shadow: 0 0 10px #ff4a4a, inset 0 0 10px #ff4a4a88; border-color: #ff4a4a; } 25% { box-shadow: 0 0 10px #ffe44a, inset 0 0 10px #ffe44a88; border-color: #ffe44a; }
  50% { box-shadow: 0 0 10px #4aff7a, inset 0 0 10px #4aff7a88; border-color: #4aff7a; } 75% { box-shadow: 0 0 10px #4aa8ff, inset 0 0 10px #4aa8ff88; border-color: #4aa8ff; } 100% { box-shadow: 0 0 10px #c85aff, inset 0 0 10px #c85aff88; border-color: #c85aff; } }
#win-admin { width: 430px; border-color: #ffb050; }
.admin-warn { background: rgba(255,170,60,.15); border: 1px solid rgba(255,170,60,.5); color: #ffd8a0; padding: 6px 10px; border-radius: 8px; font-size: 12px; margin-bottom: 8px; }
.adm-sec { margin: 10px 0 5px; } .adm-sec .gold { color: var(--gold); font-size: 15px; }
.adm-row { display: flex; flex-wrap: wrap; gap: 5px; }
.adm-row input { flex: 1; min-width: 120px; background: var(--panel2); border: 1px solid var(--line2); color: #fff; border-radius: 999px; padding: 4px 12px; font: inherit; }
.wb .plusbtn { padding: 3px 0; width: 34px; font-weight: bold; }
.wb .plusbtn.on { background: rgba(255,255,255,.22); }

/* ---------- AUTO / แชท / แท็บ / หิน / สัตว์เลี้ยง ---------- */
#autobtn { height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(255,255,255,.06); color: var(--dim); font-weight: bold; font-size: 12px; }
#autobtn.on { background: linear-gradient(#ff8a5a, #e04a3a); color: #fff; border-color: #ffb08a; box-shadow: 0 0 12px rgba(255,120,80,.6); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 20px rgba(255,120,80,.9); } }
#chat { position: fixed; left: 12px; bottom: 72px; width: 400px; max-width: calc(100vw - 24px); background: rgba(8,22,24,.7); border: 1px solid var(--line); border-radius: 999px; color: #fff; padding: 5px 12px; font: inherit; font-size: 12px; outline: none; }
#chat:focus { border-color: var(--mint); background: rgba(8,22,24,.92); }
#log { bottom: 104px; }
#worldinfo { font-size: 11px; color: var(--cream); margin-top: 3px; max-width: 180px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.tabs button { padding: 3px 10px; font-size: 12px; }
.tabs button.on, .adm-row button.on { background: rgba(140,232,207,.35); border-color: var(--mint); color: #fff; }
.tabs.small button { font-size: 11px; padding: 2px 8px; }
.cmdrow { display: flex; gap: 5px; margin: 6px 0 8px; }
.cmdrow input { flex: 1; background: var(--panel2); border: 1px solid var(--line2); color: #fff; border-radius: 999px; padding: 4px 12px; font: inherit; }
.stones { display: grid; grid-template-columns: repeat(5, 40px); gap: 5px; justify-content: center; margin: 8px 0; }
.slot.stone { cursor: pointer; }
.slot.stone.none { opacity: .35; }
.slot.stone .pct { position: absolute; left: 1px; top: -1px; font-size: 9px; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.petcard { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.petimg { font-size: 30px; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; background: rgba(255,216,58,.15); border: 1px solid #ffd83a; border-radius: 12px; }
#win-shop { width: 440px; }
.grid { max-height: 300px; overflow-y: auto; }

/* ================= มือถือ / แท็บเล็ต ================= */
html, body { touch-action: none; -webkit-tap-highlight-color: transparent; }
#itemmenu { display: none; position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 200; width: min(88vw, 300px);
  background: rgba(10,26,30,.97); border: 1px solid var(--line2); border-radius: 14px; padding: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
#itemmenu .im-body { font-size: 13px; line-height: 1.5; max-height: 40vh; overflow-y: auto; }
#itemmenu .im-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#itemmenu .im-acts button { flex: 1 1 40%; padding: 10px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(140,232,207,.15); color: #fff; font-size: 14px; }
#touchui { display: none; }
.touch #touchui { display: block; }
.touch #joyzone { position: fixed; left: 0; bottom: 0; width: 42vw; height: 58vh; z-index: 5; touch-action: none; }
.touch #joybase { position: absolute; left: 90px; top: calc(100% - 100px); width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.1), rgba(255,255,255,.04)); border: 2px solid rgba(255,255,255,.25); opacity: .6; transition: opacity .15s; pointer-events: none; }
.touch #joybase.on { opacity: 1; }
.touch #joyknob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c8fff0, #5ac8a8); box-shadow: 0 2px 10px rgba(0,0,0,.5); }
.touch #actions { position: fixed; right: max(10px, env(safe-area-inset-right)); bottom: 12px; width: 230px; height: 220px; z-index: 6; }
.touch .act { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(16,38,42,.75); color: #fff; touch-action: none;
  display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 3px 10px rgba(0,0,0,.4); overflow: hidden; padding: 0; }
.touch .act:active { transform: scale(.92); background: rgba(140,232,207,.35); }
.touch .act.big { width: 86px; height: 86px; right: 8px; bottom: 8px; font-size: 38px; background: radial-gradient(circle at 35% 30%, #ff9a6a, #c83a2a); border-color: #ffc8a8; }
.touch .hbt { width: 52px; height: 52px; }
.touch .hbt .ic { display: flex; font-size: 22px; }
.touch .hbt .n { position: absolute; bottom: 2px; right: 8px; font-size: 10px; text-shadow: 0 0 2px #000; }
.touch .hbt .cd { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.touch .hbt.empty { opacity: .45; }
.touch #t-hb0 { right: 104px; bottom: 6px; } .touch #t-hb1 { right: 108px; bottom: 66px; } .touch #t-hb2 { right: 76px; bottom: 120px; }
.touch #t-hb3 { right: 20px; bottom: 140px; } .touch #t-hb4 { right: 164px; bottom: 36px; } .touch #t-hb5 { right: 160px; bottom: 98px; }
.touch .act.sm { width: 46px; height: 46px; font-size: 18px; }
.touch #t-auto { right: 176px; bottom: 156px; font-size: 11px; font-weight: bold; }
.touch #t-auto.on { background: linear-gradient(#ff8a5a, #e04a3a); border-color: #ffb08a; animation: pulse 1.2s infinite; }
.touch #t-pick { right: 124px; bottom: 178px; } .touch #t-target { right: 70px; bottom: 182px; }
.touch #t-top { position: fixed; top: max(8px, env(safe-area-inset-top)); right: 136px; z-index: 6; display: flex; gap: 6px; }
.touch #t-top button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(16,38,42,.8); color: #fff; font-size: 18px; }
.touch #rotatehint { display: none; }
@media (orientation: portrait) { .touch #rotatehint { display: block; position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; background: rgba(0,0,0,.6);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; pointer-events: none; animation: fadeHint 6s forwards; } }
@keyframes fadeHint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* จัดหน้าจอใหม่สำหรับมือถือ */
.touch #hud { top: max(6px, env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left)); padding: 5px 8px 5px 5px; gap: 6px; }
.touch .lvbox { width: 38px; height: 38px; } .touch .lvbox b { font-size: 15px; }
.touch .bars { width: 150px; } .touch #pname { font-size: 11px; } .touch .barw { height: 11px; } .touch .barw span { font-size: 9px; line-height: 10px; }
.touch #buffs { top: 58px; left: 8px; }
.touch #mapbox { top: max(6px, env(safe-area-inset-top)); right: 6px; transform: scale(.62); transform-origin: top right; }
.touch #bottom { top: max(6px, env(safe-area-inset-top)); bottom: auto; width: auto; }
.touch #bottom .exp { width: 260px; margin: 0 auto 4px; }
.touch #bottom .row { padding: 3px 4px; gap: 4px; }
.touch #hotbar, .touch #autobtn, .touch #goldbox { display: none; }
.touch #menubar button { width: 34px; height: 34px; font-size: 16px; }
.touch #target { top: 70px; width: 200px; }
.touch #log { top: 92px; bottom: auto; left: 6px; width: 250px; height: 60px; font-size: 10.5px; pointer-events: none; background: rgba(8,22,24,.35); }
.touch #chat { display: none; top: 60px; bottom: auto; left: 50%; transform: translateX(-50%); width: min(80vw, 420px); font-size: 16px; padding: 8px 14px; z-index: 50; }
.touch #chat.show { display: block; }
.touch #maptitle { top: 30%; } .touch #maptitle .n { font-size: 26px; }
.touch .win { left: 50% !important; right: auto !important; top: max(6px, env(safe-area-inset-top)) !important; transform: translateX(-50%); width: min(96vw, 440px) !important; }
.touch .wb { max-height: calc(100vh - 60px); -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.touch .wb button, .touch .opts button { min-height: 34px; }
.touch .grid { grid-template-columns: repeat(8, 1fr); max-height: 38vh; }
.touch .slot { width: 100%; min-width: 34px; height: 40px; }
.touch .stones { grid-template-columns: repeat(5, 44px); }
.touch .slot.stone, .touch .slot.big, .touch .eqrow .slot { width: 40px; flex: 0 0 auto; }
.touch .slot.big { width: 56px; height: 56px; }
.touch #title { touch-action: pan-y; align-items: flex-start; }
.touch #title .panel { padding: 14px; } .touch #title h1 { font-size: 34px; }
.touch .cls { width: 150px; } .touch .cls canvas { width: 100px; height: 100px; } .touch .cls small { display: none; }

/* ================= BloxAge: ล็อกอิน / แชท / วิ่ง ================= */
#title h1 { font-size: 54px; letter-spacing: 1px; }
#title h1 .age { color: var(--mint); font-size: inherit; text-shadow: 0 3px 0 #1a6a5a, 0 6px 0 #0a3a30; }
.authmsg { min-height: 20px; color: #ffb0a0; margin: 6px 0; }
.step { margin-top: 6px; }
.gbtn { display: flex; justify-content: center; min-height: 46px; margin: 10px 0; }
#devlogin input { width: 200px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); color: #fff; font: inherit; }
button.big.small { padding: 8px 16px; font-size: 13px; }
.linkbtn { background: none; border: none; color: var(--dim); text-decoration: underline; font: inherit; font-size: 12px; }
.charcard { font-size: 18px; margin: 10px auto; padding: 14px; border: 1px solid var(--line2); border-radius: 12px; max-width: 360px; background: rgba(255,255,255,.04); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--mint); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 14px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
#netlost { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.55); z-index: 300; font-size: 16px; text-align: center; }

#chatbox { position: fixed; left: 12px; bottom: 116px; width: 420px; max-width: calc(100vw - 24px); z-index: 3; }
#chatbox #log { position: static; width: 100%; height: 150px; border-radius: 0 10px 0 0; }
#chattabs { display: flex; gap: 2px; }
#chattabs button { background: rgba(8,22,24,.6); border: 1px solid rgba(140,220,205,.15); border-bottom: none; color: var(--dim); font: inherit; font-size: 11px; padding: 2px 10px; border-radius: 8px 8px 0 0; }
#chattabs button.on { color: #fff; background: rgba(8,22,24,.85); }
#chatrow { display: flex; gap: 4px; margin-top: 4px; }
#chatrow select { background: rgba(8,22,24,.85); color: #fff; border: 1px solid var(--line); border-radius: 999px; font: inherit; font-size: 12px; padding: 0 6px; }
#chatbox #chat { position: static; flex: 1; width: auto; transform: none; display: block; }
#log[data-f="chat"] .msg.sys { display: none; } #log[data-f="sys"] .msg.chat { display: none; }
#log .msg.chat .tag { color: var(--dim); font-size: 10px; }
#log .ch-all b { color: #ffd36a; } #log .ch-map b { color: #8ce8cf; } #log .ch-sys { color: #ffcf8a; } #log b.adm { color: #ff7a9a !important; }
#runbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(255,255,255,.06); font-size: 18px; }
#runbtn.on { background: linear-gradient(#7affc8, #2aa07a); border-color: #bfffe8; }
#runbtn.off { opacity: .35; }
#autobtn.m2 { background: linear-gradient(#ff5ac8, #a02a8a); }
.potset { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; align-items: center; }
.potset input[type=number] { width: 48px; background: var(--panel2); border: 1px solid var(--line2); color: #fff; border-radius: 6px; padding: 2px 4px; }
.petopt { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 12px; }
.petopt .po { display: flex; gap: 6px; align-items: center; justify-content: space-between; background: rgba(0,0,0,.2); padding: 4px 8px; border-radius: 8px; }

/* มือถือ */
.touch #chatbox { top: 92px; bottom: auto; left: 6px; width: 270px; }
.touch #chatbox #log { height: 64px; font-size: 10.5px; pointer-events: none; background: rgba(8,22,24,.35); }
.touch #chattabs, .touch #chatrow { display: none; }
.touch #chatrow.show { display: flex; }
.touch #runbtn { display: none; }
.touch #t-run { right: 22px; bottom: 196px; } .touch #t-run.on { background: linear-gradient(#7affc8, #2aa07a); }
.touch #chatrow.show { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); width: min(86vw, 460px); z-index: 50; }
.touch #chatrow.show #chat { font-size: 16px; padding: 8px 14px; }
.touch #chatrow.show #chat { display: block; position: static; transform: none; }

.legal { margin: 14px 0 0; font-size: 12px; } .legal a { color: var(--dim); }

/* ---- ยูเนี่ยน / เทรด / ร้านค้า ---- */
#mountbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid #c890ff; background: rgba(160,80,255,.18); font-size: 18px; }
#mountbtn.on { background: linear-gradient(#d8a0ff, #7a2ad8); border-color: #f0d8ff; box-shadow: 0 0 12px #b050ff; }
#log .ch-union b { color: #ffb84a; }
.ulist { max-height: 300px; overflow-y: auto; margin-top: 8px; }
.urow { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-bottom: 1px solid rgba(255,255,255,.06); opacity: .65; }
.urow.on { opacity: 1; }
.urow .ur { width: 18px; text-align: center; } .urow .un { flex: 1; } .urow .ub { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.urow .ub button { font-size: 11px; padding: 3px 6px; }
button.danger { border-color: #ff7a7a !important; color: #ffb0b0; }
.trade { display: flex; gap: 8px; }
.tside { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 150px; }
.tside.locked { border-color: #ffd36a; box-shadow: inset 0 0 10px rgba(255,211,106,.25); }
.tside .th { font-size: 12px; margin-bottom: 4px; }
.tgrid { grid-template-columns: repeat(4, 40px) !important; min-height: 44px; }
.tgold { margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.tgold input { width: 110px; }
.sprice { width: 90px; } .sqty { width: 50px; }
.shoprow .btns { display: flex; gap: 3px; align-items: center; }
.touch .trade { flex-direction: column; }

/* ---- ล็อบบี้ / เลือกตัวละคร ---- */
#charlist { display: flex; flex-direction: column; gap: 8px; margin: 8px auto; max-width: 420px; }
.charcard { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line2); border-radius: 12px; background: rgba(255,255,255,.05); text-align: left; }
.charcard .ci { font-size: 26px; } .charcard .cn { flex: 1; }
.charcard .del { font-size: 18px; opacity: .7; } .charcard .del:hover { opacity: 1; }
.newchar { padding: 10px; border-radius: 12px; border: 1px dashed var(--line2); background: rgba(140,232,207,.08); color: #fff; font-size: 14px; cursor: pointer; }
#fsask { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(4,12,14,.72); align-items: center; justify-content: center; }
#fsask .panel { width: min(86vw, 340px); padding: 18px; border-radius: 16px; background: rgba(16,38,42,.96); border: 1px solid var(--line2); text-align: center; }
#fsask .fsicon { font-size: 40px; } #fsask .opts { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 10px; }

/* ---- มือถือ: จัดปุ่มใหม่ให้โล่งขึ้น (เมนูรวม ☰ + ปุ่มรอง ⋯) ---- */
.touch #bottom .row { display: none; }
.touch #t-top { right: 132px; }
.touch #t-top #t-menu { width: 44px; height: 40px; font-size: 22px; }
.touch #t-menu.flash { animation: flash 1s infinite; }
#t-drawer { display: none; }
.touch.t-menu #t-drawer { display: block; position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60;
  width: min(92vw, 420px); padding: 10px 12px 12px; border-radius: 16px; background: rgba(12,30,34,.96); border: 1px solid var(--line2); box-shadow: 0 8px 30px rgba(0,0,0,.5); }
#t-drawer .dh { text-align: center; font-weight: bold; margin-bottom: 8px; color: #bff; }
.touch #t-drawer #menubar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.touch #t-drawer #menubar button, .touch #t-drawer .dx button { width: auto; height: 58px; font-size: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: #fff; }
.touch #t-drawer button[data-label]::after { content: attr(data-label); font-size: 10.5px; color: #cfe; }
#t-drawer .dx { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
/* ปุ่มสกิลเรียงเป็นวงโค้งรอบปุ่มโจมตี เว้นระยะห่างกัน */
.touch #actions { width: 200px; height: 190px; }
.touch #t-hb0 { right: 135px; bottom: 25px; } .touch #t-hb1 { right: 117px; bottom: 85px; }
.touch #t-hb2 { right: 68px; bottom: 126px; } .touch #t-hb3 { right: 6px; bottom: 133px; }
.touch #t-auto { right: 198px; bottom: 74px; } .touch #t-pick { right: 160px; bottom: 150px; } .touch #t-more { right: 90px; bottom: 190px; font-size: 22px; }
/* ปุ่มรอง: ซ่อนไว้ กด ⋯ เพื่อแสดงเป็นแถวด้านล่าง */
.touch #t-hb4, .touch #t-hb5, .touch .act.extra { display: none; }
.touch.t-more #t-hb4, .touch.t-more #t-hb5, .touch.t-more .act.extra { display: block; }
.touch.t-more #t-more { background: rgba(140,232,207,.35); }
.touch #t-hb4 { right: 210px; bottom: 6px; width: 46px; height: 46px; } .touch #t-hb5 { right: 264px; bottom: 6px; width: 46px; height: 46px; }
.touch #t-target { right: 318px; bottom: 6px; } .touch #t-run { right: 372px; bottom: 6px; } .touch #t-mount { right: 426px; bottom: 6px; }
.touch #t-mount.on { background: linear-gradient(#d8a0ff, #7a2ad8); }
.touch #chatbox { width: 230px; } .touch #chatbox #log { height: 46px; opacity: .85; }

/* ---- ปาร์ตี้ / รายวัน / อันดับ / จดหมาย / คลัง / แอดมิน ---- */
#partyframe { display: none; position: fixed; left: 10px; top: 84px; width: 190px; z-index: 4; background: rgba(8,22,24,.72); border: 1px solid var(--line); border-radius: 10px; padding: 6px; font-size: 12px; }
#partyframe .pfh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; color: #bff; }
#partyframe button { font-size: 10px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line2); background: rgba(255,255,255,.08); color: #fff; }
.pfm { position: relative; margin: 3px 0; } .pfm.dead { opacity: .45; } .pfm.far span { opacity: .6; }
.pfm button { position: absolute; right: 0; top: 0; }
.pfb { height: 5px; background: #4a2020; border-radius: 3px; overflow: hidden; margin-top: 2px; } .pfb i { display: block; height: 100%; background: linear-gradient(90deg, #5ae05a, #9aff7a); }
.touch #partyframe { top: 160px; left: 6px; width: 150px; font-size: 10.5px; }
.lstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 6px 0; }
.lday { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.04); font-size: 10px; }
.lday.now { border-color: #ffd36a; box-shadow: 0 0 10px rgba(255,211,106,.4); } .lday.got { opacity: .45; }
.dq { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.06); } .dq > div { flex: 1; } .dq.claimed { opacity: .5; }
.ranklist { max-height: 340px; overflow-y: auto; }
.rk { display: flex; gap: 8px; align-items: baseline; padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,.05); } .rk .rn { width: 26px; } .rk.top b { color: #ffd36a; } .rk.me { background: rgba(140,232,207,.12); }
.mail { padding: 6px; border-bottom: 1px solid rgba(255,255,255,.06); cursor: pointer; } .mail.unread .mh b { color: #ffd36a; } .mail.unread .mh b::before { content: '● '; }
.mail .mb { margin: 6px 0; padding: 6px; background: rgba(255,255,255,.04); border-radius: 6px; white-space: pre-wrap; }
.mat { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 5px 0; } .mat .slot { width: 34px; height: 34px; }
.compose { display: flex; flex-direction: column; gap: 6px; } .compose textarea { resize: vertical; background: rgba(0,0,0,.3); color: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font: inherit; }
.admlist { max-height: 150px; overflow-y: auto; } .admlogs { max-height: 160px; overflow-y: auto; font-size: 11px; background: rgba(0,0,0,.25); border-radius: 6px; padding: 4px; margin-top: 4px; }
.warrow { padding: 3px 0; } .setrow { margin: 8px 0; display: flex; align-items: center; gap: 8px; } .setrow input[type=range] { flex: 1; }
.shoprow.locked { opacity: .55; }
#win-storage, #win-social, #win-daily, #win-rank, #win-craft { width: 410px; }
#win-storage .grid { grid-template-columns: repeat(8, 40px); overflow-x: hidden; max-height: 260px; }

#duelbar { display: none; position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 6px 12px; border-radius: 999px;
  background: rgba(120,20,20,.85); border: 1px solid #ff8a7a; color: #fff; font-size: 13px; box-shadow: 0 0 14px rgba(255,80,60,.5); }
#duelbar button { margin-left: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid #ffc0b0; background: rgba(255,255,255,.12); color: #fff; }
.touch #duelbar { top: 50px; font-size: 11px; }

.setbox { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; }
.setbox.on { border-color: #ffd36a; background: rgba(255,211,106,.08); box-shadow: inset 0 0 12px rgba(255,211,106,.12); } .setbox.on b { color: #ffd36a; }
.settip { margin-top: 5px; padding-top: 5px; border-top: 1px dashed rgba(255,255,255,.15); font-size: 12px; } .settip b { color: #ffd36a; }

#evbar { display: none; position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 5; padding: 4px 14px; border-radius: 999px; font-size: 12px; font-weight: bold;
  background: linear-gradient(90deg, rgba(120,20,40,.85), rgba(160,90,20,.85)); border: 1px solid #ffc080; color: #fff; box-shadow: 0 0 12px rgba(255,140,60,.4); }
.touch #evbar { top: 46px; font-size: 10.5px; }
#win-auction, #win-socket { width: 430px; }
