html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: sans-serif;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: radial-gradient(circle at 50% 30%, #2b3a2a, #101510);
  color: #eee;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: 100%;
  max-width: 360px;
  padding: 24px 20px;
  box-sizing: border-box;
  border: 2px solid #b08d3c;
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.85);
  text-align: center;
}

.panel h1 {
  margin: 0;
  font-size: 22px;
  color: #e0b84a;
}

.panel h2 {
  margin: 4px 0 18px;
  font-size: 16px;
  font-weight: normal;
}

.panel label {
  display: block;
  margin-bottom: 6px;
  text-align: left;
  font-size: 14px;
}

.panel input {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  border: 1px solid #777;
  border-radius: 6px;
  background: #111;
  color: #fff;
  font-size: 16px;
}

.genders {
  display: flex;
  gap: 12px;
  margin: 18px 0;
}

.gender {
  flex: 1;
  padding: 10px 0 8px;
  border: 2px solid #555;
  border-radius: 10px;
  background: #1b1b1b;
  color: #ddd;
  font-size: 15px;
  cursor: pointer;
}

.gender canvas {
  display: block;
  margin: 0 auto 4px;
  width: 64px;
  height: 88px;
}

.gender.selected {
  border-color: #e0b84a;
  background: #2b2616;
  color: #fff;
}

#char-start {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: #b08d3c;
  color: #1a1408;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

#char-start:disabled {
  background: #4a4535;
  color: #888;
  cursor: not-allowed;
}

/* มุมขวาล่าง: แถบช่องลัด/โพชั่นอยู่เหนือแถบปุ่มหลัก */
#dock {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: calc(100% - 24px);
}

#dock[hidden],
.float-panel[hidden] {
  display: none;
}

#toolbar {
  display: flex;
  gap: 8px;
}

#toolbar button,
#equip-close,
#team-close,
#auto-close {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #b08d3c;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.85);
  color: #eee;
  font-size: 14px;
  cursor: pointer;
}

#toolbar button.on {
  background: #b08d3c;
  color: #1a1408;
  font-weight: bold;
}

.float-panel {
  position: fixed;
  right: 12px;
  bottom: 134px;
  width: 320px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 150px);
  overflow-y: auto;
  padding: 12px;
  box-sizing: border-box;
  border: 2px solid #b08d3c;
  border-radius: 10px;
  background: rgba(20, 20, 20, 0.92);
  color: #eee;
}

.float-panel h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #e0b84a;
}

.float-panel h4 {
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: normal;
  color: #aaa;
}

#team-slots,
#team-storage {
  display: grid;
  gap: 6px;
}

.team-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid #444;
  border-radius: 8px;
  background: #1b1b1b;
  font-size: 14px;
}

.team-slot .slot-no {
  color: #888;
  font-size: 12px;
}

.team-slot em {
  color: #777;
}

.slot-remove {
  margin-left: auto;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #777;
  border-radius: 6px;
  background: #2a2a2a;
  color: #ddd;
  cursor: pointer;
}

.general-card {
  display: block;
  width: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 2px solid #555;
  border-radius: 8px;
  background: #1b1b1b;
  color: #ddd;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.general-card.selected {
  border-color: #e0b84a;
  background: #2b2616;
}

.general-card span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #aaa;
}

.general-card .general-tag {
  color: #ddd;
}

#team-note {
  min-height: 1.2em;
  margin: 8px 0;
  font-size: 12px;
  color: #ffb36a;
}

#team-close,
#auto-close {
  width: 100%;
}

#equip-weapons {
  display: grid;
  gap: 6px;
}

.weapon-item,
#equip-shield {
  display: block;
  width: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 2px solid #555;
  border-radius: 8px;
  background: #1b1b1b;
  color: #ddd;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.weapon-item span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #aaa;
}

.weapon-item.selected,
#equip-shield.selected {
  border-color: #e0b84a;
  background: #2b2616;
  color: #fff;
}

#equip-shield {
  margin-top: 10px;
}

#equip-shield:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#equip-note {
  min-height: 1.2em;
  margin: 8px 0;
  font-size: 12px;
  color: #ffb36a;
}

#equip-close {
  width: 100%;
}


.panel.wide {
  max-width: 460px;
  max-height: 100%;
  overflow-y: auto;
}

.creator-sub {
  margin: 4px 0 8px;
  font-size: 14px;
  font-weight: normal;
  text-align: left;
  color: #e0b84a;
}

#creator-basic[hidden] {
  display: none;
}

#creator-elements {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.element-card {
  display: block;
  padding: 8px 10px;
  border: 2px solid #555;
  border-radius: 10px;
  background: #1b1b1b;
  color: #ddd;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.element-card.selected {
  border-color: #e0b84a;
  background: #2b2616;
  color: #fff;
}

.element-card span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #aaa;
}

.element-card .element-rel {
  color: #cfcfcf;
}

#stats-free {
  margin: 0 0 8px;
  font-size: 15px;
  color: #9fe39f;
}

/* จองที่ให้แถบเลื่อนไว้ตลอด: ไม่งั้นเมื่อความสูงเนื้อหาขึ้น/ลงผ่านเส้นสูงสุดของหน้าต่าง แถบเลื่อนโผล่/หาย ทำให้ปุ่ม +1 +5 ขยับซ้าย/ขวา ~10px */
#stats {
  scrollbar-gutter: stable;
}

#stats-rows {
  display: grid;
  gap: 6px;
}

.stat-row {
  padding: 6px 10px;
  border: 1px solid #444;
  border-radius: 8px;
  background: #1b1b1b;
}

.stat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.stat-head strong {
  flex: 1;
}

.stat-value {
  min-width: 2.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stat-add {
  min-width: 40px;
  min-height: 34px;
  border: 1px solid #b08d3c;
  border-radius: 6px;
  background: #2a2616;
  color: #eee;
  cursor: pointer;
}

.stat-add:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stat-effect {
  margin-top: 2px;
  font-size: 12px;
  color: #cfe8ff;
}

.stat-hint {
  font-size: 11px;
  color: #888;
}

#stats-summary {
  margin: 8px 0;
  font-size: 12px;
  color: #ddd;
}

#stats-summary .sum-title {
  margin: 0 0 4px;
  font-size: 13px;
  color: #ffe9a8;
}

#stats-summary .sum-group {
  margin: 8px 0 2px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(216, 176, 74, 0.35);
  font-size: 11px;
  color: #cdb987;
}

#stats-summary .sum-row {
  display: grid;
  grid-template-columns: 1fr auto 84px;
  gap: 6px;
  align-items: baseline;
  padding: 1px 0;
}

#stats-summary .sum-value {
  font-weight: bold;
  color: #fff;
  text-align: right;
}

#stats-summary .sum-cap {
  font-size: 11px;
  color: #888;
}

#stats-summary .at-cap .sum-value,
#stats-summary .at-cap .sum-cap {
  color: #ffb36b;
}

#stats-close {
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
  border: 1px solid #777;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.85);
  color: #eee;
  font-size: 13px;
  cursor: pointer;
}

#toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: calc(100% - 24px);
}

/* ---------- ช่องลัดสกิลและโพชั่น ---------- */
#hotbar {
  display: flex;
  gap: 6px;
}

.hot-slot {
  position: relative;
  width: 68px;
  height: 58px;
  padding: 4px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid #b08d3c;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.88);
  color: #eee;
  font-size: 12px;
  line-height: 1.15;
  cursor: pointer;
}

.hot-slot > * {
  position: relative;
}

.hot-key {
  display: block;
  text-align: left;
  font-size: 11px;
  color: #e0b84a;
}

.hot-name {
  display: block;
  margin-top: 2px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hot-cost {
  display: block;
  font-size: 10px;
  color: #b9a2ff;
}

.hot-cd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: none;
}

.hot-slot.nosp {
  border-color: #6b3a3a;
  color: #aaa;
}

/* ---------- ต้นไม้สกิล ---------- */
#skills {
  width: 440px;
}

#skills-points {
  margin: 0 0 8px;
  font-size: 15px;
  color: #9fe39f;
}

#skills-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.skill-tab {
  flex: 1;
  min-height: 36px;
  border: 2px solid #444;
  border-radius: 8px;
  background: #1b1b1b;
  color: var(--tab-color, #ddd);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.skill-tab.active {
  border-color: var(--tab-color, #e0b84a);
  background: #2a2a2a;
}

#skills-tree {
  overflow-x: auto;
}

.skills-canvas {
  position: relative;
  margin: 0 auto;
}

.skills-lines {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.skills-lines line {
  stroke: #555;
  stroke-width: 3;
}

.skills-lines line.on {
  stroke: #e0b84a;
}

.skill-node {
  position: absolute;
  box-sizing: border-box;
  padding: 2px 4px;
  border: 2px solid #555;
  border-radius: 8px;
  background: #1b1b1b;
  color: #ccc;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.skill-node strong,
.skill-node span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-node span {
  font-size: 11px;
  color: #999;
}

.skill-node.learned {
  border-color: #b08d3c;
  background: #2b2616;
  color: #fff;
}

.skill-node.passive {
  border-style: dashed;
}

.skill-node.rebirth {
  border-color: #6f5aa8;
}

.skill-node.rebirth.learned {
  border-color: #b9a2ff;
  background: #231d33;
}

.skills-phase {
  position: absolute;
  left: 0;
  height: 16px;
  text-align: center;
  font-size: 11px;
  line-height: 16px;
  color: #b9a2ff;
  pointer-events: none;
}

.skill-line.phase {
  color: #b9a2ff;
}

.skill-node.selected {
  outline: 2px solid #9fe39f;
}

.skills-empty,
.skills-hint,
.skills-note {
  margin: 8px 0;
  font-size: 12px;
  color: #999;
}

.skills-note {
  color: #ffb36a;
}

#skills-detail {
  margin: 10px 0 8px;
  padding: 8px 10px;
  border: 1px solid #444;
  border-radius: 8px;
  background: #151515;
  font-size: 13px;
}

.skill-title {
  font-size: 15px;
}

.skill-desc,
.skill-line,
.skill-why {
  margin: 4px 0;
  font-size: 12px;
  color: #ccc;
}

.skill-line.next {
  color: #9fe39f;
}

.skill-why {
  color: #ffb36a;
}

.skill-action {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  border: 1px solid #b08d3c;
  border-radius: 8px;
  background: #2a2616;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.skill-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.skill-slots {
  display: flex;
  gap: 6px;
}

.skill-slot {
  flex: 1;
  min-height: 34px;
  border: 1px solid #666;
  border-radius: 6px;
  background: #222;
  color: #ddd;
  cursor: pointer;
}

.skill-slot.selected {
  border-color: #e0b84a;
  background: #3a3216;
  color: #fff;
}

#skills-close {
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
  border: 1px solid #777;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.85);
  color: #eee;
  font-size: 13px;
  cursor: pointer;
}

@media (max-width: 480px) {
  #hotbar {
    gap: 4px;
  }
  .hot-slot {
    width: 40px;
    height: 52px;
    padding: 3px;
  }
  .hot-name {
    font-size: 10px;
  }
  .hot-cost {
    display: none;
  }
  #skills {
    width: calc(100% - 24px);
  }
}

/* ---------- กฎออโต้ ---------- */
#autorules {
  width: 440px;
}

.auto-help {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #aaa;
}

#auto-list {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.auto-rule {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #5a4a22;
  border-radius: 8px;
  background: rgba(40, 34, 18, 0.55);
}

.auto-rule.off {
  opacity: 0.5;
}

.auto-rule-head,
.auto-rule-body,
.auto-rule-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.auto-rule select,
.auto-rule input[type="number"] {
  min-height: 32px;
  padding: 0 6px;
  border: 1px solid #777;
  border-radius: 6px;
  background: #1c1c1c;
  color: #eee;
  font-size: 13px;
}

.auto-rule select {
  max-width: 190px;
}

.auto-rule input[type="number"] {
  width: 56px;
}

.auto-rule input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.auto-arrow,
.auto-unit {
  color: #b9a97a;
}

.auto-rule-tools {
  justify-content: flex-end;
}

.auto-rule-tools button,
#auto-add,
#auto-defaults {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #777;
  border-radius: 6px;
  background: rgba(20, 20, 20, 0.85);
  color: #eee;
  font-size: 13px;
  cursor: pointer;
}

.auto-rule-tools button:disabled,
#auto-add:disabled {
  opacity: 0.4;
  cursor: default;
}

#auto-add,
#auto-defaults {
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
}

.auto-empty {
  margin: 4px 0;
  font-size: 13px;
  color: #aaa;
}

#auto-note {
  min-height: 1.2em;
  margin: 6px 0;
  font-size: 12px;
  color: #ffb36a;
}

/* ---------- ปุ่มจับขุนพล ---------- */
#btn-capture {
  position: fixed;
  left: 50%;
  bottom: 205px;   /* เหนือแถวช่องลัดและแถบปุ่ม ไม่ทับช่องสกิล */
  transform: translateX(-50%);
  min-height: 48px;
  max-width: calc(100% - 24px);
  padding: 0 18px;
  border: 2px solid #ffd84a;
  border-radius: 10px;
  background: rgba(60, 46, 6, 0.92);
  color: #ffe9a0;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}

#btn-capture[hidden] {
  display: none;
}

/* ---------- จุติและสมญานาม (ในหน้าสเตตัส) ---------- */
#stats-rebirth {
  margin-top: 8px;
  padding-top: 4px;
  border-top: 1px solid #5a4a22;
}

.rb-line,
.rb-title,
.rb-warn {
  margin: 4px 0;
  font-size: 12px;
  line-height: 1.5;
  color: #ccc;
}

.rb-title {
  color: #ffd84a;
}

.rb-warn {
  color: #ffb36a;
}

.rb-go,
.rb-title-btn {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 6px 10px;
  border: 1px solid #b08d3c;
  border-radius: 8px;
  background: rgba(60, 46, 6, 0.85);
  color: #ffe9a0;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.rb-go {
  text-align: center;
  font-weight: bold;
}

.rb-title-btn strong,
.rb-title-btn span {
  display: block;
}

.rb-title-btn span {
  font-size: 11px;
  color: #ccc;
}

/* ---------- รูปขบวนและคอมโบ (หน้าทีม) ---------- */
#team-formation {
  display: grid;
  gap: 6px;
}

.formation-btn {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #5a4a22;
  border-radius: 8px;
  background: rgba(30, 30, 30, 0.9);
  color: #eee;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.formation-btn.selected {
  border-color: #e0b84a;
  background: #3a3216;
}

.formation-btn strong,
.formation-btn span {
  display: block;
}

.formation-btn span {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.4;
  color: #bbb;
}

#team-combo {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #9fe39f;
}

/* ไอคอนวาดด้วยโค้ด (งานที่ 10 รหัส A): canvas เต็มกรอบของที่ครอบ */
canvas.icon {
  display: block;
  width: 100%;
  height: 100%;
}

.hot-icon {
  position: absolute !important;
  top: 3px;
  right: 3px;
  width: 26px;
  height: 26px;
}

.hot-slot.nosp .hot-icon {
  opacity: 0.45;
}

/* กำลังล็อกหลังร่ายสกิล: ช่องสกิลหม่นลงชั่วคราว */
.hot-slot.casting .hot-icon {
  opacity: 0.55;
}

.skill-node .node-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.skill-node .node-row canvas {
  flex: none;
  width: 32px;
  height: 32px;
}

.skill-node:not(.learned) .node-row canvas {
  filter: grayscale(0.85) brightness(0.7);
}

.skill-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-title-icon {
  flex: none;
  width: 44px;
  height: 44px;
}

.skill-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.skill-tab .tab-icon {
  width: 20px;
  height: 20px;
}

.element-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.element-head canvas {
  flex: none;
  width: 36px;
  height: 36px;
}

@media (max-width: 480px) {
  .hot-icon {
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
  }
}

/* ====================================================================
   งานที่ 10 รหัส E: หน้าต่าง ปุ่ม กรอบ ลวดลายขอบแบบจีนแฟนตาซี (Q29)
   ทุกอย่างวาดด้วย CSS/SVG ในโค้ด ไม่มีไฟล์ภาพ ชุดสีรวมอยู่ใน :root ปรับที่เดียว
   ==================================================================== */
:root {
  --gold: #d8b04a;
  --gold-dim: #b08d3c;
  --gold-deep: #6e4e12;
  --lacquer-top: #2a1614;      /* น้ำมันชักเงาสีแดงเข้มเกือบดำ */
  --lacquer-bottom: #130b0a;
  --jade: #6fcf9f;
  --corner-tl: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.6'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></svg>");
  --corner-tr: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18'><g transform='matrix(-1 0 0 1 18 0)'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.6'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></g></svg>");
  --corner-bl: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18'><g transform='matrix(1 0 0 -1 0 18)'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.6'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></g></svg>");
  --corner-br: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18'><g transform='matrix(-1 0 0 -1 18 18)'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.6'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></g></svg>");
  /* ลายคลื่นทะเลซ้อนเกล็ด (ใช้เป็นพื้นหลังฉากเมนูหลัก จางมาก) */
  --waves: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='24'><g fill='none' stroke='%23d8b04a' stroke-opacity='0.09' stroke-width='1.2'><circle cx='0' cy='24' r='22'/><circle cx='0' cy='24' r='15'/><circle cx='0' cy='24' r='8'/><circle cx='48' cy='24' r='22'/><circle cx='48' cy='24' r='15'/><circle cx='48' cy='24' r='8'/><circle cx='24' cy='12' r='22'/><circle cx='24' cy='12' r='15'/><circle cx='24' cy='12' r='8'/></g></svg>");
}

/* กรอบหน้าต่าง: ขอบทองชั้นนอก เส้นทองบางชั้นใน มุมประดับทั้งสี่ พื้นแล็คเกอร์ไล่สี */
.panel,
.float-panel,
.npc-dialog {
  border: 2px solid var(--gold-dim);
  border-radius: 10px;
  background:
    var(--corner-tl) top 3px left 3px / 18px 18px no-repeat,
    var(--corner-tr) top 3px right 3px / 18px 18px no-repeat,
    var(--corner-bl) bottom 3px left 3px / 18px 18px no-repeat,
    var(--corner-br) bottom 3px right 3px / 18px 18px no-repeat,
    linear-gradient(180deg, var(--lacquer-top), var(--lacquer-bottom));
  box-shadow:
    inset 0 0 0 3px rgba(10, 4, 0, 0.85),
    inset 0 0 0 4px rgba(216, 176, 74, 0.45),
    0 6px 20px rgba(0, 0, 0, 0.55);
}

.panel {
  padding: 28px 24px;
}

.float-panel {
  padding: 16px 16px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}

.overlay {
  background:
    var(--waves),
    radial-gradient(circle at 50% 30%, #3a2420, #120a09);
}

/* หัวข้อ: ตัวอักษรทอง มีเส้นคั่นรูปข้าวหลามตัดใต้หัวข้อ */
.panel h1,
.float-panel h3 {
  color: var(--gold);
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(216, 176, 74, 0.3);
  letter-spacing: 0.5px;
}

.float-panel h3 {
  position: relative;
  margin: 0 0 14px;
  padding-bottom: 9px;
  text-align: center;
  font-size: 17px;
}

.float-panel h3::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  height: 7px;
  background:
    linear-gradient(var(--gold-dim), var(--gold-dim)) left center / calc(50% - 8px) 1px no-repeat,
    linear-gradient(var(--gold-dim), var(--gold-dim)) right center / calc(50% - 8px) 1px no-repeat,
    linear-gradient(45deg, transparent 38%, var(--gold) 38% 62%, transparent 62%) center / 7px 7px no-repeat;
}

.float-panel h4 {
  padding-left: 8px;
  border-left: 3px solid var(--gold-dim);
  color: #d9c79a;
}

/* ปุ่มทั้งหมดในหน้าต่าง/แถบเครื่องมือ: ขอบทอง เส้นในบาง พื้นแล็คเกอร์ ยกสว่างตอนชี้ กดแล้วจมลงเล็กน้อย */
#toolbar button,
#equip-close,
#team-close,
#auto-close,
#skills-close,
#stats-close,
.skill-slot,
.gender,
.element-card,
.hot-slot {
  border-color: var(--gold-dim);
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  box-shadow: inset 0 0 0 1px rgba(10, 4, 0, 0.8), inset 0 0 0 2px rgba(216, 176, 74, 0.22);
  transition: filter 0.12s, transform 0.08s;
}

#toolbar button:hover,
#equip-close:hover,
#team-close:hover,
#auto-close:hover,
#skills-close:hover,
#stats-close:hover,
.skill-slot:hover,
.gender:hover,
.element-card:hover,
.hot-slot:hover {
  filter: brightness(1.25);
}

#toolbar button:active,
#equip-close:active,
#team-close:active,
#auto-close:active,
#skills-close:active,
#stats-close:active,
.skill-slot:active,
.hot-slot:active {
  transform: translateY(1px);
  filter: brightness(0.9);
}

#toolbar button.on,
.gender.selected,
.element-card.selected,
.skill-slot.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, #5a4416, #34270b);
  box-shadow: inset 0 0 0 1px rgba(10, 4, 0, 0.8), inset 0 0 0 2px rgba(255, 226, 140, 0.45), 0 0 8px rgba(216, 176, 74, 0.35);
  color: #fff4d0;
}

#char-start {
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #e7c25f, #b08d3c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 2px 0 var(--gold-deep);
}

#char-start:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

#char-start:disabled {
  background: #3a3126;
  box-shadow: none;
}

.panel input {
  border-color: var(--gold-deep);
  background: #0d0706;
}

.panel input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

button:focus-visible {
  outline: 2px solid var(--jade);
  outline-offset: 2px;
}

/* ช่องข้อมูลย่อยในหน้าต่าง (รายละเอียดสกิล การ์ดขุนพล ฯลฯ) ให้เข้าชุดกับกรอบ */
#skills-detail,
.team-slot {
  border-color: rgba(216, 176, 74, 0.35);
  background: rgba(10, 4, 2, 0.55);
}

.overlay,
.panel {
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}

/* โหมดดีบั๊ก (งานที่ 11) แสดงเฉพาะเมื่อเปิดด้วย ?debug */
.debug-panel {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 30;
  width: 250px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  box-sizing: border-box;
  border: 1px dashed #ff9a3a;
  border-radius: 8px;
  background: rgba(20, 8, 4, 0.9);
  color: #ffd9b0;
  font-size: 12px;
}

.debug-panel strong {
  display: block;
  margin-bottom: 4px;
  color: #ff9a3a;
}

.debug-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 3px 0;
}

.debug-row button,
.debug-row select,
.debug-row input {
  min-height: 26px;
  padding: 0 6px;
  border: 1px solid #8a5a2a;
  border-radius: 5px;
  background: #2a1810;
  color: #ffe6cc;
  font-size: 12px;
}

.debug-readout {
  margin-top: 4px;
  color: #bfe9ff;
}

/* หน้าต่างคุยกับ NPC (งานเมืองมหาธาตุ) */
.npc-dialog {
  position: fixed;
  top: 76px;
  left: 50%;
  z-index: 25;
  width: 420px;
  max-width: calc(100% - 24px);
  padding: 16px 20px 14px;
  box-sizing: border-box;
  color: #f2e6cc;
  transform: translateX(-50%);
}

.npc-dialog[hidden] {
  display: none;
}

.npc-dialog h3 {
  margin: 0;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 1px 0 #000;
}

.npc-title {
  margin: 2px 0 10px;
  font-size: 12px;
  color: #bfa86a;
}

.npc-text {
  min-height: 54px;
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
}

.npc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.npc-actions button {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  color: #eee;
  font-size: 13px;
  cursor: pointer;
}

.npc-actions button.npc-primary {
  border-color: var(--gold);
  background: linear-gradient(180deg, #5a4416, #34270b);
  color: #fff4d0;
}

/* หน้าต่างร้านค้า */
.shop-panel {
  width: 360px;
}

.shop-gold {
  margin: 0 0 8px;
  font-size: 13px;
  color: #ffd84a;
}

.shop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 6px 8px;
  border: 1px solid rgba(216, 176, 74, 0.35);
  border-radius: 8px;
  background: rgba(10, 4, 2, 0.55);
}

.shop-info {
  flex: 1;
  min-width: 0;
}

.shop-info strong,
.shop-info span {
  display: block;
  font-size: 12px;
}

.shop-info span {
  color: #bfa86a;
  font-size: 11px;
}

.shop-price {
  color: #ffd84a;
  font-size: 12px;
  white-space: nowrap;
}

.shop-buttons {
  display: flex;
  gap: 4px;
}

.shop-buttons button,
.shop-close {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  color: #eee;
  font-size: 12px;
  cursor: pointer;
}

.shop-buttons button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.shop-close {
  width: 100%;
  margin-top: 6px;
}

.shop-msg {
  min-height: 16px;
  margin: 6px 0 0;
  font-size: 12px;
  color: #9fe39f;
}

/* ถุงเก็บของ */
.bag-panel {
  width: 360px;
}

.bag-dot {
  flex: none;
  width: 12px;
  height: 12px;
  border: 1px solid #000;
  border-radius: 50%;
}

.bag-empty,
.bag-note {
  margin: 8px 0;
  font-size: 12px;
  color: #bfa86a;
}

.bag-total {
  margin: 8px 0 0;
  font-size: 12px;
  color: #ffd84a;
}

.shop-panel h4 {
  margin: 12px 0 4px;
}

/* ตารางช่องเก็บของ (100 ช่อง) */
.bag-panel {
  width: 430px;
}

.bag-grid {
  display: grid;
  gap: 3px;
  margin: 6px 0 8px;
}

/* ปุ่มด่วนกรองหมวดบนสุดของถุง */
.bag-tabs {
  display: flex;
  gap: 4px;
  margin: 2px 0 6px;
}

.bag-tab {
  flex: 1;
  min-height: 28px;
  padding: 0 6px;
  border: 1px solid var(--gold-dim, #7a6228);
  border-radius: 14px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  color: #d8c9a8;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.bag-tab:hover {
  filter: brightness(1.25);
}

.bag-tab.on {
  border-color: var(--gold, #e8c35a);
  background: linear-gradient(180deg, #5a4416, #34270b);
  color: #fff4d0;
}

.bag-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid rgba(216, 176, 74, 0.35);
  border-radius: 5px;
  background: linear-gradient(180deg, #24150f, #120a07);
  cursor: pointer;
}

.bag-cell.empty {
  opacity: 0.45;
  cursor: default;
}

.bag-cell.locked {
  border-color: rgba(232, 195, 90, 0.85);
}

.bag-cell .lock-icon {
  position: absolute;
  inset: auto;
  left: 1px;
  top: 1px;
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.bag-grid.lock-mode .bag-cell:not(.empty) {
  cursor: cell;
  box-shadow: 0 0 0 1px rgba(232, 195, 90, 0.35);
}

.bag-actions button.on {
  border-color: var(--gold);
  background: linear-gradient(180deg, #5a4010, #2c1e08);
  color: #ffe9a8;
}

.shop-row .bag-mini-icon {
  position: relative;
}

.shop-row .bag-mini-icon .lock-icon {
  position: absolute;
  inset: auto;
  right: -3px;
  top: -3px;
  width: 14px;
  height: 14px;
}

.bag-grid.drop-mode .bag-cell:not(.empty) {
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(224, 96, 58, 0.45);
}

.bag-drop {
  margin: 6px 0 4px;
  padding: 8px 10px;
  border: 1px solid rgba(224, 96, 58, 0.7);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(60, 22, 14, 0.9), rgba(30, 12, 8, 0.9));
}

.bag-drop-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bag-drop-sub {
  display: block;
  font-size: 11px;
  color: #c8b79a;
}

.bag-drop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.bag-drop-actions button {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  color: #eee;
  font-size: 12px;
  cursor: pointer;
}

.bag-drop-actions .bag-drop-go {
  border-color: #e0603a;
  background: linear-gradient(180deg, #6a2414, #3a120a);
  color: #ffd9c8;
}

.bag-cell.selected {
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(216, 176, 74, 0.6);
}

.bag-cell canvas {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
}

.bag-count {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 9px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 2px #000, 0 0 3px #000;
}

.bag-detail {
  min-height: 56px;
  padding: 6px 8px;
  border: 1px solid rgba(216, 176, 74, 0.35);
  border-radius: 8px;
  background: rgba(10, 4, 2, 0.55);
}

.bag-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bag-detail-icon {
  flex: none;
  width: 44px;
  height: 44px;
}

.bag-price {
  color: #ffd84a;
}

.bag-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.bag-actions button {
  flex: 1;
  min-height: 32px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  color: #eee;
  font-size: 12px;
  cursor: pointer;
}

.bag-mini-icon {
  flex: none;
  width: 28px;
  height: 28px;
}

.shop-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 6px;
}

.shop-bulk button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: linear-gradient(180deg, #5a4416, #34270b);
  color: #fff4d0;
  font-size: 12px;
  cursor: pointer;
}

.shop-sell-list {
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}

/* ====================================================================
   จัดเลย์เอาต์ใหม่ (ผู้ใช้สั่ง): ช่องลัดสกิล/โพชั่นอยู่กลางจอล่าง · ปุ่มหน้าต่างอยู่ข้างมินิแมปมุมขวาบน
   หน้าสเตตัสเปิดจากแถว Lv ซ้ายบน · หน้าต่างลอยเปิดใต้มินิแมปด้านขวา (ความสูงเริ่ม --panel-top ตั้งโดย Toolbar.layout)
   ==================================================================== */
#dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 12px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-end;
  max-width: none;
  gap: 0;
  pointer-events: none;
}

#dock > * {
  pointer-events: auto;
}

#hotbar {
  max-width: calc(100% - 24px);
  justify-content: center;
}

#toolbar {
  position: fixed;
  top: var(--toolbar-top, 12px);
  right: var(--toolbar-right, 12px);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  align-items: flex-start;
  align-content: flex-start;
  gap: 4px;
  max-width: calc(100vw - var(--toolbar-right, 12px) - 236px);
}

#toolbar button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
  white-space: nowrap;
}

/* เมนูย่อยของปุ่ม "เมนู" (สกิล ทีม อุปกรณ์ เสียง เพลง): ลอยใต้ปุ่ม ชิดขวา เรียงแนวตั้ง อยู่นอก #dock เพื่อไม่ถูกหน้าต่างลอยบัง ตำแหน่งตั้งโดย Toolbar.openMenu */
#menu-pop {
  position: fixed;
  top: 60px;
  right: 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  background: rgba(14, 9, 7, 0.94);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  overflow-y: auto;
  box-sizing: border-box;
}

#menu-pop[hidden] {
  display: none;
}

#menu-pop button {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  box-shadow: inset 0 0 0 1px rgba(10, 4, 0, 0.8), inset 0 0 0 2px rgba(216, 176, 74, 0.22);
  color: #eee;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

#menu-pop button:hover {
  filter: brightness(1.25);
}

#menu-pop button.on {
  border-color: var(--gold);
  background: linear-gradient(180deg, #5a4416, #34270b);
  color: #fff4d0;
}

#btn-capture {
  bottom: 92px;   /* เหนือแถวช่องลัดกลางจอล่าง */
}

.float-panel {
  top: var(--panel-top, 200px);
  bottom: auto;
  max-height: calc(100vh - var(--panel-top, 200px) - 108px);   /* เว้นล่างให้พ้นแถบช่องลัดสองแถว (สูง ~84px + ระยะขอบ 12px) ไม่ให้ช่องลัดบังขอบล่างของหน้าต่าง */
}

/* จอแคบ (มือถือ): ปุ่มหน้าต่างเรียงแนวตั้งใต้มินิแมป หน้าต่างลอยเต็มความกว้างด้านบน */
@media (max-width: 600px) {
  #toolbar {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-end;
    max-width: none;
  }
  #toolbar button {
    min-width: 84px;
  }
  .float-panel {
    top: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100vh - 112px);
  }
}

/* ปุ่มตี มุมขวาล่างสุด (กด Space ก็ได้): ล็อกเป้าแล้วกดตีเพื่อวิ่งเข้าไปตี กดซ้ำ = หยุด */
#btn-attack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 3px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #8a2a1c, #4a1410 70%, #2a0a08);
  box-shadow: inset 0 0 0 2px rgba(10, 4, 0, 0.8), 0 4px 14px rgba(0, 0, 0, 0.6), 0 0 10px rgba(216, 80, 50, 0.35);
  color: #ffe9a8;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

#btn-attack .atk-label {
  display: block;
  font-size: 26px;
  font-weight: bold;
  line-height: 1;
  text-shadow: 0 2px 0 #000;
}

#btn-attack .atk-key {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.7;
}

#btn-attack:active {
  transform: scale(0.94);
}

#btn-attack.on {
  border-color: #ff7a5a;
  background: radial-gradient(circle at 40% 30%, #ff5a3a, #b02a18 70%, #5a1008);
  box-shadow: inset 0 0 0 2px rgba(10, 4, 0, 0.8), 0 0 18px rgba(255, 90, 60, 0.7);
}

@media (max-width: 480px) {
  #btn-attack {
    right: 10px;
    bottom: 10px;
    width: 72px;
    height: 72px;
  }
  #btn-attack .atk-label {
    font-size: 22px;
  }
}

/* ---------- แผงอุปกรณ์ / ร้านช่างตีเหล็ก (ของสวมใส่) ---------- */
.equip-summary {
  margin: 0 0 8px;
  font-size: 12px;
  color: #e8d8a8;
}

.equip-row.selected {
  border-color: #ffd84a;
  box-shadow: 0 0 0 1px rgba(255, 216, 74, 0.5);
}

.equip-picker {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px dashed rgba(216, 176, 74, 0.5);
}

.shop-row.disabled {
  opacity: 0.55;
}

.shop-bulk button.selected {
  background: #b08d3c;
  color: #1a1408;
  font-weight: bold;
}

.shop-panel,
.premium-panel,
#equip {
  max-height: calc(100vh - var(--panel-top, 200px) - 92px);
}

/* ---------- หน้ารายละเอียดขุนพล ---------- */
.team-detail[hidden] {
  display: none;
}

/* ตัวอักษรหน้ารายละเอียดเล็กเท่าหน้าต่างอื่น (ผู้ใช้สั่ง: เดิมสืบทอด 16px จากหน้าเว็บ) */
.team-detail,
.general-info {
  font-size: 12px;
}

.general-info {
  margin: 4px 0;
  line-height: 1.4;
}

.team-back,
.general-more {
  margin: 4px 0;
  padding: 4px 10px;
  border: 1px solid #b08d3c;
  border-radius: 6px;
  background: rgba(20, 20, 20, 0.85);
  color: #eee;
  font-size: 12px;
  cursor: pointer;
}

.general-card .general-more {
  display: inline-block;
  margin-top: 6px;
}

.team-detail-name {
  display: block;
  margin: 8px 0 2px;
  font-size: 14px;
}

.general-info.locked {
  opacity: 0.55;
}

/* หน้าสเตตัสเปิดฝั่งซ้าย (ผู้ใช้สั่ง) ใต้กล่อง HUD ซ้ายบน ส่วนหน้าต่างอื่นยังเปิดฝั่งขวา */
@media (min-width: 601px) {
  #stats {
    left: 12px;
    right: auto;
    top: var(--left-panel-top, 230px);
    max-height: calc(100vh - var(--left-panel-top, 230px) - 92px);
  }
}

/* ปุ่มปิด (✕) มุมขวาบนของทุกหน้าต่าง (แทนปุ่ม "ปิด" ด้านล่างสุด) sticky = เลื่อนรายการในหน้าต่างแล้วปุ่มยังอยู่ */
.panel-x {
  position: sticky;
  top: 0;
  float: right;
  z-index: 5;
  width: 32px;
  height: 32px;
  margin: -6px -6px 0 8px;
  padding: 0;
  border: 1px solid var(--gold-dim, #b08d3c);
  border-radius: 50%;
  background: rgba(20, 10, 8, 0.92);
  color: #ffe9a8;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.panel-x:hover {
  background: #7a2a1c;
  border-color: #ffd84a;
}

.panel-x:active {
  transform: scale(0.94);
}

/* ---------- หน้าต่างอุปกรณ์แบบ MMORPG: แท็บตัวละคร ตัวละครกลางล้อมด้วยช่องสวมใส่ รายการของในถุง ---------- */
#equip {
  width: 440px;
}

.gear-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.gear-tab {
  padding: 5px 9px;
  border: 1px solid var(--gold-dim, #b08d3c);
  border-radius: 6px;
  background: rgba(20, 10, 8, 0.85);
  font-size: 12px;
  cursor: pointer;
}

.gear-tab.selected {
  background: #b08d3c;
  color: #1a1408;
  font-weight: bold;
}

.gear-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #e8d8a8;
}

.gear-head strong {
  font-size: 15px;
  color: #ffe9a8;
}

.gear-doll {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  grid-template-rows: repeat(5, 56px);
  gap: 4px 8px;
  justify-items: center;
  align-items: center;
  margin: 6px 0 10px;
  padding: 8px;
  border: 1px solid rgba(216, 176, 74, 0.45);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 38%, rgba(255, 220, 150, 0.12), rgba(0, 0, 0, 0.35));
}

.gear-fashion {
  margin: 0 0 10px;
  padding: 6px 8px 8px;
  border: 1px solid rgba(216, 176, 74, 0.35);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.gear-fashion h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #cdb987;
}

.gear-fashion .gear-slot {
  width: 46px;
  height: 46px;
}

.gear-fashion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.gear-figure-box {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gear-figure {
  width: 98px;
  height: 135px;
  image-rendering: pixelated;
}

.gear-slot {
  position: relative;
  width: 56px;
  height: 56px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(216, 176, 74, 0.35);
  border-radius: 8px;
  background: rgba(10, 6, 5, 0.8);
  cursor: pointer;
}

.gear-slot.filled {
  background: rgba(40, 28, 16, 0.9);
}

.gear-slot.selected {
  box-shadow: 0 0 0 2px #ffd84a;
}

.gear-slot-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  font-size: 10px;
  line-height: 1.1;
  color: #cdb987;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.gear-slot:not(.filled) .gear-slot-name {
  bottom: auto;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.7;
}

.gear-list h4 {
  margin: 4px 0 6px;
}

.gear-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 9px;
  box-sizing: border-box;
  border: 1px solid rgba(216, 176, 74, 0.4);
  border-radius: 8px;
  background: rgba(20, 12, 10, 0.85);
  color: #eee;
  text-align: left;
  cursor: pointer;
}

.gear-row:hover:not(:disabled) {
  border-color: #ffd84a;
  background: rgba(60, 46, 6, 0.55);
}

.gear-row.disabled {
  opacity: 0.55;
  cursor: default;
}

.gear-row .shop-info {
  flex: 1;
  min-width: 0;
}

.gear-row .shop-info span {
  display: block;
  font-size: 12px;
  color: #bdb090;
}

.gear-act {
  flex: none;
  padding: 3px 9px;
  border: 1px solid #6fcf9f;
  border-radius: 12px;
  font-size: 12px;
  color: #6fcf9f;
}

.gear-row.disabled .gear-act {
  border-color: #b06a5a;
  color: #d09a8a;
}

.gear-diff {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
}

.gear-diff .up {
  color: #6fcf9f;
}

.gear-diff .down {
  color: #e8806a;
}

@media (max-width: 480px) {
  .gear-doll {
    grid-template-columns: 56px 1fr 56px;
    grid-template-rows: repeat(5, 62px);
  }
  .gear-slot {
    width: 54px;
    height: 54px;
  }
  .gear-figure {
    width: 87px;
    height: 120px;
  }
}

/* ปุ่ม + บนตัวสกิล (ปลด/อัพขั้นทันที) */
.node-up {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  width: 20px;
  height: 20px;
  border: 1px solid #555;
  border-radius: 50%;
  background: #2a2a2a;
  color: #888;
  font-size: 16px;
  font-weight: bold;
  line-height: 17px;
  text-align: center;
  cursor: pointer;
}

.node-up.ok {
  border-color: #6fcf9f;
  background: #1f5a3c;
  color: #eafff2;
  box-shadow: 0 0 6px rgba(111, 207, 159, 0.7);
}

.node-up.ok:hover {
  background: #2a7a52;
}

/* ช่องลัดสกิล 10 ช่อง + โพชั่น 2 ช่อง: เล็กลงและขึ้นแถวใหม่ได้ ไม่ทับปุ่มตีมุมขวาล่าง */
#hotbar {
  flex-wrap: wrap;
  gap: 4px;
  max-width: calc(100vw - 216px);
}

.hot-slot {
  width: 58px;
  height: 56px;
}

@media (max-width: 480px) {
  #hotbar {
    max-width: calc(100vw - 20px);
    gap: 3px;
  }
  .hot-slot {
    width: 34px;
    height: 48px;
    padding: 2px;
  }
  .hot-name {
    display: none;
  }
  #btn-attack {
    bottom: 120px;
  }
  #btn-capture {
    bottom: 200px;
  }
}

/* ดรอปดาวน์เลือกตัวละคร (หน้าอุปกรณ์/หน้าถุง) และส่วน "ใช้" ของอุปกรณ์ในถุง */
.gear-select {
  width: 100%;
  margin-bottom: 8px;
  padding: 7px 9px;
  box-sizing: border-box;
  border: 1px solid var(--gold-dim, #b08d3c);
  border-radius: 6px;
  background: rgba(20, 10, 8, 0.92);
  color: #ffe9a8;
  font-size: 14px;
  cursor: pointer;
}

.gear-cands {
  margin-top: 4px;
}

.gear-cand {
  cursor: pointer;
  user-select: none;
}

.gear-cand:hover {
  border-color: #ffd84a;
}

.gear-cand .short {
  color: #e8a898;
}

.gear-cand.blocked {
  opacity: 0.5;
  cursor: not-allowed;
}

.bag-gear {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(216, 176, 74, 0.5);
}

.bag-gear .gear-select {
  margin-bottom: 2px;
}

.bag-gear-label {
  font-size: 12px;
  color: #cdb987;
}

.bag-gear-note {
  font-size: 12px;
  color: #bdb090;
}

.bag-use {
  align-self: flex-start;
  padding: 8px 18px;
  border: 1px solid #6fcf9f;
  border-radius: 8px;
  background: #1f5a3c;
  color: #eafff2;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.bag-use:disabled {
  border-color: #b06a5a;
  background: rgba(60, 30, 26, 0.7);
  color: #d09a8a;
  cursor: default;
  font-weight: normal;
}

/* ป้ายรายละเอียดสกิลที่ลอยตอนเอาเมาส์ชี้ (แทนกล่องรายละเอียดด้านล่างของหน้าต่าง) และหน้าต่างเล็กเลือกช่องลัด */
.skill-tip,
.skill-slotpop {
  position: fixed;
  z-index: 60;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 2px solid var(--gold-dim, #b08d3c);
  border-radius: 10px;
  background: rgba(18, 10, 8, 0.96);
  color: #eee;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.skill-tip {
  width: 310px;
  max-width: calc(100vw - 16px);
  font-size: 13px;
  pointer-events: none;
}

.skill-tip[hidden],
.skill-slotpop[hidden] {
  display: none;
}

.skill-tip .skill-line.cost {
  color: #ffe9a8;
}

.skill-slotpop-title {
  margin-bottom: 6px;
  font-size: 12px;
  color: #ffe9a8;
}

.skill-slotpop .skill-slots {
  display: grid;
  grid-template-columns: repeat(5, 34px);
  gap: 4px;
}

/* ส่วนของต้นไม้สกิล (สายพื้นฐาน / จุติ 1 / จุติ 2) แยกเป็นกล่องชัดเจน มีหัวข้อบอกวิธีได้มา */
.skills-section {
  position: absolute;
  left: 3px;
  box-sizing: border-box;
  border: 1px solid rgba(216, 176, 74, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  pointer-events: none;
}

.skills-section.rebirth1 {
  border-color: #6f5aa8;
  background: rgba(111, 90, 168, 0.1);
}

.skills-section.rebirth2 {
  border-color: #c0654a;
  background: rgba(192, 101, 74, 0.1);
}

.skills-section-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 10px;
  text-align: left;
  font-size: 12px;
  line-height: 1.3;
}

.skills-section-head strong {
  font-size: 14px;
  color: #ffe9a8;
}

.skills-section.rebirth1 .skills-section-head strong {
  color: #cdbcff;
}

.skills-section.rebirth2 .skills-section-head strong {
  color: #ffb49a;
}

.skills-section-head .how {
  color: #cdb987;
}

.skills-section-head .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 1px;
}

.skills-section-head .chips em {
  padding: 1px 8px;
  border-radius: 10px;
  font-style: normal;
  font-size: 11px;
}

.skills-section-head .chips .ok {
  border: 1px solid #6fcf9f;
  color: #6fcf9f;
}

.skills-section-head .chips .no {
  border: 1px solid #b06a5a;
  color: #e8a898;
}

.skill-node.rebirth.rebirth2 {
  border-color: #c0654a;
}

.skill-node.rebirth.rebirth2.learned {
  border-color: #ffb49a;
  background: #33201a;
}

/* กล่องห่อต้นไม้สกิล (ย่อให้พอดีความกว้างหน้าต่าง) */
.skills-fit {
  margin: 0 auto;
  overflow: visible;
}

#skills-tree {
  overflow-x: hidden;
}

/* จอแคบ: ช่องลัดสกิลขึ้นสองแถว หน้าต่างลอยต้องเว้นที่ด้านล่างให้พอ ไม่ให้ช่องลัดทับขอบล่างของหน้าต่าง */
@media (max-width: 600px) {
  .float-panel {
    max-height: calc(100vh - 150px);
  }
}

/* ร้านพิเศษ (เพชร) */
.premium-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}

.premium-balance .shop-gold {
  margin: 0;
  color: #8fd3ff;
}

.premium-free {
  min-height: 26px;
  padding: 0 10px;
  border: 1px dashed #8fd3ff;
  border-radius: 6px;
  background: rgba(30, 50, 70, 0.6);
  color: #cfe9ff;
  font-size: 12px;
  cursor: pointer;
}

.premium-note {
  margin: 4px 0 8px;
  font-size: 12px;
  color: #cdb987;
}

.premium-icons {
  display: flex;
  flex: none;
  gap: 2px;
  max-width: 108px;
  flex-wrap: wrap;
}

.premium-panel .shop-price {
  color: #8fd3ff;
}

.btn-premium {
  border-color: #8fd3ff;
  color: #cfe9ff;
}

/* ปุ่มจดหมาย: ไอคอนซองพร้อมตัวเลขจดหมายที่ยังต้องดู */
#toolbar button.btn-mail {
  position: relative;
  min-width: 44px;
  padding: 0 10px;
  font-size: 18px;
}

.mail-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  padding: 1px 5px;
  box-sizing: border-box;
  border-radius: 9px;
  background: #d0392b;
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

.mail-badge[hidden] {
  display: none;
}

.mail-row {
  cursor: pointer;
}

.mail-row.unread strong::before {
  content: '● ';
  color: #ff6a4d;
}

.mail-row.open {
  border-color: #e0b84a;
}

.mail-detail {
  margin: 4px 0 10px;
  padding: 8px 10px;
  border: 1px solid #6b5a2a;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 13px;
}

.mail-detail p {
  margin: 0 0 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mail-detail .mail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* หน้าต่างอุปกรณ์เปิดข้างถุง (ซ้ายมือของตำแหน่งที่ถุงเปิด) ให้เปิดคู่กันแล้วสวมของจากถุงได้สะดวก จอแคบกว่านี้เปิดทับตำแหน่งปกติ */
@media (min-width: 920px) {
  #equip,
  .premium-panel {
    right: 452px;
  }
}

/* ป้ายรายละเอียดของในถุงตอนเอาเมาส์ชี้ */
.bag-tip {
  position: fixed;
  z-index: 60;
  box-sizing: border-box;
  width: 290px;
  max-width: calc(100vw - 16px);
  padding: 10px 12px;
  border: 2px solid var(--gold-dim, #b08d3c);
  border-radius: 10px;
  background: rgba(18, 10, 8, 0.96);
  color: #eee;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.bag-tip[hidden] {
  display: none;
}

.bag-tip p {
  margin: 5px 0 0;
}

.gear-detail p {
  margin: 3px 0 0;
}

.gear-line-meta {
  font-size: 12px;
  color: #cdb987;
}

.gear-line-base {
  color: #fff;
}

.gear-opt-title {
  margin-top: 8px !important;
  padding-top: 5px;
  border-top: 1px solid rgba(216, 176, 74, 0.4);
  font-size: 12px;
  color: #ffd27a;
}

.gear-opt {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #9fe3b4;
}

.gear-opt em {
  flex: none;
  font-size: 11px;
  font-style: normal;
  color: #888;
}

.gear-opt em.top {
  color: #ffb36b;
  font-weight: bold;
}

.gear-opt-plus {
  color: #8fd3ff;
}

.gear-opt-none {
  font-size: 12px;
  color: #888;
}

.bag-tip-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bag-tip-head strong {
  display: block;
  font-size: 15px;
}

.bag-tip-cat {
  font-size: 12px;
  color: #cdb987;
}

.bag-tip-use,
.bag-tip-price {
  font-size: 12px;
  color: #cdb987;
}

.bag-tip-hint {
  color: #6fcf9f;
  font-size: 12px;
}

.bag-tip-bad {
  color: #e8a898;
  font-size: 12px;
}

/* แถวเลือกตัวละครที่จะสวมของให้ (เหนือตารางช่องในถุง) */
.bag-gearbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.bag-gearbar .gear-select {
  margin-bottom: 0;
}

/* หน้าจัดทีม: แถบกรอง/ค้นหา และรายการที่เก็บขุนพลแบบย่อ (รองรับขุนพลหลายร้อยคน) */
.team-filter {
  margin-bottom: 8px;
}

.team-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.team-filter .gear-select {
  width: auto;
  flex: 1 1 110px;
  margin: 0;
  padding: 5px 8px;
  font-size: 13px;
}

.team-search {
  flex: 2 1 160px;
  padding: 6px 9px;
  box-sizing: border-box;
  border: 1px solid var(--gold-dim, #b08d3c);
  border-radius: 6px;
  background: rgba(20, 10, 8, 0.92);
  color: #ffe9a8;
  font-size: 13px;
}

.team-showall {
  flex: none;
  font-size: 12px;
  color: #cdb987;
  cursor: pointer;
}

.team-count {
  margin: 2px 0 6px;
  font-size: 12px;
  color: #cdb987;
}

.general-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  padding: 6px 8px;
  border: 1px solid rgba(216, 176, 74, 0.3);
  border-left: 4px solid #888;
  border-radius: 8px;
  background: rgba(20, 12, 10, 0.85);
}

.general-row.selected {
  background: rgba(60, 46, 6, 0.5);
  border-color: #e0b84a;
}

.general-row.locked {
  opacity: 0.5;
}

.general-row-info {
  flex: 1;
  min-width: 0;
}

.general-row-info span {
  display: block;
  font-size: 11px;
  color: #bdb090;
}

.general-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rarity-chip {
  padding: 0 6px;
  border: 1px solid;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.5;
}

.general-row .shop-buttons button {
  padding: 4px 8px;
  font-size: 12px;
}

.team-filter-row .gear-select {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 4px;
  font-size: 12px;
}

/* หน้าจัดทีมกว้างขึ้นให้รายการขุนพลและตัวกรองอ่านง่าย */
#team {
  width: 440px;
}

.general-row-top strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rarity-chip {
  flex: none;
  white-space: nowrap;
}

/* ส่วนจุติขุนพล */
.team-rebirth .rb-ok {
  color: #6fcf9f;
}

.team-rebirth .rb-no {
  color: #e8a898;
}

/* ปุ่มเปิด-ปิดออโต้ในหน้าต่างออโต้ */
#btn-auto {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 10px;
  box-sizing: border-box;
  border: 2px solid var(--gold-dim, #b08d3c);
  border-radius: 8px;
  background: rgba(20, 10, 8, 0.9);
  color: #eee;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

#btn-auto.on {
  border-color: #6fcf9f;
  background: #1f5a3c;
  color: #eafff2;
  box-shadow: 0 0 10px rgba(111, 207, 159, 0.5);
}

/* ตัวเลือกออโต้ */
#auto-options {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid rgba(216, 176, 74, 0.4);
  border-radius: 8px;
  background: rgba(10, 4, 2, 0.45);
}

.auto-opt {
  display: block;
  margin: 4px 0;
  font-size: 13px;
  color: #e8d8a8;
}

.auto-opt input[type="number"] {
  width: 52px;
  margin: 0 2px;
}

/* กรอบหน้าต่างลอยแบบ border-image (แก้เนื้อหาที่เลื่อนแล้วล้นไปทับขอบประดับ): เส้นขอบและมุมประดับอยู่ในแถบขอบกว้าง 18px ส่วนเนื้อหาที่เลื่อนถูกตัดที่ขอบด้านในของแถบนี้ เลยไม่ล้นออกนอกกรอบ */
.float-panel {
  border: 18px solid transparent;
  border-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'><rect x='1' y='1' width='58' height='58' rx='8' fill='none' stroke='%23b08d3c' stroke-width='2'/><rect x='3.5' y='3.5' width='53' height='53' rx='6' fill='none' stroke='%230a0400' stroke-width='2.2' stroke-opacity='0.85'/><rect x='5.2' y='5.2' width='49.6' height='49.6' rx='5' fill='none' stroke='%23d8b04a' stroke-width='1' stroke-opacity='0.45'/><g transform='translate(0 0) scale(1 1)'><g transform='translate(4 4) scale(0.75)'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.8'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></g></g><g transform='translate(60 0) scale(-1 1)'><g transform='translate(4 4) scale(0.75)'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.8'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></g></g><g transform='translate(0 60) scale(1 -1)'><g transform='translate(4 4) scale(0.75)'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.8'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></g></g><g transform='translate(60 60) scale(-1 -1)'><g transform='translate(4 4) scale(0.75)'><path d='M1.5 16V4Q1.5 1.5 4 1.5H16' fill='none' stroke='%23d8b04a' stroke-width='1.8'/><path d='M6 6l2.6 2.6L6 11.2 3.4 8.6z' fill='%23d8b04a'/></g></g></svg>") 18 / 18px stretch;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--lacquer-top), var(--lacquer-bottom));
  background-clip: padding-box;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  padding: 0 6px 0 4px;
}

/* พื้นแล็คเกอร์ต้องคลุมใต้แถบขอบด้วย (border-box) ไม่งั้นเห็นพื้นหลังเกมทะลุแถบขอบที่โปร่ง */
.float-panel {
  background-clip: border-box;
  background-origin: border-box;
}

/* ตีบวกอุปกรณ์ */
.enhance-open,
.enhance-go {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 9px;
  box-sizing: border-box;
  border: 2px solid var(--gold-dim, #b08d3c);
  border-radius: 8px;
  background: linear-gradient(180deg, #5a2a1a, #34150c);
  color: #ffe8b0;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}

.enhance-go:hover,
.enhance-open:hover {
  filter: brightness(1.15);
}

.enhance-rule {
  margin: 4px 0 8px;
  font-size: 12px;
  color: #c8b890;
}

.enhance-detail {
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid rgba(216, 176, 74, 0.5);
  border-radius: 8px;
  background: rgba(10, 4, 2, 0.5);
}

.enhance-line {
  margin: 3px 0;
  font-size: 13px;
}

.enhance-line.short {
  color: #ff8a7a;
}

.enhance-line.risk-drop {
  color: #ffc46a;
}

.enhance-line.risk-break {
  color: #ff7a6a;
  font-weight: bold;
}

.enhance-ok {
  color: #7dff9a;
}

.enhance-panel .shop-row.selected {
  border-color: #e8c35a;
  background: rgba(60, 40, 10, 0.55);
}

/* ป้ายชื่อตอนชี้ช่องลัด (Hotbar.setTip) */
.hot-tip {
  position: fixed;
  z-index: 61;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 240px;
  padding: 5px 9px;
  border: 1px solid #b08d3c;
  border-radius: 6px;
  background: rgba(18, 10, 8, 0.96);
  color: #eee;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.hot-tip[hidden] {
  display: none;
}

.hot-tip strong {
  color: #ffe9a8;
  font-size: 13px;
}

.hot-tip span {
  color: #cdb987;
}

/* ช่องลัดของใช้ */
.hot-item .hot-key {
  color: #8fe8b8;
}

.hot-item .hot-cost {
  color: #8fe8b8;
}

/* ช่องแชต/บันทึกเหตุการณ์ ชิดมุมซ้ายล่างสุดแบบเกมออนไลน์ (ผู้ใช้สั่ง) พื้นโปร่ง ไม่มีกรอบ ตัวหนังสือมีขอบดำ มีป้ายช่อง [EXP] [ของ] พับ/กรองหมวดได้
   ChatLog.place ยกขึ้นเหนือแถวช่องลัดเองเมื่อจอแคบจนทับกัน */
.chat-log {
  position: fixed;
  left: 8px;
  bottom: 12px;
  z-index: 8;
  width: min(360px, calc(100vw - 130px));
  border-radius: 4px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.28));
  color: #f2e7c8;
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  transition: background 0.15s;
}

.chat-log:hover {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.4));
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.35);
}

.chat-head strong {
  margin-right: auto;
  padding-left: 2px;
  font-size: 11px;
  color: #cdbd94;
}

.chat-head button {
  min-height: 18px;
  padding: 0 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #b9ab88;
  font-size: 11px;
  cursor: pointer;
}

.chat-head button:hover {
  color: #fff3c8;
}

.chat-head button.on {
  background: rgba(232, 195, 90, 0.28);
  color: #fff3c8;
}

.chat-head .chat-fold {
  padding: 0 6px;
}

.chat-list {
  height: 150px;
  padding: 3px 8px 4px;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.chat-log.collapsed .chat-list {
  display: none;
}

.chat-line {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 3px #000;
  overflow-wrap: anywhere;
}

/* ป้ายช่องหน้าบรรทัด */
.chat-line::before {
  flex: none;
  font-weight: bold;
  color: #ffe066;
}

.chat-sys::before { content: '[ระบบ]'; }
.chat-exp::before { content: '[EXP]'; color: #8fe8b0; }
.chat-item::before { content: '[ของ]'; color: #8fd3ff; }
.chat-gold::before { content: '[ตำลึง]'; color: #ffd84a; }

.chat-icon {
  flex: none;
  width: 14px;
  height: 14px;
}

.chat-icon canvas {
  display: block;
  width: 14px;
  height: 14px;
}

.chat-strong {
  font-weight: bold;
}

.chat-list[data-filter='exp'] .chat-line:not(.chat-exp),
.chat-list[data-filter='item'] .chat-line:not(.chat-item) {
  display: none;
}

@media (max-width: 600px) {
  .chat-log {
    width: min(290px, calc(100vw - 110px));
    font-size: 11px;
  }
  .chat-list {
    height: 96px;
  }
}

/* หน้าต่างตั้งค่า (เมนู > ตั้งค่า) */
.settings-panel {
  width: 360px;
}

.set-section {
  margin: 0 0 12px;
  padding: 8px 10px 6px;
  border: 1px solid rgba(176, 141, 60, 0.35);
  border-radius: 8px;
  background: rgba(10, 6, 4, 0.35);
}

.set-section h4 {
  margin: 0 0 2px;
  font-size: 14px;
  color: var(--gold, #e8c35a);
}

.set-hint {
  margin: 0 0 6px;
  font-size: 11px;
  color: #b9a98a;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  font-size: 12px;
  color: #eee;
}

.set-row .set-label {
  flex: 1;
}

.set-row input[type='range'] {
  flex: 0 0 130px;
  accent-color: #d8b04a;
}

.set-row .set-val {
  flex: 0 0 38px;
  text-align: right;
  color: #ffe9a8;
}

.set-row select {
  flex: 0 0 170px;
  min-height: 26px;
  border: 1px solid var(--gold-dim, #7a6228);
  border-radius: 6px;
  background: #1c120d;
  color: #eee;
  font-size: 12px;
}

.set-check {
  cursor: pointer;
}

.set-check input {
  width: 16px;
  height: 16px;
  accent-color: #d8b04a;
}

.set-foot {
  display: flex;
  justify-content: flex-end;
}

.set-foot button {
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid var(--gold-dim, #7a6228);
  border-radius: 6px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  color: #eee;
  font-size: 12px;
  cursor: pointer;
}

@media (max-width: 600px) {
  .settings-panel {
    width: auto;
  }
  .set-row input[type='range'] {
    flex-basis: 100px;
  }
  .set-row select {
    flex-basis: 140px;
  }
}

/* ความซื่อสัตย์ขุนพล + ปุ่มไล่ออก */
.loyalty {
  font-weight: bold;
}

.loy-high { color: #8fe8b0; }
.loy-mid { color: #ffd84a; }
.loy-low { color: #ff8a7a; }

.loyalty-bar {
  position: relative;
  height: 10px;
  margin: 2px 0 6px;
  border: 1px solid rgba(176, 141, 60, 0.6);
  border-radius: 5px;
  background: rgba(10, 6, 4, 0.7);
  overflow: hidden;
}

.loyalty-fill {
  height: 100%;
  border-radius: 4px;
}

.loyalty-fill.loy-high { background: linear-gradient(180deg, #5ec688, #2f8a55); }
.loyalty-fill.loy-mid { background: linear-gradient(180deg, #f0cc4a, #b08a1a); }
.loyalty-fill.loy-low { background: linear-gradient(180deg, #e8604a, #8a2418); }

.loyalty-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  opacity: 0.8;
}

.loyalty-horses {
  flex-wrap: wrap;
}

.team-back.danger,
.shop-buttons button.danger {
  border-color: #e0603a;
  background: linear-gradient(180deg, #6a2414, #3a120a);
  color: #ffd9c8;
}

/* ---------- แถบช่องลัดแบบกะทัดรัด (ผู้ใช้สั่ง: ย่อให้สั้นลง) ----------
   สกิล 10 ช่องแถวเดียวช่องละ 42px + โพชั่น/ของใช้ 5 ช่องเล็กกว่าอยู่แถวล่าง: กว้างราว 460px สูงราว 85px (เดิมกว้าง ~640px สูง ~116px)
   ช่องไม่แสดงชื่อ/ราคา SP (ดูได้จากคำใบ้ตอนชี้) เหลือไอคอน ปุ่มลัด และจำนวนของ จอแคบ (≤600px) สกิลเป็น 5+5 โพชั่น/ของใช้เป็นตารางข้างขวา */
#hotbar {
  display: flex;
  flex-direction: column-reverse;   /* ผู้ใช้สั่ง: แถวสกิล 1-0 อยู่ล่างสุด แถวโพชั่น/ของใช้อยู่เหนือขึ้นไป */
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  max-width: calc(100vw - 24px);
}

.hot-skills,
.hot-supplies {
  display: flex;
  justify-content: center;
  gap: 4px;
}

#hotbar .hot-slot {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 7px;
}

#hotbar .hot-supplies .hot-slot {
  width: 38px;
  height: 38px;
}

#hotbar .hot-name {
  display: none;
}

#hotbar .hot-key {
  position: absolute;
  top: 1px;
  left: 3px;
  z-index: 2;
  font-size: 10px;
  line-height: 1;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}

#hotbar .hot-skills .hot-cost {
  display: none;
}

#hotbar .hot-icon {
  top: 7px;
  left: 50%;
  right: auto;
  width: 28px;
  height: 28px;
  margin-left: -14px;
}

#hotbar .hot-supplies .hot-icon {
  top: 6px;
  width: 26px;
  height: 26px;
  margin-left: -13px;
}

#hotbar .hot-supplies .hot-cost {
  display: block;
  position: absolute;
  right: 3px;
  bottom: 1px;
  z-index: 2;
  font-size: 10px;
  font-weight: bold;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}

#btn-capture {
  bottom: 104px;
}

@media (max-width: 600px) {
  #hotbar {
    flex-direction: row;
    align-items: flex-end;
    gap: 6px;
  }
  .hot-skills {
    flex-wrap: wrap;
    width: calc(5 * 46px + 4 * 4px);
  }
  #hotbar .hot-slot {
    width: 46px;
    height: 46px;
  }
  .hot-supplies {
    display: grid;
    grid-template-columns: repeat(2, 38px);
    gap: 4px;
  }
  #btn-attack {
    bottom: 140px;
  }
  #btn-capture {
    bottom: 232px;
  }
}

/* คอมโบทีม (หน้าทีมขุนพล) */
#team-combo {
  margin: 6px 0;
  font-size: 12px;
}

.combo-title {
  display: block;
  margin-bottom: 4px;
  color: var(--gold, #e8c35a);
  font-size: 13px;
}

.combo-row {
  padding: 1px 0 1px 16px;
  text-indent: -16px;   /* ป้าย ✔/✘ ยื่นซ้าย ข้อความยาวตกบรรทัดใหม่แล้วเยื้องตรงกัน */
  line-height: 1.4;
}

.combo-row.on { color: #8fe8b0; }
.combo-row.off { color: #8a7f6a; }
.combo-mark { display: inline-block; width: 16px; text-indent: 0; }

.combo-note {
  margin-top: 4px;
  font-size: 11px;
  color: #a39880;
}

/* ---------- เกจคอมโบ (เหนือช่องลัดสกิล) ---------- */
.cg-gauge {
  position: absolute;   /* ลอยเหนือแถบช่องลัด ไม่ดันเลย์เอาต์ของแถบ */
  left: 0;
  right: 0;
  bottom: 100%;
  margin-bottom: 4px;
  box-sizing: border-box;
  padding: 4px 8px 5px;
  border: 1px solid #8a6a22;
  border-radius: 6px;
  background: rgba(24, 16, 4, 0.82);
  color: #ffe9a8;
  font-size: 12px;
  pointer-events: none;
}

.cg-gauge[hidden] {
  display: none;
}

.cg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}

.cg-title {
  font-weight: bold;
  font-size: 13px;
  color: #ffd84a;
}

.cg-next {
  color: #cfe9b8;
}

.cg-bar {
  height: 4px;
  margin: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.cg-fill {
  height: 100%;
  background: linear-gradient(90deg, #d8a032, #ffd84a);
  transition: width 0.1s linear;
}

.cg-gauge.low .cg-fill {
  background: linear-gradient(90deg, #c0392b, #ff7a5a);
}

.cg-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cg-skill {
  display: inline-block;
  width: 22px;
  height: 22px;
}

.cg-skill .icon {
  width: 100%;
  height: 100%;
  display: block;
}

.cg-gauge.max {
  border-color: #ffd84a;
  box-shadow: 0 0 8px rgba(255, 216, 74, 0.65);
}

.cg-gauge.pulse {
  animation: cg-pulse 0.25s ease-out;
}

@keyframes cg-pulse {
  0% { transform: scale(1.06); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}

#hotbar {
  position: relative;
}

@media (max-width: 600px) {
  .cg-next {
    display: none;   /* จอแคบ: เหลือชื่อคอมโบ + ไอคอน */
  }
}

/* ปุ่มล่างของถุง (จัดเรียง/ล็อก/ย่อยอุปกรณ์) ตรึงไว้ก้นหน้าต่าง เลื่อนตารางแล้วก็ยังเห็นและกดได้เสมอ */
.bag-panel .bag-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin-top: 0;
  padding: 8px 0 6px;
  background: var(--lacquer-bottom, #130b0a);
}

/* ---------- แผนที่โลก ---------- */
.worldmap-panel {
  top: 12px;   /* แผนที่ใหญ่: ขึ้นไปเต็มความสูงจอ (ทับมินิแมป/ปุ่มบนชั่วคราว ปิดด้วย M/Esc/✕) */
  max-height: calc(100vh - 12px - 108px);
  left: 50%;
  right: auto;
  width: min(940px, calc(100vw - 24px));
  max-width: none;
  transform: translateX(-50%);
}

.wm-hint {
  margin: 0 0 6px;
  font-size: 12px;
  color: #bfa86a;
}

.wm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 0 0 4px;
  font-size: 12px;
  color: #d8c9a8;
}

.wm-lg-tip {
  margin-left: auto;
  color: #a39880;
}

.wm-lg-tip::before {
  display: none !important;
}

.wm-lg::before {
  display: inline-block;
  margin-right: 5px;
  vertical-align: -1px;
  content: '';
  width: 10px;
  height: 10px;
}

.wm-lg-here::before { border-radius: 50%; border: 2px solid #ff7a5a; }
.wm-lg-pillar::before { background: #ffd84a; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }
.wm-lg-spawn::before { background: #8cf096; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }
.wm-lg-safe::before { border-radius: 3px; background: #a8b08a; }

.wm-scroll {
  max-height: calc(100vh - 12px - 108px - 190px);   /* หัวข้อ+คำอธิบาย+กล่องรายละเอียดกินที่ ~190px ที่เหลือเป็นแผนที่ เลื่อนได้ในกรอบนี้ */
  min-height: 240px;
  overflow: auto;
  border: 1px solid rgba(216, 176, 74, 0.35);
  border-radius: 6px;
  background: radial-gradient(circle at 30% 20%, #2a2418, #120d08);
}

.wm-svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
}

.wm-edge {
  stroke: #6f6140;
  stroke-width: 3;
  stroke-linecap: round;
}

.wm-edge.on {
  stroke: #ffd84a;
  stroke-width: 5;
}

.wm-node {
  cursor: pointer;
  outline: none;
}

.wm-shape {
  stroke: #1a0d00;
  stroke-width: 2.4;
}

.wm-safe {
  stroke: #ffd84a;
}

.wm-node.sel .wm-shape {
  stroke: #ffffff;
  stroke-width: 3.4;
}

.wm-node:hover .wm-shape {
  filter: brightness(1.2);
}

.wm-here-ring {
  fill: none;
  stroke: #ff7a5a;
  stroke-width: 3;
}

.wm-name {
  fill: #f3e7c6;
  font-size: 17px;
  font-weight: bold;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #120d08;
  stroke-width: 3px;
}

.wm-lv {
  fill: #cdbd90;
  font-size: 14px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #120d08;
  stroke-width: 3px;
}

.wm-you {
  fill: #ff9a7a;
  font-size: 15px;
  font-weight: bold;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #120d08;
  stroke-width: 3px;
}

.wm-pillar {
  fill: #ffd84a;
  stroke: #1a0d00;
  stroke-width: 1;
}

.wm-pillar.active {
  fill: #8cf096;
}

.wm-detail {
  margin: 0 0 6px;
  padding: 6px 10px;
  border: 1px solid rgba(216, 176, 74, 0.4);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 13px;
}

.wm-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.wm-detail-head strong {
  font-size: 15px;
  color: #ffe9a8;
}

.wm-detail-lv {
  color: #cfe9b8;
}

.wm-detail-line,
.wm-route {
  margin: 4px 0 0;
  line-height: 1.45;
}

.wm-route {
  color: #ffd84a;
}

.wm-muted {
  color: #a39880;
  font-size: 12px;
}

.npc-saved {
  color: #a8f0b0;
}

/* ช่องรูปขบวนกลมๆ ล้อมปุ่มตี (ผู้ใช้สั่ง) ตำแหน่งตั้งโดย Toolbar.layoutFormationRing (วัดจากปุ่มตีจริง) กดเปลี่ยนรูปขบวนได้ตลอดเวลา */
#formation-ring {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

.formation-dot {
  position: fixed;
  left: -100px;
  top: -100px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #5a4a22;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #3a3a3a, #1c1c1c 80%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  color: #d8d0b8;
  font-size: 11px;
  line-height: 1;
  text-shadow: 0 1px 0 #000;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.formation-dot:active {
  transform: scale(0.92);
}

.formation-dot.on {
  border-color: #ffd84a;
  background: radial-gradient(circle at 40% 30%, #6a5a1e, #3a3216 80%);
  box-shadow: inset 0 0 0 1px rgba(10, 4, 0, 0.8), 0 0 10px rgba(255, 216, 74, 0.6);
  color: #fff2b8;
}

/* ตลาดกลาง: ฟอร์มลงขาย (แถวสินค้า/ปุ่ม/แท็บใช้คลาสร้านค้าเดิม) */
.market-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
}

.market-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.market-inputs label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #e8d8a8;
}

.market-inputs input {
  width: 110px;
  padding: 4px 6px;
  border: 1px solid #b08d3c;
  border-radius: 5px;
  background: rgba(20, 10, 8, 0.92);
  color: #ffe9a8;
  font-size: 13px;
}

.market-inputs input:disabled {
  opacity: 0.5;
}

/* ระบบเควส: บรรทัดเควสในหน้าคุย NPC · สมุดเควส · แถบติดตามเควสทางขวาของจอ (อยู่ใต้หน้าต่างลอย z-index ต่ำกว่า) */
.npc-quest {
  margin: 2px 0 6px;
  color: #ffd84a;
  font-size: 13px;
  font-weight: bold;
}

.quest-row {
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid #5a4a22;
  border-radius: 8px;
  background: rgba(30, 24, 18, 0.9);
}

.quest-row.quest-ready {
  border-color: #ffd84a;
}

.quest-row.quest-done {
  opacity: 0.75;
}

.quest-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.quest-head strong {
  color: #ffe9a8;
  font-size: 14px;
}

.quest-chapter {
  color: #b8a888;
  font-size: 11px;
}

.quest-desc {
  margin: 4px 0;
  color: #d8d2bd;
  font-size: 12px;
  line-height: 1.5;
}

.quest-obj {
  margin: 1px 0;
  color: #e8e0cc;
  font-size: 12px;
}

.quest-obj.done {
  color: #8fd8a8;
}

.quest-hint {
  margin-top: 3px;
  color: #ffd84a;
  font-size: 12px;
}

.quest-reward {
  margin-top: 3px;
  color: #b9d8ff;
  font-size: 12px;
}

.quest-tracker {
  position: fixed;
  right: 12px;
  top: 200px;   /* ตั้งจริงโดย QuestPanel.placeTracker ใต้กล่องรายชื่อทีม */
  z-index: 5;
  width: 230px;
  padding: 8px 10px;
  border: 1px solid #b08d3c;
  border-radius: 8px;
  background: rgba(24, 14, 8, 0.78);
  color: #e8e0cc;
  font-size: 12px;
  line-height: 1.5;
  cursor: pointer;
  pointer-events: auto;
}

.quest-tracker[hidden] {
  display: none;
}

.quest-tracker .qt-title {
  display: block;
  margin-bottom: 2px;
  color: #ffd84a;
  font-size: 13px;
}

.quest-tracker .qt-obj.done {
  color: #8fd8a8;
}

.quest-tracker .qt-hint {
  margin-top: 2px;
  color: #ffd84a;
}

@media (max-width: 600px) {
  .quest-tracker {
    width: 190px;
    font-size: 11px;
  }
}

/* ---------- ระบบฉากเนื้อเรื่อง (js/ui/sceneui.js) ---------- */
body.scene-cine > *:not(#game):not(#scene-root) { display: none !important; }   /* ฉากฉายหนัง: ซ่อน UI ผู้เล่นทั้งหมด (แผงลอย แถบช่องลัด แชต) เหลือแคนวาสกับชั้นฉาก */
.scene-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; font-family: sans-serif; }
.scene-root[hidden] { display: none; }
.scene-fade, .scene-tint, .scene-flash { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.scene-bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 0.6s ease; }
.scene-bar-top { top: 0; }
.scene-bar-bottom { bottom: 0; }
.scene-bar.on { height: 11vh; }
.scene-title { position: absolute; left: 0; right: 0; top: 38%; text-align: center; opacity: 0; pointer-events: none; }
.scene-title-main { font-size: clamp(26px, 5vw, 48px); font-weight: 700; color: #ffe9a8; letter-spacing: 0.08em; text-shadow: 0 0 18px rgba(232, 195, 90, 0.7), 0 2px 4px #000; }
.scene-title-sub { margin-top: 10px; font-size: clamp(14px, 2.2vw, 20px); color: #e8dcc0; text-shadow: 0 2px 4px #000; }
.scene-skip { position: absolute; right: 14px; top: calc(11vh + 10px); pointer-events: auto; padding: 6px 12px; font-size: 13px; color: #e8dcc0; background: rgba(20, 12, 8, 0.7); border: 1px solid var(--gold-dim, #b08d3c); border-radius: 4px; cursor: pointer; }
.scene-skip:hover { background: rgba(60, 36, 20, 0.85); }
.scene-dialog { position: absolute; left: 50%; bottom: calc(11vh + 14px); transform: translateX(-50%); width: min(880px, calc(100vw - 28px)); display: flex; gap: 14px; padding: 12px 16px; pointer-events: auto; cursor: pointer;
  background: linear-gradient(180deg, rgba(42, 22, 20, 0.94), rgba(19, 11, 10, 0.96)); border: 2px solid var(--gold-dim, #b08d3c); border-radius: 6px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6); }
.scene-dialog[hidden] { display: none; }
.scene-portrait { width: 72px; height: 72px; flex: none; image-rendering: pixelated; background: #1a110c; border: 1px solid var(--gold-dim, #b08d3c); border-radius: 4px; }
.scene-dialog-body { flex: 1; min-width: 0; }
.scene-name { font-size: 14px; font-weight: 700; color: #ffe9a8; margin-bottom: 4px; }
.scene-text { font-size: 15px; line-height: 1.55; color: #f0e8d4; min-height: 3.1em; white-space: pre-wrap; }
.scene-hint { margin-top: 4px; font-size: 11px; color: #b8a888; text-align: right; animation: scene-blink 1s infinite; }
@keyframes scene-blink { 50% { opacity: 0.35; } }
.scene-battle { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); min-width: 240px; padding: 8px 14px; text-align: center; pointer-events: none;
  background: rgba(24, 12, 8, 0.82); border: 1px solid #c0603a; border-radius: 6px; }
.scene-battle[hidden] { display: none; }
.scene-battle-title { font-size: 14px; font-weight: 700; color: #ffb48a; }
.scene-battle-line { font-size: 13px; color: #f0e8d4; margin-top: 2px; }
.scene-battle-line.urgent { color: #ff7a6a; font-weight: 700; }
.scene-battle-rules { font-size: 11px; color: #c8b898; margin-top: 3px; }

/* ดันเจี้ยนมิติ: กล่องถามเข้า/ออก และแถบเวลา */
.dungeon-ask {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  z-index: 70;
  width: 400px;
  max-height: 70vh;
  overflow-y: auto;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  padding: 14px 16px;
  border: 2px solid #b08d3c;
  border-radius: 10px;
  background: rgba(20, 20, 20, 0.95);
  color: #eee;
  font-size: 14px;
}

.dungeon-ask[hidden],
.dungeon-hud[hidden] {
  display: none;
}

.dungeon-ask h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #e0b84a;
}

.dungeon-ask p {
  margin: 0 0 12px;
  white-space: pre-line;
}

.dungeon-ask-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.dungeon-ask-row button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dungeon-ask-row button {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid #b08d3c;
  border-radius: 8px;
  background: rgba(30, 30, 30, 0.9);
  color: #eee;
  cursor: pointer;
}

.dungeon-hud {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 25;
  padding: 4px 14px;
  border: 1px solid #b08d3c;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.85);
  color: #ffe9a8;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 760px) {
  .dungeon-hud {
    top: 112px;
    left: 8px;
    transform: none;
    font-size: 12px;
  }
}

/* ---------- หน้าหอคอยมิติ ---------- */
.tower-panel {
  width: 400px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--panel-top, 200px) - 92px);
  overflow-y: auto;
}

.tower-panel h4 {
  margin: 10px 0 4px;
  font-size: 14px;
  color: #e0b84a;
}

.tower-panel .shop-bulk {
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- คู่มือในเกม ---------- */
.guide-panel {
  width: 420px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--panel-top, 200px) - 92px);
  overflow-y: auto;
}

.guide-topic {
  gap: 4px;
}

.guide-topic .premium-note {
  line-height: 1.45;
}

/* ---------- สมุดเรื่องราว ---------- */
.story-panel {
  width: 400px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--panel-top, 200px) - 92px);
  overflow-y: auto;
}

/* ===== ออนไลน์: หน้าล็อกอิน / ป้ายสถานะ / ปุ่มบัญชี ===== */
.online-overlay {
  z-index: 100;
}

.online-sub,
.online-note {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #bbb;
  text-align: left;
}

.online-note {
  margin: 14px 0 0;
  font-size: 12px;
  color: #888;
}

.online-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.online-tab {
  flex: 1;
  padding: 8px 0;
  border: 1px solid #555;
  border-radius: 8px;
  background: #1b1b1b;
  color: #ccc;
  font-size: 14px;
  cursor: pointer;
}

.online-tab.on {
  border-color: #e0b84a;
  background: #2b2616;
  color: #fff;
}

.online-field {
  margin-bottom: 12px;
}

.online-msg {
  min-height: 18px;
  margin: 0 0 10px;
  font-size: 13px;
  color: #ff9a8a;
  text-align: left;
}

.online-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px 0;
  border: 1px solid #777;
  border-radius: 8px;
  background: #222;
  color: #eee;
  font-size: 15px;
  cursor: pointer;
}

.online-btn.online-go {
  border-color: #e0b84a;
  background: #6b5217;
  color: #fff;
}

.online-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.online-badge {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 16px));
  padding: 6px 10px;
  border: 1px solid #b08d3c;
  border-radius: 8px;
  background: rgba(20, 16, 8, 0.9);
  color: #ffd98a;
  font-size: 12px;
  line-height: 1.4;
}

.online-badge[hidden] {
  display: none;
}

.set-danger {
  color: #ff9a8a;
}

/* ===== ป้ายสไตล์สกิล: แดง = สายกำลัง / ฟ้า = สายปัญญา ===== */
.skill-node.b-str::after,
.skill-node.b-wis::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.6);
}

.skill-node.b-str::after {
  background: #e0603a;
}

.skill-node.b-wis::after {
  background: #5ab0ff;
}

.skill-line.style-str {
  color: #ff9a7a;
}

.skill-line.style-wis {
  color: #8fc8ff;
}

/* ===== นั่งฝึกฌาน ===== */
.med-bar {
  height: 6px;
  margin-top: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.med-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #d8a032, #ffe27a);
}

.med-row.med-active {
  outline: 1px solid #ffd84a;
  background: rgba(255, 216, 74, 0.08);
}

/* ===== โบนัสเซตในหน้าอุปกรณ์ ===== */
.gear-sets {
  margin: 8px 0;
  padding: 6px 8px;
  border: 1px solid rgba(176, 141, 60, 0.45);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
}

.gear-sets h4 {
  margin: 0 0 4px;
  font-size: 12px;
  color: #e0b84a;
}

.gear-set-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
  padding-left: 6px;
  border-left: 3px solid #e0603a;
}

.gear-set-row.wis {
  border-left-color: #5ab0ff;
}

.gear-set-row .on {
  color: #8fe8b0;
}

.gear-set-row .off {
  color: #8a7f6a;
}

/* ===== ปุ่มสกิลเคลื่อนที่ Z ก้าวพริบตา / X วิ่งไว ===== */
#hotbar .hot-move .hot-name {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: #bfe8ff;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}

#hotbar .hot-move-light .hot-name {
  color: #ffe9a0;
}

#hotbar .hot-move.active {
  border-color: #ffe066;
  box-shadow: 0 0 8px rgba(255, 224, 102, 0.8);
}

/* ===== จัดระเบียบมุมขวาบน (ผู้ใช้สั่ง 2026-11-07): ปุ่มทุกปุ่มขนาดเท่ากัน ความกว้างตั้งโดย Toolbar.layout (--toolbar-btn-w) ===== */
#toolbar {
  gap: 4px;
}

#toolbar button,
#toolbar button.btn-mail {
  box-sizing: border-box;
  flex: 0 0 var(--toolbar-btn-w, 68px);
  width: var(--toolbar-btn-w, 68px);
  min-width: 0;
  min-height: 32px;
  padding: 0 4px;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
}

@media (max-width: 600px) {
  #toolbar button,
  #toolbar button.btn-mail {
    flex: 0 0 auto;   /* คอลัมน์แนวตั้ง: flex-basis คือความสูง จึงไม่ใช้ ความกว้างมาจาก width */
    min-width: 0;
    min-height: 34px;
    font-size: 13px;
  }
}

/* ---------- จอเตี้ย: มือถือแนวนอน (สูง < 520px) ----------
   ข้อกำหนดเดิมแยกตามความกว้างอย่างเดียว มือถือแนวนอนกว้าง > 600px จึงได้เลย์เอาต์จอคอม แต่สูงแค่ ~360-430px แล้วพัง
   (แชตกินครึ่งจอ หน้าต่างลอยเหลือที่ไม่กี่สิบพิกเซล เมนูล้นขอบล่าง) หน้าต่างลอยเริ่มที่ขอบบนผ่าน Toolbar.layout (--panel-top) */
@media (max-height: 520px) {
  .chat-log {
    width: min(260px, 30vw);
    font-size: 10.5px;
  }
  .chat-list {
    height: 54px;
  }
  #menu-pop {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-width: 280px;
  }
  #menu-pop button {
    min-height: 30px;
    padding: 0 8px;
    font-size: 12px;
  }
}

/* ---------- จอแคบและเตี้ย: iPhone SE / มือถือจอเล็ก (กว้าง ≤ 600px และสูง ≤ 720px) ----------
   ผู้ใช้บอกว่าบน iPhone SE ทุกอย่างใหญ่เกินไป: ปุ่มหน้าต่าง 2 คอลัมน์ (ความกว้างตั้งโดย Toolbar.layout), แชต/ช่องลัด/ปุ่มตีเล็กลง */
@media (max-width: 600px) and (max-height: 720px) {
  #toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 3px;
    max-width: calc(var(--toolbar-btn-w, 68px) * 2 + 4px);
  }
  #toolbar button,
  #toolbar button.btn-mail {
    min-height: 28px;
    font-size: 11.5px;
  }
  #menu-pop {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-width: 250px;
  }
  #menu-pop button {
    min-height: 30px;
    padding: 0 8px;
  }
  .chat-log {
    width: min(250px, calc(100vw - 110px));
    font-size: 10.5px;
  }
  .chat-list {
    height: 56px;
  }
  #hotbar {
    gap: 5px;
  }
  .hot-skills {
    width: calc(5 * 40px + 4 * 4px);
  }
  #hotbar .hot-slot {
    width: 40px;
    height: 40px;
  }
  #hotbar .hot-icon {
    top: 6px;
    width: 24px;
    height: 24px;
    margin-left: -12px;
  }
  .hot-supplies {
    grid-template-columns: repeat(3, 34px);
  }
  #hotbar .hot-supplies .hot-slot {
    width: 34px;
    height: 34px;
  }
  #hotbar .hot-supplies .hot-icon {
    top: 5px;
    width: 22px;
    height: 22px;
    margin-left: -11px;
  }
  #btn-attack {
    right: 8px;
    bottom: 104px;
    width: 64px;
    height: 64px;
  }
  #btn-attack .atk-label {
    font-size: 22px;
  }
  #btn-capture {
    bottom: 184px;
  }
}

/* ---------- มือถือแนวตั้ง: ขอให้หมุนจอ (UiScale ใส่ class rotate-needed บน <html>) ---------- */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: #120c08;
  color: #f0e2b4;
  font-size: 18px;
  text-align: center;
}

#rotate-hint .rotate-icon {
  font-size: 64px;
  line-height: 1;
  color: #d8b04a;
}

#rotate-hint p {
  margin: 0;
}

.rotate-needed #rotate-hint {
  display: flex;
}

/* ---------- จอยสติ๊กบนจอ (มือถือ) ซ้ายล่าง ผู้ใช้สั่ง 2026-11-08 · ลอจิกใน js/ui/joystick.js ---------- */
#joystick {
  display: none;
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 9;
  width: 120px;
  height: 120px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-ui #joystick {
  display: block;
}

#joystick .joy-ring {
  position: absolute;
  inset: 8px;
  border: 3px solid rgba(216, 176, 74, 0.7);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 12, 8, 0.28), rgba(20, 12, 8, 0.5));
  box-shadow: inset 0 0 0 2px rgba(10, 4, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.5);
}

#joystick .joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 2px solid #d8b04a;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #8a6a2a, #4a3412 70%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* ---------- ร้านพิเศษ: ลองใส่ (ผู้ใช้สั่ง 2026-11-08) ---------- */
.premium-fit {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  padding: 6px 8px;
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  background: rgba(14, 9, 7, 0.97);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.premium-fit canvas {
  flex: none;
  width: 58px;
  height: auto;
  image-rendering: pixelated;
}

.premium-fit-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  font-size: 12px;
}

.premium-fit-info strong {
  color: #ffe9a8;
}

.premium-fit-info .premium-free {
  margin-top: 4px;
}

.premium-try.on {
  background: #b08d3c;
  color: #1a1408;
  font-weight: bold;
}

/* จอเตี้ย (มือถือแนวนอน): กล่องตัวอย่างเหลือภาพเล็กกับปุ่ม ไม่งั้นกินที่รายการสินค้าที่ลอยติดขอบบน */
@media (max-height: 520px) {
  .premium-fit {
    gap: 8px;
    margin: 4px 0;
    padding: 4px 8px;
  }
  .premium-fit canvas {
    width: 44px;
  }
  .premium-fit-info span {
    display: none;
  }
  .premium-fit-info strong {
    display: none;
  }
  .premium-fit-info .premium-free {
    margin-top: 2px;
  }
}

.premium-fit-total {
  font-size: 12px;
  color: #cdb987;
}

.premium-fit-total.warn {
  color: #ff9a8a;
}

.premium-fit-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.premium-fit-btns .premium-free {
  margin: 0;
}

.premium-fit-btns .premium-free:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-height: 520px) {
  .premium-fit-total {
    font-size: 11px;
    line-height: 1.3;
  }
  .premium-fit-btns {
    margin-top: 2px;
  }
  .premium-fit-btns .premium-free {
    min-height: 24px;
    padding: 0 8px;
    font-size: 11px;
  }
}

/* ปุ่ม "ลองใส่" + "ซื้อ" ในแถวสินค้าร้านพิเศษ เรียงซ้อนแนวตั้ง ไม่แย่งความกว้างของชื่อสินค้า */
.premium-panel .shop-row .shop-buttons {
  flex-direction: column;
  flex: none;
}

.premium-panel .shop-row .shop-buttons button {
  min-height: 26px;
  padding: 0 8px;
}

/* ---------- กิจกรรมรายวัน (ผู้ใช้สั่ง 2026-11-08) ---------- */
#btn-daily,
#btn-menu,
#btn-codex {
  position: relative;
}

/* ปุ่มกิจกรรม: ไอคอนล้วนกลางปุ่ม (ขนาดปุ่มเท่าปุ่มอื่นในแถว) */
#toolbar button.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#toolbar button.btn-icon canvas {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

#btn-daily.has-alert::after,
#btn-menu.has-alert::after,
#btn-codex.has-alert::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border: 1px solid #1a0a06;
  border-radius: 50%;
  background: #e0422a;
}

.daily-panel {
  width: 380px;
}

.daily-checkin {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin: 6px 0;
}

.daily-day {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 2px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: rgba(20, 12, 8, 0.7);
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
  white-space: pre-line;
  color: #cdb987;
}

.daily-day strong {
  color: #ffe9a8;
  font-size: 11px;
}

.daily-day.got {
  opacity: 0.45;
}

.daily-day.today {
  border-color: #ffd24a;
  background: rgba(90, 64, 20, 0.8);
  box-shadow: 0 0 8px rgba(255, 210, 74, 0.5);
}

.daily-bar {
  height: 6px;
  margin: 3px 0;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.daily-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3aa86a, #8fe8b0);
}

@media (max-width: 600px) {
  .daily-panel {
    width: auto;
  }
}

/* ธาตุประจำสัปดาห์ (แท็บรายสัปดาห์ของหน้ากิจกรรม) */
.daily-element {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  padding: 6px 10px;
  border: 2px solid var(--gold-dim);
  border-radius: 8px;
  background: rgba(20, 12, 8, 0.7);
}

.daily-element-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 12px;
}

.daily-element-next {
  color: #cdb987;
  font-size: 11px;
}

.daily-element canvas {
  flex: none;
  width: 34px;
  height: 34px;
}

/* เช็กชื่อรายเดือน (แท็บรายวัน): 4 ขั้นเรียงเป็นแถว */
.daily-month {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 6px 0;
}

.daily-month .daily-day button {
  min-height: 24px;
  margin-top: 2px;
  padding: 0 4px;
  font-size: 11px;
}

/* สมุดสะสม (ผู้ใช้สั่ง 2026-11-08) */
.codex-panel {
  width: 400px;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 4px;
  margin: 6px 0;
}

.codex-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 3px 5px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: rgba(20, 12, 8, 0.7);
}

.codex-chip.unseen {
  opacity: 0.55;
  border-style: dashed;
}

.codex-ic {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: #9a8a60;
  font-weight: bold;
}

.codex-ic canvas {
  width: 22px;
  height: 22px;
}

.codex-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 11px;
  line-height: 1.25;
}

.codex-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffe9a8;
}

.codex-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #cdb987;
}

@media (max-width: 600px) {
  .codex-panel {
    width: auto;
  }
}

/* ---------- สอนเล่นช่วงแรก (ผู้ใช้สั่ง 2026-11-08) กล่องคำแนะนำกลางบน + ปุ่มกะพริบ ---------- */
#tutorial {
  position: fixed;
  top: 120px;
  left: 50%;
  width: min(380px, calc(100vw - 24px));
  transform: translateX(-50%);
  box-sizing: border-box;
  padding: 8px 12px 10px;
  border: 2px solid #ffd24a;
  border-radius: 10px;
  background: rgba(20, 12, 8, 0.94);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 14px rgba(255, 210, 74, 0.35);
  color: #f2e7c8;
  font-size: 13px;
  line-height: 1.45;
}

#tutorial[hidden] {
  display: none;
}

#tutorial .tut-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

#tutorial .tut-head strong {
  flex: 1;
  color: #ffd24a;
  font-size: 14px;
}

#tutorial .tut-text {
  margin: 0;
}

#tutorial.tut-end .tut-text {
  margin-bottom: 8px;
}

#tutorial .tut-foot {
  display: none;
  justify-content: flex-end;
  gap: 6px;
}

#tutorial.tut-end .tut-foot {
  display: flex;
}

#tutorial button {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: linear-gradient(180deg, #2c1b18, #170e0c);
  color: #eee;
  font-size: 12px;
  cursor: pointer;
}

#tutorial button.tut-ok {
  border-color: #ffd24a;
  background: #b08d3c;
  color: #1a1408;
  font-weight: bold;
}

#tutorial button[hidden] {
  display: none;
}

#tutorial .tut-close {
  opacity: 0.75;
  font-size: 11px;
}

@keyframes tutpulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 210, 74, 0.95); }
  70% { box-shadow: 0 0 0 12px rgba(255, 210, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 210, 74, 0); }
}

.tut-pulse {
  animation: tutpulse 1.1s ease-out infinite;
  outline: 2px solid rgba(255, 210, 74, 0.9);
  outline-offset: 2px;
}

#joystick.tut-pulse,
#btn-attack.tut-pulse {
  border-radius: 50%;
}

@media (max-height: 520px) {
  #tutorial {
    top: 112px;
    width: min(340px, calc(100vw - 24px));
    font-size: 12px;
    line-height: 1.4;
  }
}

/* โบนัสถาวรจากการฆ่ามอน (แท็บมอนสเตอร์ของสมุดสะสม) */
.codex-bonus {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 6px 0;
  padding: 6px 8px;
  border: 1px solid #8fe8b0;
  border-radius: 8px;
  background: rgba(20, 50, 34, 0.5);
  font-size: 12px;
}

.codex-bonus strong {
  color: #8fe8b0;
}

.codex-bonus-rule {
  color: #cdb987;
  font-size: 11px;
}

.codex-kbar {
  height: 3px;
  margin-top: 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.codex-kbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3aa86a, #8fe8b0);
}

/* นโยบายความเป็นส่วนตัวและข้อตกลง (ผู้ใช้สั่ง "ตามที่แนะนำเลย" 2026-11-08) */
.policy-overlay {
  z-index: 120;
}

.policy-overlay .policy-panel {
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  box-sizing: border-box;
  text-align: left;
}

.policy-panel h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.policy-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 8px 0;
  padding-right: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: #ddd;
}

.policy-body h3 {
  margin: 12px 0 4px;
  font-size: 14px;
  color: #ffd24a;
}

.policy-body ul {
  margin: 0;
  padding-left: 18px;
}

.policy-draft {
  margin: 0;
  color: #ffb27a;
}

.online-consent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: 8px 0 0;
  font-size: 13px;
  color: #ccc;
  text-align: left;
}

.online-consent input[type='checkbox'] {
  width: auto;
}

.online-link {
  margin-left: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: #8fd3ff;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}
