:root {
  --bg: #0b1226;
  --panel: #131c3a;
  --panel-2: #1b2650;
  --line: #4a4a5e;
  --gold: #b8975a;
  --gold-dim: #7d6a42;
  --gold-hi: #d9bd82;
  --text: #ebe9e1;
  --muted: #a0a8c2;
  --amber: #e6b44c;
  --mint: #58c9a0;
  --rose: #e0707a;
  --sky: #7aaeff;
  --font-head: "Mitr", "Noto Sans Thai", sans-serif;
  --font-body: "Noto Sans Thai", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 500; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .35rem .8rem;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--sky); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--amber); color: #2a2108; border-color: var(--amber); font-weight: 600; }
button:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

#app { max-width: 1100px; margin: 0 auto; padding: 1rem; }

/* หน้าล็อกอิน / เลือกอาชีพ */
.center { max-width: 520px; margin: 12vh auto 0; text-align: center; }
.center h1 { font-size: 2rem; }
.center p { color: var(--muted); }
.login-btn { display: inline-block; margin-top: 1rem; padding: .7rem 1.4rem; font-size: 1.05rem; text-decoration: none; color: #fff; background: #5865f2; border-radius: 8px; }
.login-or { margin: 1.2rem 0 .6rem; opacity: .7; }
.email-auth { max-width: 320px; margin: 0 auto; display: flex; flex-direction: column; gap: .55rem; padding: 1rem; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(255,255,255,.04); text-align: center; }
.email-auth h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.email-auth input { padding: .6rem .7rem; font-size: 1rem; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); color: inherit; font-family: inherit; }
.email-auth .hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.email-auth .captcha-row { display: flex; gap: .5rem; align-items: center; }
.email-auth .captcha-row input { flex: 1; min-width: 0; }
.email-auth .captcha-q { white-space: nowrap; font-weight: 600; padding: 0 .3rem; }
.email-auth .login-email-btn { margin-top: .2rem; border: 0; cursor: pointer; font-family: inherit; }
.email-auth .email-msg { color: #ff7b7b; min-height: 1.1em; font-size: .9rem; }
.email-auth .link-btn { background: none; border: 0; color: inherit; opacity: .8; text-decoration: underline; cursor: pointer; font-family: inherit; font-size: .9rem; }
.login-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.class-list { display: grid; gap: .6rem; text-align: left; margin-top: 1.2rem; }
.class-list button { padding: .7rem 1rem; text-align: left; }
.class-list b { font-family: var(--font-head); font-weight: 500; }
.class-list span { display: block; color: var(--muted); font-size: .9rem; }

/* หน้าเกม */
.topbar { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.topbar img { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line); }
.topbar .who { flex: 1; }
.topbar .who b { font-family: var(--font-head); font-weight: 500; font-size: 1.1rem; }
.topbar .who div { color: var(--muted); font-size: .9rem; }

.layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } }
/* หน้า "รายวัน": 2 คอลัมน์บนจอคอม (ซ้าย ~58% / ขวา ~42%) ฝั่งขวาสูงเท่าฝั่งซ้าย */
.daily-layout { width: 100%; max-width: 100%; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
.daily-left, .daily-right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.daily-left > .panel, .daily-right > .panel { margin: 0; }
@media (max-width: 768px) { .daily-layout { grid-template-columns: 1fr; } }
/* หน้า "รายวัน" แบบเรียงต่อกันคอลัมน์เดียว: ปฏิทิน แล้วตามด้วย Gift Code */
.daily-layout.daily-stack { grid-template-columns: minmax(0, 1fr); max-width: 760px; margin-left: auto; margin-right: auto; gap: 20px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }

.bar { margin: .5rem 0; }
.bar-label { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.bar-track { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; }
.bar-fill.exp { background: var(--amber); }
.bar-fill.stamina { background: var(--mint); }
.chip { margin: .5rem 0; padding: .35rem .7rem; border-radius: 6px; font-size: .85rem; border: 1px solid var(--line); }
.chip.on { border-color: var(--mint); color: var(--mint); }
.chip.off { border-color: var(--rose); color: #ffd3d7; }
.chip.dev { border-color: var(--amber); color: var(--amber); }
.chip a { color: var(--sky); }
.stat-row { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .6rem; font-size: .95rem; }
.stat-row b { color: var(--amber); font-weight: 600; }

.monster { display: flex; align-items: center; gap: .8rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.monster:first-of-type { border-top: 0; }
.monster .info { flex: 1; }
.monster > button.primary { white-space: nowrap; flex-shrink: 0; }
.monster .info div { color: var(--muted); font-size: .88rem; }
.win-good { color: var(--mint); }
.win-mid { color: var(--amber); }
.win-bad { color: var(--rose); }

.result { border-left: 4px solid var(--line); padding-left: .8rem; }
.result.win { border-color: var(--mint); }
.result.lose { border-color: var(--rose); }
.log { max-height: 220px; overflow: auto; margin: .6rem 0 0; padding: .6rem; background: var(--bg); border-radius: 6px; font-size: .82rem; color: var(--muted); list-style: none; }
.log li { margin-bottom: .3rem; }

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.slot { background: var(--bg); border: 1px dashed var(--line); border-radius: 6px; padding: .5rem; font-size: .9rem; min-height: 3.6rem; }
.slot small { display: block; color: var(--muted); }
.slot .broken { color: var(--rose); }

.item { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item .name { flex: 1; }
.item .name small { display: block; color: var(--muted); }
.tag-card { color: var(--sky); }
.empty { color: var(--muted); font-size: .92rem; }

.info { background: var(--panel-2); border: 1px solid var(--line); padding: .5rem .8rem; border-radius: 6px; margin-bottom: 1rem; }
.error { background: #3a1f2a; border: 1px solid var(--rose); color: #ffd3d7; padding: .5rem .8rem; border-radius: 6px; margin-bottom: 1rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ขั้นที่ 3: คราฟ / ตีบวก / ยา */
.muted { color: var(--muted); font-size: .85rem; margin: .2rem 0 .6rem; }
.potion-row { margin-bottom: .8rem; font-size: .92rem; }
.potion-row select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .25rem .5rem; }
.lock { color: var(--rose); font-family: var(--font-body); font-size: .8rem; }
.check { display: block; margin: .4rem 0 .8rem; font-size: .88rem; }
details.group { border-top: 1px solid var(--line); padding: .4rem 0; }
details.group summary { cursor: pointer; font-family: var(--font-head); font-size: .95rem; padding: .2rem 0; }
.recipe { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-top: 1px dashed var(--line); }
.recipe .info { flex: 1; font-size: .92rem; }
.recipe .info small { color: var(--muted); }
.ing { display: inline-block; margin: .15rem .5rem .15rem 0; font-size: .82rem; }
.ing.ok { color: var(--mint); }
.ing.lack { color: var(--rose); }

/* แผงแอดมิน */
.panel.admin { border-color: var(--amber); }
.admin-row { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin: .45rem 0; }
.admin-row label { width: 5.2rem; color: var(--muted); font-size: .88rem; }
.admin-row input, .admin-row select { font: inherit; font-size: .9rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .25rem .5rem; min-width: 0; }
.admin-row input[type=number] { width: 6rem; }
.admin-row input[type=text] { flex: 1; }

/* ตัวเลือกตั้งค่าบอทฟาร์ม */
.bot-opts { display: flex; flex-direction: column; gap: .4rem; margin: .5rem 0; }
.bot-opt { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .6rem; padding: .4rem .6rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.bot-opt-main { display: flex; align-items: center; gap: .45rem; flex: 1 1 14rem; font-size: .9rem; cursor: pointer; }
.bot-opt-main input { width: 1.05rem; height: 1.05rem; flex: none; }
.bot-opt-val { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .9rem; }
.bot-opt input[type=number], .bot-opt select { font: inherit; font-size: .9rem; color: var(--text); background: var(--panel, var(--bg)); border: 1px solid var(--line); border-radius: 6px; padding: .2rem .4rem; min-width: 0; }
.bot-opt input[type=number] { width: 4.2rem; }
.bot-opt select { max-width: 100%; }

/* เมนูหน้า (แท็บ) ข้างรูปโปรไฟล์ */
.topbar { flex-wrap: wrap; }
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; flex: 1; justify-content: flex-start; }
.tab { background: transparent; border: 1px solid transparent; border-bottom: 2px solid var(--line); border-radius: 6px 6px 0 0; padding: .45rem .9rem; font-family: var(--font-head); }
.tab:hover:not(:disabled) { border-color: var(--line); border-bottom-color: var(--sky); }
.tab.active { background: var(--panel-2); border-color: var(--line); border-bottom-color: var(--amber); color: var(--amber); }
@media (max-width: 700px) { .tabs { order: 3; flex-basis: 100%; } }
.strip { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .9rem; margin-bottom: 1rem; font-size: .92rem; color: var(--muted); }
.strip b { color: var(--amber); font-weight: 600; }
.repair-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-color: var(--rose); padding: .7rem 1rem; }

/* หน้าต่อสู้: แท็บแมพ, ค่าแนะนำ, โปรไฟล์มอนสเตอร์ */
.subtabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.subtab { border-radius: 999px; padding: .3rem .9rem; }
.subtab.active { background: var(--amber); color: #2a2108; border-color: var(--amber); font-weight: 600; }
.subtab.locked { color: var(--muted); border-style: dashed; }
.subtab.locked.active { color: #2a2108; }
.rec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .5rem 0; }
@media (max-width: 560px) { .rec-grid { grid-template-columns: 1fr; } }
.rec-cell { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; display: flex; flex-direction: column; }
.rec-cell small { color: var(--muted); font-size: .78rem; }
.rec-cell b { font-family: var(--font-head); font-weight: 500; font-size: 1.1rem; }
.rec-cell span { color: var(--muted); font-size: .8rem; }
.rec-cell.ok { border-color: var(--mint); }
.rec-cell.mid { border-color: var(--amber); }
.rec-cell.low { border-color: var(--rose); }
.monster.selected { background: var(--panel-2); border-radius: 8px; }
.monster .info { flex: 1; text-align: left; background: transparent; border: 0; padding: .3rem .5rem; color: inherit; border-radius: 8px; }
.monster .info:hover { background: var(--panel-2); }
.monster .info > div { color: var(--muted); font-size: .88rem; }
.monster .info .hint { color: var(--muted); opacity: .7; font-size: .75rem; }
.rec-line span.ok { color: var(--mint); }
.rec-line span.mid { color: var(--amber); }
.rec-line span.low { color: var(--rose); }
.profile-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.profile-head small { color: var(--muted); font-family: var(--font-body); font-size: .85rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .5rem; margin: .5rem 0; }
.stat { background: var(--bg); border-radius: 8px; padding: .4rem .6rem; display: flex; flex-direction: column; }
.stat small { color: var(--muted); font-size: .76rem; }
.advice { font-size: .88rem; color: var(--amber); margin: .2rem 0; }
.table-wrap { overflow-x: auto; }
table.drops { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.drops th, table.drops td { text-align: left; padding: .35rem .5rem; border-top: 1px solid var(--line); vertical-align: top; }
table.drops th { color: var(--muted); font-weight: 400; font-size: .78rem; border-top: 0; }
table.drops small { color: var(--mint); }
table.drops tr.card-row td:first-child { color: var(--sky); }
table.drops tr.rare-row td:nth-child(3) { color: var(--amber); }

/* HP */
.bar-fill.hp { background: var(--rose); }
.bar-fill.hp.low { background: #ff4d5e; box-shadow: 0 0 0 1px #ffb3ba inset; }
.hp-box { margin-bottom: .8rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }

/* ตลาดผู้เล่น */
.search { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .35rem .6rem; margin: .2rem 0 .6rem; }
table.grid-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid-table th, table.grid-table td { text-align: left; padding: .4rem .5rem; border-top: 1px solid var(--line); vertical-align: middle; }
table.grid-table th { color: var(--muted); font-weight: 400; font-size: .78rem; border-top: 0; }
table.grid-table tr.selected td { background: var(--panel-2); }
.linkbtn { background: transparent; border: 0; padding: 0; color: var(--sky); text-align: left; text-decoration: underline; cursor: pointer; }
.qty { width: 4.5rem; font: inherit; font-size: .88rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .2rem .4rem; margin-right: .3rem; }
.price { width: 7rem; font: inherit; font-size: .88rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .2rem .4rem; margin-right: .3rem; }
.sell-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.sell-row:first-of-type { border-top: 0; }
.sell-row .name { flex: 1; min-width: 12rem; }
.sell-row .name small { display: block; color: var(--muted); font-size: .8rem; }
.sell-inputs { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
/* หน้ากระเป๋า: ชื่อไอเท็มไม่ถูกบีบ, ช่องจำนวนกะทัดรัด, ราคา 2 บรรทัดซ้อนกัน */
.item { flex-wrap: nowrap; gap: .4rem; }
.item .name { min-width: 0; }
.item .sell-inputs { flex-wrap: nowrap; flex-shrink: 0; margin-left: auto; gap: .25rem; }
.item .sell-inputs .qty { width: 3.4rem; margin-right: 0; padding: .2rem .25rem; text-align: center; color: #fff; }
.item button { white-space: nowrap; flex-shrink: 0; padding-left: .5rem; padding-right: .5rem; }
.sell-price { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; line-height: 1.1; white-space: nowrap; color: var(--muted); font-size: .68rem; min-width: 4.6rem; margin-left: .2rem; }

/* สเตตัส */
.points { font-family: var(--font-body); font-size: .85rem; color: var(--muted); }
.points.has { color: var(--amber); font-weight: 600; }
table.stat-table button { padding: .15rem .6rem; margin-right: .25rem; }
table.stat-table td small { color: var(--muted); }
table.stat-table td:first-child, table.stat-table th:first-child { white-space: nowrap; width: 1%; }

/* ขั้นที่ 6: การ์ดและธาตุ */
.el { display: inline-block; padding: 0 .45rem; border-radius: 999px; font-size: .74rem; border: 1px solid var(--line); background: var(--bg); vertical-align: middle; }
.el-neutral { color: var(--muted); }
.el-water { color: #6cc8ff; border-color: #2f6f99; }
.el-fire { color: #ff8a5c; border-color: #9a4a2c; }
.el-earth { color: #c9a66b; border-color: #7a6238; }
.el-wind { color: #7be0b0; border-color: #2f7a58; }
.el-dark { color: #b49cff; border-color: #5b4a99; }
.el-holy { color: #ffe27a; border-color: #8a7a2c; }
.mult { font-size: .8rem; }
.mult.good { color: var(--mint); }
.mult.bad { color: var(--rose); }
td.mult { font-size: inherit; }
.socket-item { padding: .6rem 0; border-top: 1px solid var(--line); }
.socket-item:first-of-type { border-top: 0; }
.sockets { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .4rem; margin: .4rem 0; }
.socket { background: var(--bg); border-radius: 6px; padding: .4rem .55rem; font-size: .88rem; }
.socket small { display: block; color: var(--muted); }
.socket.empty { border: 1px dashed var(--line); color: var(--muted); }
.socket.filled { border: 1px solid var(--sky); }
.socket-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .3rem; }
.socket-form select { flex: 1; min-width: 12rem; font: inherit; font-size: .88rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .3rem .5rem; }
.slot .tag-card { font-size: .8rem; }

/* ขั้นที่ 7: ดันเจี้ยนและเซ็ตบอส */
.dungeon { padding: .8rem 0; border-top: 1px solid var(--line); display: grid; gap: .45rem; }
.dungeon:first-of-type { border-top: 0; }
.floors { display: grid; gap: .25rem; }
.floor { background: var(--bg); border-radius: 6px; padding: .35rem .6rem; font-size: .9rem; }
.floor.boss { border: 1px solid var(--amber); }
.set-item { padding: .6rem 0; border-top: 1px solid var(--line); }
.set-item:first-of-type { border-top: 0; }
.set-pieces { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; margin: .4rem 0; }
.piece { display: flex; align-items: center; gap: .4rem; min-width: 0; font-size: .8rem; padding: .35rem .45rem; border-radius: 8px; border: 2px dashed var(--line); color: var(--muted); background: rgba(0,0,0,.15); }
.piece img, .piece .ico-img, .piece .ico, .piece canvas { width: 26px; height: 26px; flex: 0 0 26px; object-fit: contain; }
.piece-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.piece-txt b { overflow-wrap: anywhere; font-weight: 600; }
.piece-txt small { opacity: .75; }
.piece:not(.own):not(.on) img { filter: grayscale(1) opacity(.55); }
.piece.own { border-style: solid; border-color: var(--line); color: var(--text); }
.piece.on { border-style: solid; border-color: var(--mint); color: var(--mint); background: rgba(80,220,170,.08); }
@media (max-width: 720px) { .set-pieces { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pet-guide-btn { margin-left: .5rem; }
.pet-guide-box { max-width: 460px; }
.pet-guide-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: .3rem; }
.pet-guide-table th, .pet-guide-table td { padding: .25rem .4rem; text-align: left; border-bottom: 1px solid var(--line); }
.pet-guide-tips { margin: .3rem 0 0; padding-left: 1.2rem; font-size: .85rem; }
.set-bonus { font-size: .88rem; color: var(--muted); }
.set-bonus.active { color: var(--mint); }
.set-line { margin-top: .5rem; font-size: .85rem; color: var(--mint); }

/* เควส & ชื่อเสียง */
.fame-big { font-size: 1.6rem; margin: .2rem 0; }
.quest.dim, tr.dim { opacity: .6; }
.rank { color: var(--amber); }

/* กิลด์ */
.guild-notice { background: var(--bg); border-left: 3px solid var(--amber); border-radius: 6px; padding: .5rem .7rem; margin: .5rem 0; white-space: pre-wrap; }
.guild-textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: .9rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .5rem; margin-top: .4rem; resize: vertical; }
.role-leader { color: var(--amber); }
.role-officer { color: var(--sky); }
.role-member { color: var(--muted); font-weight: 400; }

/* ---------- แชทรวม (กล่องลอยมุมขวาล่าง) ---------- */
[hidden] { display: none !important; }
.chat { position: fixed; right: 1rem; bottom: 1rem; width: min(360px, calc(100vw - 2rem)); z-index: 50;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.chat-head { width: 100%; text-align: left; border: 0; border-radius: 10px 10px 0 0; font-family: var(--font-head); background: var(--panel-2); }
.chat.closed .chat-head { border-radius: 10px; }
.chat.closed .chat-body { display: none; }
.chat-badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .3rem; border-radius: 1em; background: var(--rose); color: #fff; font-size: .8rem; text-align: center; }
.chat-list { list-style: none; margin: 0; padding: .5rem .7rem; height: 260px; overflow-y: auto; font-size: .88rem; }
.chat-msg { margin-bottom: .3rem; overflow-wrap: anywhere; }
.chat-time { color: var(--muted); font-size: .75rem; }
.chat-msg .title-badge { margin-right: .25rem; padding: 0 .4rem; font-size: 11px; line-height: 1.4; box-shadow: none; }
@media (max-width: 600px) { .chat-msg .title-badge { font-size: 11px; padding: 0 .3rem; margin-right: .2rem; } }
.chat-chat b { color: var(--sky); font-weight: 600; }
.chat-system { color: var(--amber); }
.chat-msg.chat-notify { color: #7be0b0; background: rgba(240, 200, 90, .1); border-left: 3px solid var(--gold-hi, #f0c85a); padding: .15rem .4rem; border-radius: 4px; }
.chat-notify b { color: var(--gold-hi, #f0c85a); font-weight: 600; }
.chat-announce b, .chat-msg.chat-announce { color: var(--rose); font-weight: 600; }
.chat-error { color: var(--rose); font-size: .8rem; }
.chat-msg.chat-whisper { color: #e6c8ff; background: rgba(190, 130, 255, .14); border-left: 3px solid #c58bff; padding: .15rem .4rem; border-radius: 4px; }
.chat-whisper b { color: #f0a8ff; cursor: pointer; }
.chat-msg.chat-mention { background: rgba(240, 200, 90, .18); border: 1px solid var(--gold-hi, #f0c85a); padding: .15rem .4rem; border-radius: 4px; }
.chat-name { cursor: pointer; }
.chat-name:hover { text-decoration: underline; }
.chat-profile { cursor: pointer; font-size: .75rem; opacity: .7; }
.chat-form { display: flex; gap: .4rem; padding: .5rem .7rem .7rem; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .3rem .5rem; }
label.chat-announce { display: block; padding: .3rem .7rem 0; font-size: .82rem; color: var(--rose); font-weight: 400; }
#app { padding-bottom: 4rem; }

/* ไอคอน SVG แนวแฟนตาซี */
.ico { display: inline-flex; vertical-align: -.18em; margin-right: .35em; line-height: 1; }
.ico svg { width: 1.15em; height: 1.15em; }
.ico-img { width: 1.8em; height: 1.8em; object-fit: contain; vertical-align: -.5em; margin-right: .35em; }
.ico-img-lg { width: 40px; height: 40px; margin-right: .4em; vertical-align: middle; }
.slot-item { display: flex; align-items: center; margin: .2rem 0; }
.ico-tab, .ico-slot, .ico-equipment { color: var(--amber); }
.ico-stat { color: var(--sky); }
.ico-material { color: #b08968; }
.ico-potion { color: var(--rose); }
.ico-card { color: var(--sky); }
.tab.active .ico { color: inherit; }

/* ---------- ธีมแฟนตาซี: น้ำเงินเข้ม + ขอบทองหม่น ---------- */
html { scroll-behavior: smooth; }
.chat-list { scroll-behavior: smooth; overscroll-behavior: contain; }
body {
  background:
    radial-gradient(ellipse at 50% -10%, #1c2a5a 0%, transparent 55%),
    radial-gradient(ellipse at 50% 120%, #0a0f20 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { color: var(--gold-hi); text-shadow: 0 1px 2px rgba(0,0,0,.6); letter-spacing: .02em; }

/* การ์ด/แผง: ขอบทองหม่น เงาและมิติ */
.panel, .strip, .chat {
  background: linear-gradient(180deg, #17224a 0%, var(--panel) 40%, #0f1731 100%);
  border: 1px solid var(--gold-dim);
  box-shadow:
    0 6px 18px rgba(0,0,0,.45),
    0 1px 0 rgba(217,189,130,.18) inset,
    0 0 0 1px rgba(0,0,0,.5);
}
.panel { border-radius: 10px; }
.panel.admin { border-color: var(--amber); }
.info {
  background: linear-gradient(180deg, var(--panel-2), #151f42);
  border-color: var(--gold-dim);
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.rec-cell, .stat, .slot, .socket, .floor {
  background: linear-gradient(180deg, #0a1022, #0e1630);
  box-shadow: 0 1px 4px rgba(0,0,0,.5) inset;
  border: 1px solid rgba(125,106,66,.45);
}
.slot, .socket.empty { border-style: dashed; }
.floor.boss, .socket.filled { box-shadow: 0 0 8px rgba(230,180,76,.25), 0 1px 4px rgba(0,0,0,.5) inset; }
.socket.filled { border-color: var(--sky); }
.rec-cell.ok { border-color: var(--mint); }
.rec-cell.mid { border-color: var(--amber); }
.rec-cell.low { border-color: var(--rose); }
.floor.boss { border-color: var(--amber); }
.log, .bar-track { background: #070c1b; box-shadow: 0 2px 5px rgba(0,0,0,.6) inset; }
.bar-track { border: 1px solid rgba(125,106,66,.5); }
.bar-fill.exp { background: linear-gradient(180deg, #f6d27a, #c58f27); }
.bar-fill.stamina { background: linear-gradient(180deg, #7fe0bb, #2f9e78); }
.bar-fill.hp { background: linear-gradient(180deg, #f08a92, #b8434e); }
.bar-fill.hp.low { background: linear-gradient(180deg, #ff6b7a, #d12a3c); }

.topbar img { border: 2px solid var(--gold); box-shadow: 0 0 0 2px #0b1226, 0 0 10px rgba(184,151,90,.4); }
.monster, .item, .recipe, .dungeon, .set-item, .socket-item, .sell-row, .hp-box,
table.drops th, table.drops td, table.grid-table th, table.grid-table td, details.group {
  border-color: rgba(125,106,66,.35);
}
.monster.selected { box-shadow: 0 0 0 1px var(--gold-dim) inset; }

/* ปุ่มสไตล์เกมแฟนตาซี */
button {
  color: var(--gold-hi);
  background: linear-gradient(180deg, #2a3a74 0%, #1a2652 55%, #131c3d 100%);
  border: 1px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 2px 0 #070b18, 0 3px 6px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.18) inset;
  text-shadow: 0 1px 1px rgba(0,0,0,.7);
  transition: filter .12s, transform .08s, box-shadow .12s;
}
button:hover:not(:disabled) {
  border-color: var(--gold-hi);
  filter: brightness(1.2);
  box-shadow: 0 2px 0 #070b18, 0 0 10px rgba(217,189,130,.35), 0 1px 0 rgba(255,255,255,.2) inset;
}
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 #070b18, 0 1px 3px rgba(0,0,0,.6) inset; }
button:disabled { filter: grayscale(.6); border-color: var(--gold-dim); }
button.primary {
  background: linear-gradient(180deg, #f4d584 0%, #d9a73a 50%, #a97a1f 100%);
  color: #2a1c04; border-color: #f0d08a;
  text-shadow: 0 1px 0 rgba(255,235,180,.6);
  box-shadow: 0 2px 0 #5a3f0c, 0 3px 8px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.5) inset;
}
button.primary:hover:not(:disabled) { box-shadow: 0 2px 0 #5a3f0c, 0 0 12px rgba(240,184,74,.55), 0 1px 0 rgba(255,255,255,.5) inset; }
button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.linkbtn, .monster .info, .chat-head.linkbtn { background: transparent; border: 0; box-shadow: none; text-shadow: none; }
.linkbtn { color: var(--sky); }
.monster .info { color: inherit; }
.monster .info:hover { background: var(--panel-2); filter: none; box-shadow: none; }
.monster .info:active { transform: none; }
.chat-head { background: linear-gradient(180deg, #24336a, #141d40); color: var(--gold-hi); }

/* แท็บ */
.tab { background: transparent; border: 1px solid transparent; border-bottom: 2px solid var(--gold-dim); box-shadow: none; color: var(--text); }
.tab:hover:not(:disabled) { border-color: var(--gold-dim); border-bottom-color: var(--gold-hi); filter: none; box-shadow: none; }
.tab.active {
  background: linear-gradient(180deg, #24336a, #17224a);
  border-color: var(--gold); border-bottom-color: var(--amber); color: var(--amber);
  box-shadow: 0 -2px 8px rgba(230,180,76,.15) inset;
}
.tab:active:not(:disabled) { transform: none; }
.subtab { border-radius: 999px; }
.subtab.active { background: linear-gradient(180deg, #f4d584, #c58f27); color: #2a1c04; border-color: #f0d08a; }
.subtab.locked { color: var(--muted); border-style: dashed; }
.subtab.locked.active { color: #2a1c04; }

/* ช่องกรอก */
input, select, textarea, .search, .qty, .price, .guild-textarea, .inv-search {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff;
  background: #0f1d4d !important;
  border-color: var(--gold-hi) !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.55) inset;
  color-scheme: dark;
}
input::placeholder, textarea::placeholder { color: #aab4d6 !important; -webkit-text-fill-color: #aab4d6; opacity: 1; }
select option { color: #ffffff; background: #0f1d4d; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.guild-notice { box-shadow: 0 1px 4px rgba(0,0,0,.5) inset; border-left-color: var(--gold); }
.stat-row b, .strip b { color: var(--gold-hi); }
.chat { box-shadow: 0 8px 28px rgba(0,0,0,.6), 0 1px 0 rgba(217,189,130,.18) inset; }

/* จัดระเบียบ Header + เมนูหลัก: เมนูเรียง 2 แถว เต็มความกว้างเท่ากัน */
.topbar .tabs { order: 3; flex: 1 1 100%; gap: .3rem; justify-content: stretch; }
.topbar .tabs .tab {
  flex: 1 1 calc(100% / 7 - .3rem); min-width: 0;
  padding: .4rem .3rem; font-size: .85rem; line-height: 1.2;
  text-align: center; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere;
  border-radius: 6px;
}
.topbar .tabs .tab .ico { margin-right: .25em; }
.topbar .who .logout-btn { margin-top: .3rem; padding: .15rem .6rem; font-size: .78rem; }
@media (max-width: 700px) {
  .topbar .tabs .tab { flex-basis: calc(25% - .3rem); font-size: .78rem; padding: .4rem .15rem; }
}
@media (max-width: 380px) {
  .topbar .tabs .tab { flex-basis: calc(100% / 3 - .3rem); }
}

/* ---------- รูปมอนสเตอร์ / บอส / การ์ด ---------- */
.portrait { object-fit: contain; flex: none; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 8px; }
.portrait-48 { width: 48px; height: 48px; }
.portrait-96 { width: 96px; height: 96px; }
.portrait-128 { width: 128px; height: 128px; }
.portrait-boss { border-color: var(--gold); }
.profile-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.profile-title { flex: 1; min-width: 180px; }
.boss-banner, .dungeon > .arena { margin: .5rem auto; }
/* กล่องฉากหลังต่อสู้: รูปจาก --arena-bg + เงามืด rgba(0,0,0,.35) ทับ ให้รูปมอน/บอสเด่น */
.arena { position: relative; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: .4rem; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--arena-bg) center / cover no-repeat; }
.arena::before { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.35); pointer-events: none; }
.arena > * { position: relative; filter: drop-shadow(0 3px 5px rgba(0,0,0,.6)); }
.arena .portrait { background: transparent; border: 0; margin: 0 auto; }
.arena-sm { padding: .2rem; }
.arena-wide { width: 100%; max-width: 560px; min-height: 180px; padding: .8rem; }
@media (max-width: 600px) { .arena-wide { min-height: 150px; } .arena-wide .portrait-128 { width: 104px; height: 104px; } }
.floor { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.card-cell { display: flex; flex-direction: column; gap: .3rem; }
.card-cell.dim .card-frame { opacity: .55; filter: grayscale(.5); }
/* การ์ดใบเล็กในหน้า "การ์ดทั้งหมด" + หน้าต่างขยาย */
.card-grid-sm { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; }
.card-cell-click { cursor: pointer; outline: none; }
.card-mini { --rc: #9aa0b4; display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .5rem .4rem; text-align: center;
  background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 2px solid var(--rc); border-radius: 10px;
  transition: transform .15s, box-shadow .15s; }
.card-cell-click:hover .card-mini, .card-cell-click:focus-visible .card-mini { transform: translateY(-3px) scale(1.03); box-shadow: 0 0 14px color-mix(in srgb, var(--rc) 70%, transparent), 0 6px 14px rgba(0,0,0,.45); }
.card-cell.dim .card-mini { opacity: .55; filter: grayscale(.5); }
.card-mini-art { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; max-height: 88px; }
.card-mini-art .portrait { width: 100%; height: 100%; border: 0; background: transparent; object-fit: contain; }
.card-mini-name { font-size: .82rem; font-weight: 600; color: #fff; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-mini-have { font-size: .72rem; color: var(--muted); }
.card-mini-have.own { color: var(--rc); filter: brightness(1.25); font-weight: 600; }
@media (max-width: 640px) { .card-grid-sm { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 8px; } .card-mini-name { font-size: .72rem; } }
.card-preview-backdrop { animation: cpFade .18s ease-out; }
.card-preview { display: flex; gap: 1.2rem; align-items: center; max-width: 640px; max-height: 92vh; overflow: auto; padding: 1.2rem;
  background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 2px solid var(--gold-dim); border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.7); animation: cpPop .22s cubic-bezier(.2,.9,.3,1.2); }
.card-preview-frame { flex: 0 0 min(300px, 42vw); }
.card-preview-detail { flex: 1; display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.card-preview-name { --rc: #fff; font-size: 1.3rem; color: var(--rc); font-family: var(--font-head); }
.card-preview-row { display: flex; flex-direction: column; gap: .1rem; }
.card-preview-row b.rarity-common, .card-preview-row b.rarity-uncommon, .card-preview-row b.rarity-rare, .card-preview-row b.rarity-epic, .card-preview-row b.rarity-legendary { color: var(--rc); filter: brightness(1.25); }
.card-preview-close { margin-top: .4rem; align-self: flex-start; }
@media (max-width: 560px) { .card-preview { flex-direction: column; } .card-preview-frame { flex-basis: auto; width: min(260px, 70vw); } .card-preview-close { align-self: stretch; } }
@keyframes cpFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cpPop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* พื้นหลัง card_bg.png (อัตราส่วน 2:3) — ตำแหน่งช่องเป็น % ของรูป */
.card-frame { --rc: #9aa0b4; position: relative; width: 100%; aspect-ratio: 2 / 3; container-type: inline-size;
  background: url('/images/card_bg.png') center / 100% 100% no-repeat; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--rc) 55%, transparent)); }
.card-frame .card-art { position: absolute; left: 8%; right: 8%; top: 5.5%; height: 53.5%; display: flex; align-items: center; justify-content: center; }
.card-frame .portrait { width: 88%; height: 88%; border: 0; background: transparent; border-radius: 0; }
.card-name { position: absolute; left: 13%; right: 13%; top: 60.2%; height: 6.9%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 600; font-size: 7.5cqw; line-height: 1; color: #fff; text-align: center; white-space: nowrap; overflow: hidden;
  text-shadow: 0 0 6px var(--rc), 0 1px 2px #000; }
.card-info { position: absolute; left: 9%; right: 9%; top: 69.5%; height: 23.5%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5cqw; text-align: center; overflow: hidden; }
.card-info small { font-size: 5.6cqw; line-height: 1.25; }
.card-rarity { color: var(--rc); letter-spacing: .03em; font-weight: 600; filter: brightness(1.25); }
.card-text { color: #dfe4f5; }
.card-have { color: #fff; }
.rarity-common { --rc: #a9afbf; }
.rarity-uncommon { --rc: #58c9a0; }
.rarity-rare { --rc: #7aaeff; }
.rarity-epic { --rc: #b983ff; }
.rarity-legendary { --rc: #f0b840; box-shadow: 0 0 16px color-mix(in srgb, var(--rc) 70%, transparent), inset 0 0 0 1px rgba(255,255,255,.15); }
@media (max-width: 480px) { .portrait-128 { width: 96px; height: 96px; } }


/* ---------- เอฟเฟกต์คราฟ/ตีบวก (fx.js) ---------- */
.topbar { position: relative; }
.mute-btn { position: absolute; top: .4rem; right: .4rem; padding: .15rem .5rem; font-size: 1rem; line-height: 1.2; }
.fx-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: rgba(5,8,20,.75); cursor: pointer; }
.fx-overlay.fx-flash::before { content: ''; position: absolute; inset: 0; background: #f33; animation: fx-flash .6s ease-out forwards; pointer-events: none; }
.fx-box { position: relative; min-width: 260px; max-width: 90vw; padding: 2rem 2.5rem; text-align: center; border-radius: 14px; background: #121a33; border: 2px solid var(--line, #445); }
.fx-item { display: inline-block; }
.fx-item img, .fx-item svg { width: 96px; height: 96px; }
.fx-msg { margin-top: 1rem; font-family: var(--font-head, inherit); font-size: 1.2rem; }
.fx-working .fx-item { animation: fx-shake .1s linear infinite; }
.fx-sparks { position: absolute; left: 50%; top: 4.5rem; width: 0; height: 0; }
.fx-sparks i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #ffb84d; box-shadow: 0 0 8px #ff8a00; opacity: 0; animation: fx-spark .4s ease-out infinite; }
.fx-success { border-color: #ffd700; box-shadow: 0 0 40px 10px rgba(255,215,0,.6), inset 0 0 30px rgba(255,215,0,.3); animation: fx-glow 1s ease-in-out infinite alternate; }
.fx-success .fx-msg { color: #ffd700; }
.fx-success .fx-item { animation: fx-pop .5s ease-out; }
.fx-drop { border-color: #ff8c1a; box-shadow: 0 0 20px rgba(255,140,26,.5); animation: fx-shake .12s linear 4; }
.fx-drop .fx-msg { color: #ff8c1a; }
.fx-break { border-color: #e02020; box-shadow: 0 0 30px rgba(224,32,32,.7); }
.fx-break .fx-msg { color: #ff5555; }
.fx-break .fx-item { animation: fx-shatter .8s ease-in forwards; }
.fx-screenshake { animation: fx-bigshake .6s linear; }
@keyframes fx-shake { 0% { transform: translate(0,0) rotate(0); } 25% { transform: translate(-3px,2px) rotate(-3deg); } 50% { transform: translate(3px,-2px) rotate(3deg); } 75% { transform: translate(-2px,-2px) rotate(-2deg); } 100% { transform: translate(0,0); } }
@keyframes fx-bigshake { 0%,100% { transform: translate(0,0); } 10% { transform: translate(-14px,8px); } 30% { transform: translate(12px,-10px); } 50% { transform: translate(-10px,-8px); } 70% { transform: translate(10px,10px); } 90% { transform: translate(-6px,4px); } }
@keyframes fx-spark { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0); } 100% { opacity: 0; transform: rotate(var(--a)) translateY(-70px); } }
@keyframes fx-glow { from { box-shadow: 0 0 25px 5px rgba(255,215,0,.5); } to { box-shadow: 0 0 60px 18px rgba(255,215,0,.8); } }
@keyframes fx-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes fx-flash { 0% { opacity: .85; } 100% { opacity: 0; } }
@keyframes fx-shatter { 0% { transform: scale(1); filter: none; opacity: 1; } 30% { transform: scale(1.15) rotate(4deg); filter: brightness(2); } 100% { transform: scale(1.6) rotate(-12deg); filter: blur(6px); opacity: 0; } }

/* เอฟเฟกต์ต่อสู้ / เลเวลอัป */
.fx-float { position: fixed; top: 45%; z-index: 9998; transform: translateX(-50%); font-family: var(--font-head, inherit); font-size: 2rem; font-weight: 700; pointer-events: none; text-shadow: 0 2px 4px #000; animation: fx-rise 1.2s ease-out forwards; }
.fx-dmg { color: #fff; }
.fx-crit { color: #ffd700; font-size: 2.8rem; text-shadow: 0 0 12px #ff8a00, 0 2px 4px #000; }
.fx-hurt { color: #ff5555; }
.fx-levelup { position: fixed; left: 50%; top: 40%; z-index: 10000; transform: translate(-50%, 0); font-family: var(--font-head, inherit); font-size: clamp(2.5rem, 10vw, 5rem); font-weight: 700; color: #ffd700; text-shadow: 0 0 20px #ff8a00, 0 0 40px #ffb84d, 0 3px 6px #000; pointer-events: none; animation: fx-lvl 2s ease-out forwards; white-space: nowrap; }
@keyframes fx-rise { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -80px) scale(1); } }
@keyframes fx-lvl { 0% { opacity: 0; transform: translate(-50%, 40px) scale(.5); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } 70% { opacity: 1; transform: translate(-50%, -30px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -90px) scale(1); } }

/* แผงควบคุมเสียง */
.audio-panel { position: absolute; top: .4rem; right: .4rem; display: flex; align-items: center; gap: .25rem; }
.audio-panel .mute-btn { position: static; }
.audio-panel .mute-btn.off { opacity: .45; filter: grayscale(1); }
.vol-slider { width: 56px; height: 4px; cursor: pointer; }
@media (max-width: 520px) { .vol-slider { width: 40px; } }
.topbar img.ico-menu-img, .ico-menu-img { width: 24px; height: 24px; border: 0; border-radius: 0; background: none; box-shadow: none; object-fit: contain; vertical-align: -.45em; margin-right: .2em; }

/* ป้ายสถานะเซิร์ฟเวอร์ */
.server-badge { position: relative; margin-right: .3rem; }
.server-badge .sb-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .15rem .6rem; font-size: .78rem; }
.server-badge .sb-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 6px #3ddc84; animation: sb-pulse 2s ease-in-out infinite; }
@keyframes sb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.server-badge .sb-popup { position: absolute; right: 0; top: 100%; z-index: 50; min-width: 11rem; max-height: 16rem; overflow-y: auto; margin-top: .25rem; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: #1b1f2a; font-size: .8rem; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.server-badge .sb-popup[hidden] { display: none; }
.sb-popup .sp-row { display: flex; justify-content: space-between; gap: 1rem; padding: .15rem 0; }
.sb-popup .sp-empty { opacity: .7; }

/* ---------- Combat VFX (fx.js) ---------- */
.vfx { position: fixed; z-index: 9990; pointer-events: none; }
.vfx-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.vfx-slash { stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; animation: vfx-slash .35s ease-out forwards; }
@keyframes vfx-slash { 0% { stroke-dashoffset: 1; opacity: 1; } 60% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
.vfx-ghost { z-index: 9989; }
.vfx-ghost img { width: 100%; height: 100%; object-fit: contain; animation: vfx-flashred .5s linear forwards; }
.vfx-ghost.vfx-shake img { animation: vfx-flashred .5s linear forwards, fx-shake .08s linear 5; }
.vfx-ghost.vfx-shake-hard img { animation: vfx-flashred .5s linear forwards, fx-bigshake .4s linear; }
@keyframes vfx-flashred { 0% { filter: sepia(1) saturate(8) hue-rotate(-40deg) brightness(1.3); opacity: .9; } 100% { filter: none; opacity: 0; } }
.vfx-burst { transform-origin: 50px 50px; animation: vfx-burst .6s ease-out forwards; }
@keyframes vfx-burst { 0% { transform: scale(.2) rotate(0); opacity: 1; } 60% { transform: scale(1.1) rotate(25deg); opacity: 1; } 100% { transform: scale(1.4) rotate(40deg); opacity: 0; } }
.vfx-hit-crit { filter: drop-shadow(0 0 10px #ff8a00); }
.vfx-num { position: fixed; z-index: 9995; transform: translateX(-50%); pointer-events: none; font-family: var(--font-head, inherit); font-weight: 700; white-space: nowrap; text-shadow: 0 2px 4px #000; animation: fx-rise 1.2s ease-out forwards; }
.vfx-dmg { color: #fff; font-size: 2rem; }
.vfx-crit { color: #ffd700; font-size: 3.2rem; text-shadow: 0 0 14px #ff8a00, 0 0 4px #f00, 0 2px 4px #000; }
.vfx-crit-label { color: #ff4a2a; font-size: 1.3rem; letter-spacing: .15em; text-shadow: 0 0 10px #ffd700, 0 2px 4px #000; }
.vfx-hurt { color: #ff4a4a; font-size: 2rem; }
.vfx-miss { color: #cfd6e6; font-size: 1.6rem; font-style: italic; animation: vfx-miss 1s ease-out forwards; }
@keyframes vfx-miss { 0% { opacity: 0; transform: translate(-50%, 0); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(40px, -30px) rotate(10deg); } }
.vfx-claw-box { z-index: 9992; border-radius: 8px; animation: vfx-redflash .8s ease-out forwards; }
@keyframes vfx-redflash { 0% { box-shadow: 0 0 0 3px #ff2a2a, inset 0 0 30px rgba(255,0,0,.6); background: rgba(255,0,0,.18); } 30% { box-shadow: 0 0 0 3px #ff2a2a, inset 0 0 30px rgba(255,0,0,.6); background: rgba(255,0,0,.05); } 50% { background: rgba(255,0,0,.18); } 100% { box-shadow: 0 0 0 0 transparent; background: transparent; } }
.vfx-dissolve img { width: 100%; height: 100%; object-fit: contain; animation: vfx-dissolve 1.3s ease-in forwards; }
@keyframes vfx-dissolve { 0% { opacity: 1; filter: none; transform: scale(1); } 100% { opacity: 0; filter: blur(8px) brightness(2); transform: scale(1.15) translateY(-12px); } }
.vfx-victory { z-index: 9993; animation: vfx-vic 1.6s ease-out forwards; }
.vfx-swords { transform-origin: 50px 40px; animation: vfx-swords .5s ease-out; }
@keyframes vfx-swords { 0% { transform: scale(.3) rotate(-30deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.vfx-victory-text { position: absolute; bottom: 4%; left: 0; right: 0; text-align: center; font-family: var(--font-head, inherit); font-size: 1.6rem; font-weight: 700; color: #ffd700; text-shadow: 0 0 12px #ff8a00, 0 2px 4px #000; }
@keyframes vfx-vic { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .vfx-ghost img, .vfx-burst { animation-duration: .01s; } .fx-screenshake { animation: none; } }

/* แถบประกาศเซิร์ฟเวอร์ (Announcement Ticker) */
.ticker { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; padding: .45rem .8rem; border-radius: 8px; border: 2px solid #8a6d3b; background: linear-gradient(180deg, #3b2a14, #24180a); color: #f3e2b3; box-shadow: inset 0 0 0 1px rgba(255, 215, 128, .25), 0 2px 6px rgba(0, 0, 0, .35); }
.ticker-icon { flex: none; font-size: 1.1rem; }
.ticker-track { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.ticker-text { display: inline-block; padding-left: 100%; font-weight: 600; animation: ticker-scroll 20s linear infinite; }
.ticker:hover .ticker-text { animation-play-state: paused; }
.ticker-event { border-color: #e0b341; background: linear-gradient(180deg, #5a4210, #3a2a08); color: #ffe9a3; }
.ticker-alert { border-color: #d24a4a; background: linear-gradient(180deg, #5a1616, #3a0c0c); color: #ffd0d0; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .ticker-text { animation: none; padding-left: 0; white-space: normal; } .ticker-track { white-space: normal; } }

/* ---------- ป้ายฉายาพิเศษ (Special Titles) ---------- */
.title-badge { display: inline-block; margin-right: .4rem; padding: .02rem .6rem; border-radius: 999px; border: 1px solid; font-size: .76rem; font-weight: 600; line-height: 1.5; vertical-align: middle; white-space: nowrap; }
.title-badge.tb-event { color: #e6dcff; border-color: #9b7cff; background: linear-gradient(135deg, #5b3fd0, #2f86d6); box-shadow: 0 0 8px rgba(122,150,255,.55); }
.title-badge.tb-achievement { color: #dcfff0; border-color: #58c9a0; background: linear-gradient(135deg, #1f8f6a, #2a7fc0); box-shadow: 0 0 7px rgba(88,201,160,.45); }
.title-badge.tb-legendary { color: #3a2400; border-color: #ffe08a; background: linear-gradient(110deg, #ffd45a, #fff0b0, #ff9ad5, #8fd4ff, #ffd45a); background-size: 250% 100%; box-shadow: 0 0 10px rgba(255,210,90,.8), 0 0 18px rgba(255,150,220,.4); animation: tb-shine 3s linear infinite; }
/* ฉายาโดเนท 7 ขั้น */
.title-badge.tb-d1 { color: #e0fff6; border-color: #3fe0b0; background: linear-gradient(135deg, #0f9d74, #1e90d0); box-shadow: 0 0 6px rgba(63,224,176,.5); }
.title-badge.tb-d2 { color: #e8f6ff; border-color: #6fd0ff; background: linear-gradient(135deg, #1a5fd0, #3fb6ff); box-shadow: 0 0 10px rgba(80,180,255,.85); }
.title-badge.tb-d3 { color: #f3e8ff; border-color: #c08cff; background: linear-gradient(135deg, #6a2bd0, #b05cff); box-shadow: 0 0 12px rgba(176,92,255,.9); }
.title-badge.tb-d4 { color: #fff3dc; border-color: #ffb040; background: linear-gradient(135deg, #e0561a, #ffb21f); box-shadow: 0 0 12px rgba(255,140,30,.85); }
.title-badge.tb-d5 { color: #3a2800; border-color: #ffe27a; background: linear-gradient(135deg, #ffcf3a, #fff1a0, #f0b000); box-shadow: 0 0 14px rgba(255,210,60,.95); }
.title-badge.tb-d6 { color: #3a1030; border-color: #ffd9f0; background: linear-gradient(110deg, #ff8fd0, #ffe08a, #9fe8ff, #ff8fd0); background-size: 250% 100%; box-shadow: 0 0 14px rgba(255,150,220,.8), 0 0 20px rgba(255,220,120,.6); animation: tb-shine 4s linear infinite; }
.title-badge.tb-d7 { color: #fff; text-shadow: 0 0 4px rgba(0,0,0,.7); border-color: #fff; background: linear-gradient(100deg, #ff3b3b, #ffa63b, #fff53b, #3bff6a, #3bc8ff, #8a3bff, #ff3bd0, #ff3b3b); background-size: 300% 100%; box-shadow: 0 0 10px #fff, 0 0 20px rgba(255,120,255,.8), 0 0 30px rgba(120,200,255,.6); animation: tb-shine 2.5s linear infinite, tb-aura 1.8s ease-in-out infinite alternate; }
.title-badge.tb-ref1 { color: #fff8dc; text-shadow: 0 0 4px rgba(0,40,90,.8); border-color: #ffe08a; background: linear-gradient(110deg, #1e90ff, #6fd0ff, #ffd45a, #1e90ff); background-size: 250% 100%; box-shadow: 0 0 10px rgba(80,180,255,.9), 0 0 16px rgba(255,210,90,.7); animation: tb-shine 3.5s linear infinite; }
.title-badge.tb-ref2 { color: #fff; text-shadow: 0 0 4px rgba(0,0,0,.75); border-color: #fff; background: linear-gradient(100deg, #ff6ad5, #c774e8, #ad8cff, #8795e8, #94d0ff, #7cf5c8, #fff58a, #ff6ad5); background-size: 300% 100%; box-shadow: 0 0 10px #fff, 0 0 20px rgba(173,140,255,.8); animation: tb-shine 2.2s linear infinite, tb-aura 1.8s ease-in-out infinite alternate; }
@keyframes tb-aura { from { box-shadow: 0 0 8px #fff, 0 0 16px rgba(255,120,255,.6); } to { box-shadow: 0 0 14px #fff, 0 0 30px rgba(120,200,255,.9), 0 0 40px rgba(255,220,120,.6); } }
.donate-bar { height: 12px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; margin: .4rem 0; }
.donate-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #3fe0b0, #b05cff, #ffcf3a); }
@keyframes tb-shine { to { background-position: 250% 0; } }
.profile-name { margin-bottom: .5rem; font-size: 1.05rem; }
.item.equipped { background: rgba(88,201,160,.08); }
@media (prefers-reduced-motion: reduce) { .title-badge.tb-legendary, .title-badge.tb-d6, .title-badge.tb-d7, .title-badge.tb-ref1, .title-badge.tb-ref2 { animation: none; } }

/* ===== ไอเท็มไชน์นี่ (Shiny) ===== */
.shiny-name { display: inline-flex; align-items: center; gap: .3em; flex-wrap: wrap; }
.shiny-text {
  font-weight: 700;
  background: linear-gradient(100deg, #ffd86b, #ff9ad5, #8be9ff, #b6ff9a, #ffd86b, #ff9ad5);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: shiny-shimmer 6s linear infinite;
}
.shiny-spark { animation: shiny-twinkle 2.4s ease-in-out infinite; }
.shiny-badge {
  font-size: .62em; font-weight: 800; letter-spacing: .08em; padding: .05em .45em; border-radius: 999px;
  color: #3a2a00; background: linear-gradient(90deg, #ffd86b, #fff3b0, #ffd86b);
  box-shadow: 0 0 6px rgba(255,216,107,.7);
}
.ico-shiny { animation: shiny-glow 2.6s ease-in-out infinite; }
.shiny-box {
  border: 1px solid rgba(255,216,107,.6) !important;
  border-radius: 8px;
  background: linear-gradient(120deg, rgba(255,216,107,.10), rgba(255,154,213,.08) 40%, rgba(139,233,255,.08) 70%, rgba(182,255,154,.08));
  box-shadow: 0 0 10px rgba(255,216,107,.25), inset 0 0 12px rgba(255,255,255,.05);
}
tr.shiny-box { box-shadow: inset 3px 0 0 rgba(255,216,107,.8); border-radius: 0; }
.slot.shiny-box { padding: .3rem; }
/* แถวรายการ (กระเป๋า/ตลาด): ไม่ซ้อนกล่อง ใช้เส้นขอบแถวเดิมเป็นสีทองเรืองแสง */
.item.shiny-box, .sell-row.shiny-box {
  border: 0 !important; border-top: 1px solid rgba(255,216,107,.85) !important;
  border-radius: 0; background: none;
  box-shadow: 0 -1px 6px -2px rgba(255,216,107,.6);
}
/* ไอคอน + ชื่อ อยู่แถวเดียวกันเสมอ ไม่ตกบรรทัด */
.item .name > span:has(.shiny-name), .sell-row .name > span:has(.shiny-name) {
  display: flex; flex-wrap: nowrap; align-items: center; gap: .3em; min-width: 0;
}
.item .name > span:has(.shiny-name) > img, .sell-row .name > span:has(.shiny-name) > img { flex-shrink: 0; }
.shiny-name { flex-wrap: nowrap; min-width: 0; white-space: nowrap; }
.shiny-name .shiny-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.shiny-name .shiny-spark, .shiny-name .shiny-badge { flex-shrink: 0; }
.shiny-badge { font-size: 10px !important; padding: 0 .35em !important; line-height: 1.5; letter-spacing: .04em; }
@keyframes shiny-shimmer { from { background-position: 0% 0; } to { background-position: 250% 0; } }
@keyframes shiny-twinkle { 0%,100% { opacity: .6; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes shiny-glow {
  0%,100% { filter: drop-shadow(0 0 3px rgba(255,216,107,.9)) drop-shadow(0 0 6px rgba(255,154,213,.5)); }
  50% { filter: drop-shadow(0 0 6px rgba(139,233,255,.9)) drop-shadow(0 0 10px rgba(255,216,107,.7)); }
}
@media (prefers-reduced-motion: reduce) { .shiny-text, .shiny-spark, .ico-shiny { animation: none; } }

/* ---- เอฟเฟกต์ฉลองระดับหายาก: Shiny craft / ตีบวก +10 ---- */
.fx-box.fx-shiny, .fx-box.fx-legend { overflow: visible; padding: 3rem 3rem 2rem; }
.fx-shiny { border-color: #fff; animation: fx-rainbow-glow 2s linear infinite; }
.fx-legend { border-color: #ffb300; background: #1f0e05; animation: fx-fire-glow .35s ease-in-out infinite alternate; }
.fx-shiny .fx-item, .fx-legend .fx-item { position: relative; z-index: 2; animation: fx-pop .6s ease-out; }
.fx-shiny .fx-msg, .fx-legend .fx-msg { position: relative; z-index: 2; }
.fx-rays { position: absolute; left: 50%; top: 4.5rem; width: 420px; height: 420px; margin: -210px 0 0 -210px; z-index: 1; pointer-events: none; border-radius: 50%;
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%); mask: radial-gradient(circle, #000 25%, transparent 70%); animation: fx-spin 4s linear infinite; }
.fx-shiny .fx-rays { background: repeating-conic-gradient(from 0deg, #ff3b6b 0 15deg, #ffd23b 15deg 30deg, #4dff88 30deg 45deg, #3bd2ff 45deg 60deg, #a23bff 60deg 75deg, #ff3bd2 75deg 90deg); opacity: .75; }
.fx-legend .fx-rays { background: repeating-conic-gradient(from 0deg, #ffd700 0 12deg, #ff6a00 12deg 24deg, #fff3a0 24deg 36deg, #ff2a00 36deg 48deg); opacity: .85; animation-duration: 2.2s; }
.fx-banner { position: relative; z-index: 3; margin-bottom: 1rem; font-family: var(--font-head, inherit); font-weight: 800; font-size: 1.5rem; letter-spacing: .04em; white-space: nowrap; animation: fx-banner-in .6s cubic-bezier(.2,1.6,.4,1) both; }
.fx-shiny .fx-banner { background: linear-gradient(90deg, #ff3b6b, #ffd23b, #4dff88, #3bd2ff, #a23bff, #ff3b6b); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: fx-banner-in .6s both, fx-rainbow-text 2s linear infinite; filter: drop-shadow(0 0 8px rgba(255,255,255,.7)); }
.fx-legend .fx-banner { font-size: 2rem; color: #ffd700; text-shadow: 0 0 10px #ff8a00, 0 0 24px #ff4400, 0 2px 0 #7a2e00; }
.fx-shiny .fx-msg { color: #fff; } .fx-legend .fx-msg { color: #ffd700; }
.fx-burst-stars { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 4; pointer-events: none; }
.fx-burst-stars i { position: absolute; font-style: normal; font-size: 1.4rem; opacity: 0; color: hsl(var(--h, 45) 100% 65%); text-shadow: 0 0 8px hsl(var(--h, 45) 100% 60%); animation: fx-burst 1.4s ease-out forwards; }
.fx-legend .fx-burst-stars i { color: initial; text-shadow: none; }
.fx-overlay.fx-flash-gold::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, #fff6c0, #ffb300 40%, transparent 75%); animation: fx-flash .8s ease-out forwards; pointer-events: none; }
@keyframes fx-spin { to { transform: rotate(360deg); } }
@keyframes fx-burst { 0% { transform: translate(0,0) scale(.3); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(180deg); opacity: 0; } }
@keyframes fx-banner-in { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fx-rainbow-text { to { background-position: 300% 0; } }
@keyframes fx-rainbow-glow { 0% { box-shadow: 0 0 40px 10px #ff3b6b; } 25% { box-shadow: 0 0 40px 10px #ffd23b; } 50% { box-shadow: 0 0 40px 10px #4dff88; } 75% { box-shadow: 0 0 40px 10px #3bd2ff; } 100% { box-shadow: 0 0 40px 10px #ff3b6b; } }
@keyframes fx-fire-glow { from { box-shadow: 0 0 40px 10px rgba(255,140,0,.7), inset 0 0 30px rgba(255,80,0,.4); } to { box-shadow: 0 0 70px 22px rgba(255,215,0,.9), inset 0 0 40px rgba(255,120,0,.6); } }
@media (prefers-reduced-motion: reduce) { .fx-rays, .fx-shiny, .fx-legend, .fx-banner { animation: none; } }

/* ---------- สัตว์เลี้ยง ---------- */
.pet-img { object-fit: contain; flex: none; }
.pet-img-sm { width: 36px; height: 36px; }
.pet-img-md { width: 72px; height: 72px; }
.pet-img-lg { width: 128px; height: 128px; max-width: 40vw; max-height: 40vw; }
.pet-chip-click { cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s; }
.pet-chip-click:hover, .pet-chip-click:focus-visible { transform: translateY(-1px); box-shadow: 0 2px 10px rgba(0,0,0,.4); background: rgba(255,255,255,.08); outline: none; }
.pet-modal-backdrop { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(5,8,20,.7); }
.pet-modal { box-sizing: border-box; width: 100%; max-width: 360px; max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto; border: 2px solid var(--line); border-radius: 12px; padding: 1rem; background: var(--panel, #1b2133); display: flex; flex-direction: column; gap: .7rem; animation: petPop .2s ease-out; }
.pet-modal-head { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; }
.pet-modal-name { font-size: 1.15rem; overflow-wrap: anywhere; }
.pet-modal-stats { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.pet-modal-stat { padding: .15rem .5rem; border-radius: 6px; background: rgba(0,0,0,.25); }
.pet-modal-row { display: flex; gap: .5rem; padding: .25rem .5rem; border-radius: 6px; background: rgba(0,0,0,.2); }
.pet-modal-score { text-align: center; }
.pet-chip { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); width: fit-content; max-width: 100%; }
.pet-chip-text { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.pet-grade { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1px solid; }
.pet-grade-poor { color: #b99a9e; background: rgba(160,110,115,.18); border-color: #8a6a6e; }
.pet-grade-normal { color: #fff; background: rgba(255,255,255,.12); border-color: #e8e8e8; }
.pet-grade-great { color: #b9b4ff; background: rgba(110,150,255,.18); border-color: #8f9cf0; }
.pet-grade-legendary { color: #3a2400; background: linear-gradient(90deg,#ffd75e,#fff2b0,#ffb52e,#ffe48a); background-size: 200% 100%; border-color: #ffd75e; box-shadow: 0 0 8px rgba(255,200,70,.8); animation: petShine 2.2s linear infinite; }
@keyframes petShine { to { background-position: -200% 0; } }
.pet-hatch { display: flex; align-items: center; gap: 1rem; margin-top: .8rem; flex-wrap: wrap; }
.pet-egg { font-size: 2.6rem; animation: petWobble .45s ease-in-out infinite; }
@keyframes petWobble { 0%,100% { transform: rotate(-14deg) scale(1); } 50% { transform: rotate(14deg) scale(1.15); } }
.pet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; margin-top: .6rem; }
.pet-card { border: 1px solid var(--line); border-radius: 10px; padding: .7rem; background: var(--panel-2); display: flex; flex-direction: column; gap: .5rem; }
.pet-card.equipped { outline: 2px solid var(--mint); }
.pet-card.fresh { animation: petPop .6s ease-out; }
@keyframes petPop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.pet-card-poor { border-color: #8a6a6e; }
.pet-card-normal { border-color: #e8e8e8; }
.pet-card-great { border-color: #8f9cf0; box-shadow: 0 0 8px rgba(130,140,255,.35); }
.pet-card-legendary { border-color: #ffd75e; box-shadow: 0 0 14px rgba(255,205,80,.65), 0 0 30px rgba(255,160,40,.25) inset; }
.pet-head { display: flex; gap: .6rem; align-items: center; }
.pet-on { color: var(--mint); }
.pet-traits { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.pet-traits li label { display: flex; align-items: center; gap: .5rem; padding: .2rem .4rem; border-radius: 6px; background: rgba(0,0,0,.2); cursor: pointer; }
.pet-traits li.locked label { background: rgba(230,180,76,.18); }
.pet-trait-name { flex: 1; }
.pet-pos { color: #5fe08f; }
.pet-neg { color: #ff6b6b; }
.pet-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.pet-actions button { flex: 1 1 auto; }
@media (prefers-reduced-motion: reduce) { .pet-egg, .pet-grade-legendary, .pet-card.fresh { animation: none; } }

/* ---------- ปฏิทินเช็คอิน 7 วัน ---------- */
.daily-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-top: .8rem; }
.daily-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .7rem .5rem; text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 10px; }
.daily-card.big { grid-column: 1 / -1; padding: 1rem; border: 2px solid var(--gold-hi);
  background: linear-gradient(180deg, #2a2347, var(--panel)); box-shadow: 0 0 14px rgba(217,189,130,.45), inset 0 0 18px rgba(217,189,130,.12); }
.daily-day { font-family: var(--font-head); color: var(--gold-hi); font-size: .85rem; }
.daily-imgs { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.daily-item { position: relative; display: inline-flex; }
.daily-item .ico-img, .daily-item svg { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
.daily-count { position: absolute; right: -6px; bottom: -4px; background: #000a; color: #fff; font-size: .72rem; padding: 0 .3rem; border-radius: 6px; }
.daily-name { font-size: .78rem; color: var(--muted); }
.daily-badges { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: center; }
.daily-badge { font-size: .78rem; padding: .1rem .45rem; border-radius: 999px; background: #0006; border: 1px solid var(--line); }
.daily-badge.gold { color: var(--amber); } .daily-badge.stam { color: var(--sky); }
.daily-card.claimed { opacity: .65; filter: brightness(.85); }
.daily-stamp { color: #fff; background: #2f9e6b; border-radius: 6px; padding: .15rem .6rem; font-size: .82rem; font-weight: 600; }
.daily-card.ready { border: 2px solid var(--amber); animation: dailyGlow 1.6s ease-in-out infinite; }
.daily-claim { width: 100%; padding: .55rem 1rem; font-size: 1rem; font-weight: 700; }
.daily-card.pending { opacity: .85; }
.daily-wait { color: var(--muted); font-size: .8rem; }
@keyframes dailyGlow { 0%,100% { box-shadow: 0 0 6px rgba(230,180,76,.4); } 50% { box-shadow: 0 0 18px rgba(230,180,76,.9); } }
@media (max-width: 560px) { .daily-grid { grid-template-columns: repeat(2, 1fr); } }
@media (prefers-reduced-motion: reduce) { .daily-card.ready { animation: none; } }

.hud-icon { width: 18px; height: 18px; vertical-align: -4px; margin-right: .25rem; object-fit: contain; }
.daily-badge { display: inline-flex; align-items: center; }
.daily-badge .hud-icon { margin-right: .2rem; vertical-align: 0; }

/* ---------- กาชา: หน้าต่างเปิดรางวัล (public/gacha.js) ---------- */
.gc-box { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 760px; width: 100%; padding: 16px; cursor: default; }
.gc-crystal { font-size: 84px; animation: gc-shake .16s linear infinite, gc-glow .8s ease-in-out infinite alternate; }
@keyframes gc-shake { 0% { transform: translate(-3px,0) rotate(-6deg); } 50% { transform: translate(3px,-2px) rotate(6deg); } 100% { transform: translate(-3px,0) rotate(-6deg); } }
@keyframes gc-glow { from { filter: drop-shadow(0 0 10px #7fd4ff); } to { filter: drop-shadow(0 0 44px #fff) drop-shadow(0 0 60px #b27fff); } }
.gc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: 100%; }
.gc-grid.gc-one { grid-template-columns: 1fr; justify-items: center; }
@media (max-width: 560px) { .gc-grid { grid-template-columns: repeat(2, 1fr); } }
.gc-card { perspective: 700px; aspect-ratio: 3 / 4; width: 100%; position: relative; }
.gc-card.gc-big { width: min(260px, 70vw); }
.gc-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .45s; }
.gc-flipped .gc-inner { transform: rotateY(180deg); }
.gc-instant .gc-inner { transition: none; }
.gc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px; overflow: hidden; border: 2px solid var(--gc, #7fd4ff); box-shadow: 0 0 14px var(--gc, #7fd4ff); background: #121a33; }
.gc-back { color: #7fd4ff; font-size: 34px; background: repeating-linear-gradient(45deg, #1b2750, #1b2750 8px, #121a33 8px, #121a33 16px); border-color: #4a5a99; box-shadow: none; }
.gc-front { transform: rotateY(180deg); color: #fff; text-align: center; }
.gc-front img { width: 60%; max-height: 55%; object-fit: contain; }
.gc-big .gc-front img { width: 70%; }
.gc-name { font-size: 12px; line-height: 1.25; }
.gc-big .gc-name { font-size: 16px; }
.gc-badge { position: absolute; top: 5px; left: 5px; padding: 1px 7px; border-radius: 6px; font-weight: 700; font-size: 12px; color: #111; background: var(--gc, #7fd4ff); }
.gc-n { --gc: #8a93a8; } .gc-r { --gc: #7fd4ff; } .gc-sr { --gc: #c07bff; } .gc-ssr { --gc: #ffd84a; }
.gc-sr .gc-front { box-shadow: 0 0 22px #c07bff, inset 0 0 18px rgba(192,123,255,.5); }
.gc-ssr .gc-front { background: linear-gradient(135deg, #3a2a05, #121a33 60%); box-shadow: 0 0 30px #ffd84a, inset 0 0 22px rgba(255,216,74,.5); }
.gc-holo { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: .55; background: linear-gradient(115deg, transparent 20%, #ff6ec7 35%, #ffe96e 45%, #6effc8 55%, #6ea8ff 65%, transparent 80%); background-size: 250% 100%; animation: gc-holo 1.6s linear infinite; }
@keyframes gc-holo { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.gc-burst { position: absolute; left: 50%; top: 50%; pointer-events: none; z-index: 5; }
.gc-burst i { position: absolute; font-style: normal; color: #ffd84a; text-shadow: 0 0 8px #fff; animation: gc-star 1s ease-out forwards; }
@keyframes gc-star { from { transform: translate(0,0) scale(.4); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1.6); opacity: 0; } }
.gc-bar { display: flex; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .gc-crystal, .gc-holo { animation: none; } .gc-inner { transition: none; } }

/* ---------- หน้าใส่การ์ด: ไอคอนอุปกรณ์ + สีช่องการ์ดตามความหายาก ---------- */
.socket-head { display: flex; align-items: center; gap: .5rem; }
.socket-eq-ico .ico-img, .socket-eq-ico svg { width: 28px; height: 28px; margin: 0; vertical-align: middle; object-fit: contain; }
.socket.filled { display: flex; align-items: center; gap: .5rem; --sc: #8fa3c0; --sn: #f1ede0; border: 1.5px solid var(--sc); }
.socket-art { width: 36px; height: 36px; flex: none; object-fit: contain; }
.socket-txt { min-width: 0; }
.socket.filled .sock-name { color: var(--sn); }
.socket.filled.sock-common { --sc: #8fa3c0; --sn: #f1ede0; }
.socket.filled.sock-uncommon, .socket.filled.sock-rare { --sc: #3a8fd9; --sn: #7cc4ff; box-shadow: 0 0 6px rgba(58,143,217,.35); }
.socket.filled.sock-epic { --sc: #b45cff; --sn: #d4a2ff; box-shadow: 0 0 10px rgba(180,92,255,.55); }
.socket.filled.sock-legendary { --sn: #ffd24a; border-color: transparent; background: linear-gradient(var(--bg), var(--bg)) padding-box, linear-gradient(120deg,#ffd24a,#ff8ad8,#6ee7ff,#ffd24a) border-box; box-shadow: 0 0 14px rgba(255,200,60,.6); }

/* กระเป๋า: แถบหมวดหมู่ + ช่องค้นหา + รายการเลื่อนได้ */
.inv-bar { display: flex; flex-wrap: nowrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.inv-tabs { display: flex; flex-wrap: wrap; gap: .3rem; flex: 1 1 auto; min-width: 0; }
.inv-tab { background: transparent; border: 1px solid var(--gold-dim); border-radius: 999px; padding: .25rem .7rem; font-size: .85rem; color: var(--text); box-shadow: none; }
.inv-tab:hover { border-color: var(--gold-hi); }
.inv-tab.active { background: var(--panel-2); border-color: var(--amber); color: var(--amber); }
.inv-search { flex: 0 0 12rem; min-width: 8rem; padding: .3rem .6rem; font-size: .85rem; }
@media (max-width: 700px) {
  .inv-bar { flex-wrap: wrap; }
  .inv-search { flex: 1 1 100%; }
}
.inv-list { max-height: 480px; overflow-y: auto; padding-right: .25rem; scrollbar-width: thin; scrollbar-color: var(--gold-dim) var(--bg); }
.inv-list::-webkit-scrollbar { width: 8px; }
.inv-list::-webkit-scrollbar-track { background: var(--bg); border-radius: 4px; }
.inv-list::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 4px; border: 1px solid var(--bg); }
.inv-list::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ส่องโปรไฟล์ผู้เล่นอื่น */
.player-link { cursor: pointer; transition: color .15s; }
.player-link:hover, .player-link:focus-visible { color: #8fd4ff; text-decoration: underline; outline: none; }
.inspect-modal { position: relative; max-width: 460px; gap: .6rem; }
.inspect-close { position: absolute; top: .4rem; right: .4rem; width: 2rem; height: 2rem; padding: 0; line-height: 1; border-radius: 50%; }
.inspect-head { display: flex; align-items: center; gap: .8rem; padding-right: 2rem; }
.inspect-avatar { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.inspect-head-text { min-width: 0; display: flex; flex-direction: column; gap: .15rem; align-items: flex-start; }
.inspect-head-text .title-badge { margin-right: 0; }
.inspect-name { font-size: 1.15rem; overflow-wrap: anywhere; }
.inspect-premium { color: #ffd45a; }
.inspect-power b { color: #ffd45a; }
.inspect-stats { display: flex; flex-wrap: wrap; gap: .35rem; }
.inspect-sec { margin-top: .2rem; }
.inspect-gear { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .45rem; }
.inspect-slot { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .4rem; border-radius: 8px; background: rgba(0,0,0,.25); border: 1px solid var(--line); text-align: center; min-width: 0; }
.inspect-slot.shiny { border-color: #ffd45a; box-shadow: 0 0 8px rgba(255,210,90,.45); }
.inspect-slot.empty { opacity: .6; }
.inspect-slot-label { font-size: .75rem; }
.inspect-slot-empty { padding: .8rem 0; }
.inspect-slot-ico { position: relative; display: inline-flex; }
.inspect-slot-ico .ico-img-lg { margin: 0; width: 48px; height: 48px; }
.inspect-refine { position: absolute; right: -.5rem; bottom: -.2rem; padding: 0 .3rem; border-radius: 6px; background: #2a2f45; color: #ffd45a; font-size: .8rem; }
.inspect-slot-name { font-size: .85rem; overflow-wrap: anywhere; }
.inspect-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem; }
.inspect-card { padding: 0 .35rem; border-radius: 6px; background: rgba(110,150,255,.2); border: 1px solid #8f9cf0; font-size: .7rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inspect-pet { display: flex; align-items: center; gap: .7rem; padding: .5rem; border-radius: 8px; border: 1px solid var(--line); }
.inspect-pet-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }

/* ===== ออร่าอุปกรณ์ตีบวกสูง (+7~+9 ฟ้า/ม่วง, +10↑ ทอง-ส้มเพลิง, ไชน์นี่ +10↑ รุ้งผสมทอง) ===== */
.ico-img.aura-hi, img.ico-img.aura-hi { border-radius: 8px; animation: none !important; filter: drop-shadow(0 0 4px rgba(90,200,255,.95)) drop-shadow(0 0 9px rgba(160,110,255,.75)) !important; }
.ico-img.aura-max, img.ico-img.aura-max { border-radius: 8px; filter: drop-shadow(0 0 5px #ffd700) drop-shadow(0 0 10px #ff6a00) !important; animation: aura-fire 1.6s ease-in-out infinite !important; }
.ico-img.aura-max.aura-shiny, img.ico-img.aura-max.aura-shiny { animation: aura-rainbow 2s linear infinite !important; }
.slot.slot-aura-hi, .item.slot-aura-hi, .sell-row.slot-aura-hi, .inspect-slot.slot-aura-hi {
  border-color: rgba(120,190,255,.8) !important; box-shadow: 0 0 10px rgba(110,170,255,.45), inset 0 0 8px rgba(160,110,255,.18);
}
.slot.slot-aura-max, .item.slot-aura-max, .sell-row.slot-aura-max, .inspect-slot.slot-aura-max {
  border-color: #ffb830 !important; box-shadow: 0 0 10px rgba(255,170,30,.8), inset 0 0 8px rgba(255,140,0,.3); animation: aura-frame 1.8s ease-in-out infinite;
}
.slot.slot-aura-max.slot-aura-shiny, .item.slot-aura-max.slot-aura-shiny, .sell-row.slot-aura-max.slot-aura-shiny, .inspect-slot.slot-aura-max.slot-aura-shiny {
  animation: aura-frame-rainbow 2.2s linear infinite;
}
.refine-tag { font-weight: 700; margin-right: .25em; }
.refine-tag.rf-hi, .inspect-refine.rf-hi { color: #6fd8ff; text-shadow: 0 0 5px rgba(90,200,255,.7); }
.refine-tag.rf-max, .inspect-refine.rf-max { color: #ffc933; font-weight: 800; text-shadow: 0 0 6px rgba(255,170,30,.95), 0 0 12px rgba(255,120,0,.6); }
.label-rf { display: inline-flex; align-items: baseline; flex-wrap: nowrap; min-width: 0; }
.mk-ico { display: inline-flex; align-items: center; margin-right: .3em; }
@keyframes aura-fire {
  0%,100% { filter: drop-shadow(0 0 3px #ffd700) drop-shadow(0 0 6px #ff8c00); }
  50% { filter: drop-shadow(0 0 6px #ffe14d) drop-shadow(0 0 13px #ff5a00); }
}
@keyframes aura-rainbow {
  0% { filter: drop-shadow(0 0 6px #ff3b6b) drop-shadow(0 0 10px #ffd23b); }
  33% { filter: drop-shadow(0 0 6px #4dff88) drop-shadow(0 0 10px #ffd23b); }
  66% { filter: drop-shadow(0 0 6px #3bd2ff) drop-shadow(0 0 10px #ffd23b); }
  100% { filter: drop-shadow(0 0 6px #ff3b6b) drop-shadow(0 0 10px #ffd23b); }
}
@keyframes aura-frame {
  0%,100% { box-shadow: 0 0 6px rgba(255,200,40,.5), inset 0 0 6px rgba(255,140,0,.2); }
  50% { box-shadow: 0 0 14px rgba(255,150,20,.9), inset 0 0 12px rgba(255,200,40,.35); }
}
@keyframes aura-frame-rainbow {
  0% { box-shadow: 0 0 12px rgba(255,59,107,.8), 0 0 4px #ffd23b; }
  33% { box-shadow: 0 0 12px rgba(77,255,136,.8), 0 0 4px #ffd23b; }
  66% { box-shadow: 0 0 12px rgba(59,210,255,.8), 0 0 4px #ffd23b; }
  100% { box-shadow: 0 0 12px rgba(255,59,107,.8), 0 0 4px #ffd23b; }
}
@media (prefers-reduced-motion: reduce) { .ico-img.aura-max, .slot-aura-max { animation: none !important; } } /* ยังคงแสงนิ่งไว้ ไม่ให้ออร่าหาย */

/* ---------- Gift Code ---------- */
.ticker-codes { flex-wrap: wrap; }
.ticker-code { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; flex-wrap: wrap; }
.ticker-code b { color: #fff; letter-spacing: .05em; background: rgba(0, 0, 0, .35); padding: .05rem .45rem; border-radius: 5px; }
.ticker-code-reward { font-weight: 400; font-size: .85rem; }
.ticker-copy { flex: none; font-size: .8rem; padding: .15rem .55rem; }
.giftcode-row { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.giftcode-input { flex: 1; min-width: 10rem; font: inherit; font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: #1b1b1b; border: 1px solid var(--line); border-radius: 6px; padding: .45rem .7rem; }
.giftcode-input::placeholder { color: #aaa; text-transform: none; letter-spacing: 0; }
.giftcode-result { margin-top: .6rem; }
.giftcode-result ul { margin: .3rem 0 0 1.2rem; padding: 0; }
.giftcode-admin { margin: .8rem 0; padding: .6rem 0; border-top: 1px solid var(--line); }
.giftcode-admin h3 { margin: 0 0 .3rem; }
.gc-check { width: auto !important; }
.giftcode-table-wrap { overflow-x: auto; margin-top: .6rem; }
.giftcode-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.giftcode-table th, .giftcode-table td { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.giftcode-table .gc-off { opacity: .55; }

/* ---------- กล่องปะทะ: ผู้เล่น (ซ้าย) VS ศัตรู (ขวา) ---------- */
.arena.duel { flex-direction: row; justify-content: space-around; align-items: flex-end; gap: .4rem; width: 100%; max-width: 560px; min-height: 170px; padding: .7rem .6rem; }
.arena.duel.arena-sm { width: 220px; max-width: 46%; min-height: 0; padding: .35rem .3rem; flex: none; }
.duel-side { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 0; flex: 1; }
.duel-pic { position: relative; display: flex; align-items: center; justify-content: center; }
.duel-avatar { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 3px solid #4fc3ff; background: #1d2a4a;
  box-shadow: 0 0 0 2px #e8b84a, 0 0 12px rgba(79,195,255,.7); }
.duel-enemy .duel-avatar { border-color: #ff6b6b; box-shadow: 0 0 0 2px #e8b84a, 0 0 12px rgba(255,80,80,.6); }
.duel-pets { position: absolute; left: 0; right: 0; bottom: -8px; display: flex; justify-content: center; gap: 2px; pointer-events: none; }
.duel-pet { background: rgba(10,14,30,.85); border: 1px solid #e8b84a; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.duel-pet .pet-img { width: 22px; height: 22px; }
.pet-podium { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 8px; align-items: center; margin: .5rem 0; }
.pet-pod { box-sizing: border-box; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .4rem .3rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); text-align: center; }
.pet-pod-1 { padding: .6rem .3rem; border: 2px solid #ffd75e; box-shadow: 0 0 12px rgba(255,205,80,.45); }
.pet-pod-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.pet-pod-1 .pet-pod-name { font-size: .95rem; }
.pet-pod .pet-team-slot { margin: 0; font-size: .7rem; }
.pet-pod .pet-grade { font-size: .65rem; padding: .05rem .4rem; }
.pet-pod-empty { align-self: stretch; justify-content: center; min-height: 64px; background: transparent; border: 1px dashed var(--line); opacity: .4; box-shadow: none; }
@media (max-width: 480px) {
  .pet-podium { gap: 5px; }
  .pet-pod .pet-img-sm { width: 30px; height: 30px; }
  .pet-pod .pet-img-md { width: 56px; height: 56px; }
  .pet-pod-name { font-size: .75rem; }
}
.pet-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.pet-chips .pet-chip { margin: 0; }
.pet-team-slot { opacity: .75; margin-right: .25rem; }
.pet-team { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: .25rem; width: 100%; }
.pet-team-item { display: flex; align-items: center; gap: 3px; max-width: 100%; padding: 1px 5px 1px 2px; border-radius: 999px; background: rgba(10,14,30,.7); border: 1px solid var(--line); font-size: .7rem; color: #fff; }
.pet-team-item .pet-img { width: 20px; height: 20px; }
.pet-team-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-name { font-size: .85rem; color: #fff; text-shadow: 0 1px 3px #000; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-hp { width: 100%; max-width: 130px; }
.duel-hp .bar-track { height: 8px; }
.duel-hp small { display: block; font-size: .7rem; color: #fff; text-shadow: 0 1px 2px #000; }
.duel-me .duel-hp { display: flex; flex-direction: column; gap: 1px; }
.duel-me .duel-hp small { line-height: 1.1; }
.duel-sta { position: relative; width: 100%; max-width: 130px; height: 12px; border-radius: 6px; overflow: hidden; background: #070c1b; border: 1px solid rgba(255,215,0,.5); box-sizing: border-box; }
.duel-sta-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #f2c230, #4fd3ff); transition: width .3s; }
.duel-sta-txt { position: relative; display: block; text-align: center; font-size: .62rem; line-height: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 2px #000; white-space: nowrap; }
.arena-sm .duel-sta { height: 11px; } .arena-sm .duel-sta-txt { font-size: .58rem; line-height: 9px; }
@media (max-width: 600px) { .duel-hp .bar-track { height: 7px; } .duel-sta { height: 11px; } .duel-sta-txt { font-size: .58rem; line-height: 9px; } }
.duel-vs { align-self: center; font-family: var(--font-head, inherit); font-weight: 900; font-size: 1.8rem; letter-spacing: .05em; color: #ffd700;
  text-shadow: 0 0 10px #ff3b2f, 0 0 20px #ff8a00, 0 2px 3px #000; animation: duel-vs-pulse 1.6s ease-in-out infinite; }
.arena-sm .duel-avatar, .arena-sm .duel-enemy .portrait { width: 52px; height: 52px; }
.arena-sm .duel-vs { font-size: 1rem; }
.arena-sm .duel-pet { width: 18px; height: 18px; } .arena-sm .duel-pet .pet-img { width: 15px; height: 15px; }
.arena-sm .duel-pets { bottom: -6px; }
.arena-sm .duel-name { font-size: .7rem; } .arena-sm .duel-hp small { display: none; }
.duel-enemy .portrait { width: 96px; height: 96px; }
@media (max-width: 600px) { .duel-avatar { width: 68px; height: 68px; } .duel-enemy .portrait { width: 80px; height: 80px; } .duel-vs { font-size: 1.4rem; } .arena.duel { min-height: 150px; } }
tr.opp-focus { background: rgba(79,195,255,.12); }
.arena-opp tbody tr { cursor: pointer; }
@keyframes duel-vs-pulse { 50% { transform: scale(1.15); filter: brightness(1.3); } }
/* ภาพเงาพุ่งเข้าปะทะ */
.vfx-lunge { z-index: 9991; }
.vfx-lunge img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.vfx-lunge-r { animation: duel-go-r .6s ease-in-out; }
.vfx-lunge-l { animation: duel-go-l .6s ease-in-out .25s; animation-fill-mode: backwards; }
@keyframes duel-go-r { 0% { transform: translateX(0); } 40% { transform: translateX(70px) scale(1.12); } 100% { transform: translateX(0); } }
@keyframes duel-go-l { 0% { transform: translateX(0); } 40% { transform: translateX(-70px) scale(1.12); } 100% { transform: translateX(0); } }
@media (max-width: 600px) { @keyframes duel-go-r { 40% { transform: translateX(40px) scale(1.1); } } @keyframes duel-go-l { 40% { transform: translateX(-40px) scale(1.1); } } }

/* ---------- แรงก์อารีน่า ---------- */
.arena-rank { display: inline-block; font-weight: 800; white-space: nowrap; letter-spacing: .01em; }
.arena-rank.ar-bronze { color: #cd7f32; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
.arena-rank.ar-silver { color: #e2e8f0; text-shadow: 0 0 6px rgba(226,232,240,.35); }
.arena-rank.ar-gold { color: #fbbf24; text-shadow: 0 0 8px rgba(251,191,36,.7); }
.arena-rank.ar-platinum { color: #2dd4bf; text-shadow: 0 0 8px rgba(45,212,191,.7); }
.arena-rank.ar-diamond { color: #38bdf8; text-shadow: 0 0 6px rgba(56,189,248,.8), 0 0 14px rgba(56,189,248,.5); }
.arena-rank.ar-champion {
  background: linear-gradient(100deg, #fbbf24, #a855f7, #ef4444, #fbbf24, #a855f7);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 5px rgba(217,119,255,.65));
  animation: ar-champion 4s linear infinite;
}
.arena-rank.ar-champion .ar-crown { -webkit-text-fill-color: initial; margin-right: .2em; }
@keyframes ar-champion { to { background-position: 300% 0; } }
/* ป้าย (badge) ใช้กับหัวข้อ/ป้ายแรงก์ปัจจุบัน */
.arena-rank.ar-badge { padding: .02rem .7rem; border-radius: 999px; border: 1px solid currentColor; background-color: rgba(255,255,255,.04); }
.arena-rank.ar-badge.ar-champion { border-color: #c084fc; background-color: rgba(168,85,247,.12); }
.arena-rank.ar-badge.ar-diamond { box-shadow: 0 0 12px rgba(56,189,248,.55), inset 0 0 8px rgba(56,189,248,.2); }
@media (prefers-reduced-motion: reduce) { .arena-rank.ar-champion { animation: none; } }

/* รูปเหรียญตราแรงค์อารีน่า & ไอคอนรางวัล */
.arena-rank .ar-medal { width: 24px; height: 24px; vertical-align: middle; margin-right: .3em; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); -webkit-text-fill-color: initial; }
.ar-reward { display: inline-flex; align-items: center; gap: .25em; vertical-align: middle; }
.ar-ricon { width: 20px; height: 20px; object-fit: contain; }

/* ไอคอนเล็กในหน้าเควส/กิลด์ */
.mini-icon { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; margin-right: .25rem; flex: none; }
.reward-row { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; }
.reward-chip { display: inline-flex; align-items: center; font-size: .85em; }
.quest-claim { box-shadow: 0 0 0 2px rgba(251,191,36,.7), 0 0 14px rgba(251,191,36,.55); font-weight: 800; animation: quest-claim-pulse 1.4s ease-in-out infinite; }
@keyframes quest-claim-pulse { 50% { box-shadow: 0 0 0 2px rgba(251,191,36,.9), 0 0 22px rgba(251,191,36,.85); } }
@media (prefers-reduced-motion: reduce) { .quest-claim { animation: none; } }

/* กล่องชื่อเสียง */
.fame-box { margin-top: .5rem; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer; display: flex; flex-direction: column; gap: .35rem; transition: border-color .15s, transform .15s; }
.fame-box:hover, .fame-box:focus-visible { border-color: var(--gold-hi); transform: translateY(-1px); outline: none; }
.fame-box-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.fame-badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .6rem; border-radius: 999px; border: 1px solid; font-size: .85rem; font-weight: 600; }
.fame-badge.t0, .fame-badge.t1 { color: #9fd8ff; border-color: #6ab8ee; background: rgba(106,184,238,.15); }
.fame-badge.t2, .fame-badge.t3 { color: #6ee7b7; border-color: #34b98a; background: rgba(52,185,138,.15); }
.fame-badge.t4, .fame-badge.t5 { color: #d3a8ff; border-color: #a66be8; background: rgba(166,107,232,.18); }
.fame-badge.t6 { color: #ffe08a; border-color: #ffc93c; background: rgba(255,201,60,.18); box-shadow: 0 0 10px rgba(255,201,60,.65); animation: fameGlow 1.8s ease-in-out infinite alternate; }
@keyframes fameGlow { from { box-shadow: 0 0 6px rgba(255,201,60,.4); } to { box-shadow: 0 0 14px rgba(255,201,60,.9); } }
.fame-progress { height: 8px; border-radius: 999px; background: rgba(0,0,0,.35); overflow: hidden; }
.fame-progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #6ab8ee, #58c9a0); transition: width .4s; }
.fame-box.t2 .fame-progress-fill, .fame-box.t3 .fame-progress-fill { background: linear-gradient(90deg, #34b98a, #4a90e2); }
.fame-box.t4 .fame-progress-fill, .fame-box.t5 .fame-progress-fill { background: linear-gradient(90deg, #a66be8, #d98cff); }
.fame-box.t6 .fame-progress-fill { background: linear-gradient(90deg, #ffc93c, #fff0a0); }

/* แถบสถานะส่วนกลาง: ไอคอน + ช่องชื่อเสียง */
.hud-emoji { display: inline-block; width: 18px; margin-right: .25rem; text-align: center; font-size: 15px; line-height: 1; vertical-align: -2px; }
.hud-emoji.hud-level { filter: drop-shadow(0 0 3px rgba(255,201,60,.8)); }
.hud-emoji.hud-power { filter: drop-shadow(0 0 3px rgba(255,110,60,.8)); }
.hud-emoji.hud-fame { color: #ffc93c; font-size: 17px; text-shadow: 0 0 6px rgba(255,201,60,.9); }
.strip-fame { display: inline-flex; flex-direction: column; gap: .25rem; cursor: pointer; min-width: 190px; max-width: 100%; }
.strip-fame:hover, .strip-fame:focus-visible { outline: none; filter: brightness(1.2); }
.strip-fame-top { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .1rem .3rem; }
.strip-fame .fame-badge { font-size: .78rem; padding: 0 .55rem; margin-left: .2rem; }
.topbar .who b .title-badge { margin-right: .4rem; font-size: .72rem; }

/* ===== กระดานเควส: แท็บ Rank & สี ===== */
.rank-F { --rc: #94a3b8; } .rank-E { --rc: #34d399; } .rank-D { --rc: #38bdf8; } .rank-C { --rc: #60a5fa; }
.rank-B { --rc: #c084fc; } .rank-A { --rc: #fb923c; } .rank-S { --rc: #fbbf24; } .rank-guild { --rc: #2dd4bf; } .rank-active { --rc: #f472b6; }
.quest-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.quest-tab { border: 1px solid var(--rc); color: var(--rc); background: color-mix(in srgb, var(--rc) 12%, transparent); border-radius: 8px; padding: .35rem .8rem; font-weight: 700; cursor: pointer; }
.quest-tab:hover { box-shadow: 0 0 8px var(--rc); }
.quest-tab.on { background: color-mix(in srgb, var(--rc) 30%, transparent); box-shadow: 0 0 0 1px var(--rc), 0 0 14px var(--rc); }
.quest-tab.rank-S.on, .quest-tab.rank-S { text-shadow: 0 0 8px rgba(251,191,36,.8); }
.quest-tab.rank-S { box-shadow: 0 0 10px rgba(251,191,36,.45); }
.quest-tab.rank-guild { border-color: #fbbf24; box-shadow: inset 0 0 0 1px var(--rc); }
.rank-badge { display: inline-block; padding: .05rem .5rem; border-radius: 6px; border: 1px solid var(--rc); color: var(--rc); background: color-mix(in srgb, var(--rc) 14%, transparent); font-size: .82rem; }
.rank-badge.rank-S { box-shadow: 0 0 10px rgba(251,191,36,.7); text-shadow: 0 0 6px rgba(251,191,36,.8); }
.rank-badge.rank-guild { border-color: #fbbf24; }
.quest.dungeon { border-left: 3px solid transparent; }
.guild-bonus { display: inline-block; margin-top: .2rem; padding: .1rem .6rem; border-radius: 999px; border: 1px solid #fbbf24; color: #2dd4bf; background: rgba(45,212,191,.12); font-size: .82rem; font-weight: 700; }

.pet-price { color: #fff; width: 8rem; }
.pet-price::placeholder { color: #9aa3b8; }

.center-wide { max-width: 760px; }
.class-list { grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .class-list { grid-template-columns: 1fr; } }
.class-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .4rem; padding: 1.4rem 1rem 1rem; background: linear-gradient(160deg, var(--panel-2), var(--panel)); border: 2px solid var(--gold-dim); border-radius: 12px; transition: transform .2s, box-shadow .2s, border-color .2s; }
.class-card:hover:not(:disabled), .class-card.selected { transform: translateY(-4px); border-color: var(--gold-hi); box-shadow: 0 0 18px rgba(230,180,76,.55), 0 6px 16px rgba(0,0,0,.5); }
.class-card.selected { background: linear-gradient(160deg, #2a2f5a, var(--panel-2)); }
.class-card .class-icon { width: 96px; height: 96px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.6)); }
.class-card b { font-size: 1.25rem; color: var(--gold-hi); }
.class-card .class-main { color: var(--text); }
.class-card .class-sub { color: var(--muted); font-size: .85rem; }
.class-tag { position: absolute; top: .6rem; right: .6rem; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem !important; font-weight: 600; background: linear-gradient(90deg, var(--amber), var(--rose)); color: #2a1a08 !important; }
.start-btn { margin-top: 1.4rem; padding: .85rem 2.4rem; font-size: 1.15rem; border-radius: 10px; box-shadow: 0 0 16px rgba(230,180,76,.5); }
.start-btn:disabled { box-shadow: none; }

.player-id{font-size:12px;margin:2px 0}
.id-copy{font-size:11px;padding:1px 6px;margin-left:4px;cursor:pointer}

.admin-box { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; margin: .6rem 0; }
.admin-box h3 { margin: 0 0 .3rem; font-size: 1rem; }

/* หอคอย 100 ชั้น */
.tower-top { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.tower-banner { display: flex; align-items: center; justify-content: center; gap: .6rem; flex-wrap: wrap; padding: .5rem .8rem; margin: .4rem auto; max-width: 560px; border-radius: 10px;
  font-size: 1.3rem; color: #fff; background: linear-gradient(90deg, #1d2a4a, #2c3e70, #1d2a4a); border: 1px solid #4fc3ff; text-align: center; }
.tower-banner.boss { background: linear-gradient(90deg, #5a0f0f, #b8860b, #5a0f0f); border-color: #ffd700; color: #ffe27a;
  text-shadow: 0 0 8px #ff3b2f; animation: tower-boss-glow 1.6s ease-in-out infinite; }
.tower-boss-tag { padding: .1rem .6rem; border-radius: 999px; background: #8b0000; border: 1px solid #ffd700; font-size: .95rem; }
.tower-info { display: grid; gap: .25rem; margin: .5rem auto; max-width: 560px; }
.tower-fight { display: block; width: 100%; max-width: 560px; margin: .5rem auto; font-size: 1.1rem; }
.grid-table tr.me td { background: rgba(79, 195, 255, .15); }
@keyframes tower-boss-glow { 50% { box-shadow: 0 0 18px rgba(255, 215, 0, .7); filter: brightness(1.15); } }

/* หอเกียรติยศผู้สนับสนุน */
.hall-list { display: flex; flex-direction: column; gap: .5rem; }
.hall-card { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 10px; border: 2px solid #555; background: rgba(255,255,255,.04); }
.hall-1 { border-color: #ffd45a; box-shadow: 0 0 14px rgba(255,210,90,.7); }
.hall-2 { border-color: #cfd6e0; box-shadow: 0 0 8px rgba(207,214,224,.5); }
.hall-3 { border-color: #cd7f32; box-shadow: 0 0 8px rgba(205,127,50,.5); }
.hall-medal { font-size: 1.6rem; }
.hall-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; cursor: pointer; border: 2px solid rgba(255,255,255,.3); }
.hall-info { flex: 1; min-width: 0; }
.hall-name { font-weight: 700; cursor: pointer; }
.hall-name:hover { text-decoration: underline; }
.hall-total { font-weight: 700; color: #ffd45a; white-space: nowrap; }

/* โชว์ไอเทม/สัตว์เลี้ยงในแชท + ปุ่ม 📢 + แผงอีโมจิ */
.share-btn { padding: .1rem .35rem; font-size: .85rem; line-height: 1.2; }
.chat-share { display: inline-flex; align-items: center; gap: .2rem; vertical-align: middle; cursor: pointer; padding: 0 .4rem; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.06); }
.chat-share img { width: 18px; height: 18px; object-fit: contain; }
.chat-share-rf-hi { border-color: #9a7cff; color: #c9b8ff; }
.chat-share-rf-max { border-color: var(--gold-hi, #f0c85a); color: var(--gold-hi, #f0c85a); }
.chat-share-shiny { box-shadow: 0 0 6px rgba(255, 220, 120, .6); }
.chat-form { position: relative; }
.chat-emoji-wrap { position: static; }
.chat-emoji-btn { padding: .2rem .4rem; }
.chat-emoji-pop { position: absolute; left: .7rem; bottom: 100%; width: 15rem; max-width: calc(100% - 1.4rem); display: flex; flex-wrap: wrap; gap: .1rem; padding: .4rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); z-index: 5; }
.chat-emoji-pop[hidden] { display: none; }
.chat-emoji { padding: .15rem .3rem; font-size: 1.15rem; background: transparent; border: 0; box-shadow: none; }

/* กล่องระบบเชิญเพื่อน */
.referral-box .ref-code-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.referral-box .ref-code { flex: 1; min-width: 9rem; font-size: 1.25rem; font-weight: 700; letter-spacing: .12em; text-align: center; color: #fff; background: #1b1b1b; border: 1px dashed #ffd45a; border-radius: 6px; padding: .4rem .7rem; }
.referral-box .ref-input { flex: 1; min-width: 10rem; font: inherit; font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: #1b1b1b; border: 1px solid var(--line); border-radius: 6px; padding: .45rem .7rem; }
.referral-box .ref-input::placeholder { color: #aaa; text-transform: none; letter-spacing: 0; }
.referral-box .ref-banner { margin: .6rem 0; padding: .5rem .7rem; border-radius: 8px; font-weight: 700; color: #3a2400; background: linear-gradient(110deg, #ffd45a, #fff0b0, #8fd4ff); box-shadow: 0 0 10px rgba(255,210,90,.5); }

/* ตารางเป้าหมายรางวัลสะสม (ระบบเชิญเพื่อน) ให้กะทัดรัด */
.referral-box .ref-milestones { width: 100%; font-size: 12.5px; }
.referral-box .ref-milestones td { padding: .3rem .35rem; vertical-align: middle; }
.referral-box .ref-milestones .ref-count { white-space: nowrap; }
.referral-box .ref-milestones td:nth-child(2) { white-space: nowrap; }
.referral-box .ref-milestones td:last-child { white-space: nowrap; text-align: center; }
.referral-box .ref-milestones .title-badge { font-size: 11.5px; padding: 0 .3rem; margin: 0; }
@media (max-width: 600px) { .referral-box .ref-milestones td:nth-child(2) { white-space: normal; } }

/* 📖 Wiki */
.wiki-btn { padding: .15rem .6rem; font-size: .78rem; margin-right: .3rem; border-color: #d4a937; color: #f1d27a; }
.wk-backdrop { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.wk-box { width: min(60rem, 100%); max-height: 90vh; display: flex; flex-direction: column; background: #0d1b3a; color: #e6ecff; border: 2px solid #d4a937; border-radius: 10px; box-shadow: 0 0 24px rgba(212,169,55,.35); overflow: hidden; }
.wk-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem 1rem; background: #13265a; border-bottom: 2px solid #d4a937; }
.wk-head h2 { margin: 0; font-size: 1.15rem; color: #f1d27a; }
.wk-x { padding: .2rem .6rem; }
.wk-main { display: flex; min-height: 0; flex: 1; }
.wk-side { display: flex; flex-direction: column; gap: .35rem; padding: .7rem; width: 15rem; flex-shrink: 0; overflow-y: auto; background: #0a1530; border-right: 1px solid #d4a93766; }
.wk-nav { text-align: left; font-size: .85rem; background: #13265a; border: 1px solid #d4a93788; color: #e6ecff; }
.wk-nav:hover { background: #1c367a; }
.wk-body { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; line-height: 1.7; font-size: .95rem; }
.wk-body section { margin-bottom: 1.4rem; }
.wk-body h3 { margin: 0 0 .4rem; color: #f1d27a; border-bottom: 1px solid #d4a93766; padding-bottom: .25rem; }
.wk-body ul { padding-left: 1.2rem; margin: .4rem 0; }
.wk-card { background: #13265a; border: 1px solid #d4a93788; border-radius: 8px; padding: .5rem .8rem; margin: .5rem 0; }
.wk-card h4 { margin: 0 0 .25rem; color: #f1d27a; }
.wk-card ul { margin: .2rem 0; }
.wk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .5rem; }
.wk-tip { background: #13265a; border-left: 3px solid #d4a937; padding: .4rem .7rem; border-radius: 4px; }
@media (max-width: 640px) {
  .wk-main { flex-direction: column; }
  .wk-side { width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid #d4a93766; }
  .wk-nav { white-space: nowrap; }
}

/* ป้ายสิทธิ์ฟื้นสตามิน่า */
.sta-perk { font-size: 12px; line-height: 1.4; padding: 4px 8px; margin: 4px 0; border-radius: 6px; border: 1px solid transparent; }
.sta-perk.premium { color: #3b2a00; background: linear-gradient(90deg, #ffd45a, #ffb300); border-color: #e0a100; font-weight: 600; }
.sta-perk.free { color: #cfd6e4; background: rgba(120, 140, 180, .15); border-color: rgba(120, 140, 180, .35); }

/* แจ้งเตือนเควสพร้อมส่ง */
.tab-badge { display: inline-block; margin-left: .35rem; padding: 0 .4rem; border-radius: 999px; background: #c62828; color: #fff; font-size: .75rem; line-height: 1.4; font-weight: 700; animation: quest-pulse 1.6s ease-in-out infinite; }
@keyframes quest-pulse { 50% { transform: scale(1.12); box-shadow: 0 0 8px #ff5252; } }
#quest-toasts { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; max-width: min(340px, calc(100vw - 2rem)); pointer-events: none; }
.quest-toast { pointer-events: auto; cursor: pointer; padding: .7rem 1rem; border-radius: 8px; background: linear-gradient(135deg, #2e7d32, #1b5e20); color: #fff; border: 1px solid #81c784; box-shadow: 0 4px 16px rgba(0,0,0,.5); animation: quest-toast-in .35s ease-out; }
@keyframes quest-toast-in { from { opacity: 0; transform: translateX(40px); } }

/* ===== มือถือ (≤768px): เต็มจอ + เมนูล่าง + การ์ดมอนสเตอร์แนวตั้ง ===== */
@media (max-width: 768px) {
  #app { max-width: 100%; width: 100%; padding: 8px 8px 70px; box-sizing: border-box; }
  .panel, .card, .box { border-radius: 8px; }

  .topbar .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 999;
    display: flex; flex-wrap: nowrap; gap: .25rem; margin: 0; padding: .35rem .4rem;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    background: var(--panel, #0f1d4d); border-top: 2px solid var(--gold-dim, #8a7a4a);
    box-shadow: 0 -4px 14px rgba(0,0,0,.5); padding-bottom: max(.35rem, env(safe-area-inset-bottom));
  }
  .topbar .tabs::-webkit-scrollbar { display: none; }
  .topbar .tabs .tab {
    flex: 0 0 auto; min-width: 64px; min-height: 44px; padding: .3rem .55rem;
    font-size: .75rem; white-space: nowrap; border-radius: 8px; border-bottom-width: 2px;
  }
  .topbar .tabs .tab .ico { display: block; margin: 0 auto 2px; }

  .monster { flex-direction: column; align-items: stretch; gap: .5rem; }
  .monster .info { flex: none; width: 100%; text-align: left; overflow-wrap: break-word; word-break: normal; }
  .monster > button.primary { width: 100%; min-height: 44px; font-size: 1rem; }

  .table-wrap, .inv-list { max-width: 100%; }
  table { width: 100%; }
  .pet-modal, .wk-box, .inspect-modal { max-width: 100%; width: 100%; box-sizing: border-box; }
  .pet-modal-backdrop { padding: .5rem; }
  input, select, textarea { font-size: 16px !important; }

  /* Header: แถวบน = รูป/ชื่อ/ออกจากระบบ, แถวล่าง = คู่มือ + ออนไลน์ + ตัวปรับเสียง (ไม่ซ้อนทับ) */
  .topbar { flex-wrap: wrap; gap: 6px; }
  .topbar .who { min-width: 0; overflow-wrap: anywhere; }
  .topbar .audio-panel {
    position: static; order: 2; flex: 1 1 100%;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 6px;
  }
  .topbar .audio-panel .mute-btn { position: static; }
  .topbar .server-badge { margin-right: 0; }
  .topbar .server-badge .sb-popup { left: 0; right: auto; max-width: calc(100vw - 24px); }
}

/* ===== แชทลอยบนมือถือ (≤768px) — PC ไม่กระทบ ===== */
.chat-fab, .chat-close { display: none; }
@media (max-width: 768px) {
  .chat-fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; bottom: 75px; right: 14px; z-index: 1000;
    width: 52px; height: 52px; padding: 0; border-radius: 50%; font-size: 1.5rem;
    background: linear-gradient(180deg, #24336a, #141d40); border: 2px solid var(--gold-dim, #8a7a4a);
    box-shadow: 0 4px 14px rgba(0,0,0,.6);
  }
  .chat-fab[hidden], .chat-fab.chat-fab-hide { display: none; }
  .chat-fab-badge {
    position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box;
    border-radius: 10px; background: #e53935; color: #fff; font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center;
  }
  .chat-fab-badge[hidden] { display: none; }
  .chat { right: 3vw; left: 3vw; bottom: 75px; width: 94vw; height: 55vh; z-index: 1001; display: flex; flex-direction: column; }
  .chat.closed { display: none; }
  .chat .chat-head { display: none; }
  .chat .chat-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding-top: 2.4rem; }
  .chat .chat-list { flex: 1; height: auto; min-height: 0; }
  .chat-close {
    display: block; position: absolute; top: .4rem; right: .5rem; z-index: 2;
    padding: .25rem .6rem; font-size: .85rem; min-height: 32px;
  }
  .chat-form input, #chat-input { font-size: 16px !important; }
}

/* ===== หน้าต่อสู้: จัดระเบียบ + ผลการต่อสู้ลอยตามจอ ===== */
#battle-bar { display: none; }
.battle-main > .panel { padding: .7rem .8rem; margin-bottom: .6rem; }
.battle-main > .repair-bar { padding: .45rem .8rem; margin-bottom: .5rem; }
.battle-main .hp-box { margin: .35rem 0; padding: .45rem .6rem; }
.battle-main #bot-panel { margin: .4rem 0; padding: .45rem .6rem; }
.battle-main .monster { padding: .4rem 0; }
/* เดสก์ท็อป: การ์ดมอนสเตอร์ 2 คอลัมน์ (ซ้าย: กรอบ VS + ปุ่มต่อสู้ / ขวา: ข้อมูลเต็มความกว้าง) */
@media (min-width: 769px) {
  .battle-main .monster { display: grid; grid-template-columns: 170px minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: .8rem; row-gap: .4rem; align-items: start; }
  .battle-main .monster > .arena.duel.arena-sm { grid-column: 1; grid-row: 1; width: 100%; max-width: none; }
  .battle-main .monster > button.primary { grid-column: 1; grid-row: 2; width: 100%; height: 38px; min-height: 0; padding: 0 .6rem; }
  .battle-main .monster > .info { grid-column: 2; grid-row: 1 / span 3; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: .15rem .5rem; }
  .battle-main .monster > .info > div, .battle-main .monster > .info > small { flex: 0 0 100%; }
  .battle-main .monster > .info > .rec-line { white-space: nowrap; }
}
.battle-side > .panel { margin-bottom: .5rem; padding: .6rem .7rem; }
.battle-side h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.battle-side h3 { margin: .5rem 0 .3rem; font-size: .92rem; }
.battle-side .stat-grid, .battle-side .rec-grid { gap: .3rem; }
.battle-side .stat { padding: .3rem .45rem; }
.battle-side .muted { font-size: .78rem; line-height: 1.35; }
.battle-side .advice { padding: .35rem .5rem; font-size: .8rem; }
.battle-side .result { padding: .45rem .6rem; font-size: .88rem; line-height: 1.4; }
.battle-side .log { max-height: 160px; }
@media (min-width: 769px) {
  .battle-side { position: sticky; top: 16px; align-self: start; }
}
@media (max-width: 768px) {
  #battle-bar {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    position: fixed; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 998;
    padding: .45rem .7rem; border-radius: 8px; font-size: .85rem; line-height: 1.3; color: #fff;
    border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.55); background: var(--panel, #0f1d4d);
  }
  #battle-bar[hidden] { display: none; }
  #battle-bar.win { border-color: var(--mint); background: linear-gradient(135deg, #1b4d2c, #0f2a1a); }
  #battle-bar.lose { border-color: var(--rose); background: linear-gradient(135deg, #5a1f2a, #2a0f15); }
  #battle-bar .bb-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  #battle-bar .bb-hp { flex-shrink: 0; opacity: .85; white-space: nowrap; }
  #battle-bar.bb-flash { animation: bb-pop .35s ease-out; }
  #app { padding-bottom: 120px; }
}
@keyframes bb-pop { from { transform: translateY(12px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #battle-bar.bb-flash { animation: none; } }

/* ตลาดมืด */
.bm-panel { background: linear-gradient(180deg, #1a1030, #0d0a1c); border: 1px solid #5b3a8c; box-shadow: 0 0 18px rgba(120, 70, 200, .25); }
.bm-reset { margin: .5rem 0 .8rem; padding: .4rem .8rem; border-radius: 8px; background: rgba(91, 58, 140, .25); display: inline-block; }
.bm-reset b { font-variant-numeric: tabular-nums; color: #d9b8ff; }
.bm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
@media (max-width: 1000px) { .bm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .bm-grid { grid-template-columns: 1fr; } }
.bm-card { display: flex; flex-direction: column; gap: .4rem; padding: .8rem; border-radius: 10px; background: #150f27; border: 1px solid #4a2f75; transition: transform .15s, box-shadow .15s; }
.bm-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(120, 70, 200, .35); }
.bm-card.sold-out { opacity: .55; filter: grayscale(.6); }
.bm-name { font-weight: 600; font-size: 1.05rem; }
.bm-price { color: #ffd36b; font-size: 1.15rem; font-weight: 600; }
.bm-price small { color: var(--muted); font-weight: 400; }
.bm-special { position: relative; border: 2px solid #c9a227; background: linear-gradient(160deg, #2a1650, #1a1030 60%, #3a2a0a); box-shadow: 0 0 14px rgba(201, 162, 39, .45), inset 0 0 12px rgba(150, 80, 230, .3); }
.bm-badge { align-self: flex-start; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: linear-gradient(90deg, #7b3fd1, #c9a227); color: #fff; }
.bm-reward { color: #ffd36b; font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: .3rem; }
.bm-req { color: #d9b8ff; }
.bm-actions { display: flex; flex-direction: column; gap: .35rem; margin-top: .2rem; }

/* ---------- สมุดสะสมการ์ด (Card Codex) ---------- */
.title-badge.tb-codex { color: #e4f3ff; border-color: #6fb7e8; background: linear-gradient(135deg, #2a5fa8, #3c9ac4); box-shadow: 0 0 7px rgba(111,183,232,.5); }
.title-badge.tb-codex_grand { color: #3a2400; border-color: #fff0b0; background: linear-gradient(110deg, #ffc93a, #fff3b8, #ffb347, #fff3b8, #ffc93a); background-size: 250% 100%; box-shadow: 0 0 12px rgba(255,205,70,.9), 0 0 24px rgba(255,170,40,.5); animation: tb-shine 2.5s linear infinite; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .title-badge.tb-codex_grand { animation: none; } }
.codex-summary { margin: 0 0 .8rem; padding: .5rem .8rem; border: 1px solid var(--gold-dim); border-radius: 8px; background: var(--panel-2); }
.codex-set { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; margin-bottom: .9rem; background: var(--panel-2); }
.codex-set.done { border-color: var(--mint); }
.codex-set.grand { border-color: var(--gold-hi); box-shadow: 0 0 14px rgba(255,205,70,.25); background: linear-gradient(160deg, var(--panel-2), #2a2410); }
.codex-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem; }
.codex-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; margin: .5rem 0; }
.codex-bar > div { height: 100%; background: linear-gradient(90deg, var(--mint), var(--amber)); transition: width .3s; }
.codex-reward { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .4rem 0 .7rem; font-size: .9rem; }
.codex-cell { position: relative; }
.codex-cell.locked .card-frame { filter: grayscale(1) brightness(.35); opacity: .75; }
.codex-cell.got .card-frame { box-shadow: 0 0 10px rgba(88,201,160,.55); }
.codex-tick { position: absolute; top: 4px; right: 4px; z-index: 2; background: var(--mint); color: #06281d; border-radius: 999px; width: 22px; height: 22px; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.codex-claim { background: var(--amber); color: #2a2108; font-weight: 700; }

/* เปลี่ยนชื่อตัวละคร */
.rename-btn { margin-left: .4rem; padding: .15rem .5rem; font-size: .85rem; }
.rename-input { width: 100%; box-sizing: border-box; }
.rename-fee { text-align: center; padding: .4rem; border-radius: 6px; background: rgba(0,0,0,.25); }
.rename-fee.free { color: #51cf66; }
.rename-err { min-height: 1.1em; text-align: center; color: #ff6b6b; font-size: .9rem; }

/* ---------- ส่วนหัวโปรไฟล์ ---------- */
.prof-top { display: flex; gap: 16px; align-items: center; margin-bottom: .8rem; }
.prof-info { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.prof-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--line); }

/* ป้ายสถานะบอทลอย (เห็นทุกแท็บ) */
.bot-float { position: fixed; left: 12px; bottom: 12px; z-index: 9000; display: flex; align-items: center; gap: 10px;
  max-width: min(92vw, 420px); padding: 8px 12px; border-radius: 10px; background: #1b2a1f; color: #fff;
  border: 2px solid #2e9e4f; box-shadow: 0 4px 14px rgba(0,0,0,.45); }
.bot-float.stopped { background: #3a1b1b; border-color: #c0392b; }
.bot-float-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.bot-float-txt small { opacity: .9; }
.bot-float button { flex: none; background: #c0392b; color: #fff; border: 0; border-radius: 6px; padding: 6px 10px; cursor: pointer; font-weight: 600; }

/* badge บอทฟาร์มลอย + กล่องสรุปบอท (เหมาะกับมือถือ) */
.auto-farm-badge { position: fixed; top: calc(env(safe-area-inset-top) + 6px); right: 8px; z-index: 900; pointer-events: none;
  padding: 3px 9px; font-size: 12px; border-radius: 14px; border: 1px solid #3a7; background: rgba(20,60,40,.92); color: #fff;
  cursor: pointer; max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-farm-badge:not([style*="display: none"]) { pointer-events: auto; }
.auto-summary { margin: 6px 0; line-height: 1.6; }
.auto-summary > div { display: flex; flex-wrap: wrap; gap: 0 .3rem; }

/* ---------- กิจกรรมลอยกระทง ---------- */
.title-badge.tb-loy { color: #fff4d6; border-color: #ffb84a; background: linear-gradient(135deg, #c2571a, #f0a030); box-shadow: 0 0 8px rgba(255,170,60,.6); }
.title-badge.tb-loy_gold { color: #3a2400; border-color: #fff0a0; background: linear-gradient(110deg, #ffd45a, #fff6c0, #ffc83a, #fff6c0, #ffd45a); background-size: 250% 100%; box-shadow: 0 0 12px rgba(255,215,90,.9), 0 0 22px rgba(255,190,60,.5); animation: tb-shine 3s linear infinite; }
.loy-banner { text-align: center; height: 170px; padding: 0; background: linear-gradient(180deg, #091326 0%, #0d2142 60%, #102a54 100%); border-color: #ffb84a; position: relative; overflow: hidden; }
.loy-banner-text { position: absolute; left: 0; right: 0; top: 10px; z-index: 2; pointer-events: none; padding: 0 .8rem; text-shadow: 0 1px 6px #000; }
.loy-banner-text h2 { margin: 0 0 .2rem; font-size: 1.15rem; }
.loy-river { position: absolute; inset: 0; overflow: hidden; }
.loy-total { position: absolute; top: 6px; right: 10px; z-index: 3; font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.45); color: #cfe3ff; }
.loy-boat { position: absolute; left: 0; display: flex; flex-direction: column; align-items: center; will-change: transform; animation: loy-drift linear infinite; }
.loy-boat-icon { font-size: 1.5rem; filter: drop-shadow(0 0 6px rgba(255,180,60,.8)); }
.loy-boat-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .65rem; padding: 0 5px; border-radius: 6px; background: rgba(0,0,0,.4); color: #e6eeff; border: 1px solid transparent; }
.loy-boat.mine { z-index: 2; }
.loy-boat.mine .loy-boat-name { border-color: var(--gold); color: #fff3cf; background: rgba(60,40,0,.65); box-shadow: 0 0 8px rgba(226,184,87,.7); }
@keyframes loy-drift { from { transform: translateX(100vw); } to { transform: translateX(-120px); } }
@media (max-width: 600px) { .loy-banner-text h2 { font-size: 1rem; } .loy-banner-text .muted { font-size: .72rem; } }
.loy-lantern { font-size: 3rem; animation: loy-float 3.5s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(255,180,60,.9)); }
@keyframes loy-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.loy-mats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin: .6rem 0; }
.loy-mat { padding: .6rem; border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.loy-mat.ok { border-color: #ffb84a; box-shadow: 0 0 10px rgba(255,184,74,.35); }
.loy-float { width: 100%; min-height: 44px; font-size: 1.05rem; margin-bottom: .5rem; }
.loy-bar { position: relative; height: 16px; margin: 1rem 0 1.6rem; border-radius: 999px; background: rgba(255,255,255,.1); border: 1px solid var(--line); }
.loy-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ff9a3a, #ffd45a); transition: width .4s; }
.loy-mark { position: absolute; top: 20px; transform: translateX(-50%); font-size: .8rem; opacity: .6; }
.loy-mark.on { opacity: 1; color: #ffd45a; font-weight: 700; }
.loy-ms-list { display: grid; gap: .6rem; }
.loy-ms { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .6rem; border: 1px solid var(--line); border-radius: 10px; }
.loy-ms.gold { border-color: #ffd45a; box-shadow: 0 0 10px rgba(255,212,90,.35); }
@media (prefers-reduced-motion: reduce) { .loy-boat { animation: none; left: 40%; } .loy-lantern,.title-badge.tb-loy_gold { animation: none; } }

/* ===== Redesign (ขั้นที่ 2): Design Tokens + component กลาง — ดู REDESIGN_SPEC.md ===== */
:root {
  /* Surfaces */
  --bg-app: #0A0F1C; --bg-panel: #121A2E; --bg-nav: #10172A; --bg-inset: #0E1527;
  --bg-track: #0B1122; --bg-track-sm: #1A2340; --bg-hover: #1F2A47; --bg-slot: #1C2742;
  /* Borders */
  --border-subtle: #1C2640; --border: #26324F; --border-nav: #222D48; --border-strong: #3A4668;
  /* Text */
  --text-heading: #F1E7CC; --text-primary: #E8E6DF; --text-secondary: #AEB5C8; --text-muted: #8A93AB; --text-disabled: #4F5A78;
  /* Accent (--gold ตามสเปคอยู่ใน .rd ด้านล่าง เพราะชื่อชนกับ --gold เดิมที่หน้าอื่นใช้อยู่) */
  --gold-light: #F3D58A; --on-gold: #1A1406;
  /* Resource bars */
  --hp: #E05A5A; --stamina: #3FBF9F; --exp: var(--gold); --reputation: #6AA8FF;
  --durability: #8FB3D9; --durability-low: #F0B45A; --durability-broken: #F07A7A;
  /* Semantic */
  --online: #3FBF9F;
  --alert-bg: #2A1712; --alert-border: #6B3420; --alert-accent: #FF9A6B; --alert-title: #FFD9C7; --alert-body: #D9B3A3;
  --system-bg: #241A10; --system-border: #4D3517; --system-text: #F3D9B0; --system-meta: #C9A36B;
  --admin-name: #FF9A6B; --user-name: #6AA8FF;
  /* Item type tags */
  --tag-equip-bg: #1E2B4A; --tag-equip: #A9C4F0;
  --tag-use-bg: #3A1C22; --tag-use: #F2A7B0;
  --tag-mat-bg: #1E3029; --tag-mat: #9ED9C0;
  --tag-card-bg: #2B2550; --tag-card: #C9C0FF;
  --title-badge-bg: #2B2550; --title-badge-border: #4A3F8A;
  --rank-badge-bg: #173A33; --rank-badge: #8FE3CB;
  /* Typography (--font-body ตามสเปคอยู่ใน .rd) */
  --font-display: 'Noto Serif Thai', serif;
  --fs-xs: 11px; --fs-sm: 12px; --fs-base: 13px; --fs-md: 14px;
  --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 26px; --fs-3xl: 30px;
  --lh: 1.5;
  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-7: 28px;
  /* Radius */
  --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px; --r-card: 16px; --r-nav: 14px; --r-pill: 999px;
  /* Sizing */
  --control-h: 40px; --control-h-sm: 32px; --nav-item-h: 38px;
  --bar-lg: 10px; --bar-md: 6px; --bar-sm: 4px;
}
/* ค่าที่ชนกับตัวแปรเดิม: ใช้เฉพาะภายในหน้าที่ออกแบบใหม่ (ครอบด้วย class "rd") เพื่อไม่ให้หน้าอื่นเปลี่ยนสี/ฟอนต์ */
.rd {
  --gold: #E2B857;
  --font-body: 'IBM Plex Sans Thai', system-ui, sans-serif;
  font-family: var(--font-body); line-height: var(--lh); color: var(--text-primary);
}
.rd .num, .rd-num { font-variant-numeric: tabular-nums; }

/* Panel */
.rd-panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r-card); padding: 22px 24px; }

/* Button */
.rd-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--control-h); padding: 0 var(--sp-4); font: 600 var(--fs-md)/1 var(--font-body); border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.rd-btn.sm { min-height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-base); border-radius: var(--r-sm); }
.rd-btn:focus-visible, .rd-nav-item:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rd-btn:disabled { color: var(--text-disabled); cursor: not-allowed; opacity: 1; }
.rd-btn.primary-gold { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.rd-btn.primary-gold:hover:not(:disabled) { background: var(--gold-light); border-color: var(--gold-light); }
.rd-btn.secondary { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.rd-btn.secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.rd-btn.ghost { background: transparent; color: var(--gold); border-color: transparent; padding: 0 var(--sp-2); }
.rd-btn.ghost:hover:not(:disabled) { color: var(--gold-light); background: transparent; border-color: transparent; }
.rd-btn.danger-alert { background: var(--alert-accent); color: var(--alert-bg); border-color: var(--alert-accent); }
.rd-btn.danger-alert:hover:not(:disabled) { filter: brightness(1.1); border-color: var(--alert-accent); }
.rd-btn.icon { width: var(--control-h); padding: 0; background: var(--bg-panel); color: var(--text-secondary); border-color: var(--border); }
.rd-btn.icon.sm { width: var(--control-h-sm); }
.rd-btn.icon:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.rd-btn .rd-ico { width: 18px; height: 18px; flex: none; }

/* ProgressBar */
.rd-bar { background: var(--bg-track); border-radius: var(--r-pill); overflow: hidden; height: var(--bar-lg); }
.rd-bar.md { height: var(--bar-md); }
.rd-bar.sm { height: var(--bar-sm); background: var(--bg-track-sm); }
.rd-bar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--bar-color, var(--gold)); }

/* Pill / Tag */
.rd-pill { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 2px var(--sp-3); border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; line-height: 1.5; background: var(--bg-hover); color: var(--text-secondary); }
.rd-pill.gold { background: var(--gold); color: var(--on-gold); }
.rd-pill.title { background: var(--title-badge-bg); color: var(--tag-card); border: 1px solid var(--title-badge-border); }
.rd-pill.rank { background: var(--rank-badge-bg); color: var(--rank-badge); }
.rd-pill.alert { background: var(--alert-accent); color: var(--alert-bg); }
.rd-pill.rep { background: var(--reputation); color: var(--bg-app); }
.rd-tag { display: inline-block; padding: 1px var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; }
.rd-tag.equip { background: var(--tag-equip-bg); color: var(--tag-equip); }
.rd-tag.use { background: var(--tag-use-bg); color: var(--tag-use); }
.rd-tag.mat { background: var(--tag-mat-bg); color: var(--tag-mat); }
.rd-tag.card { background: var(--tag-card-bg); color: var(--tag-card); }

/* ResourceChip */
.rd-chip { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h); padding: 0 var(--sp-4); background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r-pill); }
.rd-chip .rd-ico { width: 18px; height: 18px; color: var(--gold); flex: none; }
.rd-chip small { font-size: var(--fs-sm); color: var(--text-muted); }
.rd-chip b { font-size: var(--fs-md); color: var(--text-heading); font-variant-numeric: tabular-nums; }

/* NavGroup / NavItem */
.rd-nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--sp-4); }
.rd-nav-title { margin: 0 var(--sp-3) var(--sp-1); font: 600 var(--fs-xs)/1.5 var(--font-body); letter-spacing: .08em; color: var(--text-muted); }
.rd-nav-item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--nav-item-h); padding: 0 var(--sp-3); font: 400 var(--fs-md)/1 var(--font-body); color: #C3C9D9; background: transparent; border: 1px solid transparent; border-radius: var(--r-md); text-align: left; cursor: pointer; text-decoration: none; }
.rd-nav-item:hover { background: var(--bg-hover); }
.rd-nav-item.active { background: var(--bg-hover); border-color: var(--border-strong); color: var(--gold-light); font-weight: 600; }
.rd-nav-item .rd-ico { width: 18px; height: 18px; flex: none; }
.rd-nav-item .rd-badge { margin-left: auto; }

/* ===== Redesign ขั้นที่ 3: เลย์เอาต์ Desktop (>= 1024px) — ใช้เฉพาะเมื่อ JS ใส่ .rd-shell-on ให้ #app จึงไม่กระทบมือถือ/จอเล็ก ===== */
#app.rd-shell-on { max-width: 1440px; padding: var(--sp-5); }
.rd-shell { display: flex; gap: var(--sp-5); align-items: flex-start; }
.rd-main { flex: 999 1 560px; min-width: 0; }
.rd-side { flex: 0 0 216px; position: sticky; top: var(--sp-5); display: flex; flex-direction: column; max-height: calc(100vh - 40px); overflow-y: auto; padding: var(--sp-4) var(--sp-3); background: var(--bg-nav); border: 1px solid var(--border-nav); border-radius: var(--r-nav); }
.rd-logo { display: flex; align-items: center; gap: var(--sp-2); margin: 0 var(--sp-2) var(--sp-5); font: 700 var(--fs-xl)/1.3 var(--font-display); color: var(--text-heading); }
.rd-logo .rd-ico { width: 24px; height: 24px; color: var(--gold); }
.rd-side-foot { margin-top: auto; padding-top: var(--sp-3); border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 2px; }
.rd-side .server-badge { margin: 0; }
.rd-side .server-badge .sb-popup { top: auto; bottom: 100%; left: 0; right: auto; width: 100%; margin: 0 0 4px; background: var(--bg-panel); border-color: var(--border); }
.rd-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--online); flex: none; margin: 0 5px; }
.rd-nav-item:hover:not(:disabled) { border-color: transparent; }
.rd-nav-item.active:hover:not(:disabled) { border-color: var(--border-strong); }
.rd-nav-item .rd-badge { display: inline-flex; }
.rd-nav-item .rd-pill { padding: 0 var(--sp-2); font-size: var(--fs-xs); }

/* ไอคอนเมนูซ้าย: กรอบ 28x28 + Duotone (พื้นจาง fill-opacity .2 + เส้นสดตามหมวด) */
.rd-nav-group { --nav-c: #7CC4FF; --nav-c2: #E3B94F; }
.rd-nav-group[data-cat="char"] { --nav-c: #7CC4FF; --nav-c2: #E3B94F; }
.rd-nav-group[data-cat="adv"]  { --nav-c: #FF9A4D; --nav-c2: #FF5A4D; }
.rd-nav-group[data-cat="eco"]  { --nav-c: #E3B94F; --nav-c2: #4FD68A; }
.rd-nav-group[data-cat="soc"]  { --nav-c: #B48CFF; --nav-c2: #5FB8FF; }
.rd-nav-group[data-cat="adm"]  { --nav-c: #FF7A7A; --nav-c2: #E3B94F; }
.rd-side .rd-nav-item .rd-ico { width: 28px; height: 28px; padding: 5px; box-sizing: border-box; border-radius: 8px; background: var(--bg-slot); color: var(--nav-c, #7CC4FF); transition: background .15s, color .15s; }
.rd-side .rd-nav-item .rd-ico svg { fill: var(--nav-c2, #E3B94F); fill-opacity: 0.2; }
.rd-side .rd-nav-item:hover .rd-ico { color: var(--nav-c2, var(--gold-light)); }
.rd-side .rd-nav-item.active .rd-ico { background: rgba(243, 213, 138, 0.28); color: var(--gold-light); }
.rd-side .rd-nav-item.active .rd-ico svg { fill: var(--gold-light); fill-opacity: 0.2; }

.rd-topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.rd-eyebrow { font-size: var(--fs-sm); color: var(--text-muted); }
.rd-topbar h1 { margin: 0; font: 700 var(--fs-2xl)/1.3 var(--font-display); color: var(--text-heading); }
.rd-topbar-right { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.rd-audio { position: relative; display: flex; gap: var(--sp-2); }
.rd-btn.icon.off { color: var(--text-disabled); }
.rd-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 220px; display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.rd-pop[hidden] { display: none; }
.rd-slider { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-muted); }
.rd-slider input { width: 100%; accent-color: var(--gold); cursor: pointer; }

.rd-alert { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-4); padding: 14px 18px; background: var(--alert-bg); border: 1px solid var(--alert-border); border-radius: var(--r-xl); }
.rd-alert-ico { width: 28px; height: 28px; flex: none; color: var(--alert-accent); }
.rd-alert-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rd-alert-text b { color: var(--alert-title); font-size: var(--fs-md); }
.rd-alert-text span { color: var(--alert-body); font-size: var(--fs-sm); }

/* ===== Redesign ขั้นที่ 4-5: Hero card / Stats / Equipment (Desktop เท่านั้น — JS สร้างเฉพาะเมื่อ >= 1024px) ===== */
.rd { --exp: var(--gold); }
.rd-profile { display: flex; flex-direction: column; gap: var(--sp-5); }
.rd-profile .panel { margin: 0; }
.rd-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: var(--sp-5); align-items: start; }
.rd-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.rd-card-head h2 { margin: 0; font: 600 var(--fs-lg)/1.3 var(--font-display); color: var(--text-heading); }
.rd-card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-4); }
.rd-card-foot small { color: var(--text-muted); font-size: var(--fs-sm); }

/* popover / เมนู */
.rd-dd { position: relative; display: inline-block; }
.rd-pop.rd-title-pop, .rd-pop.rd-menu-pop { right: auto; left: 0; min-width: 260px; gap: 2px; padding: var(--sp-2); }
.rd-pop.rd-menu-pop { left: auto; right: 0; min-width: 180px; }
.rd-menu-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: var(--sp-2) var(--sp-3); font: 500 var(--fs-base)/1.4 var(--font-body); color: var(--text-primary); background: transparent; border: 1px solid transparent; border-radius: var(--r-md); text-align: left; cursor: pointer; }
.rd-menu-item:hover:not(:disabled) { background: var(--bg-hover); border-color: transparent; }
.rd-menu-item.active { background: var(--bg-hover); color: var(--gold-light); }
.rd-menu-item:disabled { color: var(--text-disabled); }
.rd-menu-item small { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 400; }
.rd-menu-item .rd-ico { width: 16px; height: 16px; }
.rd-menu-pop .rd-menu-item { flex-direction: row; align-items: center; gap: var(--sp-2); }
.rd-menu-item:focus-visible, .rd-fame:focus-visible, .rd-title-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rd-empty { padding: var(--sp-3); color: var(--text-muted); font-size: var(--fs-sm); }

/* Hero */
.rd-hero { display: flex; flex-wrap: wrap; gap: var(--sp-7); align-items: flex-start; }
.rd-hero-left { display: flex; gap: var(--sp-5); flex: 0 1 auto; min-width: 0; }
.rd-hero-right { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.rd-avatar-wrap { position: relative; flex: none; width: 104px; height: 104px; }
.rd-hero img.rd-avatar { width: 104px; height: 104px; border-radius: 20px; border: 2px solid var(--gold); object-fit: cover; box-shadow: none; display: block; }
.rd-lv { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); white-space: nowrap; }
.rd-hero-info { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); min-width: 0; }
.rd-title-btn { cursor: pointer; font-family: var(--font-body); }
.rd-title-btn:hover:not(:disabled) { border-color: var(--title-badge-border); background: var(--title-badge-bg); filter: brightness(1.2); }
.rd-title-btn .rd-ico { width: 14px; height: 14px; }
.rd-name-row { display: flex; align-items: center; gap: var(--sp-2); }
.rd-name { margin: 0; font: 700 var(--fs-3xl)/1.2 var(--font-display); color: var(--text-heading); overflow-wrap: anywhere; }
.rd-sub { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1); font-size: var(--fs-base); color: var(--text-secondary); }
.rd-premium { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-base); color: var(--gold-light); }
.rd-premium .rd-ico { width: 18px; height: 18px; }
.rd-res-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); margin-bottom: 6px; font-size: var(--fs-md); font-weight: 600; color: var(--text-heading); }
.rd-res-head small { font-weight: 400; font-size: var(--fs-sm); color: var(--text-muted); }
.rd-res-note { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.rd-hero-right .pet-podium { margin: 0; }
.rd-fame { display: flex; flex-direction: column; gap: var(--sp-2); width: 100%; padding: var(--sp-3) var(--sp-4); font: inherit; color: var(--text-primary); background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--r-lg); text-align: left; cursor: pointer; }
.rd-fame:hover:not(:disabled) { border-color: var(--border-strong); }
.rd-fame-top { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-base); }
.rd-fame-top b { color: var(--text-heading); }
.rd-fame-top small { margin-left: auto; color: var(--text-muted); font-size: var(--fs-sm); }
.rd-avatar-picker { flex: 1 1 100%; }

/* Stats */
.rd-points { font-size: var(--fs-base); color: var(--text-muted); }
.rd-points b { color: var(--text-heading); font-size: var(--fs-md); }
.rd-points.has b { color: var(--gold-light); }
.rd-stat-row { display: grid; grid-template-columns: 64px 56px 1fr auto; gap: var(--sp-3); align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border-subtle); }
.rd-stat-name { display: flex; flex-direction: column; line-height: 1.3; }
.rd-stat-name b { color: var(--text-heading); font-size: var(--fs-md); }
.rd-stat-name small, .rd-stat-desc small { color: var(--text-muted); font-size: var(--fs-sm); }
.rd-stat-total { font-size: 22px; color: var(--text-heading); }
.rd-stat-desc { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-sm); color: var(--text-secondary); line-height: 1.4; }
.rd-stat-btns { display: flex; gap: var(--sp-1); }
.rd-btn.rd-step { width: 36px; min-height: 32px; padding: 0; }
.rd-derived { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); margin-top: var(--sp-4); }
.rd-derived-cell { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-2) var(--sp-3); background: var(--bg-inset); border-radius: var(--r-md); min-width: 0; }
.rd-derived-cell small { font-size: var(--fs-xs); color: var(--text-muted); }
.rd-derived-cell b { font-size: 17px; color: var(--text-heading); overflow-wrap: anywhere; }

/* Equipment */
.rd-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.rd-slot { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); background: var(--bg-inset); border: 1px solid var(--border-subtle); border-radius: var(--r-lg); min-width: 0; }
.rd-slot.empty { background: transparent; border: 1px dashed var(--border-strong); }
.rd-slot-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.rd-slot-name { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }
.rd-slot-name .rd-ico { width: 16px; height: 16px; }
.rd-slot-act { display: flex; align-items: center; gap: 2px; }
.rd-slot-empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-1); color: var(--text-muted); font-size: var(--fs-base); }
.rd-slot-empty .rd-btn.ghost { padding: 0; min-height: 28px; }
.rd-slot-body { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.rd-slot-body .ico-img, .rd-slot-body .ico { flex: none; width: 40px; height: 40px; margin: 0; font-size: 28px; }
.rd-slot-info { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-base); color: var(--text-heading); }
.rd-slot-info small { color: var(--text-muted); font-size: var(--fs-sm); }
.rd-slot-info small.broken { color: var(--durability-broken); }
.rd-slot-cards { color: var(--tag-card); font-size: var(--fs-xs); }
.rd-dur { display: flex; align-items: center; gap: var(--sp-2); }
.rd-dur .rd-bar { flex: 1; }
.rd-dur small { font-size: var(--fs-xs); color: var(--text-muted); }
.rd-set-line { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-secondary); }

/* ===== Redesign ขั้นที่ 6: กระเป๋า (Desktop) ===== */
.rd-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.rd-search { position: relative; display: flex; align-items: center; }
.rd-search .rd-ico { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.rd-search input { width: 240px; height: var(--control-h-sm); padding: 0 var(--sp-3) 0 34px; font: 400 var(--fs-base) var(--font-body); color: var(--text-primary); background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--r-md); }
.rd-search input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rd-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.rd-filter { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h-sm); padding: 0 var(--sp-3); font: 500 var(--fs-base)/1 var(--font-body); color: var(--text-secondary); background: transparent; border: 1px solid var(--border); border-radius: var(--r-pill); cursor: pointer; }
.rd-filter:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-strong); }
.rd-filter.active, .rd-filter.active:hover:not(:disabled) { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.rd-filter span { font-size: var(--fs-xs); opacity: .85; }
.rd-filter:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rd-table-wrap { overflow-x: auto; }
.rd-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.rd-table th { padding: var(--sp-2) var(--sp-3); font: 600 var(--fs-sm) var(--font-body); color: var(--text-muted); text-align: left; border-bottom: 1px solid var(--border); background: transparent; }
.rd-table td { padding: var(--sp-3); vertical-align: middle; border-bottom: 1px solid var(--border-subtle); }
.rd-table th:nth-child(3), .rd-table td:nth-child(3) { width: 170px; }
.rd-inv-item { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.rd-inv-item .ico-img, .rd-inv-item .ico { flex: none; width: 34px; height: 34px; margin: 0; font-size: 26px; }
.rd-inv-name { display: flex; flex-direction: column; min-width: 0; }
.rd-inv-name b { font-size: var(--fs-md); color: var(--text-heading); font-weight: 600; }
.rd-inv-name small { font-size: var(--fs-sm); color: var(--text-muted); }
.rd-qtytag { color: var(--gold); font-weight: 600; }
.rd-inv-dur { display: flex; flex-direction: column; gap: var(--sp-1); max-width: 140px; font-size: var(--fs-sm); color: var(--durability); }
.rd-inv-dur.durability-low { color: var(--durability-low); }
.rd-inv-dur.durability-broken { color: var(--durability-broken); }
.rd-dur-none { font-size: var(--fs-sm); color: var(--text-disabled); }
.rd-inv-act { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2); }
.rd-qty { width: 64px; height: var(--control-h-sm); padding: 0 var(--sp-2); font: 400 var(--fs-base) var(--font-body); color: var(--text-primary); background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--r-sm); }
.rd-qty:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rd-btn.rd-sell { background: var(--bg-hover); border-color: var(--bg-hover); color: var(--gold-light); }
.rd-btn.rd-sell:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-hover); filter: brightness(1.15); }
.rd-btn.rd-sell:disabled { color: var(--text-disabled); }
.rd-table .rd-menu-pop { z-index: 40; }
#inv-panel > .rd-empty { text-align: center; padding: var(--sp-6); }

/* ===== Redesign ขั้นที่ 7: Chat rail (คอลัมน์ขวา) — เฉพาะจอ >= 1200px; แคบกว่านั้นใช้กล่องลอยเดิม ===== */
.rd-chat-sfx, .rd-chat-online { display: none; }
@media (min-width: 1200px) {
  body.rd-desktop #app.rd-shell-on { padding-right: 340px; }
  body.rd-desktop .chat {
    --gold: #E2B857;
    top: var(--sp-5); bottom: auto; left: auto; right: max(20px, calc((100vw - 1440px) / 2 + 20px));
    width: 300px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
    background: var(--bg-nav); border: 1px solid var(--border-nav); border-radius: var(--r-nav); box-shadow: none;
    font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; z-index: 20;
  }
  body.rd-desktop .chat-fab, body.rd-desktop .chat-close { display: none; }
  body.rd-desktop .chat-head { display: flex; align-items: center; gap: var(--sp-1); flex: none; padding: var(--sp-4); background: transparent; border: 0; border-bottom: 1px solid var(--border-subtle); border-radius: 0; color: var(--text-heading); font: 600 var(--fs-md) var(--font-display); text-align: left; cursor: default; pointer-events: none; }
  body.rd-desktop .rd-chat-sfx { display: inline; }
  body.rd-desktop .rd-chat-online { display: inline; margin-left: auto; font: 400 var(--fs-sm) 'IBM Plex Sans Thai', sans-serif; color: var(--online); }
  body.rd-desktop .chat.closed .chat-body { display: flex; }
  body.rd-desktop .chat .chat-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding-top: 0; }
  body.rd-desktop .chat-list { flex: 0 1 620px; height: auto; min-height: 160px; max-height: 620px; padding: var(--sp-3) var(--sp-4); font-size: var(--fs-base); line-height: 1.5; color: var(--text-primary); }
  body.rd-desktop .chat-msg { margin-bottom: var(--sp-2); }
  body.rd-desktop .chat-time { font-size: var(--fs-xs); color: var(--text-muted); }
  body.rd-desktop .chat-chat b { color: var(--user-name); }
  body.rd-desktop .chat-msg.chat-admin b { color: var(--admin-name); }
  body.rd-desktop .chat-msg.chat-mention { background: var(--bg-hover); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: var(--sp-1) var(--sp-2); }
  body.rd-desktop .chat-msg.chat-system { background: var(--system-bg); border: 1px solid var(--system-border); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); color: var(--system-text); }
  body.rd-desktop .chat-system .chat-time, body.rd-desktop .chat-system b { color: var(--system-meta); font-size: var(--fs-xs); font-weight: 400; }
  body.rd-desktop .chat-system .chat-text { display: block; }
  body.rd-desktop .chat-form { flex: none; padding: var(--sp-3) var(--sp-4) var(--sp-4); border-top: 1px solid var(--border-subtle); align-items: center; }
  body.rd-desktop .chat-form input { height: var(--control-h); padding: 0 var(--sp-3); font: 400 var(--fs-base) 'IBM Plex Sans Thai', sans-serif; color: var(--text-primary); background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--r-md); }
  body.rd-desktop .chat-form input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  body.rd-desktop .chat-form > button:not(.chat-emoji-btn) { height: var(--control-h); padding: 0 var(--sp-4); font: 600 var(--fs-md) 'IBM Plex Sans Thai', sans-serif; color: var(--on-gold); background: var(--gold); border: 1px solid var(--gold); border-radius: var(--r-md); cursor: pointer; }
  body.rd-desktop .chat-form > button:not(.chat-emoji-btn):hover { background: var(--gold-light); border-color: var(--gold-light); }
  body.rd-desktop .chat-emoji-btn { height: var(--control-h); background: var(--bg-inset); border-color: var(--border); border-radius: var(--r-md); }
  body.rd-desktop label.chat-announce { padding: 0 var(--sp-4) var(--sp-2); }
}

/* ===== Redesign: ล้างสไตล์ปุ่ม/ช่องกรอกธีมเดิมที่รั่วเข้ามาใน component ใหม่ ===== */
.rd-btn, .rd-nav-item, .rd-menu-item, .rd-filter, .rd-fame, .rd-pill { box-shadow: none; text-shadow: none; filter: none; transform: none; }
.rd-btn:active:not(:disabled), .rd-nav-item:active:not(:disabled), .rd-menu-item:active:not(:disabled), .rd-filter:active:not(:disabled) { transform: none; box-shadow: none; }
.rd-btn:disabled { filter: none; }
.rd-search input, .rd-qty, .rd-slider input[type="range"], body.rd-desktop .chat-form input { box-shadow: none; }
.rd-search input, .rd-qty, body.rd-desktop .chat-form input { background: var(--bg-inset) !important; border-color: var(--border) !important; color: var(--text-primary) !important; -webkit-text-fill-color: var(--text-primary); }
.rd-search input:focus, .rd-qty:focus, body.rd-desktop .chat-form input:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.rd-search input::placeholder, body.rd-desktop .chat-form input::placeholder { color: var(--text-muted) !important; -webkit-text-fill-color: var(--text-muted); }
.rd-slider input[type="range"] { background: transparent !important; border: 0 !important; padding: 0; }

/* แชทบนจอ Desktop แคบ (1024-1199px): ไม่ลอยบังเนื้อหา — ตกลงไปอยู่ล่างสุดของหน้าเป็นการ์ดเต็มความกว้าง */
body.rd-desktop .chat { position: static; width: calc(100% - 40px); max-width: 1400px; margin: 0 auto var(--sp-5); }
@media (min-width: 1200px) { body.rd-desktop .chat { position: fixed; margin: 0; width: 300px; max-width: none; } }

/* ---------- กิจกรรมประจำวัน (Daily Activity) ---------- */
.da-banner { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-4); padding: 12px 18px; background: var(--rank-badge-bg); border: 1px solid var(--line); border-radius: var(--r-xl); color: var(--text); }
.da-ico { width: 26px; height: 26px; flex: none; color: var(--gold-light); }
.da-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.da-text b { color: var(--gold-light); }
.da-text > span { color: var(--muted); font-size: var(--fs-sm); }
.da-tier { margin-left: .5rem; padding: 0 .5rem; border-radius: 999px; border: 1px solid var(--rank-badge); color: var(--rank-badge); font-size: .78rem; }
.da-rare { border-color: var(--rank-badge); }
.da-legendary { border-color: var(--gold-light); box-shadow: 0 0 10px color-mix(in srgb, var(--gold-light) 40%, transparent); }
.da-legendary .da-tier { border-color: var(--gold-light); color: var(--gold-light); }
.da-left { flex: none; font-size: var(--fs-sm); color: var(--muted); text-align: right; }
.da-left b { color: var(--text); font-variant-numeric: tabular-nums; }
.da-badge { display: inline-flex; align-items: center; gap: .35rem; margin: 0 0 .6rem; padding: .15rem .6rem; border-radius: 999px; border: 1px solid var(--gold-light); color: var(--gold-light); background: color-mix(in srgb, var(--gold-light) 12%, transparent); font-size: .82rem; }
.da-badge-ico { width: 14px; height: 14px; flex: none; }
@media (max-width: 600px) { .da-banner { flex-wrap: wrap; padding: 10px 12px; } .da-left { width: 100%; text-align: left; } }

/* ---------- ตลาด Token ---------- */
.tm-card { gap: .45rem; }
.tm-head { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.tm-serial { background: var(--panel); border: 1px solid var(--gold-dim); color: var(--gold-hi); border-radius: 6px; padding: 0 .4rem; font-family: var(--font-head); font-size: .82rem; }
.tm-prov { font-size: .8rem; }
.tm-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.tm-price { display: inline-flex; align-items: center; gap: .3rem; color: var(--amber); }
.tm-ico { display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -.2em; }
.tm-lock { display: inline-flex; align-items: center; gap: .3rem; color: var(--rose); font-size: .82rem; }
.tm-net { font-size: .82rem; }
.tm-rules ul { margin: .4rem 0 0; padding-left: 1.2rem; color: var(--muted); font-size: .88rem; }
.tm-eco { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; margin-top: .5rem; }
.tm-eco-cell { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; background: var(--panel-2); }
.tm-eco-cell b { color: var(--gold-hi); font-size: 1.1rem; }

/* ---------- สงครามกิลด์ (GvG) สนามซ้อม ---------- */
.gvg-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.gvg-mode { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-heading); }
.gvg-mode .rd-ico { width: 20px; height: 20px; color: var(--gold); }
.gvg-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.gvg-stage { background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; line-height: 0; }
.gvg-canvas { display: block; width: 100%; height: auto; aspect-ratio: 800 / 500; cursor: crosshair; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.gvg-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); margin-top: var(--sp-3); }
.gvg-skill { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding: var(--sp-2) var(--sp-3); background: var(--bg-slot); border: 1px solid var(--border); border-radius: var(--r-md); min-width: 0; }
.gvg-skill { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; transition: transform .08s, border-color .08s, background .08s; }
.gvg-skill:active, .gvg-skill.pressed { transform: scale(.94); border-color: var(--gold); background: var(--bg-inset); }
.gvg-skill.cooling .gvg-cd { font-size: var(--fs-xl, 1.5rem); color: var(--gold); text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.gvg-skill kbd { align-self: flex-start; font: 600 var(--fs-xs)/1 var(--font-body); color: var(--on-gold); background: var(--gold); border-radius: var(--r-sm); padding: 3px 6px; }
.gvg-skill b { color: var(--text-heading); font-size: var(--fs-md); }
.gvg-skill small { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.35; }
.gvg-skill::after { content: ""; position: absolute; inset: 0; background: var(--bg-app); opacity: .65; transform-origin: bottom; transform: scaleY(var(--cd, 0)); pointer-events: none; }
.gvg-skill.cooling { border-color: var(--border-subtle); }
.gvg-cd { position: absolute; top: var(--sp-2); right: var(--sp-3); z-index: 1; font: 700 var(--fs-lg)/1 var(--font-body); color: var(--text-primary); }
.gvg-help { margin-top: var(--sp-3); font-size: var(--fs-sm); }
@media (max-width: 640px) { .gvg-bar { grid-template-columns: repeat(2, 1fr); } }
/* มือถือ: ใช้จอยสติ๊ก + ปุ่มสกิลวงกลมที่วาดบน canvas (mobileControls.js) แทนแถบสกิลด้านล่าง และขยาย canvas ให้เต็มความกว้างจอ */
@media (max-width: 900px) {
  .gvg-bar { display: none; }
  .gvg-stage { width: 100vw; max-width: 100vw; margin-left: calc(50% - 50vw); border-radius: 0; border-left: 0; border-right: 0; }
  .gvg-canvas { width: auto; max-width: 100%; height: auto; max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); margin: 0 auto; }
}

/* GvG ออนไลน์: ล็อบบี้ด้านบนสนาม (สีอ่านจาก token ใน :root เท่านั้น) */
.gvg-lobby { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.gvg-lobby-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.gvg-status { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-heading); font-size: var(--fs-sm); }
.gvg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); }
.gvg-dot.on { background: var(--stamina); }
.gvg-dot.wait { background: var(--gold); }
.gvg-dot.off { background: var(--hp); }
.gvg-war { padding: 2px var(--sp-3); border-radius: var(--r-md); border: 1px solid currentColor; font-weight: 700; font-size: var(--fs-sm); }
.gvg-war.open { color: var(--hp); }
.gvg-war.closed { color: var(--text-muted); }
.gvg-lobby [hidden] { display: none !important; }
.gvg-roster { display: block; }
.gvg-roster-col { list-style: none; margin: 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--border-strong); background: var(--bg-slot); border-radius: var(--r-md); font-size: var(--fs-xs); max-height: 110px; overflow-y: auto; min-height: 24px; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); }
.gvg-roster-col li { color: var(--text-primary); line-height: 1.5; }
.gvg-roster-col li.me { color: var(--gold); font-weight: 700; }
.gvg-roster-col li.total { color: var(--text-muted); margin-left: auto; }
.gvg-note { min-height: 1em; color: var(--gold); font-size: var(--fs-sm); }

/* กันไอคอน SVG ในปุ่มขยายใหญ่ผิดปกติ (ขนาดเริ่มต้น 16px) */
button svg { width: 16px; height: 16px; flex-shrink: 0; }
button .rd-ico { display: inline-flex; width: 16px; height: 16px; flex-shrink: 0; vertical-align: -.2em; }

/* ---------- แมพฟาร์มมอนสเตอร์ Real-time (fieldCanvas.js) ---------- */
.battle-field-layout { max-width: 980px; margin: 0 auto; }
.field-panel { padding: .7rem .8rem; }
.field-maps { flex-wrap: wrap; }
.field-maps .subtab.here { box-shadow: inset 0 -3px 0 var(--gold); }
.field-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2, .5rem); margin: .5rem 0; }
.field-conn { font-size: var(--fs-sm, .85rem); color: var(--text-secondary, #aeb5c8); margin-right: auto; }
.field-target { display: inline-flex; align-items: center; gap: .4rem; font-size: var(--fs-sm, .85rem); }
.field-host { margin: .4rem 0; }
.field-bar { grid-template-columns: repeat(4, 1fr); }
.field-bar .gvg-skill { padding: var(--sp-2, .5rem); }
.field-note { min-height: 1.4em; margin-top: var(--sp-2, .5rem); font-size: var(--fs-sm, .85rem); color: var(--text-secondary, #aeb5c8); }
.field-help { font-size: var(--fs-xs, .75rem); line-height: 1.5; margin-top: .4rem; }
.field-info { margin: .6rem 0; }
.field-info-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; margin-bottom: .6rem; }
.field-mon { display: flex; align-items: center; gap: .5rem; text-align: left; padding: .4rem; }
.field-mon.selected { border-color: var(--gold); }
.field-mon span { display: flex; flex-direction: column; min-width: 0; }
.classic-box { margin-top: .8rem; }
.classic-box > summary { cursor: pointer; padding: .4rem 0; color: var(--text-secondary, #aeb5c8); }
@media (max-width: 640px) {
  .field-bar { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .field-bar .gvg-skill small { display: none; }
  .field-bar .gvg-skill b { font-size: var(--fs-sm, .85rem); }
  .field-controls button, .field-target { flex: 1 1 100%; }
}

/* ===== ขวดยาฟื้นเลือดในสนาม Real-time (public/potionHud.js) ===== */
.gvg-bar.has-potion, .field-bar.has-potion { grid-template-columns: repeat(5, 1fr); }
.potion-slot { color: var(--stamina); }
.potion-slot .potion-ico { width: 22px; height: 22px; }
.potion-slot .potion-name { font-size: var(--fs-sm, .85rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.potion-slot .potion-count { font: 800 var(--fs-xl, 1.5rem)/1 var(--font-body); color: var(--text-heading); }
.potion-slot.empty { color: var(--hp); }
.potion-slot.empty .potion-count { color: var(--hp); }
.potion-badge { position: absolute; top: var(--sp-2); right: var(--sp-2); z-index: 1; padding: 2px 6px; border-radius: var(--r-sm); background: var(--bg-inset); border: 1px solid var(--stamina); color: var(--stamina); font: 700 var(--fs-xs) / 1 var(--font-body); }
.potion-badge.empty { border-color: var(--hp); color: var(--hp); }
.gvg-skill.has-badge .gvg-cd { top: auto; bottom: var(--sp-2); }
@media (max-width: 640px) { .gvg-bar.has-potion, .field-bar.has-potion { grid-template-columns: repeat(3, 1fr); } .field-bar .potion-slot small { display: none; } }
