* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #0f1220;
  color: #e8e4dc;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* —— Auth / Login (พรีวิว tools/login_ui_preview.html) —— */
#auth-screen {
  position: relative;
  overflow: auto;
  padding: 1rem 0.75rem;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  background: #05070c;
}

#auth-screen .auth-bg {
  position: absolute;
  inset: 0;
  background: url('/assets/sprites/ui/login_auth_bg.png?v=1') center / cover no-repeat;
  filter: brightness(1.18) contrast(1.04) saturate(1.06);
  pointer-events: none;
  z-index: 0;
}

#auth-screen .auth-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 42% at 50% 45%, rgba(4, 6, 12, 0.12) 0%, transparent 65%),
    linear-gradient(180deg, rgba(4, 6, 12, 0.04) 0%, rgba(4, 6, 12, 0.18) 100%);
}

#auth-screen .auth-panel {
  position: relative;
  z-index: 2;
  width: min(400px, 94vw);
  padding: 1.6rem 1.45rem 1.35rem;
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(14, 18, 30, 0.94), rgba(8, 10, 18, 0.96));
  border: 1px solid rgba(201, 162, 39, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 16px 48px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
}

#auth-screen .auth-brand {
  text-align: center;
  margin-bottom: 0.35rem;
  font-family: Cinzel, Georgia, serif;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(201, 162, 39, 0.75);
}

#auth-screen .auth-panel h1 {
  margin: 0;
  text-align: center;
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(1.55rem, 4vw, 1.9rem);
  font-weight: 700;
  color: #f0d78c;
  letter-spacing: 0.08em;
  text-shadow: 0 0 24px rgba(201, 162, 39, 0.25);
}

#auth-screen .auth-rule {
  display: block;
  width: 120px;
  height: 1px;
  margin: 0.65rem auto 0.7rem;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.7), transparent);
}

#auth-screen .subtitle {
  text-align: center;
  color: #a8b0c0;
  margin: 0 0 1.15rem;
  font-size: 0.86rem;
  line-height: 1.35;
}

#auth-screen #auth-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 4px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#auth-screen .tab {
  flex: 1;
  padding: 0.55rem 0.4rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #9aa5b1;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#auth-screen .tab.active {
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.28), rgba(201, 162, 39, 0.12));
  color: #f0d78c;
  box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.35);
}

#auth-screen form input {
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 10, 18, 0.72);
  color: #e8ecf4;
  font: inherit;
  outline: none;
}

#auth-screen form input:focus {
  border-color: rgba(201, 162, 39, 0.55);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.12);
}

#auth-screen form input::placeholder {
  color: #6b7280;
}

#auth-screen .auth-submit {
  width: 100%;
  margin-top: 0.25rem;
  margin-bottom: 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(201, 162, 39, 0.55);
  border-radius: 10px;
  background: linear-gradient(180deg, #c9a227, #8a6a1e);
  color: #1a1408;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(201, 162, 39, 0.22);
}

#auth-screen .auth-submit:hover {
  filter: brightness(1.06);
}

#auth-screen .auth-terms {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.35rem 0 0.65rem;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #c6b8a0;
  text-align: left;
  cursor: pointer;
}

#auth-screen .auth-terms input {
  width: auto;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

#auth-screen .auth-web-link {
  display: block;
  margin-top: 0.75rem;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.8rem;
  color: #d4b56a;
  text-decoration: none;
}

#auth-screen .auth-web-link:hover {
  text-decoration: underline;
}

#auth-screen .message {
  min-height: 1.2rem;
  color: #fc8181;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  text-align: center;
}

#auth-screen .hint {
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: #6b7280;
  text-align: center;
  line-height: 1.35;
}

/* มือถือแนวนอนสั้น — แผงกระชับ */
@media (orientation: landscape) and (max-height: 500px) {
  #auth-screen {
    padding: 0.5rem 0.6rem;
    align-items: flex-start;
  }
  #auth-screen .auth-panel {
    width: min(380px, 70vw);
    padding: 1rem 1.15rem 0.9rem;
    margin: 0.35rem auto;
  }
  #auth-screen .auth-panel h1 {
    font-size: 1.35rem;
  }
  #auth-screen .subtitle {
    margin-bottom: 0.65rem;
    font-size: 0.78rem;
  }
  #auth-screen form input {
    margin-bottom: 0.4rem;
    padding: 0.5rem 0.7rem;
  }
  #auth-screen .auth-submit {
    padding: 0.55rem 0.8rem;
  }
  #auth-screen .hint {
    display: none;
  }
}

/* สำรองฟอร์มอื่นที่ยังใช้ selector เก่า */
.panel {
  background: rgba(20, 24, 40, 0.95);
  border: 2px solid #4a5568;
  border-radius: 12px;
  padding: 2rem;
  width: min(420px, 92vw);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

form input, form button {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.65rem;
  border-radius: 6px;
  border: 1px solid #4a5568;
  background: #1a2035;
  color: #e8e4dc;
}

form button {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  cursor: pointer;
  font-weight: bold;
}

form button:hover {
  filter: brightness(1.1);
}

.message {
  min-height: 1.2rem;
  color: #fc8181;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.hint {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: #718096;
  text-align: center;
}

/* ââ Character creation â à¸à¸´à¸¨ A: à¹à¸à¹à¸à¸¡à¸à¸µà¸ªà¸²à¸¡à¸ à¸ ââ */
#char-screen {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1.25rem 0.75rem;
  background: #0a0814;
  /* Aethelgard type: Cinzel = à¸à¸·à¹à¸­à¹à¸¥à¸à¹à¸à¹à¸²à¸à¸±à¹à¸ Â· Sarabun = UI à¸­à¹à¸²à¸à¸à¹à¸²à¸¢ */
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
}

#char-select-screen {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1.25rem 0.75rem;
  background: #0a0814;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
}

#char-select-screen[data-race="titan"] .char-a-veil {
  background:
    radial-gradient(ellipse 50% 45% at 50% 40%, rgba(180, 120, 40, 0.14), transparent 55%),
    radial-gradient(ellipse 55% 50% at 50% 42%, transparent 18%, rgba(8, 6, 16, 0.58) 75%),
    linear-gradient(180deg, rgba(10, 8, 18, 0.3) 0%, rgba(6, 4, 14, 0.75) 100%);
}

#char-select-screen[data-race="sylph"] .char-a-veil {
  background:
    radial-gradient(ellipse 50% 45% at 50% 40%, rgba(50, 140, 90, 0.14), transparent 55%),
    radial-gradient(ellipse 55% 50% at 50% 42%, transparent 18%, rgba(8, 6, 16, 0.58) 75%),
    linear-gradient(180deg, rgba(10, 8, 18, 0.3) 0%, rgba(6, 4, 14, 0.75) 100%);
}

#char-select-screen[data-race="astral"] .char-a-veil {
  background:
    radial-gradient(ellipse 50% 45% at 50% 40%, rgba(100, 80, 180, 0.18), transparent 55%),
    radial-gradient(ellipse 55% 50% at 50% 42%, transparent 18%, rgba(8, 6, 16, 0.58) 75%),
    linear-gradient(180deg, rgba(10, 8, 18, 0.3) 0%, rgba(6, 4, 14, 0.75) 100%);
}

.char-select-panel {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 24px));
  padding: 1.15rem 1.15rem 1.3rem;
  border-radius: 14px;
  border: 1px solid rgba(107, 74, 40, 0.72);
  background:
    linear-gradient(165deg, rgba(52, 40, 26, 0.96) 0%, rgba(22, 18, 12, 0.98) 55%, rgba(14, 12, 10, 0.99) 100%);
  box-shadow:
    0 16px 42px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.char-select-panel::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 39, 0.12);
  pointer-events: none;
}

.char-select-header {
  margin-bottom: 0.25rem;
}

.char-select-rule {
  display: block;
  width: min(180px, 48%);
  height: 2px;
  margin: 0.55rem auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.85), transparent);
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.35);
}

.char-select-body {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  margin-top: 0.95rem;
}

.char-select-slots-wrap {
  flex: 1;
  min-width: 0;
}

.char-select-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  padding: 0 0.15rem;
}

.char-select-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #c4b896;
  text-transform: uppercase;
}

.char-select-slot-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fbd38d;
  font-variant-numeric: tabular-nums;
}

.char-select-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.char-select-slot {
  position: relative;
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  border-radius: 12px;
  border: 2px solid rgba(107, 74, 40, 0.58);
  background: linear-gradient(180deg, rgba(32, 28, 20, 0.92) 0%, rgba(12, 10, 8, 0.96) 100%);
  color: #f7fafc;
  cursor: pointer;
  font-family: inherit;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.char-select-slot:hover {
  border-color: rgba(201, 162, 39, 0.78);
  transform: translateY(-1px);
}

.char-select-slot.is-selected {
  border-color: #d4af37;
  box-shadow:
    0 0 0 2px rgba(201, 162, 39, 0.38),
    0 8px 22px rgba(201, 162, 39, 0.18),
    inset 0 0 28px rgba(201, 162, 39, 0.1);
  transform: translateY(-2px);
}

.char-select-slot.is-filled[data-race="titan"].is-selected {
  box-shadow:
    0 0 0 2px rgba(201, 162, 39, 0.38),
    0 8px 22px rgba(180, 120, 40, 0.22),
    inset 0 0 28px rgba(180, 120, 40, 0.12);
}

.char-select-slot.is-filled[data-race="sylph"].is-selected {
  box-shadow:
    0 0 0 2px rgba(201, 162, 39, 0.38),
    0 8px 22px rgba(50, 140, 90, 0.2),
    inset 0 0 28px rgba(50, 140, 90, 0.1);
}

.char-select-slot.is-filled[data-race="astral"].is-selected {
  box-shadow:
    0 0 0 2px rgba(201, 162, 39, 0.38),
    0 8px 22px rgba(100, 80, 180, 0.24),
    inset 0 0 28px rgba(100, 80, 180, 0.12);
}

.char-select-slot.is-filled {
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-select-slot.is-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.char-select-slot.is-empty:hover {
  background: linear-gradient(180deg, rgba(40, 34, 22, 0.94) 0%, rgba(18, 14, 10, 0.97) 100%);
}

.char-select-slot.is-empty:hover .char-select-slot-plus {
  border-color: rgba(201, 162, 39, 0.75);
  background: rgba(201, 162, 39, 0.14);
  color: #fbd38d;
}

.char-select-slot-index {
  position: absolute;
  top: 0.35rem;
  left: 0.4rem;
  z-index: 2;
  min-width: 1.15rem;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(0, 0, 0, 0.45);
  font-size: 0.62rem;
  font-weight: 700;
  color: #fbd38d;
  line-height: 1.3;
  text-align: center;
}

.char-select-slot-index.is-muted {
  border-color: rgba(113, 128, 150, 0.35);
  color: #718096;
}

.char-select-slot-glow {
  position: absolute;
  inset: 12% 10% 28%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.16) 0%, transparent 72%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.char-select-slot.is-selected .char-select-slot-glow {
  opacity: 1;
}

.char-select-slot-pedestal {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 18%;
  height: 18%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(201, 162, 39, 0.28) 0%, transparent 72%);
  pointer-events: none;
}

.char-select-slot-portrait {
  position: relative;
  z-index: 1;
  width: min(76px, 80%);
  height: auto;
  max-height: 74%;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
  transition: transform 0.18s ease;
}

.char-select-slot.is-selected .char-select-slot-portrait {
  transform: translateY(-2px) scale(1.04);
}

.char-select-slot-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 0.42rem 0.3rem 0.35rem;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.82));
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fbd38d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-select-slot.is-pending-delete {
  border-color: rgba(197, 48, 48, 0.75);
  background:
    linear-gradient(180deg, rgba(155, 44, 44, 0.28), rgba(20, 12, 12, 0.55)),
    rgba(18, 12, 12, 0.72);
  box-shadow: inset 0 0 0 1px rgba(252, 129, 129, 0.18);
}

.char-select-slot.is-pending-delete.is-selected {
  border-color: #fc8181;
  box-shadow:
    0 0 0 1px rgba(252, 129, 129, 0.45),
    0 0 18px rgba(197, 48, 48, 0.35);
}

.char-select-slot.is-pending-delete .char-select-slot-portrait {
  filter: grayscale(0.45) brightness(0.82);
  opacity: 0.92;
}

.char-select-pending-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  padding: 0.18rem 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(254, 178, 178, 0.55);
  background: rgba(155, 44, 44, 0.92);
  color: #fff5f5;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.char-select-hero.is-pending-delete .char-select-hero-ring {
  border-color: #c53030;
  box-shadow: 0 0 0 1px rgba(197, 48, 48, 0.45);
}

.char-select-hero.is-pending-delete img {
  filter: grayscale(0.35) brightness(0.88);
}

.char-select-pending-note {
  display: block;
  margin-top: 0.15rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(197, 48, 48, 0.5);
  background: rgba(155, 44, 44, 0.22);
  color: #feb2b2;
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: center;
  justify-content: center;
}

.char-select-slot-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 50%;
  border: 2px dashed rgba(201, 162, 39, 0.48);
  background: rgba(201, 162, 39, 0.08);
  color: #c9a227;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.char-select-slot-plus svg {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
}

.char-select-slot-empty-text {
  font-size: 0.72rem;
  color: #a0aec0;
}

.char-select-detail {
  display: flex;
  flex-direction: column;
  width: min(220px, 36%);
  min-width: 168px;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(107, 74, 40, 0.5);
  background:
    linear-gradient(180deg, rgba(18, 14, 10, 0.72) 0%, rgba(8, 6, 5, 0.82) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.char-select-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(201, 162, 39, 0.18);
}

.char-select-hero.hidden {
  display: none;
}

.char-select-hero-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  border: 2px solid rgba(201, 162, 39, 0.55);
  background:
    radial-gradient(circle at 50% 35%, rgba(201, 162, 39, 0.18) 0%, rgba(12, 10, 8, 0.92) 68%);
  box-shadow: 0 0 18px rgba(201, 162, 39, 0.16);
}

#char-select-screen[data-race="titan"] .char-select-hero-ring {
  border-color: rgba(201, 162, 39, 0.65);
  box-shadow: 0 0 18px rgba(180, 120, 40, 0.22);
}

#char-select-screen[data-race="sylph"] .char-select-hero-ring {
  border-color: rgba(72, 187, 120, 0.55);
  box-shadow: 0 0 18px rgba(50, 140, 90, 0.2);
}

#char-select-screen[data-race="astral"] .char-select-hero-ring {
  border-color: rgba(159, 122, 234, 0.55);
  box-shadow: 0 0 18px rgba(100, 80, 180, 0.24);
}

.char-select-hero-ring img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.char-select-hero-name {
  margin: 0;
  max-width: 100%;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fbd38d;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-select-stats {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  flex: 1;
}

.char-select-stats.hidden {
  display: none;
}

.char-select-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.32rem 0.4rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.78rem;
  line-height: 1.35;
}

.char-select-stats dt {
  margin: 0;
  color: #a0aec0;
  font-weight: 500;
}

.char-select-stats dd {
  margin: 0;
  color: #fbd38d;
  font-weight: 700;
  text-align: right;
}

.char-select-detail-empty {
  margin: 0 0 0.75rem;
  flex: 1;
  padding: 0.65rem 0.35rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #a0aec0;
  text-align: center;
}

.char-select-detail-empty.hidden {
  display: none;
}

.char-select-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
}

.char-select-start {
  margin: 0;
  padding: 0.7rem 0.85rem;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #1a1520;
  border: 1px solid rgba(240, 215, 140, 0.55);
  border-radius: 8px;
  background: linear-gradient(180deg, #e0c060 0%, #b8922e 55%, #8a6a18 100%);
  box-shadow: 0 3px 0 #4a3a10, 0 6px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.char-select-start:hover:not(:disabled) {
  filter: brightness(1.05);
}

.char-select-start:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #4a3a10, 0 3px 8px rgba(0, 0, 0, 0.3);
}

.char-select-start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.35);
  box-shadow: none;
  transform: none;
}

.char-select-logout {
  border: 1px solid rgba(113, 128, 150, 0.42);
  background: rgba(0, 0, 0, 0.18);
  color: #a0aec0;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.char-select-logout:hover {
  border-color: rgba(201, 162, 39, 0.45);
  color: #cbd5e0;
  background: rgba(201, 162, 39, 0.06);
}

#char-select-screen .message {
  margin-top: 0.65rem;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

@media (max-width: 560px) {
  .char-select-body {
    flex-direction: column;
  }

  .char-select-detail {
    width: 100%;
    min-width: 0;
  }

  .char-select-grid {
    gap: 0.55rem;
  }

  .char-select-slot-plus {
    width: 2.35rem;
    height: 2.35rem;
  }

  .char-select-slot-plus svg {
    width: 1.1rem;
    height: 1.1rem;
  }

  .char-select-hero-ring {
    width: 4.75rem;
    height: 4.75rem;
  }

  .char-select-hero-ring img {
    width: 3.85rem;
    height: 3.85rem;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  #char-select-screen {
    padding: 0.5rem 0.75rem;
    align-items: flex-start;
  }

  .char-select-panel {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
    overflow-y: auto;
  }

  .char-select-body {
    flex-direction: row;
  }

  .char-select-detail {
    width: min(190px, 38%);
  }

  .char-select-hero {
    margin-bottom: 0.55rem;
    padding-bottom: 0.55rem;
  }

  .char-select-hero-ring {
    width: 4.5rem;
    height: 4.5rem;
  }

  .char-select-hero-ring img {
    width: 3.65rem;
    height: 3.65rem;
  }
}

.char-a .char-a-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.char-a .char-back-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.62rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.55);
  background: linear-gradient(180deg, rgba(42, 34, 22, 0.95) 0%, rgba(22, 18, 12, 0.98) 100%);
  color: #f0d78c;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.char-a .char-back-btn:hover {
  border-color: #c9a227;
  background: linear-gradient(180deg, rgba(52, 42, 28, 0.98) 0%, rgba(28, 22, 14, 0.99) 100%);
  color: #fbd38d;
}

.char-a .char-back-btn:hover .char-back-icon {
  color: #fbd38d;
}

.char-a .char-back-btn:active {
  transform: translateY(1px);
}

.char-a .char-back-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  color: #e8c96a;
}

.char-a .char-back-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.char-a-bg {
  position: absolute;
  inset: -20px;
  background:
    url('/assets/sprites/maps/bgs/shard_rift.png') center / cover no-repeat;
  filter: blur(4px) saturate(0.9) brightness(0.42);
  transform: scale(1.06);
  pointer-events: none;
  z-index: 0;
}

.char-a-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 55% 50% at 50% 42%, transparent 18%, rgba(8, 6, 16, 0.58) 75%),
    linear-gradient(180deg, rgba(10, 8, 18, 0.35) 0%, rgba(6, 4, 14, 0.75) 100%);
}

#char-screen[data-race="titan"] .char-a-veil {
  background:
    radial-gradient(ellipse 50% 45% at 50% 40%, rgba(180, 120, 40, 0.14), transparent 55%),
    radial-gradient(ellipse 55% 50% at 50% 42%, transparent 18%, rgba(8, 6, 16, 0.58) 75%),
    linear-gradient(180deg, rgba(10, 8, 18, 0.3) 0%, rgba(6, 4, 14, 0.75) 100%);
}

#char-screen[data-race="sylph"] .char-a-veil {
  background:
    radial-gradient(ellipse 50% 45% at 50% 40%, rgba(50, 140, 90, 0.14), transparent 55%),
    radial-gradient(ellipse 55% 50% at 50% 42%, transparent 18%, rgba(8, 6, 16, 0.58) 75%),
    linear-gradient(180deg, rgba(10, 8, 18, 0.3) 0%, rgba(6, 4, 14, 0.75) 100%);
}

#char-screen[data-race="astral"] .char-a-veil {
  background:
    radial-gradient(ellipse 50% 45% at 50% 40%, rgba(100, 80, 180, 0.18), transparent 55%),
    radial-gradient(ellipse 55% 50% at 50% 42%, transparent 18%, rgba(8, 6, 16, 0.58) 75%),
    linear-gradient(180deg, rgba(10, 8, 18, 0.3) 0%, rgba(6, 4, 14, 0.75) 100%);
}

.char-a {
  position: relative;
  z-index: 2;
  width: min(560px, 96vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.char-a-header {
  text-align: center;
  margin-bottom: 0.85rem;
}

.char-a-lore {
  font-family: 'Cinzel', 'Sarabun', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #c4b896;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.char-a-header h2 {
  font-family: 'Sarabun', 'Segoe UI', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: #f3efe6;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
}

.char-a-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.1rem;
}

.char-a-pedestal {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 0.55rem;
}

.char-a-rift {
  position: absolute;
  left: 50%;
  bottom: 4%;
  width: 150px;
  height: 48px;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 2px solid rgba(200, 170, 90, 0.35);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    inset 0 0 18px rgba(246, 211, 101, 0.12),
    0 0 28px rgba(160, 120, 40, 0.2);
  background: radial-gradient(ellipse, rgba(20, 16, 10, 0.65), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#char-screen[data-race="sylph"] .char-a-rift {
  border-color: rgba(90, 190, 130, 0.4);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    inset 0 0 18px rgba(100, 220, 150, 0.12),
    0 0 28px rgba(50, 140, 90, 0.22);
}

#char-screen[data-race="astral"] .char-a-rift {
  border-color: rgba(150, 120, 220, 0.4);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    inset 0 0 18px rgba(170, 130, 255, 0.12),
    0 0 28px rgba(100, 80, 180, 0.22);
}

.char-a-glow {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 120px;
  height: 36px;
  transform: translateX(-50%);
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.65;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse, rgba(246, 200, 100, 0.55), transparent 70%);
  transition: background 0.25s ease;
}

#char-screen[data-race="sylph"] .char-a-glow {
  background: radial-gradient(ellipse, rgba(100, 220, 150, 0.5), transparent 70%);
}

#char-screen[data-race="astral"] .char-a-glow {
  background: radial-gradient(ellipse, rgba(170, 130, 255, 0.5), transparent 70%);
}

.char-a-portrait {
  position: relative;
  z-index: 1;
  width: 192px;
  height: 192px;
  object-fit: contain;
  object-position: bottom center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.65));
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.char-a-portrait.is-swapping {
  opacity: 0.28;
  transform: translateY(8px) scale(0.97);
}

.char-a-hint {
  font-family: 'Sarabun', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f0d78c;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  margin-bottom: 0.35rem;
}

.char-a-skill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.65rem;
  padding: 0.25rem 0.7rem;
  border-radius: 4px;
  border: 1px solid rgba(180, 150, 80, 0.35);
  background: rgba(12, 16, 12, 0.7);
  font-size: 0.8rem;
  color: #e8e4dc;
  backdrop-filter: blur(2px);
}

.char-a-skill-label {
  font-size: 0.65rem;
  color: #a89a78;
  letter-spacing: 0.04em;
}

#char-preview-skill-name {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.char-a-gender {
  display: flex;
  gap: 0.4rem;
  width: min(220px, 70vw);
  margin: 0;
}

.char-a-gender .gender-chip {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.5rem;
  border: 1px solid rgba(120, 110, 80, 0.45);
  border-radius: 6px;
  cursor: pointer;
  background: rgba(10, 14, 10, 0.65);
  backdrop-filter: blur(2px);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.char-a-gender .gender-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}

.char-a-gender .gender-chip span {
  font-size: 0.82rem;
  color: #c8c0b0;
}

.char-a-gender .gender-chip:hover {
  border-color: rgba(200, 170, 90, 0.55);
}

.char-a-gender .gender-chip:has(input:checked) {
  border-color: #d4b04a;
  background: rgba(60, 48, 20, 0.55);
}

.char-a-gender .gender-chip:has(input:checked) span {
  color: #f0d78c;
  font-weight: 650;
}

.char-a-shards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  width: 100%;
  margin-bottom: 1rem;
}

.char-shard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.55rem 0.35rem 0.65rem;
  cursor: pointer;
  text-align: center;
  border-radius: 10px 10px 6px 6px;
  border: 1px solid rgba(90, 80, 55, 0.55);
  background:
    linear-gradient(180deg, rgba(28, 32, 24, 0.55) 0%, rgba(12, 14, 10, 0.82) 100%);
  backdrop-filter: blur(3px);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.char-shard input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}

.char-shard-gem {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  margin-bottom: 0.05rem;
  background: none;
  clip-path: none;
  box-shadow: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.char-shard-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
  pointer-events: none;
  user-select: none;
}

.char-shard:hover .char-shard-gem {
  transform: translateY(-2px) scale(1.06);
}

.char-shard:hover {
  transform: translateY(-3px);
  border-color: rgba(200, 170, 90, 0.45);
}

.char-shard:has(input:checked) {
  border-color: #d4b04a;
  box-shadow:
    0 0 0 1px rgba(212, 176, 74, 0.25),
    0 10px 24px rgba(0, 0, 0, 0.4);
  background:
    linear-gradient(180deg, rgba(48, 42, 24, 0.7) 0%, rgba(16, 14, 10, 0.9) 100%);
}

.char-shard:has(input:checked) .char-shard-gem {
  transform: translateY(-4px) scale(1.12);
  filter: brightness(1.06) saturate(1.08);
}

.char-shard-name {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  color: #ebe6dc;
  letter-spacing: 0.02em;
}

.char-shard-role {
  font-family: 'Sarabun', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: #9a9178;
  line-height: 1.25;
}

.char-shard:has(input:checked) .char-shard-role {
  color: #d4b04a;
}

.char-a-footer {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.9rem;
  align-items: stretch;
}

.char-a-name .char-field-label {
  display: block;
  font-size: 0.7rem;
  color: #a89a78;
  margin-bottom: 0.3rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.char-a #char-name {
  margin-bottom: 0;
  background: rgba(10, 14, 10, 0.72);
  border: 1px solid rgba(140, 120, 70, 0.45);
  color: #f0ebe3;
  font-family: 'Sarabun', sans-serif;
  font-weight: 500;
}

.char-a #char-name:focus {
  outline: none;
  border-color: #d4b04a;
  box-shadow: 0 0 0 1px rgba(212, 176, 74, 0.25);
}

.char-a-stats {
  border-radius: 8px;
  border: 1px solid rgba(110, 95, 55, 0.5);
  background: rgba(14, 16, 12, 0.78);
  overflow: hidden;
  backdrop-filter: blur(3px);
}

.char-a-stats-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(110, 95, 55, 0.4);
  font-size: 0.68rem;
  color: #a89a78;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(28, 26, 18, 0.65);
}

.char-stats-lv {
  color: #d4b04a;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.char-a-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 0;
  padding: 0.2rem 0;
}

.char-a-stats-grid > div {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem;
}

.char-a-stats-grid > div:last-child {
  grid-column: 1 / -1;
  max-width: 50%;
}

.char-a-stats-grid dt {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: #a89a78;
  letter-spacing: 0.02em;
}

.char-a-stats-grid dd {
  margin: 0;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ebe6dc;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.char-a-stats-grid > div.is-vital:first-child dd { color: #fc8181; }
.char-a-stats-grid > div.is-vital:nth-child(2) dd { color: #63b3ed; }

.char-a .char-submit {
  width: 100%;
  margin: 0;
  padding: 0.85rem 1rem;
  font-family: 'Sarabun', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #1a1520;
  border: 1px solid rgba(240, 215, 140, 0.55);
  border-radius: 8px;
  background: linear-gradient(180deg, #e0c060 0%, #b8922e 55%, #8a6a18 100%);
  box-shadow: 0 4px 0 #4a3a10, 0 8px 20px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.char-a .char-submit:hover {
  filter: brightness(1.05);
}

.char-a .char-submit:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #4a3a10, 0 4px 10px rgba(0, 0, 0, 0.35);
}

.char-a .message {
  min-height: 1.1rem;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

@media (max-width: 560px) {
  .char-a-pedestal {
    width: 176px;
    height: 176px;
  }

  .char-a-portrait {
    width: 156px;
    height: 156px;
  }

  .char-a-footer {
    grid-template-columns: 1fr;
  }

  .char-a-stats-grid > div:last-child {
    max-width: none;
  }

  .char-shard-role {
    font-size: 0.62rem;
  }
}

/* ââ à¸ªà¸£à¹à¸²à¸à¸à¸±à¸§: à¸¡à¸·à¸­à¸à¸·à¸­à¹à¸à¸§à¸à¸­à¸ (à¹à¸¥à¸¢à¹à¹à¸­à¸²à¸à¹à¹à¸¢à¸ à¸ªà¸­à¸à¸à¸­à¸¥à¸±à¸¡à¸à¹) ââ */
@media (orientation: landscape) and (max-height: 560px) {
  #char-screen {
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
    padding: 0.35rem 0.55rem;
    padding-left: max(0.55rem, env(safe-area-inset-left));
    padding-right: max(0.55rem, env(safe-area-inset-right));
  }

  .char-a {
    width: min(960px, 100%);
    height: 100%;
    max-height: calc(100dvh - 0.7rem);
    display: grid;
    grid-template-columns: minmax(150px, 0.85fr) minmax(260px, 1.35fr);
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
      'stage header'
      'stage shards'
      'stage footer'
      'stage submit'
      'stage message';
    column-gap: 0.85rem;
    row-gap: 0.28rem;
    align-content: center;
  }

  .char-a-header {
    grid-area: header;
    margin-bottom: 0;
    text-align: left;
  }

  .char-a-lore {
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    margin-bottom: 0.1rem;
  }

  .char-a-header h2 {
    font-size: 1.15rem;
  }

  .char-a-stage {
    grid-area: stage;
    margin-bottom: 0;
    align-self: center;
    justify-self: center;
  }

  .char-a-pedestal {
    width: 128px;
    height: 128px;
    margin-bottom: 0.25rem;
  }

  .char-a-rift {
    width: 92px;
    height: 30px;
  }

  .char-a-glow {
    width: 76px;
    height: 24px;
  }

  .char-a-portrait {
    width: 112px;
    height: 112px;
  }

  .char-a-hint {
    font-size: 0.88rem;
    margin-bottom: 0.2rem;
  }

  .char-a-skill {
    margin: 0 0 0.35rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
  }

  .char-a-skill-label {
    font-size: 0.58rem;
  }

  .char-a-gender {
    width: min(150px, 100%);
  }

  .char-a-gender .gender-chip {
    padding: 0.28rem 0.35rem;
  }

  .char-a-gender .gender-chip span {
    font-size: 0.72rem;
  }

  .char-a-shards {
    grid-area: shards;
    margin-bottom: 0;
    gap: 0.4rem;
    align-self: start;
  }

  .char-shard {
    padding: 0.3rem 0.25rem 0.4rem;
    gap: 0.1rem;
  }

  .char-shard-gem {
    width: 52px;
    height: 52px;
  }

  .char-shard-img {
    width: 48px;
    height: 48px;
  }

  .char-shard-name {
    font-size: 0.8rem;
  }

  .char-shard-role {
    font-size: 0.58rem;
  }

  .char-a-footer {
    grid-area: footer;
    margin-bottom: 0;
    gap: 0.45rem;
    align-self: stretch;
  }

  .char-a-name .char-field-label {
    font-size: 0.62rem;
    margin-bottom: 0.15rem;
  }

  .char-a #char-name {
    padding: 0.4rem 0.5rem;
    font-size: 0.88rem;
  }

  .char-a-stats-head {
    padding: 0.22rem 0.45rem;
    font-size: 0.6rem;
  }

  .char-a-stats-grid {
    padding: 0.1rem 0;
  }

  .char-a-stats-grid > div {
    padding: 0.15rem 0.45rem;
  }

  .char-a-stats-grid dt {
    font-size: 0.6rem;
  }

  .char-a-stats-grid dd {
    font-size: 0.78rem;
  }

  .char-a .char-a-actions {
    grid-area: submit;
    margin: 0;
    gap: 0.35rem;
  }

  .char-a .char-back-btn {
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
  }

  .char-a .char-submit {
    margin: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    letter-spacing: 0.06em;
    box-shadow: 0 3px 0 #4a3a10, 0 5px 12px rgba(0, 0, 0, 0.4);
  }

  .char-a .message {
    grid-area: message;
    min-height: 0.9rem;
    font-size: 0.75rem;
    margin: 0;
  }
}

/* à¹à¸à¸§à¸à¸­à¸à¸à¸­à¹à¸à¸µà¹à¸¢à¸¡à¸²à¸ â à¸à¸µà¸à¸¡à¸à¸µà¹à¸à¸´à¹à¸¡ */
@media (orientation: landscape) and (max-height: 400px) {
  .char-a-pedestal {
    width: 104px;
    height: 104px;
  }

  .char-a-portrait {
    width: 92px;
    height: 92px;
  }

  .char-shard-gem {
    width: 42px;
    height: 42px;
  }

  .char-shard-img {
    width: 40px;
    height: 40px;
  }

  .char-a-header h2 {
    font-size: 1rem;
  }

  .char-shard-role {
    display: none;
  }
}

#game-screen {
  display: block;
  position: relative;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #1a472a;
  image-rendering: pixelated;
}

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  pointer-events: none;
  z-index: 30;
}

#quest-tracker {
  position: absolute;
  top: 154px;
  left: 12px;
  z-index: 30;
  width: min(360px, calc(100vw - 24px));
  color: #e2e8f0;
  font-size: 0.78rem;
  line-height: 1.25;
  text-shadow: 1px 1px 2px #000;
}

.quest-tracker-entry + .quest-tracker-entry {
  margin-top: 7px;
}

.quest-tracker-title {
  color: #f6d365;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quest-tracker-objective {
  padding-left: 2px;
  overflow-wrap: anywhere;
}

.quest-tracker-objective.is-active {
  color: #f6d365;
}

.quest-tracker-objective.is-done {
  color: #68d391;
}

.quest-tracker-objective.is-locked {
  color: rgba(160, 174, 192, 0.72);
}

.hud-block {
  background: rgba(8, 12, 18, 0.45);
  padding: 8px 10px;
  border-radius: 6px;
  min-width: 168px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(2px);
}

#player-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: #f6d365;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.hud-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.hud-title-row #player-name {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.bar-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #a0aec0;
}

.bar-label-lv {
  color: #f6d365;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar-value {
  font-size: 0.65rem;
  color: #cbd5e0;
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 8px;
  background: rgba(45, 55, 72, 0.85);
  border-radius: 3px;
  overflow: hidden;
}

#hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c53030, #fc8181);
  transition: width 0.2s;
}

#mp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2b6cb0, #63b3ed);
  transition: width 0.2s;
}

#exp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #b7791f, #f6e05e);
  transition: width 0.2s;
}

.hud-meta {
  margin-top: 4px;
  opacity: 0.85;
}

#map-info {
  font-size: 0.7rem;
  color: #a0aec0;
  margin-top: 2px;
}

#logout-btn {
  /* #hud is pointer-events: none, so re-enable clicks on the button itself */
  pointer-events: auto;
  margin-top: 6px;
  padding: 3px 8px;
  font-size: 0.68rem;
  background: transparent;
  color: #718096;
  border: 1px solid rgba(74, 85, 104, 0.6);
  border-radius: 4px;
  cursor: pointer;
}

#logout-btn:hover {
  border-color: #fc8181;
  color: #fc8181;
}

#fullscreen-btn {
  pointer-events: auto;
  flex-shrink: 0;
  margin-top: 0;
  padding: 2px 7px;
  font-size: 0.62rem;
  line-height: 1.2;
  background: transparent;
  color: #a0aec0;
  border: 1px solid rgba(74, 85, 104, 0.6);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

#fullscreen-btn:hover {
  border-color: #f6d365;
  color: #f6d365;
}

#fullscreen-btn[aria-pressed='true'] {
  border-color: #68d391;
  color: #68d391;
}

#minimap-wrap {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 35;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#world-map-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 92;
}

#world-map-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: min(960px, calc(100vw - 24px));
  max-height: min(720px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: rgba(8, 10, 18, 0.97);
  border: 1px solid #d69e2e;
  border-radius: 10px;
  z-index: 93;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

#world-map-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px 12px;
  background:
    radial-gradient(ellipse at center, rgba(40, 24, 72, 0.35), transparent 70%),
    #06080f;
}

#world-map-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  max-width: 100%;
}

#world-map-img {
  display: block;
  max-width: min(940px, calc(100vw - 44px));
  max-height: min(640px, calc(100vh - 96px));
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
  -webkit-user-drag: none;
}

/* à¸«à¸¡à¸¸à¸à¸à¸³à¹à¸«à¸à¹à¸à¸à¸¹à¹à¹à¸¥à¹à¸ â à¸ªà¹à¸à¸¥à¹à¸à¸¥à¹à¸²à¸¢ Google Maps */
#world-map-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  transform: translate(-50%, -100%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}

.world-map-pin-marker {
  width: 22px;
  height: 22px;
  background: #ea4335;
  border: 2.5px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-sizing: border-box;
}

.world-map-pin-marker::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  background: #fff;
  border-radius: 50%;
}

.world-map-pin-label {
  margin-top: 4px;
  padding: 2px 7px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  background: rgba(8, 10, 18, 0.82);
  border: 1px solid rgba(234, 67, 53, 0.75);
  border-radius: 4px;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}

@media (max-width: 768px) {
  .world-map-pin-marker {
    width: 18px;
    height: 18px;
    border-width: 2px;
  }
  .world-map-pin-marker::after {
    width: 5px;
    height: 5px;
    margin: -2.5px 0 0 -2.5px;
  }
  .world-map-pin-label {
    font-size: 0.55rem;
    padding: 1px 5px;
    margin-top: 3px;
  }
}

#status-alerts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: auto;
  max-width: min(280px, 70vw);
  pointer-events: none;
  align-items: flex-end;
}

.status-alert {
  margin: 0;
  padding: 5px 7px;
  border-radius: 4px;
  font-size: 0.62rem;
  line-height: 1.3;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(2px);
  text-align: left;
  width: fit-content;
  max-width: 100%;
}

.status-alert strong {
  display: block;
  font-size: 0.65rem;
  margin-bottom: 1px;
}

.status-alert--warn {
  border: 1px solid rgba(246, 173, 85, 0.65);
  color: #fbd38d;
}

.status-alert--warn strong {
  color: #f6ad55;
}

.status-alert--danger {
  border: 1px solid rgba(252, 129, 129, 0.7);
  color: #feb2b2;
}

.status-alert--danger strong {
  color: #fc8181;
}

#broken-gear-banner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
}

.broken-gear-banner-copy {
  min-width: 0;
}

.broken-gear-doll {
  width: 28px;
  height: 48px;
  flex-shrink: 0;
  display: block;
  overflow: visible;
}

.doll-zone {
  fill: #5a524c;
  stroke: #1a1410;
  stroke-width: 0.75;
}

.doll-zone.is-broken {
  fill: #fc8181;
}

.status-alert--info {
  border: 1px solid #9f7aea;
  color: #e9d8fd;
}

.status-alert--info strong {
  color: #d6bcfa;
}

#minimap-canvas {
  display: block;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 2px rgba(246, 211, 101, 0.35),
    0 4px 16px rgba(0, 0, 0, 0.45);
  background: rgba(10, 20, 16, 0.7);
  pointer-events: auto;
  cursor: pointer;
}

#minimap-canvas:hover {
  box-shadow:
    0 0 0 2px rgba(246, 211, 101, 0.65),
    0 4px 16px rgba(0, 0, 0, 0.45);
}

#minimap-legend {
  display: flex;
  gap: 8px;
  font-size: 0.62rem;
  color: rgba(226, 232, 240, 0.75);
  text-shadow: 0 1px 2px #000;
}

#minimap-legend span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

#minimap-legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

#minimap-legend .leg-player {
  background: #f6e05e;
  box-shadow: 0 0 4px #f6e05e;
}

#minimap-legend .leg-quest {
  background: #48bb78;
}

#minimap-legend .leg-warp {
  border-radius: 1px;
  background: #3182ce;
  width: 6px;
  height: 8px;
}

#chat-panel {
  position: absolute;
  bottom: 48px;
  left: 12px;
  width: min(360px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  pointer-events: auto;
  z-index: 35;
  text-shadow: 1px 1px 2px #000;
  transition: background 0.15s ease, border-color 0.15s ease, backdrop-filter 0.15s ease;
}

/* à¸à¸³à¸¥à¸±à¸à¸à¸´à¸¡à¸à¹ â à¹à¸à¹à¸¡à¸à¸¶à¹à¸à¹à¸«à¹à¸­à¹à¸²à¸/à¸à¸´à¸¡à¸à¹à¸à¹à¸²à¸¢ */
#chat-panel.is-composing {
  padding: 6px 8px;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(4px);
  border-color: rgba(74, 85, 104, 0.7);
}

#chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

#chat-tabs button {
  padding: 3px 8px;
  font-size: 0.72rem;
  background: transparent;
  color: rgba(160, 174, 192, 0.85);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  text-shadow: 1px 1px 2px #000;
}

#chat-panel.is-composing #chat-tabs button {
  background: rgba(0, 0, 0, 0.35);
  border-color: #4a5568;
  color: #a0aec0;
  text-shadow: none;
}

#chat-tabs button.active {
  color: #f6d365;
  border-color: transparent;
}

#chat-panel.is-composing #chat-tabs button.active {
  color: #f6d365;
  border-color: #f6d365;
  background: rgba(40, 30, 10, 0.55);
}

#chat-tabs button.has-unread:not(.active) {
  color: #90cdf4;
}

#chat-panel.is-composing #chat-tabs button.has-unread:not(.active) {
  border-color: #63b3ed;
}

#chat-tabs button:hover:not(.active) {
  color: #e2e8f0;
}

#chat-panel.is-composing #chat-tabs button:hover:not(.active) {
  border-color: #718096;
}

#chat-logs {
  position: relative;
  min-height: 72px;
  max-height: 120px;
}

.chat-log {
  height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
  line-height: 1.25;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

/* idle: à¹à¸à¸à¹à¸¥à¸·à¹à¸­à¸à¸à¸²à¸à¸¡à¸²à¸ â à¸¢à¸±à¸à¹à¸¥à¸·à¹à¸­à¸à¸à¹à¸§à¸¢à¸¥à¹à¸­à¹à¸¡à¸²à¸ªà¹/à¸à¸±à¸à¹à¸à¹ */
#chat-panel:not(.is-composing) .chat-log {
  scrollbar-width: none;
}
#chat-panel:not(.is-composing) .chat-log::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}

/* à¸à¸³à¸¥à¸±à¸à¸à¸´à¸¡à¸à¹: à¹à¸à¸à¹à¸¥à¸·à¹à¸­à¸à¸à¸²à¸ à¹ à¸­à¹à¸²à¸à¸à¹à¸²à¸¢à¸à¸¶à¹à¸à¹à¸¥à¹à¸à¸à¹à¸­à¸¢ */
#chat-panel.is-composing .chat-log {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}
#chat-panel.is-composing .chat-log::-webkit-scrollbar {
  width: 5px;
  background: transparent;
}
#chat-panel.is-composing .chat-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 4px;
}
#chat-panel.is-composing .chat-log::-webkit-scrollbar-track {
  background: transparent;
}

.chat-log.hidden {
  display: none;
}

.chat-line {
  color: #e2e8f0;
  word-break: break-word;
}

.chat-line.is-error {
  color: #fc8181;
}

.chat-line-name {
  color: #f6d365;
  font-weight: 600;
}

#chat-tap-hint {
  align-self: flex-start;
  padding: 2px 0;
  margin: 0;
  font-size: 0.7rem;
  color: rgba(160, 174, 192, 0.9);
  background: transparent;
  border: none;
  cursor: pointer;
  text-shadow: 1px 1px 2px #000;
}

#chat-panel.is-composing #chat-tap-hint {
  display: none;
}

/* idle: à¸à¹à¸­à¸à¹à¸à¸à¸à¸´à¸¡à¸à¹ à¸¥à¸à¸à¸±à¸à¹à¸¡à¸ â à¸à¸ Enter / à¹à¸à¸°à¹à¸à¸à¹à¸¥à¹à¸§à¹à¸à¸à¸±à¸ªà¸à¸°à¹à¸à¸§à¹ */
#chat-compose {
  display: none;
  gap: 6px;
  align-items: center;
}

#chat-panel.is-composing #chat-compose {
  display: flex;
}

#chat-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font-size: 0.8rem;
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #4a5568;
  border-radius: 4px;
  outline: none;
}

#chat-input:focus {
  border-color: #f6d365;
}

#chat-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#chat-send {
  padding: 5px 10px;
  font-size: 0.75rem;
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #4a5568;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

#chat-send:hover:not(:disabled) {
  border-color: #f6d365;
  color: #f6d365;
}

#chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#right-dock {
  position: absolute;
  top: 168px;
  right: 12px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(420px, 70vw);
}

#menu-dock {
  position: static;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 100%;
}

#menu-dock button {
  padding: 6px 10px;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.65);
  color: #e2e8f0;
  border: 1px solid #4a5568;
  border-radius: 6px;
  cursor: pointer;
}

#menu-dock button:hover:not(:disabled) {
  border-color: #f6d365;
  color: #f6d365;
}

#menu-dock button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#audio-settings-btn.audio-settings-gear {
  min-width: 34px;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 0.95rem;
  line-height: 1;
}

#audio-settings-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 55;
}

#audio-settings-panel {
  position: absolute;
  top: 168px;
  right: 12px;
  z-index: 56;
  width: min(280px, calc(100vw - 24px));
  background: rgba(12, 16, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.audio-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.audio-settings-header h2 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: #f6d365;
}

.audio-settings-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.audio-settings-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audio-settings-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-settings-label {
  flex: 1;
  font-size: 0.78rem;
  color: #e2e8f0;
  font-weight: 600;
}

.audio-settings-pct {
  font-size: 0.68rem;
  color: #a0aec0;
  font-variant-numeric: tabular-nums;
  min-width: 2.4em;
  text-align: right;
}

.audio-mute-btn {
  flex-shrink: 0;
  width: 28px;
  height: 26px;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1;
  background: transparent;
  color: #a0aec0;
  border: 1px solid rgba(74, 85, 104, 0.7);
  border-radius: 4px;
  cursor: pointer;
}

.audio-mute-btn:hover {
  border-color: #f6d365;
  color: #f6d365;
}

.audio-mute-btn--on {
  color: #718096;
  border-color: rgba(74, 85, 104, 0.45);
}

#audio-bgm-volume,
#audio-sfx-volume {
  width: 100%;
  height: 5px;
  accent-color: #68d391;
  cursor: pointer;
}

#audio-bgm-volume:disabled,
#audio-sfx-volume:disabled {
  opacity: 0.35;
  cursor: default;
}

#player-menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50;
}

#player-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 92vw);
  max-height: min(640px, calc(100vh - 24px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: rgba(16, 20, 34, 0.96);
  border: 2px solid #4a5568;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  z-index: 60;
  overflow: hidden;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#player-menu.theme-round-gold {
  width: fit-content;
  max-width: min(560px, calc(100vw - 16px));
  background: linear-gradient(165deg, #2e2a24 0%, #161412 100%);
  border: 2px solid #6b5a32;
  border-radius: 14px;
  box-shadow:
    0 0 0 1px #0a0806,
    0 0 0 3px #2a2418,
    inset 0 1px 0 rgba(255, 220, 140, 0.1),
    0 10px 32px rgba(0, 0, 0, 0.65);
}

/* Quests / Skills / Social — อย่าให้ fit-content หดแคบยาว (dual Status/Bag คง fit-content) */
#player-menu.theme-round-gold:not(.is-dual-layout) {
  width: min(480px, 92vw);
}

#player-menu.theme-round-gold .player-menu-header {
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.12) 0%, transparent 100%);
  border-bottom: 2px solid #6b5a32;
  padding: 8px 12px;
}

#player-menu.theme-round-gold .player-menu-header h2 {
  font-family: Cinzel, Georgia, serif;
  font-size: 0.74rem;
  letter-spacing: 1.2px;
  color: #f0d78c;
}

#player-menu.theme-round-gold .menu-close-btn {
  border-radius: 8px;
  border: 2px solid #4a4030;
  background: linear-gradient(180deg, #2a2620 0%, #141210 100%);
  box-shadow: inset 0 1px 0 rgba(255, 220, 140, 0.08);
  color: #f0d78c;
}

#player-menu.theme-round-gold .player-menu-tabs {
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 2px solid #3d3428;
  padding: 6px 10px;
  gap: 5px;
}

#player-menu.theme-round-gold .player-menu-tabs button {
  border-radius: 999px;
  border: 2px solid #3d3428;
  background: linear-gradient(180deg, #282420 0%, #181614 100%);
  box-shadow: inset 0 1px 0 rgba(255, 220, 140, 0.07);
  color: #9aa3b5;
  padding: 5px 10px;
  font-size: 0.75rem;
}

#player-menu.theme-round-gold .player-menu-tabs button.active {
  border-color: #8b7332;
  background: linear-gradient(180deg, #3a3224 0%, #242018 100%);
  color: #f0d78c;
  box-shadow:
    inset 0 0 8px rgba(201, 162, 39, 0.22),
    inset 0 1px 0 rgba(255, 220, 140, 0.12);
}

.player-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #2d3748;
  flex-shrink: 0;
}

.player-menu-header h2 {
  font-size: 1rem;
  color: #f6d365;
  letter-spacing: 1px;
}

.menu-close-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #4a5568;
  border-radius: 6px;
  background: #1a2035;
  color: #e2e8f0;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.menu-close-btn:hover {
  border-color: #fc8181;
  color: #fc8181;
}

.player-menu-tabs {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid #2d3748;
  overflow-x: auto;
}

.player-menu-tabs button {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 0.75rem;
  background: #1a2035;
  color: #a0aec0;
  border: 1px solid #4a5568;
  border-radius: 6px;
  cursor: pointer;
}

.player-menu-tabs button.active {
  color: #f6d365;
  border-color: #f6d365;
  background: #252b42;
}

.player-menu-tabs button.is-soon:not(.active) {
  opacity: 0.7;
}

.player-menu-body {
  flex: 1;
  min-height: 0;
  padding: 12px 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#pet-book-overlay { position: fixed; inset: 0; z-index: 1190; background: rgba(0,0,0,.45); }
#pet-book {
  position: fixed;
  z-index: 1200;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  width: min(480px,92vw);
  height: min(70vh,560px);
  max-height: min(70vh,560px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  background: linear-gradient(165deg,#2e2a24 0%,#161412 100%);
  border: 2px solid #6b5a32;
  color: #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 0 0 1px #0a0806,0 0 0 3px #2a2418,0 14px 38px rgba(0,0,0,.7);
  font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
}
#pet-book .player-menu-header {
  padding: 8px 12px;
  background: linear-gradient(180deg,rgba(201,162,39,.12) 0%,transparent 100%);
  border-bottom: 2px solid #6b5a32;
}
#pet-book .player-menu-header h2 { font-family: Cinzel,Georgia,serif; font-size: .74rem; letter-spacing: 1.2px; color: #f0d78c; }
#pet-book .menu-close-btn { border-radius: 8px; border: 2px solid #4a4030; background: linear-gradient(180deg,#2a2620 0%,#141210 100%); color: #f0d78c; }
.pet-book-body { position: relative; flex: 1; min-height: 0; padding: 12px 48px 16px; overflow-y: auto; display: block; background: rgba(0,0,0,.12); scrollbar-width: thin; scrollbar-color: rgba(201,162,39,.35) transparent; }
.pet-book-page { width: 100%; text-align: center; }
.pet-book-page h3 { margin: 4px 0 1px; color: #f0d78c; font-size: 1rem; }
.pet-book-page h4 { margin: 0 0 3px; color: #e8d48a; font-size: .86rem; }
.pet-book-page p { margin: 2px 0; font-size: .82rem; line-height: 1.35; }
.pet-book-page section,.pet-evo-box { margin: 8px 0; padding: 8px 10px; background: linear-gradient(180deg,#242018 0%,#141210 100%); border: 2px solid #3d3428; border-radius: 8px; box-shadow: inset 1px 1px 2px rgba(0,0,0,.35); }
.pet-portrait { margin: 0 auto; width: 96px; height: 96px; display: grid; place-items: center; background: transparent; }
.pet-portrait img,.pet-evolution-image { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.pet-portrait img { padding: 0; box-sizing: border-box; }
.pet-portrait.is-locked img { filter: grayscale(1) brightness(.48); opacity: .72; }
.pet-evolution-image { padding: 8px; box-sizing: border-box; }
.pet-page-arrow { position: fixed; top: 48%; z-index: 2; padding: 4px; font-size: 30px; border: 0; background: transparent; color: #f6d365; cursor: pointer; }
.pet-page-prev { left: 12px; }.pet-page-next { right: 12px; }
.pet-role,.pet-page-count { color: #b8a888; }.pet-page-count { margin-top: 2px; }.pet-max-evo { color: #9ae6b4; }
.pet-book-page small { display: block; margin-top: 2px; color: #b8a888; line-height: 1.35; }
.pet-skill-name { color: #f0d78c; font-weight: 700; }
.pet-next-skill { padding-top: 3px; border-top: 1px solid rgba(107,90,50,.45); }
.pet-main-action button,.pet-evo-box button { min-width: 138px; padding: 6px 12px; border: 2px solid #5a4a28; border-radius: 7px; background: linear-gradient(180deg,#3a3224 0%,#242018 100%); color: #f0d78c; cursor: pointer; }
.pet-main-action button:disabled { color: #777064; border-color: #3d3428; cursor: default; }

#pet-confirm-overlay { position: fixed; inset: 0; z-index: 1300; background: rgba(0,0,0,.52); }
#pet-confirm-dialog { position: fixed; z-index: 1310; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(420px,calc(100vw - 28px)); padding: 16px 18px; background: linear-gradient(165deg,#2e2a24 0%,#161412 100%); border: 2px solid #6b5a32; border-radius: 14px; color: #e2e8f0; box-shadow: 0 0 0 1px #0a0806,0 0 0 3px #2a2418,0 14px 38px rgba(0,0,0,.7); font-family: "Sarabun","Segoe UI",Tahoma,sans-serif; }
.pet-confirm-close { position: absolute; right: 9px; top: 9px; }
.pet-confirm-header { padding-right: 42px; margin-bottom: 12px; }
#pet-confirm-title { color: #f6d365; font-weight: 700; font-size: 1rem; }
#pet-confirm-subtitle { color: #a0aec0; font-size: .72rem; margin-top: 2px; }
.pet-confirm-message { padding: 12px; background: linear-gradient(180deg,#242018 0%,#141210 100%); border: 2px solid #3d3428; border-radius: 8px; line-height: 1.55; white-space: pre-line; }
.pet-confirm-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 14px; }
.pet-confirm-actions button { border-radius: 6px; padding: 7px 16px; cursor: pointer; }
#pet-confirm-cancel { background: linear-gradient(180deg,#282420 0%,#181614 100%); border: 2px solid #3d3428; color: #c8cdd8; }
#pet-confirm-ok { background: linear-gradient(180deg,#3a3224 0%,#242018 100%); border: 2px solid #8b7332; color: #f0d78c; font-weight: 700; }
#pet-confirm-ok:hover,#pet-confirm-cancel:hover { filter: brightness(1.12); }

.pet-evolution-result { position: fixed; inset: 0; z-index: 1400; display: grid; place-items: center; overflow: hidden; background: rgba(4,3,9,.84); backdrop-filter: blur(4px); }
.pet-evolution-result.hidden { display: none; }
.pet-evolution-burst { position: absolute; width: min(76vw,620px); aspect-ratio: 1; border-radius: 50%; opacity: 0; transform: scale(.2) rotate(0); background: repeating-conic-gradient(from 0deg,rgba(255,220,105,.48) 0 4deg,transparent 4deg 18deg); }
.pet-evolution-card { position: relative; width: min(430px,calc(100vw - 32px)); padding: 30px 24px 22px; overflow: hidden; text-align: center; color: #f7ecd0; border: 2px solid #8b7332; border-radius: 18px; background: radial-gradient(circle at 50% 20%,#49391d 0,#201a13 46%,#100e0d 100%); box-shadow: 0 0 0 2px #0b0907,0 0 60px rgba(246,211,101,.2),0 20px 60px rgba(0,0,0,.75); opacity: 0; transform: translateY(24px) scale(.88); }
.pet-evolution-result.fail .pet-evolution-card { border-color: #75505b; background: radial-gradient(circle at 50% 20%,#39242b 0,#1e1719 48%,#0e0c0d 100%); }
.pet-evolution-orb { width: 104px; height: 104px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; font-size: 46px; color: #fff4b0; border: 3px solid #d9b84f; background: radial-gradient(circle,#fff7bd 0 8%,#d79b25 9% 22%,#50320d 58%,#17110a 100%); box-shadow: 0 0 18px #f6d365,0 0 52px rgba(246,211,101,.55); }
.pet-evolution-result.fail .pet-evolution-orb { color: #d7c5cc; border-color: #8b6672; filter: grayscale(.55); box-shadow: 0 0 20px rgba(130,90,105,.55); }
.pet-evolution-kicker { margin: 0; color: #d8bc68; font: 700 .72rem/1 Cinzel,Georgia,serif; letter-spacing: 3px; }
.pet-evolution-card h3 { margin: 8px 0 6px; color: #ffe78c; font: 700 1.55rem/1.2 Cinzel,Georgia,serif; }
.pet-evolution-result.fail .pet-evolution-card h3 { color: #d9aab9; }
.pet-evolution-card p[data-pet-result-message] { min-height: 42px; margin: 0 auto 18px; color: #d9d2c3; line-height: 1.45; }
.pet-evolution-card button { min-width: 140px; padding: 8px 18px; cursor: pointer; color: #211606; font-weight: 700; border: 1px solid #ffe38a; border-radius: 8px; background: linear-gradient(#f5d76e,#b8871e); }
.pet-evolution-result.play .pet-evolution-burst { animation: pet-evo-burst 1.1s ease-out both; }
.pet-evolution-result.play .pet-evolution-card { animation: pet-evo-card .72s cubic-bezier(.2,.85,.25,1.2) .12s both; }
.pet-evolution-result.play .pet-evolution-orb { animation: pet-evo-orb 1.15s ease-in-out .18s both; }
.pet-evolution-result.fail.play .pet-evolution-orb { animation: pet-evo-fail .55s ease-in-out .2s both; }
@keyframes pet-evo-burst { 0%{opacity:0;transform:scale(.15) rotate(0)} 35%{opacity:1} 100%{opacity:0;transform:scale(1.25) rotate(28deg)} }
@keyframes pet-evo-card { from{opacity:0;transform:translateY(24px) scale(.88)} to{opacity:1;transform:none} }
@keyframes pet-evo-orb { 0%{transform:scale(.35);filter:brightness(2)} 45%{transform:scale(1.18) rotate(8deg)} 70%{transform:scale(.95) rotate(-4deg)} 100%{transform:none;filter:none} }
@keyframes pet-evo-fail { 0%{opacity:.2;transform:scale(1.12)} 35%{opacity:1;transform:translateX(-7px) rotate(-5deg)} 65%{transform:translateX(7px) rotate(5deg)} 100%{transform:none} }
@media (prefers-reduced-motion: reduce) { .pet-evolution-result * { animation-duration: .01ms !important; animation-delay: 0ms !important; } }
@media (max-width: 640px) {
  .pet-evolution-result { padding: max(12px,env(safe-area-inset-top)) 14px max(12px,env(safe-area-inset-bottom)); }
  .pet-evolution-burst { width: min(110vw,420px); }
  .pet-evolution-card { width: min(340px,100%); max-height: calc(100dvh - 28px); padding: 20px 16px 16px; border-radius: 14px; overflow-y: auto; }
  .pet-evolution-orb { width: 78px; height: 78px; margin-bottom: 10px; font-size: 34px; border-width: 2px; }
  .pet-evolution-kicker { font-size: .62rem; letter-spacing: 2px; }
  .pet-evolution-card h3 { margin: 6px 0 4px; font-size: 1.22rem; }
  .pet-evolution-card p[data-pet-result-message] { min-height: 0; margin-bottom: 13px; font-size: .82rem; line-height: 1.35; }
  .pet-evolution-card button { min-width: 122px; padding: 7px 15px; font-size: .82rem; }
}
@media (max-width: 420px), (max-height: 520px) {
  .pet-evolution-card { width: min(300px,100%); padding: 14px 13px 12px; }
  .pet-evolution-orb { width: 62px; height: 62px; margin-bottom: 7px; font-size: 27px; }
  .pet-evolution-kicker { font-size: .56rem; letter-spacing: 1.5px; }
  .pet-evolution-card h3 { font-size: 1.04rem; }
  .pet-evolution-card p[data-pet-result-message] { margin-bottom: 10px; font-size: .76rem; }
  .pet-evolution-card button { min-width: 108px; padding: 6px 13px; }
}

#player-menu.is-dual-layout .player-menu-body {
  padding: 0;
  overflow: hidden;
}

.menu-dual-layout {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0;
  width: fit-content;
  max-width: 100%;
  align-items: start;
  flex: 0 0 auto;
}

.menu-equip-column,
.menu-detail-column {
  min-height: 0;
  padding: 6px 8px 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.menu-equip-column {
  position: relative;
  z-index: 2;
  width: 228px;
  border-right: 1px solid #2d3748;
  background: rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.menu-detail-column {
  position: relative;
  z-index: 1;
}

#menu-equip-view-tabs {
  position: relative;
  z-index: 3;
  pointer-events: auto;
}

#menu-equip-view-tabs .equip-view-btn {
  pointer-events: auto;
  cursor: pointer;
}

#player-menu.theme-round-gold .menu-equip-column {
  background: rgba(0, 0, 0, 0.15);
  border-right: 2px solid #3d3428;
}

.menu-detail-column {
  width: 248px;
  flex-shrink: 0;
}

.menu-detail-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.menu-detail-panel.hidden {
  display: none;
}

.menu-full-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 8px;
}

/* Quests / Skills / Social — scroll ชั้นใน + panel-scroll เหมือน stat-grid / inv-scroll-wrap */
#player-menu:not(.is-dual-layout) .player-menu-body {
  overflow: hidden;
}

.menu-full-panel.hidden {
  display: none;
}

.col-title {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: none;
  color: #c8cdd8;
  margin: 0 0 6px;
  text-align: center;
  flex-shrink: 0;
}

.col-title-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.4em;
  margin: 0 0 6px;
  flex-shrink: 0;
}

.col-title-row .col-title {
  margin: 0;
}

.col-title-row .inv-sort-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

#player-menu.theme-round-gold .col-title {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  color: #e8d48a;
}

.panel-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
  scrollbar-gutter: stable;
}

.panel-scroll::-webkit-scrollbar {
  width: 3px;
}

.panel-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}

.panel-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.38);
}

/* Gold thin scrollbar — in-game panels (Character · forge · trade/mail/warp/party) */
#player-menu.theme-round-gold .panel-scroll,
.theme-forge .panel-scroll,
#trade-panel .panel-scroll,
#mail-panel .panel-scroll,
#warp-pick-panel .panel-scroll,
#party-hud.panel-scroll {
  scrollbar-color: rgba(201, 162, 39, 0.35) transparent;
}

#player-menu.theme-round-gold .panel-scroll::-webkit-scrollbar-thumb,
.theme-forge .panel-scroll::-webkit-scrollbar-thumb,
#trade-panel .panel-scroll::-webkit-scrollbar-thumb,
#mail-panel .panel-scroll::-webkit-scrollbar-thumb,
#warp-pick-panel .panel-scroll::-webkit-scrollbar-thumb,
#party-hud.panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(201, 162, 39, 0.35);
}

#player-menu.theme-round-gold .panel-scroll::-webkit-scrollbar-thumb:hover,
.theme-forge .panel-scroll::-webkit-scrollbar-thumb:hover,
#trade-panel .panel-scroll::-webkit-scrollbar-thumb:hover,
#mail-panel .panel-scroll::-webkit-scrollbar-thumb:hover,
#warp-pick-panel .panel-scroll::-webkit-scrollbar-thumb:hover,
#party-hud.panel-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(201, 162, 39, 0.5);
}

.stat-bar-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.stat-chip {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 4px;
  align-items: center;
  padding: 4px 5px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid #2d3748;
  border-radius: 4px;
  font-size: 0.72rem;
  white-space: nowrap;
}

#player-menu.theme-round-gold .stat-chip {
  border-radius: 8px;
  border: 2px solid #3d3428;
  background: linear-gradient(180deg, #1e1a16 0%, #12100e 100%);
  box-shadow: inset 0 1px 0 rgba(255, 220, 140, 0.06);
}

.stat-chip .chip-label {
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-chip .ico {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.stat-chip strong {
  font-size: 0.72rem;
  font-weight: 600;
  text-align: right;
  justify-self: end;
  color: #f0ebe3;
}

/* dual Status — 4 ช่อง balance: ป้ายกลางบน · ค่ากลางล่าง · คอลัมน์เท่ากัน */
#player-menu.is-dual-layout .stat-bar-group {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

#player-menu.is-dual-layout .stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 4px 3px;
  text-align: center;
}

#player-menu.is-dual-layout .stat-chip .chip-label {
  justify-content: center;
}

#player-menu.is-dual-layout .stat-chip strong {
  display: block;
  width: 100%;
  text-align: center;
  justify-self: unset;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

#player-menu.is-dual-layout .stat-chip strong .stat-bonus {
  font-size: 0.85em;
  font-weight: 500;
}

.inv-scroll-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

#player-menu.is-dual-layout .inv-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
  overflow: hidden;
}

.bag-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #2d3748;
  font-size: 0.72rem;
  line-height: 1.35;
  flex-shrink: 0;
  color: #c8cdd8;
}

#player-menu.theme-round-gold .bag-footer {
  border-top: 2px solid #3d3428;
}

.bag-footer-gold {
  color: #f0d78c;
}

.bag-footer-premium {
  color: #c8cdd8;
}

.inv-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.inv-toolbar .inv-summary {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

.inv-sort-btn {
  flex-shrink: 0;
  padding: 3px 8px;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.68rem;
  border: 1px solid #4a5568;
  border-radius: 6px;
  background: #1a2035;
  color: #c8cdd8;
  cursor: pointer;
}

.inv-sort-btn:hover {
  border-color: #63b3ed;
  color: #ebf8ff;
}

#player-menu.theme-round-gold .inv-sort-btn {
  border: 2px solid #3d3428;
  border-radius: 8px;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
  color: #e8d48a;
}

#player-menu.theme-round-gold .inv-sort-btn:hover {
  border-color: #8b7332;
  color: #f0d78c;
}

.desktop-hotbar-btn.is-out {
  border-color: #fc8181;
  opacity: 0.65;
}

.equip-costume-locked-banner {
  margin: 0 0 6px;
  padding: 5px 8px;
  text-align: center;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: #f0d78c;
  background: rgba(201, 162, 39, 0.12);
  border: 1px solid #6b5a32;
  border-radius: 8px;
  flex-shrink: 0;
}

#player-menu.theme-round-gold .equip-costume-locked-banner {
  border-width: 2px;
  border-color: #6b5a32;
}

.equip-costume-preview-layout .equip-cell.is-costume-preview {
  opacity: 0.55;
  pointer-events: none;
  cursor: default;
}

.equip-costume-hint {
  margin: 6px 0 0;
  font-size: 0.65rem;
  color: #a0aec0;
  text-align: center;
  line-height: 1.35;
}

#player-menu.theme-round-gold .equip-costume-hint {
  color: #b8a888;
}

.equip-char-spacer {
  width: 92px;
  height: 46px;
  flex-shrink: 0;
}

.equip-bonus {
  font-size: 0.72rem;
  color: #8fd48f;
  text-align: center;
  margin: 6px 0 0;
  line-height: 1.3;
  flex-shrink: 0;
}

#player-menu.is-dual-layout .stat-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding-bottom: 4px;
  box-sizing: border-box;
}

#player-menu.is-dual-layout .stat-bonus {
  font-size: 0.8em;
}

#player-menu.is-dual-layout .stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 8px;
  align-items: baseline;
  padding: 6px 8px;
  font-size: 0.85rem;
  width: 100%;
}

#player-menu.is-dual-layout .stat-row span {
  white-space: nowrap;
  color: #c8cdd8;
}

#player-menu.is-dual-layout .stat-row strong {
  white-space: nowrap;
  justify-self: end;
}

#player-menu.theme-round-gold.is-dual-layout .stat-row {
  border-radius: 8px;
  border: 2px solid rgba(61, 52, 40, 0.75);
  background: linear-gradient(90deg, rgba(42, 36, 28, 0.75) 0%, rgba(22, 18, 14, 0.45) 100%);
}

#player-menu.theme-round-gold.is-dual-layout .stat-row strong {
  color: #f0e8d8;
}

#player-menu.is-dual-layout .inv-summary {
  font-size: 0.75rem;
  margin-bottom: 6px;
  line-height: 1.35;
  flex-shrink: 0;
  color: #c8cdd8;
}

#player-menu.is-dual-layout .inv-cat-tabs {
  gap: 4px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

#player-menu.is-dual-layout .inv-cat-btn {
  padding: 4px 8px;
  font-size: 0.72rem;
}

#player-menu.theme-round-gold.is-dual-layout .inv-cat-btn {
  border-radius: 999px;
  border: 2px solid #3d3428;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
}

#player-menu.theme-round-gold.is-dual-layout .inv-cat-btn.active {
  border-color: #8b7332;
  background: linear-gradient(180deg, #3a3224 0%, #242018 100%);
  color: #f0d78c;
}

#player-menu.is-dual-layout .equip-view-tabs {
  gap: 3px;
  margin-bottom: 4px;
  justify-content: center;
}

#player-menu.is-dual-layout .equip-view-btn {
  padding: 4px 10px;
  font-size: 0.72rem;
}

#player-menu.theme-round-gold.is-dual-layout .equip-view-btn {
  border-radius: 999px;
  border: 2px solid #3d3428;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
}

#player-menu.theme-round-gold.is-dual-layout .equip-view-btn.active {
  border-color: #8b7332;
  background: linear-gradient(180deg, #3a3224 0%, #282018 100%);
  color: #f0d78c;
}

#player-menu.is-dual-layout .equip-ro-layout {
  grid-template-columns: 46px 92px 46px;
  column-gap: 8px;
  row-gap: 3px;
  align-items: stretch;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 0;
  margin: 0 auto;
}

#player-menu.is-dual-layout .equip-col {
  gap: 2px;
}

#player-menu.is-dual-layout .equip-col.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  min-height: 0;
  overflow: visible;
}

#player-menu.is-dual-layout .equip-cell {
  width: 46px;
  height: 46px;
  padding: 2px;
  font-size: 0.55rem;
  line-height: 1.15;
}

#player-menu.is-dual-layout .equip-cell.is-empty .equip-cell-label {
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  word-break: normal;
  overflow-wrap: normal;
  color: #e8e4dc;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  -webkit-font-smoothing: auto;
  text-rendering: geometricPrecision;
}

#player-menu.is-dual-layout .equip-cell.is-empty {
  justify-content: center;
  align-items: center;
}

#player-menu.is-dual-layout .equip-cell.filled .equip-cell-label {
  display: none;
}

#player-menu.is-dual-layout .equip-cell-icon {
  width: 24px;
  height: 24px;
}

#player-menu.is-dual-layout .equip-cell-icon .slot-icon-img {
  width: 22px;
  height: 22px;
}

#player-menu.is-dual-layout .equip-cell-dur {
  font-size: 0.55rem;
  color: #f6d365;
}

#player-menu.is-dual-layout .equip-cell.is-ammo {
  width: 46px;
  flex-shrink: 0;
}

#player-menu.theme-round-gold.is-dual-layout .equip-cell,
#player-menu.theme-round-gold.is-dual-layout .slot-cell {
  border-radius: 8px;
  border: 2px solid #2a2418;
  background: linear-gradient(180deg, #100e0c 0%, #1a1814 100%);
  box-shadow:
    inset 2px 2px 3px rgba(0, 0, 0, 0.55),
    inset -1px -1px 0 rgba(255, 220, 140, 0.05);
}

#player-menu.theme-round-gold.is-dual-layout .equip-cell.filled,
#player-menu.theme-round-gold.is-dual-layout .slot-cell.filled {
  border-color: #4a4030;
  background: linear-gradient(180deg, #242018 0%, #181614 100%);
  box-shadow:
    inset 1px 1px 2px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(201, 162, 39, 0.18);
}

#player-menu.theme-round-gold.is-dual-layout .equip-cell.filled.is-broken,
#player-menu.theme-round-gold.is-dual-layout .slot-cell.filled.is-broken {
  border-color: #fc8181;
  box-shadow:
    inset 0 0 0 1px rgba(252, 129, 129, 0.35),
    inset 1px 1px 2px rgba(0, 0, 0, 0.4);
}

#player-menu.is-dual-layout .equip-cell.is-broken .equip-cell-dur {
  color: #fc8181;
}

#player-menu.is-dual-layout .equip-char.equip-char-floating {
  width: 92px;
  max-width: 92px;
  min-height: 0;
  flex: 1 1 0;
  padding: 0;
  gap: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  justify-content: center;
  align-items: center;
  overflow: visible;
}

#player-menu.is-dual-layout .equip-char-floating .equip-char-silhouette {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

#player-menu.is-dual-layout .equip-char-floating .equip-char-silhouette.is-fallback {
  width: 72px;
  height: 72px;
  max-width: none;
  max-height: none;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.2);
  transform: scale(1.44);
  transform-origin: center center;
}

#player-menu.is-dual-layout .equip-char-floating .equip-char-sprite {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  transform: scale(1.44);
  transform-origin: center center;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

#player-menu.theme-round-gold.is-dual-layout .equip-char.equip-char-floating,
#player-menu.theme-round-gold.is-dual-layout .equip-char.equip-char-floating.race-titan,
#player-menu.theme-round-gold.is-dual-layout .equip-char.equip-char-floating.race-sylph,
#player-menu.theme-round-gold.is-dual-layout .equip-char.equip-char-floating.race-astral {
  border: none;
  background: transparent;
  box-shadow: none;
}

#player-menu.is-dual-layout .equip-char-meta {
  display: none;
}

#player-menu.theme-round-gold.is-dual-layout .equip-char {
  border-radius: 12px;
  border-width: 2px;
  border-style: solid;
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(255, 220, 140, 0.1);
}

#player-menu.theme-round-gold.is-dual-layout .equip-char.race-titan {
  border-color: #4a5a42;
  background:
    radial-gradient(ellipse 80% 35% at 50% 95%, rgba(104, 180, 90, 0.28) 0%, transparent 70%),
    linear-gradient(180deg, #3d4a3a 0%, #1a2218 100%);
}

#player-menu.theme-round-gold.is-dual-layout .equip-char.race-sylph {
  border-color: #3a5560;
  background:
    radial-gradient(ellipse 80% 35% at 50% 95%, rgba(88, 200, 220, 0.26) 0%, transparent 70%),
    linear-gradient(180deg, #2f4a55 0%, #152028 100%);
}

#player-menu.theme-round-gold.is-dual-layout .equip-char.race-astral {
  border-color: #4a4568;
  background:
    radial-gradient(ellipse 80% 35% at 50% 95%, rgba(160, 130, 220, 0.28) 0%, transparent 70%),
    linear-gradient(180deg, #3a3558 0%, #181524 100%);
}

#player-menu.is-dual-layout .slot-grid {
  grid-template-columns: repeat(5, 36px);
  gap: 3px;
  width: 192px;
  max-width: 192px;
  flex-shrink: 0;
  align-content: start;
  justify-content: start;
  box-sizing: border-box;
}

#player-menu.is-dual-layout .slot-cell {
  width: 36px;
  height: 36px;
  padding: 0;
  align-items: center;
  justify-content: center;
}

#player-menu.is-dual-layout .slot-icon-btn {
  min-height: 36px;
}

#player-menu.is-dual-layout .slot-icon-img {
  width: 30px;
  height: 30px;
}

#player-menu.is-dual-layout .slot-storage-cell .slot-action-btn {
  font-size: 0.5rem;
  min-height: 11px;
  line-height: 1.2;
}

#player-menu.is-dual-layout .slot-qty {
  font-size: 0.55rem;
}

#player-menu.is-dual-layout .equip-costume-placeholder {
  min-height: 120px;
  font-size: 0.65rem;
  padding: 10px;
}

.stat-grid {
  display: grid;
  gap: 6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  font-size: 0.85rem;
}

.stat-row span {
  color: #a0aec0;
}

.stat-row strong {
  color: #e8e4dc;
  text-align: right;
}

.inv-summary {
  font-size: 0.75rem;
  color: #a0aec0;
  margin-bottom: 8px;
}

.inv-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.inv-cat-btn {
  background: #1a2035;
  border: 1px solid #4a5568;
  color: #a0aec0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
}

.inv-cat-btn.active {
  background: #2b6cb0;
  border-color: #63b3ed;
  color: #ebf8ff;
}

.inv-grid {
  display: grid;
  gap: 6px;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 36px);
  gap: 2px;
  justify-content: start;
}

.slot-cell {
  position: relative;
  width: 36px;
  height: 36px;
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
  padding: 2px;
  border: 1px dashed #4a5568;
  border-radius: 3px;
  background: #121826;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1px;
  overflow: hidden;
  box-sizing: border-box;
}

.slot-cell.empty {
  opacity: 0.55;
}

.slot-cell.empty.is-filtered {
  opacity: 0.28;
}

.slot-cell.filled {
  border-style: solid;
  border-color: #718096;
  background: #1a2035;
  cursor: default;
}

.warehouse-slot-cell.filled {
  cursor: pointer;
}

.warehouse-slot-cell.filled:hover {
  border-color: #63b3ed;
  background: #1e2a44;
}

.slot-cell-name {
  font-size: 0.52rem;
  line-height: 1.15;
  color: #f6d365;
  word-break: break-word;
  flex: 1;
  overflow: hidden;
}

.slot-storage-cell {
  padding: 0;
  gap: 0;
}

.slot-storage-cell.is-blocked {
  opacity: 0.45;
}

.slot-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 36px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

.slot-icon-btn:disabled {
  cursor: not-allowed;
}

.slot-icon-glyph {
  font-size: 1rem;
  line-height: 1;
  pointer-events: none;
}

.slot-icon-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}

.slot-plus-badge {
  position: absolute;
  top: 1px;
  left: 1px;
  font-size: 0.45rem;
  line-height: 1.1;
  color: #90cdf4;
  background: rgba(0, 0, 0, 0.75);
  padding: 0 2px;
  border-radius: 2px;
  pointer-events: none;
}

.slot-status-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #48bb78;
  pointer-events: none;
}

.slot-status-dot.is-worn {
  background: #ecc94b;
}

.slot-status-dot.is-broken {
  background: #fc8181;
}

.slot-storage-cell .slot-action-btn {
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 1px;
  z-index: 2;
  padding: 0 1px;
  font-size: 0.42rem;
  line-height: 1.15;
  min-height: 10px;
}

.slot-storage-cell .slot-action-btn.slot-action-remove {
  background: rgba(155, 44, 44, 0.85);
  border-color: #fc8181;
  color: #fed7d7;
}

.slot-qty {
  position: absolute;
  right: 2px;
  bottom: 2px;
  min-width: 12px;
  padding: 0 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: #e2e8f0;
  font-size: 0.55rem;
  text-align: center;
  line-height: 1.2;
}

.slot-action-btn {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  background: #2d3748;
  border: 1px solid #718096;
  color: #e2e8f0;
  border-radius: 2px;
  padding: 1px 3px;
  font-size: 0.5rem;
  cursor: pointer;
  line-height: 1.15;
}

.slot-action-btn.is-active {
  background: #2b6cb0;
  border-color: #63b3ed;
  color: #ebf8ff;
}

.equip-panel {
  background: #1a2035;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 12px;
}

.equip-panel-header {
  margin-bottom: 8px;
}

.equip-view-tabs {
  display: flex;
  gap: 6px;
}

.equip-view-btn {
  background: #121826;
  border: 1px solid #4a5568;
  color: #a0aec0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
}

.equip-view-btn.active {
  background: #2b6cb0;
  border-color: #63b3ed;
  color: #ebf8ff;
}

.equip-ro-layout {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 8px;
  align-items: center;
}

.equip-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.equip-col.center {
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.equip-cell {
  width: 56px;
  height: 64px;
  box-sizing: border-box;
  padding: 2px 3px 3px;
  border: 1px dashed #4a5568;
  border-radius: 5px;
  background: #121826;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  overflow: hidden;
  color: inherit;
  font: inherit;
  text-align: center;
}

.equip-cell.is-empty {
  opacity: 0.7;
}

.equip-cell.filled {
  border-style: solid;
  border-color: #718096;
  background: #1e2a44;
  cursor: pointer;
}

.equip-cell.filled:hover {
  border-color: #63b3ed;
}

button.equip-cell {
  margin: 0;
}

.equip-cell-label {
  font-size: 0.55rem;
  color: #a0aec0;
  line-height: 1.1;
}

.equip-cell-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.equip-cell-icon .slot-icon-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: auto;
}

.equip-cell-icon .slot-icon-glyph {
  font-size: 1rem;
  line-height: 1;
}

.equip-cell-plus {
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: 0.45rem;
  line-height: 1.1;
  color: #90cdf4;
  background: rgba(0, 0, 0, 0.75);
  padding: 0 2px;
  border-radius: 2px;
  pointer-events: none;
}

.equip-cell-dur {
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  color: #e2e8f0;
  line-height: 1.15;
  max-width: 100%;
  overflow: visible;
  white-space: nowrap;
  font-weight: 600;
}

.equip-cell.is-broken .equip-cell-dur {
  color: #fc8181;
}

.equip-cell-name {
  font-size: 0.52rem;
  color: #f6d365;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.equip-cell-bonus {
  font-size: 0.48rem;
  color: #68d391;
  line-height: 1.1;
}

.equip-char {
  width: 100%;
  max-width: 176px;
  min-height: 210px;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  border: 1px solid #4a5568;
  background: linear-gradient(180deg, #2a3550 0%, #151b2c 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 8px 8px;
  box-sizing: border-box;
  overflow: hidden;
}

.equip-char.race-titan {
  background: linear-gradient(180deg, #3d4a3a 0%, #1a2218 100%);
}

.equip-char.race-sylph {
  background: linear-gradient(180deg, #2f4a55 0%, #152028 100%);
}

.equip-char.race-astral {
  background: linear-gradient(180deg, #3a3558 0%, #181524 100%);
}

/* à¹à¸§à¸à¸µà¸¢à¸·à¸à¸à¸±à¸§à¸¥à¸°à¸à¸£ â à¸à¸±à¸à¸à¸¥à¸²à¸ à¹à¸¡à¹à¸à¸¢à¸²à¸¢à¸ªà¹à¸à¸£à¸à¹ */
.equip-char-silhouette {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background:
    radial-gradient(ellipse 48% 16% at 50% 68%, rgba(0, 0, 0, 0.4) 0%, transparent 70%);
  overflow: hidden;
}

/* fallback à¸à¸±à¸§à¸­à¸±à¸à¸©à¸£à¹à¸¡à¸·à¹à¸­à¸¢à¸±à¸à¹à¸¡à¹à¸¡à¸µà¸ªà¹à¸à¸£à¸à¹ */
.equip-char-silhouette.is-fallback {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  align-self: center;
  margin: auto 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  align-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #e2e8f0;
}

.equip-char-sprite {
  width: auto;
  height: min(100%, 168px);
  max-width: 100%;
  flex: 1 1 auto;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.35));
}

.equip-char.gender-female .equip-char-silhouette.is-fallback {
  border-color: rgba(246, 173, 185, 0.45);
}

.equip-char-meta {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: #cbd5e0;
  line-height: 1.2;
}

.equip-costume-placeholder {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  color: #a0aec0;
  font-size: 0.82rem;
  text-align: center;
  border: 1px dashed #4a5568;
  border-radius: 8px;
  background: #121826;
}

.equip-costume-hint {
  font-size: 0.7rem;
  color: #718096;
}

.equip-bonus-summary {
  margin-top: 8px;
  font-size: 0.72rem;
  color: #a0aec0;
  text-align: center;
}

.stat-bonus {
  color: #68d391;
  font-style: normal;
  font-size: 0.85em;
}

.inv-slot {
  padding: 8px 10px;
  border: 1px solid #4a5568;
  border-radius: 6px;
  background: #1a2035;
}

.inv-slot.filled {
  border-color: #718096;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inv-slot-main {
  min-width: 0;
}

.inv-hotbar-btn {
  flex-shrink: 0;
  background: #2d3748;
  border: 1px solid #718096;
  color: #e2e8f0;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.7rem;
  cursor: pointer;
}

.inv-hotbar-btn.is-active {
  background: #2b6cb0;
  border-color: #63b3ed;
  color: #ebf8ff;
}

#hotbar-item-1.has-item {
  border-color: #68d391;
  color: #c6f6d5;
}

#hotbar-item-1:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.inv-name {
  font-size: 0.85rem;
  color: #f6d365;
  margin-bottom: 2px;
}

.inv-meta {
  font-size: 0.72rem;
  color: #a0aec0;
}

.menu-empty,
.menu-placeholder {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  color: #a0aec0;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 8px 2px;
}

.quest-card {
  background: #1a2035;
  border: 1px solid #2d3748;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.quest-card h3 {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  color: #f6d365;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 4px;
}

.quest-card p {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  color: #a0aec0;
  font-size: 0.78rem;
  margin-bottom: 8px;
  line-height: 1.35;
}

.skill-menu-title strong {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  color: #f6d365;
}

.skill-menu-desc {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  margin: 0;
  color: #a0aec0;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-line;
}

.quest-card.is-done {
  opacity: 0.65;
}

.quest-objectives {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.78rem;
  color: #e2e8f0;
  line-height: 1.35;
}

.quest-objectives li {
  margin-bottom: 4px;
  line-height: 1.3;
}

.quest-objectives li.obj-done {
  color: #68d391;
}

.quest-rewards {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #2d3748;
}

.quest-rewards-title {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  color: #f6d365;
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}

.quest-rewards ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.78rem;
  color: #c6f6d5;
  line-height: 1.35;
}

.quest-rewards li {
  margin-bottom: 2px;
}

.quest-section-title {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  color: #a0aec0;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Quest + Skills — Rounded Gold (ธีมทอง · typography เควสเดิม) */
#player-menu.theme-round-gold .menu-full-panel {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
}

#player-menu.theme-round-gold .quest-card {
  border: 2px solid #3d3428;
  border-radius: 8px;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
  box-shadow:
    inset 1px 1px 2px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(201, 162, 39, 0.08);
}

#player-menu.theme-round-gold .quest-card h3,
#player-menu.theme-round-gold .skill-menu-title strong {
  color: #f0d78c;
}

#player-menu.theme-round-gold .quest-card p,
#player-menu.theme-round-gold .skill-menu-desc,
#player-menu.theme-round-gold .menu-full-panel .menu-placeholder,
#player-menu.theme-round-gold .menu-full-panel .menu-empty {
  color: #c8cdd8;
  font-size: 0.78rem;
}

#player-menu.theme-round-gold .menu-full-panel .menu-placeholder:first-child,
#player-menu.theme-round-gold .menu-full-panel > .menu-placeholder {
  font-size: 0.85rem;
}

#player-menu.theme-round-gold .quest-section-title {
  color: #e8d48a;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#player-menu.theme-round-gold .quest-rewards-title {
  color: #e8d48a;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

#player-menu.theme-round-gold .quest-objectives {
  color: #c8cdd8;
}

#player-menu.theme-round-gold .quest-objectives li.obj-done {
  color: #8fd48f;
}

#player-menu.theme-round-gold .quest-rewards {
  border-top-color: #3d3428;
}

#player-menu.theme-round-gold .quest-rewards ul {
  color: #8fd48f;
}

#player-menu.theme-round-gold .skill-menu-row {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #3d3428;
}

#player-menu.theme-round-gold .skill-menu-title span {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.78rem;
  color: #b8a888;
  flex-shrink: 0;
}

#player-menu.theme-round-gold .skill-menu-bind span {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.78rem;
  color: #b8a888;
}

#player-menu.theme-round-gold .skill-menu-bind button {
  min-width: 26px;
  padding: 2px 6px;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  border: 2px solid #3d3428;
  border-radius: 6px;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
  color: #e8d48a;
}

#player-menu.theme-round-gold .skill-menu-bind button.is-bound {
  border-color: #8b7332;
  background: linear-gradient(180deg, #3a3224 0%, #282018 100%);
  color: #f0d78c;
}

/* Social — typography เควสเดิม + ธีมทอง (match Quest/Skills) */
#player-menu.theme-round-gold .trade-social-hint {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.85rem;
  color: #c8cdd8;
  line-height: 1.4;
  margin-bottom: 10px;
}

#player-menu.theme-round-gold #party-social-status {
  margin-bottom: 8px;
}

#player-menu.theme-round-gold #party-social-status .menu-placeholder {
  font-size: 0.85rem;
  color: #c8cdd8;
  padding: 10px 12px;
  margin: 0;
  border: 2px solid #3d3428;
  border-radius: 8px;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
}

#player-menu.theme-round-gold .party-social-line {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #f0d78c;
  line-height: 1.35;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 2px solid #3d3428;
  border-radius: 8px;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
  box-shadow:
    inset 1px 1px 2px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(201, 162, 39, 0.08);
}

#player-menu.theme-round-gold .party-social-modes {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 400;
  color: #b8a888;
}

#player-menu.theme-round-gold .trade-nearby-row {
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 2px solid #3d3428;
  border-radius: 8px;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
  box-shadow:
    inset 1px 1px 2px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(201, 162, 39, 0.08);
}

#player-menu.theme-round-gold .trade-nearby-info {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.9rem;
  gap: 3px;
}

#player-menu.theme-round-gold .trade-nearby-info strong {
  color: #f0d78c;
  font-weight: 600;
  font-size: 0.9rem;
}

#player-menu.theme-round-gold .trade-nearby-info span {
  font-size: 0.78rem;
  color: #b8a888;
}

#player-menu.theme-round-gold .trade-nearby-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#player-menu.theme-round-gold .trade-nearby-btn {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.75rem;
  padding: 4px 8px;
  border: 2px solid #3d3428;
  border-radius: 6px;
  background: linear-gradient(180deg, #242018 0%, #141210 100%);
  color: #e8d48a;
  white-space: nowrap;
}

#player-menu.theme-round-gold .trade-nearby-btn:hover {
  border-color: #8b7332;
  color: #f0d78c;
}

#player-menu.theme-round-gold .trade-nearby-btn.party-invite-btn {
  background: linear-gradient(180deg, #242018 0%, #141210 100%) !important;
  border-color: #5a4a78;
  color: #d4c8e8;
}

#player-menu.theme-round-gold .trade-nearby-btn.party-invite-btn:hover {
  border-color: #7a6a98;
  color: #ece4f8;
}

#player-menu.theme-round-gold .trade-nearby-btn.duel-invite-btn {
  border-color: #6b4038;
  color: #f0c8c0;
}

#player-menu.theme-round-gold .trade-nearby-btn.duel-invite-btn:hover {
  border-color: #8b5048;
  color: #ffd8d0;
}

#npc-dialog {
  position: relative;
  flex-shrink: 0;
  width: min(440px, calc(100vw - 24px));
  background: rgba(12, 16, 28, 0.94);
  border: 1px solid #f6d365;
  border-radius: 10px;
  padding: 10px 12px 20px;
  z-index: 1;
  overflow: visible;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#npc-dialog-close {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
  background: transparent;
  border: none;
  color: #a0aec0;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}

#npc-dialog-close:hover {
  color: #fc8181;
}

.npc-dialog-body {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 96px;
}

.npc-dialog-portrait-col {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transition: width 0.12s ease, opacity 0.12s ease;
}

#npc-dialog.has-portrait .npc-dialog-portrait-col {
  width: 120px;
  opacity: 1;
}

.npc-dialog-portrait {
  width: 112px;
  height: 112px;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}

.npc-dialog-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-top: 4px;
  padding-right: 22px;
}

#npc-dialog.has-portrait .npc-dialog-main {
  padding-top: 2px;
}

.npc-dialog-role {
  color: #a0aec0;
  font-size: 0.72rem;
  line-height: 1.3;
  margin-bottom: 4px;
  min-height: 0;
}

.npc-dialog-role:empty {
  display: none;
}

#npc-dialog-text {
  flex: 1;
  color: #e2e8f0;
  font-size: 0.88rem;
  line-height: 1.45;
  min-height: 2.8em;
  margin: 0 0 8px;
}

.npc-dialog-nameplate {
  position: absolute;
  left: 12px;
  bottom: -1px;
  transform: translateY(50%);
  padding: 4px 14px 5px;
  background: rgba(12, 16, 28, 0.98);
  border: 1px solid #f6d365;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  max-width: calc(100% - 48px);
}

#npc-dialog-name {
  color: #f6d365;
  font-weight: bold;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.npc-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#npc-dialog-action {
  background: #2b6cb0;
  color: #ebf8ff;
  border: 1px solid #63b3ed;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}

#npc-dialog-next {
  background: #2d3748;
  color: #f6d365;
  border: 1px solid #f6d365;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}

#item-detail-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 96;
}

#item-detail-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(300px, calc(100vw - 32px));
  background: rgba(12, 16, 28, 0.97);
  border: 1px solid #63b3ed;
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 97;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.item-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

#item-detail-title {
  color: #f6d365;
  font-weight: bold;
  font-size: 0.95rem;
  line-height: 1.25;
}

.item-detail-type {
  color: #a0aec0;
  font-size: 0.72rem;
  margin-top: 2px;
}

.item-detail-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.item-detail-icon {
  width: clamp(88px, 18vmin, 144px);
  height: clamp(88px, 18vmin, 144px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #4a5568;
  border-radius: 8px;
  background: #1a2035;
}

.item-detail-icon .slot-icon-glyph {
  font-size: 1.75rem;
}

.item-detail-icon .slot-icon-img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.item-detail-icon .item-detail-image {
  width: 100%;
  height: 100%;
  padding: 6px;
  box-sizing: border-box;
  object-fit: contain;
  image-rendering: auto;
  opacity: 0;
  transition: opacity 120ms ease-out;
}

.item-detail-icon .item-detail-image.is-loaded {
  opacity: 1;
}

.item-detail-icon.is-worn {
  border-color: #ecc94b;
}

.item-detail-icon.is-broken {
  border-color: #fc8181;
  opacity: 0.75;
}

.item-detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.item-detail-stats span {
  font-size: 0.75rem;
  color: #90cdf4;
  background: rgba(43, 108, 176, 0.2);
  border: 1px solid rgba(99, 179, 237, 0.35);
  border-radius: 4px;
  padding: 2px 8px;
}

.item-detail-desc {
  color: #cbd5e0;
  font-size: 0.8rem;
  line-height: 1.45;
  text-align: center;
  margin: 0;
  white-space: pre-line;
}

.item-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.item-detail-action {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid #4a5568;
  background: #1a2035;
  color: #e2e8f0;
  font-size: 0.8rem;
  cursor: pointer;
}

.item-detail-action.is-primary {
  background: #2b6cb0;
  border-color: #63b3ed;
  color: #ebf8ff;
}

.item-detail-action:hover {
  filter: brightness(1.08);
}

#qty-dialog-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 120;
}

#qty-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100vw - 24px));
  background: rgba(12, 16, 28, 0.96);
  border: 1px solid #f6d365;
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 125;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#qty-dialog .qty-dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.qty-dialog-header {
  padding-right: 38px;
  margin-bottom: 4px;
}

#qty-dialog-title {
  color: #f6d365;
  font-weight: bold;
  font-size: 0.95rem;
  line-height: 1.25;
}

#qty-dialog-hint {
  color: #a0aec0;
  font-size: 0.72rem;
  margin-top: 2px;
  line-height: 1.3;
}

#qty-dialog-hint.is-error {
  color: #fc8181;
}

.qty-dialog-body {
  display: flex;
  gap: 8px;
  margin: 8px 0 10px;
}

#qty-dialog-input {
  flex: 1;
  min-width: 0;
  background: #0f1424;
  border: 1px solid #4a5568;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 8px 10px;
  font-size: 1rem;
}

#qty-dialog-max {
  flex-shrink: 0;
  background: #2d3748;
  border: 1px solid #718096;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.78rem;
}

.qty-dialog-actions {
  justify-content: flex-end;
}

#qty-dialog-confirm {
  background: #2d3748;
  color: #f6d365;
  border: 1px solid #f6d365;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.82rem;
}

/* มือถือ — ปุ่ม «เสร็จ» ปิดคีย์บอร์ด (desktop ซ่อน) */
.mobile-kbd-dismiss {
  display: none;
}

.mobile-kbd-row {
  display: contents;
}

@media (max-width: 768px) {
  .mobile-kbd-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .mobile-kbd-row input[type="number"] {
    flex: 1 1 auto;
    min-width: 0;
  }

  .mobile-kbd-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 6px 10px;
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 6px;
    border: 1px solid #718096;
    background: #2d3748;
    color: #e2e8f0;
    cursor: pointer;
    white-space: nowrap;
  }

  .mobile-kbd-dismiss:active {
    filter: brightness(1.08);
  }

  .market-price-row .mobile-kbd-dismiss {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .qty-dialog-body {
    flex-wrap: wrap;
    align-items: center;
  }

  .qty-dialog-body .mobile-kbd-row {
    flex: 1 1 120px;
    min-width: 0;
  }

  #qty-dialog-input {
    min-width: 0;
  }

  .trade-bag-money-actions .mobile-kbd-row {
    flex: 1 1 140px;
    min-width: 120px;
  }

  .trade-bag-money-actions input[type="number"] {
    min-width: 0;
  }

  /* คีย์บอร์ดเปิด — dialog ถูก pin ด้วย JS (visualViewport); ปุ่มยืนยันต้องแตะได้ */
  #qty-dialog.is-kbd-open {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  }

  #qty-dialog.is-kbd-open .qty-dialog-actions,
  #qty-dialog.is-kbd-open .npc-dialog-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding-top: 6px;
    margin-top: 2px;
    background: rgba(12, 16, 28, 0.98);
  }
}

#hotbar-hud {
  position: absolute;
  right: 12px;
  bottom: 52px;
  z-index: 40;
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.desktop-hotbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(12, 16, 28, 0.9);
  border: 1px solid #718096;
  border-radius: 10px;
  color: #e2e8f0;
  padding: 5px 6px;
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  box-sizing: border-box;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  pointer-events: none;
  user-select: none;
}

.desktop-hotbar-btn.has-item {
  border-color: #68d391;
}

.desktop-hotbar-btn.is-empty {
  border-color: #718096;
  opacity: 0.75;
}

.desktop-hotbar-btn.is-out {
  border-color: #fc8181;
  opacity: 0.65;
  cursor: not-allowed;
}

.desktop-hotbar-icon {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.desktop-hotbar-icon .slot-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: auto;
}

.desktop-hotbar-qty {
  font-size: 0.62rem;
  font-weight: 700;
  color: #c6f6d5;
  line-height: 1;
}

.desktop-hotbar-btn kbd,
.desktop-hotbar-slot-label {
  font-size: 0.58rem;
  font-weight: 600;
  color: #a0aec0;
  line-height: 1;
}

.desktop-hotbar-btn kbd {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #4a5568;
  border-radius: 4px;
  padding: 1px 4px;
}

#bottom-center-hud {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}

#bottom-center-hud > * {
  pointer-events: auto;
}

#skill-bar-hud {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.ammo-hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  box-sizing: border-box;
  padding: 0 10px;
  margin-right: 2px;
  background: rgba(12, 16, 28, 0.9);
  border: 1px solid #718096;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

.ammo-hud.is-hidden {
  display: none;
}

.ammo-hud[data-element='light'] {
  border-color: #ecc94b;
  color: #faf089;
}

.ammo-hud[data-element='dark'] {
  border-color: #9f7aea;
  color: #d6bcfa;
}

.ammo-hud[data-element='neutral'] {
  border-color: #a0aec0;
}

.equip-ammo-row {
  display: flex;
  justify-content: center;
  margin-top: 8px;
  gap: 8px;
}

#skill-bar-page-btn {
  width: 40px;
  height: 48px;
  flex: 0 0 40px;
  background: rgba(12, 16, 28, 0.9);
  border: 1px solid #a0aec0;
  border-radius: 8px;
  color: #f6e05e;
  font-weight: 700;
  cursor: pointer;
}

.auto-farm-toggle {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  padding: 0;
  box-sizing: border-box;
  background: rgba(20, 16, 12, 0.92);
  border: 1px solid #6b4a28;
  border-radius: 8px;
  color: #a0aec0;
  font-family: var(--font-body, "Sarabun", sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auto-farm-toggle.is-on {
  color: #fbd38d;
  border-color: #c9a227;
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.35);
  background: rgba(46, 36, 24, 0.95);
}

.auto-farm-toggle.is-pending {
  color: #ecc94b;
  border-color: #8a7020;
  opacity: 0.85;
}

.auto-farm-settings-btn {
  width: 36px;
  height: 48px;
  flex: 0 0 36px;
  background: rgba(20, 16, 12, 0.92);
  border: 1px solid #6b4a28;
  border-radius: 8px;
  color: #fbd38d;
  font-size: 16px;
  cursor: pointer;
}

#auto-farm-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 120;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 112px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
  font-family: "Sarabun", "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(165deg, #2e2418, #14100c);
  border: 1px solid #6b4a28;
  border-radius: 10px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.48);
  color: #e8e0d4;
}

#auto-farm-panel.hidden {
  display: none !important;
}

.auto-farm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.auto-farm-panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fbd38d;
  font-family: "Sarabun", "Segoe UI", Tahoma, sans-serif;
}

#auto-farm-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.auto-farm-status {
  margin: 0;
  font-size: 13px;
  color: #fbd38d;
}

.auto-farm-hint {
  margin: 0;
  font-size: 12px;
  color: #a0aec0;
  line-height: 1.4;
}

.auto-farm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #e8e0d4;
}

.auto-farm-field input[type="range"] {
  width: 100%;
  accent-color: #c9a227;
}

.auto-farm-target-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.auto-farm-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fbd38d;
}

#auto-farm-target-all {
  padding: 3px 8px;
  border: 1px solid #806629;
  border-radius: 5px;
  background: rgba(35, 28, 19, 0.9);
  color: #fbd38d;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.auto-farm-target-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.auto-farm-target-card {
  min-width: 0;
  padding: 5px 3px 4px;
  border: 1px solid #4a4034;
  border-radius: 7px;
  background: rgba(12, 16, 24, 0.72);
  color: #b8b0a4;
  cursor: pointer;
  text-align: center;
}

.auto-farm-target-card.is-selected {
  border-color: #d6ad3a;
  color: #fff3c4;
  background: rgba(75, 57, 24, 0.82);
  box-shadow: inset 0 0 0 1px rgba(246, 224, 94, 0.2);
}

.auto-farm-target-thumb {
  display: block;
  width: 52px;
  height: 52px;
  margin: 0 auto 2px;
  object-fit: contain;
  image-rendering: pixelated;
}

.auto-farm-target-name,
.auto-farm-target-level {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.auto-farm-target-name { font-size: 11px; font-weight: 700; }
.auto-farm-target-level { font-size: 10px; color: #a0aec0; }
.auto-farm-notes {
  margin: 4px 0 0;
  padding-left: 1.1em;
  font-size: 12px;
  color: #a0aec0;
  line-height: 1.45;
}

.auto-farm-notes li {
  margin-bottom: 4px;
}

@media (max-width: 768px) {
  #auto-farm-panel {
    width: min(294px, calc(100vw - 16px));
    top: 42%;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 112px);
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  #auto-farm-panel {
    width: min(336px, calc(100vw - 16px));
    top: 40%;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 88px);
  }
}

.skill-slot-btn {
  position: relative;
  width: 48px;
  height: 48px;
  min-width: 48px;
  max-width: 48px;
  flex: 0 0 48px;
  padding: 0;
  box-sizing: border-box;
  background: rgba(12, 16, 28, 0.9);
  border: 1px solid #718096;
  border-radius: 8px;
  color: #e2e8f0;
  cursor: pointer;
  display: block;
  overflow: hidden;
}

.skill-slot-btn.has-skill {
  border: 2px solid #ed8936;
  box-shadow: none;
}

/* à¸à¸£à¹à¸­à¸¡à¹à¸à¹ â à¸à¸­à¸à¹à¸à¸µà¸¢à¸§à¸à¸±à¸ (inset à¹à¸¡à¹à¸à¸¹à¸ overflow:hidden à¸à¸±à¸) */
.skill-slot-btn.has-skill.is-ready {
  border: 2px solid #9ae6b4;
  background: rgba(26, 58, 42, 0.95);
  box-shadow:
    inset 0 0 0 1px rgba(154, 230, 180, 0.55),
    0 0 10px rgba(104, 211, 145, 0.4);
}

.skill-slot-btn.has-skill.is-cooldown {
  border: 2px solid #4a5568;
  background: rgba(12, 16, 28, 0.9);
  box-shadow: none;
}

.skill-slot-btn.has-skill.is-cooldown .skill-slot-icon {
  opacity: 0.4;
}

.skill-slot-btn.is-empty {
  opacity: 0.75;
}

.skill-slot-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.58rem;
  line-height: 1;
  color: #a0aec0;
  z-index: 2;
  pointer-events: none;
}

.skill-slot-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  z-index: 1;
  pointer-events: none;
}

.skill-slot-btn .skill-icon-img {
  display: block;
  width: min(30px, calc(100% - 10px));
  height: min(30px, calc(100% - 10px));
  object-fit: contain;
  object-position: center center;
}

.skill-slot-btn .skill-icon-glyph {
  font-size: 1rem;
  line-height: 1;
}

.skill-icon-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}

.skill-menu-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
}

.skill-menu-icon .skill-icon-img {
  width: 32px;
  height: 32px;
}

.skill-slot-cd {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: 7px;
  pointer-events: none;
  z-index: 2;
  background: conic-gradient(
    from 0deg,
    rgba(0, 0, 0, 0.72) 0deg,
    rgba(0, 0, 0, 0.72) calc(var(--cd-pct, 0) * 360deg),
    rgba(0, 0, 0, 0.15) calc(var(--cd-pct, 0) * 360deg)
  );
  align-items: center;
  justify-content: center;
}

.skill-slot-btn.is-cooldown .skill-slot-cd {
  display: flex;
}

.skill-slot-cd-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f7fafc;
  text-shadow: 0 1px 2px #000;
  line-height: 1;
}

.skill-menu-bind {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.skill-menu-bind button {
  min-width: 28px;
  padding: 2px 6px;
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.75rem;
  cursor: pointer;
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 4px;
  color: #e2e8f0;
}

.skill-menu-bind button.is-bound {
  border-color: #ed8936;
  color: #f6e05e;
}

.skill-menu-row {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #2d3748;
}

.skill-menu-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.skill-menu-title strong {
  flex: 1;
  min-width: 0;
}

.skill-menu-title span {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.78rem;
  color: #a0aec0;
  flex-shrink: 0;
}

.skill-menu-bind span {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.78rem;
  color: #a0aec0;
}

#hotbar-hud-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(12, 16, 28, 0.9);
  border: 1px solid #63b3ed;
  border-radius: 10px;
  color: #e2e8f0;
  padding: 6px 8px;
  cursor: pointer;
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  box-sizing: border-box;
}

#hotbar-hud-btn.has-item {
  border-color: #68d391;
}

#hotbar-hud-btn.is-empty {
  border-color: #718096;
  opacity: 0.85;
}

#hotbar-hud-icon {
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

#hotbar-hud-icon .slot-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: auto;
}

#hotbar-hud-icon .slot-icon-glyph {
  font-size: 1.1rem;
  line-height: 1;
}

#hotbar-item-1 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
}

#hotbar-item-1 .hotbar-mobile-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

#hotbar-item-1 .hotbar-mobile-icon .slot-icon-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  image-rendering: auto;
}

#hotbar-item-1 .hotbar-mobile-qty {
  font-size: 0.7rem;
  font-weight: 700;
  color: #c6f6d5;
}

#hotbar-hud-qty {
  font-size: 0.72rem;
  font-weight: bold;
  color: #c6f6d5;
  line-height: 1;
  min-width: 0;
}

#hotbar-hud-btn kbd {
  background: #2d3748;
  border: 1px solid #4a5568;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.65rem;
  color: #a0aec0;
  line-height: 1.3;
}

#hotbar-item-1.has-item {
  border-color: #68d391;
  color: #c6f6d5;
}

#hotbar-item-1:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  #hotbar-hud {
    display: none;
  }
}

#warehouse-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 85;
}

#trade-overlay,
#trade-invite-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 85;
}

#trade-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(12, 16, 28, 0.96);
  border: 1px solid #9ae6b4;
  border-radius: 10px;
  z-index: 90;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

#trade-panel {
  width: min(476px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  border-color: #4a5568;
}

.trade-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.trade-panel-header h2 {
  font-size: 1rem;
}

.trade-invite-sub {
  font-size: 0.78rem;
  color: #a0aec0;
  margin-top: 4px;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.trade-accept-btn {
  border-color: #48bb78 !important;
  color: #9ae6b4 !important;
}

.trade-panel-header {
  flex-shrink: 0;
}

.trade-status {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: #9ae6b4;
  border-bottom: 1px solid #2d3748;
  text-align: center;
}

.trade-sides {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  padding: 10px 12px;
  min-height: 0;
}

.trade-sides-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  font-size: 1.1rem;
  color: #718096;
  user-select: none;
}

.trade-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  border: 2px solid transparent;
}

.trade-side-self {
  border-color: #63b3ed;
  background: rgba(99, 179, 237, 0.08);
}

.trade-side-partner {
  border-color: #ed8936;
  background: rgba(237, 137, 54, 0.08);
}

.trade-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.trade-side-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
}

.trade-side-self .trade-side-badge {
  color: #90cdf4;
}

.trade-side-partner .trade-side-badge {
  color: #fbd38d;
}

.trade-confirm-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #4a5568;
  color: #a0aec0;
  white-space: nowrap;
}

.trade-confirm-badge.is-confirmed {
  border-color: #48bb78;
  color: #9ae6b4;
  background: rgba(72, 187, 120, 0.15);
}

.trade-side-copper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #a0aec0;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.trade-side-copper strong {
  color: #f6d365;
  font-size: 0.8rem;
}

.trade-offer-list {
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
  flex: 1;
}

.trade-offer-grid,
.trade-bag-grid {
  justify-content: start;
}

.trade-offer-slot.is-removable .slot-icon-btn {
  cursor: pointer;
}

.trade-offer-empty {
  color: #718096;
  font-size: 0.75rem;
  padding: 16px 8px;
  border: 1px dashed #4a5568;
  border-radius: 5px;
  text-align: center;
  flex: 1;
}

.trade-side-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.trade-side-actions button {
  flex: 1;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid #4a5568;
  background: #1a2035;
  color: #e2e8f0;
  font-size: 0.78rem;
  cursor: pointer;
}

#trade-confirm-btn.is-confirmed {
  border-color: #48bb78;
  color: #9ae6b4;
  background: rgba(72, 187, 120, 0.15);
}

.trade-bag-section {
  border-top: 1px solid #2d3748;
  padding: 8px 12px 10px;
  background: rgba(0, 0, 0, 0.15);
}

.trade-bag-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: #a0aec0;
  margin-bottom: 6px;
}

.trade-bag-balance {
  color: #f6d365;
  white-space: nowrap;
}

.trade-bag-compact,
.trade-bag-grid-wrap {
  margin-bottom: 8px;
  min-height: 36px;
}

.trade-bag-empty {
  font-size: 0.72rem;
  color: #718096;
  padding: 6px 0;
}

.trade-bag-money-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.trade-bag-money-actions input {
  flex: 1;
  min-width: 100px;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid #4a5568;
  background: #1a2035;
  color: #e2e8f0;
  font-size: 0.75rem;
}

.trade-bag-money-actions button {
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid #4a5568;
  background: #1a2035;
  color: #cbd5e0;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}

.trade-bag-money-actions button:hover {
  border-color: #63b3ed;
}

.trade-nearby-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid #2d3748;
  border-radius: 8px;
  background: rgba(26, 32, 53, 0.6);
}

.trade-nearby-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
}

.trade-nearby-info span {
  color: #a0aec0;
  font-size: 0.75rem;
}

.trade-nearby-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #48bb78;
  background: rgba(72, 187, 120, 0.12);
  color: #9ae6b4;
  cursor: pointer;
  white-space: nowrap;
}

.trade-social-hint {
  margin-bottom: 10px;
}

#warehouse-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 16px));
  max-height: min(560px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: rgba(12, 16, 28, 0.96);
  border: 1px solid #63b3ed;
  border-radius: 10px;
  z-index: 90;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

#warehouse-panel .warehouse-panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  margin: 0;
}

#warehouse-panel .warehouse-panel-header {
  position: relative;
  padding: 12px 44px 12px 14px;
  justify-content: flex-start;
}

#smith-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 85;
}

#smith-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 16px));
  max-height: min(640px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #2e2418 0%, #14100c 100%);
  border: 2px solid #6b4a28;
  border-radius: 14px;
  z-index: 90;
  overflow: hidden;
  box-shadow:
    0 0 0 1px #0a0806,
    0 0 0 3px #2a1c10,
    inset 0 1px 0 rgba(255, 180, 100, 0.1),
    0 12px 36px rgba(0, 0, 0, 0.65);
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
}

#smith-panel.theme-forge .smith-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 44px 10px 12px;
  border-bottom: 2px solid #4a3420;
  background: linear-gradient(180deg, rgba(237, 137, 54, 0.14) 0%, transparent 100%);
  position: relative;
}

#smith-panel.theme-forge .smith-panel-header .menu-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 8px;
  border: 2px solid #4a4030;
  background: linear-gradient(180deg, #2a2620 0%, #141210 100%);
  color: #fbd38d;
}

/* Forge — warp pick + social invites (ทุกขนาดจอ) */
#warp-pick-panel.theme-forge {
  background: linear-gradient(165deg, #2e2418 0%, #14100c 100%);
  border: 2px solid #6b4a28;
  border-radius: 14px;
  box-shadow:
    0 0 0 1px #0a0806,
    0 0 0 3px #2a1c10,
    inset 0 1px 0 rgba(255, 180, 100, 0.1),
    0 12px 36px rgba(0, 0, 0, 0.65);
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  color: #e2e8f0;
}

/* Invite เทรด / ปาร์ตี้ / Duel — กล่องสมมาตร */
.social-invite-dialog.theme-forge,
#trade-invite.theme-forge,
#party-invite.theme-forge,
#duel-invite.theme-forge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 97;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(288px, calc(100vw - 32px));
  min-width: 0;
  max-width: calc(100vw - 24px);
  padding: 12px 14px;
  overflow: hidden;
  background: linear-gradient(165deg, #2e2418 0%, #14100c 100%);
  border: 2px solid #6b4a28;
  border-radius: 14px;
  box-shadow:
    0 0 0 1px #0a0806,
    0 0 0 3px #2a1c10,
    inset 0 1px 0 rgba(255, 180, 100, 0.1),
    0 12px 36px rgba(0, 0, 0, 0.65);
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  color: #e2e8f0;
}

#warp-pick-panel.theme-forge .player-menu-header {
  position: relative;
  padding: 10px 44px 10px 12px;
  border-bottom: 2px solid #4a3420;
  background: linear-gradient(180deg, rgba(237, 137, 54, 0.14) 0%, transparent 100%);
}

#warp-pick-panel.theme-forge .player-menu-header h2 {
  margin: 0;
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fbd38d;
  letter-spacing: 0.2px;
}

#warp-pick-panel.theme-forge .menu-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 8px;
  border: 2px solid #4a4030;
  background: linear-gradient(180deg, #2a2620 0%, #141210 100%);
  color: #fbd38d;
}

#warp-pick-panel.theme-forge .market-hint {
  color: #a0aec0;
  border-bottom: 1px solid #3d3428;
}

#warp-pick-panel.theme-forge .warp-pick-btn {
  border: 2px solid #3d3428;
  border-radius: 8px;
  background: linear-gradient(180deg, #242018 0%, #181614 100%);
  color: #e2e8f0;
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.35);
}

#warp-pick-panel.theme-forge .warp-pick-btn:hover {
  border-color: #ed8936;
  color: #fbd38d;
  background: linear-gradient(180deg, #4a3020 0%, #281810 100%);
}

.social-invite-dialog.theme-forge .npc-dialog-header,
#trade-invite.theme-forge .npc-dialog-header,
#party-invite.theme-forge .npc-dialog-header,
#duel-invite.theme-forge .npc-dialog-header {
  margin: 0;
  min-width: 0;
}

.social-invite-dialog.theme-forge .npc-dialog-header > div,
#trade-invite.theme-forge .npc-dialog-header > div,
#party-invite.theme-forge .npc-dialog-header > div,
#duel-invite.theme-forge .npc-dialog-header > div {
  min-width: 0;
}

.social-invite-dialog.theme-forge .npc-dialog-header > div > div:first-child,
#trade-invite.theme-forge .npc-dialog-header > div > div:first-child,
#party-invite.theme-forge .npc-dialog-header > div > div:first-child,
#duel-invite.theme-forge .npc-dialog-header > div > div:first-child {
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fbd38d;
  line-height: 1.3;
}

.social-invite-dialog.theme-forge .trade-invite-sub,
#trade-invite.theme-forge .trade-invite-sub,
#party-invite.theme-forge .trade-invite-sub,
#duel-invite.theme-forge .trade-invite-sub {
  color: #a0aec0;
  font-size: 0.76rem;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.social-invite-dialog.theme-forge .npc-dialog-actions,
#trade-invite.theme-forge .npc-dialog-actions,
#party-invite.theme-forge .npc-dialog-actions,
#duel-invite.theme-forge .npc-dialog-actions {
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

.social-invite-dialog.theme-forge .npc-dialog-actions button,
#trade-invite.theme-forge .npc-dialog-actions button,
#party-invite.theme-forge .npc-dialog-actions button,
#duel-invite.theme-forge .npc-dialog-actions button {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 8px;
  font-size: 0.74rem;
  border-radius: 8px;
  border: 2px solid #3d3428;
  background: linear-gradient(180deg, #242018 0%, #181614 100%);
  color: #cbd5e0;
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}

.social-invite-dialog.theme-forge .npc-dialog-actions button:hover,
#trade-invite.theme-forge .npc-dialog-actions button:hover,
#party-invite.theme-forge .npc-dialog-actions button:hover,
#duel-invite.theme-forge .npc-dialog-actions button:hover {
  border-color: #6b4a28;
  color: #fbd38d;
}

.social-invite-dialog.theme-forge .trade-accept-btn,
#trade-invite.theme-forge .trade-accept-btn,
#party-invite.theme-forge .trade-accept-btn,
#duel-invite.theme-forge .trade-accept-btn {
  border: 2px solid #ed8936 !important;
  background: linear-gradient(180deg, rgba(237, 137, 54, 0.35) 0%, rgba(180, 80, 20, 0.25) 100%);
  color: #fbd38d !important;
}

.social-invite-dialog.theme-forge .trade-accept-btn:hover,
#trade-invite.theme-forge .trade-accept-btn:hover,
#party-invite.theme-forge .trade-accept-btn:hover,
#duel-invite.theme-forge .trade-accept-btn:hover {
  filter: brightness(1.08);
}

.smith-header-portrait {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.smith-portrait-img,
.smith-portrait-fallback {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid #4a3420;
  background: #1a1410;
  object-fit: contain;
  object-position: bottom center;
  flex-shrink: 0;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
}

.smith-portrait-fallback {
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.smith-portrait-fallback.hidden,
.smith-portrait-img.hidden {
  display: none;
}

.smith-header-text {
  min-width: 0;
}

.smith-header-text h2 {
  margin: 0;
  font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fbd38d;
  letter-spacing: 0.2px;
}

.smith-tagline {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: #a0aec0;
  line-height: 1.35;
}

.smith-money-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid #3d3428;
  color: #a0aec0;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.smith-money-row strong {
  color: #fbd38d;
}

#smith-body {
  padding: 10px 12px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

#scribe-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 85;
}

#scribe-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 16px));
  max-height: min(560px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: rgba(12, 16, 28, 0.96);
  border: 1px solid #9ae6b4;
  border-radius: 10px;
  z-index: 90;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

#scribe-body {
  padding: 10px 14px 14px;
  overflow-y: auto;
}

.scribe-status {
  padding: 6px 14px;
  color: #9ae6b4;
  font-size: 0.85rem;
  border-bottom: 1px solid #2d3748;
}

.scribe-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.scribe-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid #4a5568;
  background: #1a202c;
  color: #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
}

.scribe-tab.active {
  border-color: #9ae6b4;
  color: #9ae6b4;
}

.scribe-stub {
  color: #a0aec0;
  padding: 12px 4px;
}

.scribe-fuse-header {
  color: #a0aec0;
  font-size: 0.85rem;
  margin-bottom: 10px;
  line-height: 1.4;
}

.scribe-fuse-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #2d3748;
}

.scribe-tome-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scribe-tome-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scribe-tome-icon {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

.scribe-tome-icon .slot-icon-img,
.scribe-tome-icon img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}

.scribe-fuse-icon {
  flex-shrink: 0;
}

.scribe-tome-text {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.scribe-tome-qty {
  color: #a0aec0;
  font-size: 0.85rem;
}

.scribe-tome-empty {
  color: #a0aec0;
  font-size: 0.85rem;
}

.scribe-cost {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.scribe-cost-tome {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
}

.scribe-cost-tome .slot-icon-img,
.scribe-cost-tome img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.scribe-fuse-info {
  flex: 1;
}

.scribe-fuse-count,
.scribe-fuse-cost,
.scribe-fuse-chance {
  margin-top: 2px;
  color: #a0aec0;
  font-size: 0.85rem;
}

.scribe-hint {
  margin: 0 0 10px;
  color: #a0aec0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.scribe-subhead {
  margin: 12px 0 4px;
  color: #cbd5e0;
  font-size: 0.9rem;
  font-weight: 600;
}

.scribe-skill-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #2d3748;
}

.scribe-skill-info {
  flex: 1;
}

.scribe-skill-info p {
  margin: 4px 0 0;
  color: #a0aec0;
  font-size: 0.85rem;
  white-space: pre-line;
}

.scribe-lv {
  margin-top: 2px;
  color: #e2e8f0;
  font-size: 0.85rem;
}

.scribe-cost {
  margin-top: 6px;
  color: #cbd5e0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.scribe-cost.is-max {
  color: #68d391;
}

.scribe-cost.is-warn {
  color: #f6ad55;
}

.scribe-cost-gate {
  margin-top: 2px;
  color: #f6e05e;
  font-size: 0.78rem;
}

.scribe-have.is-ok {
  color: #9ae6b4;
}

.scribe-have.is-short {
  color: #fc8181;
}

.scribe-kind {
  margin-left: 8px;
  font-size: 0.75rem;
  color: #68d391;
}

.scribe-skill-row button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tome-normal { color: #68d391; }
.tome-rare { color: #63b3ed; }
.tome-epic { color: #fc8181; }
.tome-legendary { color: #f6e05e; }

.smith-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.smith-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 999px;
  border: 2px solid #3d3428;
  background: linear-gradient(180deg, #242018 0%, #181614 100%);
  color: #cbd5e0;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.smith-tab.active {
  border-color: #ed8936;
  color: #fbd38d;
  background: linear-gradient(180deg, #4a3020 0%, #281810 100%);
  box-shadow: inset 0 0 12px rgba(237, 137, 54, 0.2);
}

#market-overlay,
#mail-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 85;
}

#market-panel,
#mail-panel,
#vendor-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 16px));
  max-height: min(560px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: rgba(12, 16, 28, 0.96);
  border: 1px solid #68d391;
  border-radius: 10px;
  z-index: 90;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

#vendor-panel {
  z-index: 100;
  background: rgba(12, 16, 28, 0.97);
}

#mail-panel {
  border-color: #90cdf4;
}

.market-money-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid #2d3748;
  color: #a0aec0;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.market-money-row strong {
  color: #f6d365;
}

.market-hint {
  padding: 6px 14px;
  color: #a0aec0;
  font-size: 0.75rem;
  border-bottom: 1px solid #2d3748;
  flex-shrink: 0;
}

.market-status {
  padding: 6px 14px;
  font-size: 0.8rem;
  color: #9ae6b4;
  background: rgba(72, 187, 120, 0.12);
  border-bottom: 1px solid #2d3748;
  flex-shrink: 0;
}

.market-status.is-error {
  color: #feb2b2;
  background: rgba(229, 62, 62, 0.15);
}

#market-browse-wrap,
#market-sell-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.market-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #2d3748;
  flex-shrink: 0;
}

.market-cat {
  padding: 5px 10px;
  border: 1px solid #4a5568;
  background: #1a2035;
  color: #cbd5e0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.75rem;
}

.market-cat.active {
  border-color: #68d391;
  color: #9ae6b4;
  background: rgba(104, 211, 145, 0.15);
}

.market-list-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 10px 10px;
  min-height: 0;
  max-height: min(360px, 48vh);
  -webkit-overflow-scrolling: touch;
}

.market-bag-scroll {
  max-height: min(280px, 40vh);
}

.market-row {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid #2d3748;
  border-radius: 8px;
  background: rgba(26, 32, 53, 0.9);
  color: #e2e8f0;
  cursor: pointer;
}

.market-row:hover {
  border-color: #68d391;
  background: rgba(104, 211, 145, 0.08);
}

.market-row-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  margin-bottom: 3px;
  border-radius: 6px;
}

.market-row-line {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.market-row-compact .market-row-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #f7fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.market-row-compact .market-row-time {
  flex-shrink: 0;
  font-size: 0.62rem;
  color: #a0aec0;
  white-space: nowrap;
}

.market-row-compact .market-row-price {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  color: #f6d365;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.market-row-compact .market-row-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.market-row-compact .market-row-icon .slot-icon-img {
  width: 24px;
  height: 24px;
}

.market-row-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 1.1rem;
}

.market-row-icon .slot-icon-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: auto;
}

.market-row-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #f7fafc;
}

.market-row-sub {
  margin-top: 2px;
  font-size: 0.72rem;
  color: #a0aec0;
}

.market-row-price {
  font-size: 0.8rem;
  color: #f6d365;
  white-space: nowrap;
}

.market-footer {
  flex-shrink: 0;
  padding: 8px 12px 12px;
  border-top: 1px solid #2d3748;
  background: rgba(12, 16, 28, 0.98);
}

.market-footer-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #68d391;
  background: rgba(104, 211, 145, 0.18);
  color: #c6f6d5;
  font-weight: 600;
  cursor: pointer;
}

.market-footer-btn:hover {
  filter: brightness(1.08);
}

/* Desktop — ตลาด Lia browse: ซ้ายแท็บ+ฝากขาย / ขวารายการ (อ้างอิงมือถือแนวนอน) */
@media (min-width: 769px) {
  #market-panel #market-browse-wrap:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(96px, 0.88fr) minmax(0, 1.32fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      'tabs list'
      'sell list';
    gap: 0;
    min-height: 0;
    flex: 1 1 auto;
  }
  #market-panel #market-browse-wrap .market-cat-tabs {
    grid-area: tabs;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    padding: 8px 8px 4px;
    overflow: hidden;
    border-bottom: none;
    border-right: 1px solid #2d3748;
    min-height: 0;
  }
  #market-panel #market-browse-wrap .market-cat {
    width: 100%;
    text-align: center;
    font-size: 0.72rem;
    padding: 6px 8px;
    min-height: 28px;
    border-radius: 6px;
    flex: 0 0 auto;
  }
  #market-panel #market-browse-wrap #market-listings.market-list-scroll {
    grid-area: list;
    min-height: 0;
    max-height: none;
    padding: 6px 8px 8px;
  }
  #market-panel #market-browse-wrap .market-footer {
    grid-area: sell;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    align-self: stretch;
    border-top: none;
    border-right: 1px solid #2d3748;
    padding: 0 8px 8px;
    box-shadow: none;
    background: transparent;
  }
  #market-panel #market-browse-wrap .market-footer-btn {
    width: 100%;
    min-height: 28px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px 8px;
    line-height: 1.2;
    white-space: nowrap;
    border-radius: 6px;
    border-width: 1px;
  }

  /* Desktop — ธีม forge (Torin) ทุกแผง NPC (ยกเว้นขนาด Torin 760px) */
  #warehouse-panel.theme-forge,
  #scribe-panel.theme-forge,
  #market-panel.theme-forge,
  #premium-panel.theme-forge,
  #vendor-panel.theme-forge,
  #dungeon-panel.theme-forge {
    background: linear-gradient(165deg, #2e2418 0%, #14100c 100%);
    border: 2px solid #6b4a28;
    border-radius: 14px;
    box-shadow:
      0 0 0 1px #0a0806,
      0 0 0 3px #2a1c10,
      inset 0 1px 0 rgba(255, 180, 100, 0.1),
      0 12px 36px rgba(0, 0, 0, 0.65);
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  }

  .theme-forge .smith-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 44px 10px 12px;
    border-bottom: 2px solid #4a3420;
    background: linear-gradient(180deg, rgba(237, 137, 54, 0.14) 0%, transparent 100%);
    position: relative;
  }

  .theme-forge .smith-panel-header .menu-close-btn,
  .theme-forge .smith-panel-header .warehouse-panel-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border-radius: 8px;
    border: 2px solid #4a4030;
    background: linear-gradient(180deg, #2a2620 0%, #141210 100%);
    color: #fbd38d;
  }

  .theme-forge .smith-header-text h2 {
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fbd38d;
    letter-spacing: 0.2px;
  }

  .theme-forge .smith-tagline {
    font-size: 0.72rem;
    color: #a0aec0;
  }

  .theme-forge .smith-money-row,
  .theme-forge .market-money-row {
    border-bottom-color: #3d3428;
    color: #a0aec0;
    font-size: 0.85rem;
  }

  .theme-forge .smith-money-row strong,
  .theme-forge .market-money-row strong {
    color: #fbd38d;
  }

  .theme-forge .market-hint,
  .theme-forge .scribe-status,
  .theme-forge .market-status {
    border-bottom-color: #3d3428;
  }

  #market-panel.theme-forge #market-browse-wrap .market-cat-tabs,
  #market-panel.theme-forge #market-browse-wrap .market-footer {
    border-right-color: #3d3428;
  }

  /* Desktop forge — แท็บ/ปุ่มเมนูภายในแผง (อ้างอิง Torin .smith-tab / .smith-forge-btn) */
  .theme-forge .scribe-tab,
  .theme-forge .market-cat,
  .theme-forge .vendor-tab {
    border: 2px solid #3d3428;
    background: linear-gradient(180deg, #242018 0%, #181614 100%);
    color: #cbd5e0;
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  }

  .theme-forge .scribe-tab.active,
  .theme-forge .market-cat.active,
  .theme-forge .vendor-tab.is-active {
    border-color: #ed8936;
    color: #fbd38d;
    background: linear-gradient(180deg, #4a3020 0%, #281810 100%);
    box-shadow: inset 0 0 12px rgba(237, 137, 54, 0.2);
  }

  .theme-forge .market-cat-tabs {
    border-bottom-color: #3d3428;
  }

  .theme-forge .market-footer {
    border-top-color: #3d3428;
    background: transparent;
  }

  .theme-forge .market-footer-btn,
  .theme-forge .premium-buy-btn,
  .theme-forge .dungeon-enter-btn,
  .theme-forge .scribe-skill-row button,
  .theme-forge .scribe-fuse-row button {
    padding: 8px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
    border: 2px solid #ed8936;
    background: linear-gradient(180deg, rgba(237, 137, 54, 0.35) 0%, rgba(180, 80, 20, 0.25) 100%);
    color: #fbd38d;
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 200, 120, 0.15);
    cursor: pointer;
  }

  .theme-forge .market-footer-btn:hover,
  .theme-forge .premium-buy-btn:not(:disabled):hover,
  .theme-forge .dungeon-enter-btn:not(:disabled):hover,
  .theme-forge .scribe-skill-row button:not(:disabled):hover,
  .theme-forge .scribe-fuse-row button:not(:disabled):hover {
    filter: brightness(1.08);
  }

  .theme-forge .premium-buy-btn:disabled,
  .theme-forge .dungeon-enter-btn:disabled,
  .theme-forge .scribe-skill-row button:disabled,
  .theme-forge .scribe-fuse-row button:disabled {
    opacity: 0.38;
    cursor: not-allowed;
  }

  .theme-forge .market-back-btn,
  .theme-forge .dungeon-footer button {
    border-radius: 8px;
    border: 2px solid #3d3428;
    background: linear-gradient(180deg, #242018 0%, #181614 100%);
    color: #cbd5e0;
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
    cursor: pointer;
  }

  .theme-forge .market-back-btn:hover,
  .theme-forge .dungeon-footer button:hover {
    border-color: #6b4a28;
    color: #fbd38d;
  }

  .theme-forge .warehouse-money-tap {
    border: 2px solid #3d3428;
    background: linear-gradient(180deg, #242018 0%, #181614 100%);
  }

  .theme-forge .warehouse-money-tap:hover:not(:disabled) {
    border-color: #ed8936;
    background: linear-gradient(180deg, #302418 0%, #1c1610 100%);
  }

  .theme-forge .warehouse-money-tap.is-deposit:not(:disabled),
  .theme-forge .warehouse-money-tap.is-withdraw:not(:disabled) {
    border-color: #3d3428;
  }

  .theme-forge .warehouse-money-tap.is-deposit:not(:disabled):hover,
  .theme-forge .warehouse-money-tap.is-withdraw:not(:disabled):hover {
    border-color: #ed8936;
  }

  .theme-forge .warehouse-money-amount,
  .theme-forge #warehouse-bag-money,
  .theme-forge #warehouse-vault-money {
    color: #fbd38d;
  }

  /* Keln/Lia — ปุ่มบนช่องไอเทม คงสไตล์เดิม (อ่านง่ายบนช่องเล็ก) */
  #warehouse-panel.theme-forge .slot-action-btn,
  #market-panel.theme-forge .slot-action-btn {
    border: 1px solid #718096;
    background: #2d3748;
    color: #e2e8f0;
    border-radius: 2px;
    padding: 1px 3px;
    font-size: 0.5rem;
    font-weight: 400;
    box-shadow: none;
  }

  .theme-forge .dungeon-diff-row {
    border-color: #4a3420;
    background: rgba(40, 24, 16, 0.5);
  }

  .theme-forge .dungeon-group-title {
    color: #fbd38d;
  }

  #market-panel.theme-forge #market-browse-wrap .market-cat {
    border: 2px solid #3d3428;
    background: linear-gradient(180deg, #242018 0%, #181614 100%);
    color: #cbd5e0;
  }

  #market-panel.theme-forge #market-browse-wrap .market-cat.active {
    border-color: #ed8936;
    color: #fbd38d;
    background: linear-gradient(180deg, #4a3020 0%, #281810 100%);
    box-shadow: inset 0 0 12px rgba(237, 137, 54, 0.2);
  }

  #market-panel.theme-forge #market-browse-wrap .market-footer-btn {
    border: 2px solid #ed8936;
    background: linear-gradient(180deg, rgba(237, 137, 54, 0.35) 0%, rgba(180, 80, 20, 0.25) 100%);
    color: #fbd38d;
  }

  /* เทรด — Desktop เท่านั้น (มือถือคง CSS เดิม · ไม่แตะ media max-width) */
  #trade-panel.theme-forge {
    background: linear-gradient(165deg, #2e2418 0%, #14100c 100%);
    border: 2px solid #6b4a28;
    border-radius: 14px;
    box-shadow:
      0 0 0 1px #0a0806,
      0 0 0 3px #2a1c10,
      inset 0 1px 0 rgba(255, 180, 100, 0.1),
      0 12px 36px rgba(0, 0, 0, 0.65);
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
  }

  #trade-panel.theme-forge .player-menu-header {
    position: relative;
    padding: 10px 44px 10px 12px;
    border-bottom: 2px solid #4a3420;
    background: linear-gradient(180deg, rgba(237, 137, 54, 0.14) 0%, transparent 100%);
  }

  #trade-panel.theme-forge .player-menu-header h2 {
    margin: 0;
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fbd38d;
    letter-spacing: 0.2px;
  }

  #trade-panel.theme-forge .menu-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    border-radius: 8px;
    border: 2px solid #4a4030;
    background: linear-gradient(180deg, #2a2620 0%, #141210 100%);
    color: #fbd38d;
  }

  #trade-panel.theme-forge .trade-status {
    color: #a0aec0;
    border-bottom-color: #3d3428;
  }

  #trade-panel.theme-forge .trade-bag-section {
    border-top-color: #3d3428;
  }

  #trade-panel.theme-forge .trade-bag-head {
    color: #a0aec0;
  }

  #trade-panel.theme-forge .trade-bag-balance {
    color: #fbd38d;
  }

  #trade-panel.theme-forge .trade-side-actions button,
  #trade-panel.theme-forge .trade-bag-money-actions button {
    border: 2px solid #3d3428;
    border-radius: 8px;
    background: linear-gradient(180deg, #242018 0%, #181614 100%);
    color: #cbd5e0;
    font-family: "Sarabun", "Segoe UI", system-ui, sans-serif;
    font-weight: 600;
  }

  #trade-panel.theme-forge .trade-side-actions button:hover,
  #trade-panel.theme-forge .trade-bag-money-actions button:hover {
    border-color: #6b4a28;
    color: #fbd38d;
  }

  #trade-panel.theme-forge #trade-confirm-btn {
    border: 2px solid #ed8936;
    background: linear-gradient(180deg, rgba(237, 137, 54, 0.35) 0%, rgba(180, 80, 20, 0.25) 100%);
    color: #fbd38d;
  }

  #trade-panel.theme-forge #trade-confirm-btn:hover {
    filter: brightness(1.08);
  }

  #trade-panel.theme-forge #trade-confirm-btn.is-confirmed {
    border-color: #48bb78;
    color: #9ae6b4;
    background: rgba(72, 187, 120, 0.15);
  }

  #trade-panel.theme-forge .trade-bag-money-actions input {
    border: 2px solid #3d3428;
    background: #141210;
    color: #e2e8f0;
  }

  #trade-panel.theme-forge .trade-offer-empty {
    border-color: #3d3428;
    color: #718096;
  }
}

.market-sell-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #2d3748;
  color: #e2e8f0;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.market-back-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #4a5568;
  background: #1a2035;
  color: #cbd5e0;
  cursor: pointer;
  font-size: 0.75rem;
}

.market-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: #a0aec0;
  font-size: 0.8rem;
  border-bottom: 1px solid #2d3748;
  flex-shrink: 0;
}

.market-price-label {
  margin-right: 4px;
}

.market-price-row input {
  width: 58px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid #4a5568;
  background: #0f1524;
  color: #e2e8f0;
}

.market-sell-tip {
  margin: 0;
  padding: 6px 12px;
  font-size: 0.72rem;
  color: #718096;
  flex-shrink: 0;
}

.market-empty {
  color: #718096;
  font-size: 0.85rem;
  padding: 16px 8px;
  text-align: center;
}

.market-slot-grid {
  margin-top: 4px;
}

.mail-actions {
  padding: 8px 14px;
  border-bottom: 1px solid #2d3748;
}

#mail-claim-all {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #63b3ed;
  background: rgba(49, 130, 206, 0.2);
  color: #bee3f8;
  cursor: pointer;
}

#mail-list {
  padding: 10px 14px 14px;
  overflow-y: auto;
}

#mail-hud-btn {
  pointer-events: auto;
  margin-top: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  background: rgba(49, 130, 206, 0.35);
  color: #bee3f8;
  border: 1px solid rgba(144, 205, 244, 0.7);
  border-radius: 4px;
  cursor: pointer;
}

#mail-hud-btn:hover {
  filter: brightness(1.1);
}

.smith-hint {
  font-size: 0.75rem;
  color: #a0aec0;
  margin: 0 0 10px;
  line-height: 1.45;
}

.smith-repair-all {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(237, 137, 54, 0.12);
  border: 2px solid rgba(237, 137, 54, 0.45);
  border-radius: 8px;
  color: #fbd38d;
  font-size: 0.78rem;
}

.smith-layout-c {
  display: grid;
  grid-template-columns: minmax(0, 210px) minmax(0, 1fr);
  gap: 10px;
  min-height: 280px;
}

.smith-preview-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 2px solid #3d3428;
  background: rgba(0, 0, 0, 0.22);
  min-height: 0;
}

.smith-preview-detail {
  font-size: 0.75rem;
  color: #a0aec0;
  line-height: 1.45;
}

.smith-preview-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: auto;
  gap: 2px;
}

.smith-list-pane {
  overflow-y: auto;
  min-height: 0;
  max-height: 360px;
}

.smith-section {
  margin-bottom: 10px;
}

.smith-section:last-child {
  margin-bottom: 0;
}

.smith-section-title {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #d4a574;
}

.smith-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.smith-gear-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 2px solid #3d3428;
  background: linear-gradient(180deg, #242018 0%, #181614 100%);
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.35);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.smith-gear-card.is-broken {
  border-color: #fc8181;
  box-shadow: inset 0 0 0 1px rgba(252, 129, 129, 0.3);
}

.smith-gear-card.is-locked {
  opacity: 0.78;
}

.smith-gear-card.is-selected {
  border-color: #ed8936;
  box-shadow:
    inset 0 0 0 1px rgba(237, 137, 54, 0.35),
    0 0 10px rgba(237, 137, 54, 0.12);
}

.smith-gear-icon-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 2px solid #2a2418;
  background: linear-gradient(180deg, #100e0c 0%, #1a1814 100%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: inset 2px 2px 3px rgba(0, 0, 0, 0.5);
}

.smith-gear-icon-wrap.is-large {
  width: 68px;
  height: 68px;
  margin: 0 auto;
}

.smith-gear-icon-wrap.is-broken {
  border-color: #fc8181;
}

.smith-gear-icon-wrap .slot-icon-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.smith-gear-icon-wrap.is-large .slot-icon-img {
  width: 52px;
  height: 52px;
}

.smith-gear-icon-wrap .slot-icon-glyph {
  font-size: 1.1rem;
  line-height: 1;
}

.smith-gear-icon-wrap.is-large .slot-icon-glyph {
  font-size: 1.75rem;
}

.smith-gear-plus {
  position: absolute;
  bottom: -2px;
  right: -2px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.85);
  color: #fbd38d;
  font-size: 0.62rem;
  font-weight: 700;
  border: 1px solid #4a4030;
  z-index: 1;
}

.smith-gear-grade {
  position: absolute;
  top: -2px;
  left: -2px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.smith-gear-grade.grade-1 { background: #2d3748; color: #cbd5e0; }
.smith-gear-grade.grade-2 { background: #276749; color: #9ae6b4; }
.smith-gear-grade.grade-3 { background: #2c5282; color: #90cdf4; }
.smith-gear-grade.grade-4 { background: #742a2a; color: #feb2b2; }

.smith-gear-main {
  min-width: 0;
}

.smith-gear-name {
  margin: 0 0 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.smith-gear-name.is-preview {
  white-space: normal;
  text-align: center;
  font-size: 0.88rem;
}

.smith-gear-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.smith-chip {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.68rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  color: #cbd5e0;
  line-height: 1.3;
}

.smith-chip.stat { color: #9ae6b4; border-color: rgba(104, 211, 145, 0.3); }
.smith-chip.chance-high { color: #9ae6b4; border-color: rgba(104, 211, 145, 0.4); }
.smith-chip.chance-mid { color: #ecc94b; border-color: rgba(236, 201, 75, 0.4); }
.smith-chip.chance-low { color: #fc8181; border-color: rgba(252, 129, 129, 0.4); }
.smith-chip.lock { color: #a0aec0; }
.smith-chip.cost { color: #fbd38d; border-color: rgba(237, 137, 54, 0.35); }

.smith-dur-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  margin-bottom: 3px;
}

.smith-dur-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #68d391;
}

.smith-dur-bar.is-worn > span { background: #ecc94b; }
.smith-dur-bar.is-broken > span { background: #fc8181; width: 4% !important; }

.smith-dur-label {
  font-size: 0.68rem;
  color: #a0aec0;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.smith-dur-label.is-broken { color: #fc8181; }
.smith-dur-label.is-worn { color: #ecc94b; }

.smith-forge-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid #ed8936;
  background: linear-gradient(180deg, rgba(237, 137, 54, 0.35) 0%, rgba(180, 80, 20, 0.25) 100%);
  color: #fbd38d;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 200, 120, 0.15);
}

.smith-forge-btn-inline {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.78rem;
}

.smith-forge-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.smith-forge-btn-sub {
  display: block;
  font-size: 0.68rem;
  color: #a0aec0;
  text-align: center;
  line-height: 1.3;
}

/* Refine result FX — hammer/anvil dialog (reusable success/fail sprites) */
.smith-forge-fx {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(8, 6, 4, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.smith-forge-fx.is-open {
  opacity: 1;
  pointer-events: auto;
}
.smith-forge-fx-card {
  position: relative;
  width: min(168px, 48vw);
  padding: 8px;
  border-radius: 14px;
  border: 2px solid #6b4a28;
  background:
    radial-gradient(160px 120px at 50% 40%, rgba(237, 137, 54, 0.16), transparent 70%),
    linear-gradient(165deg, #2a2016 0%, #120e0a 100%);
  box-shadow:
    0 0 0 3px #2a1c10,
    0 14px 32px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 220, 160, 0.12);
  transform: scale(0.9) translateY(8px);
  transition: transform 0.2s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.smith-forge-fx.is-open .smith-forge-fx-card {
  transform: scale(1) translateY(0);
}
.smith-forge-fx-card.is-success {
  border-color: #c05621;
  box-shadow:
    0 0 0 3px #2a1c10,
    0 0 22px rgba(237, 137, 54, 0.45),
    0 14px 32px rgba(0, 0, 0, 0.7);
}
.smith-forge-fx-card.is-fail {
  border-color: #c53030;
  box-shadow:
    0 0 0 3px #2a1010,
    0 0 22px rgba(245, 101, 101, 0.4),
    0 14px 32px rgba(0, 0, 0, 0.7);
}
.smith-forge-fx-card.is-repair {
  border-color: #2b6cb0;
  box-shadow:
    0 0 0 3px #102030,
    0 0 22px rgba(99, 179, 237, 0.4),
    0 14px 32px rgba(0, 0, 0, 0.7);
}
.smith-forge-fx-stage {
  /* สัดส่วน = เฟรมแพ็กจริง (flush-top) — สไปรต์ชิดขอบเฟรม ไม่จัตุรัสว่าง */
  width: 100%;
  height: auto;
  aspect-ratio: 145 / 228;
  border-radius: 10px;
  border: 2px solid #3d3428;
  background:
    radial-gradient(circle at 50% 78%, rgba(237, 137, 54, 0.14), transparent 55%),
    linear-gradient(180deg, #1a1410 0%, #0c0a08 100%);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: stretch;
  overflow: hidden;
}
.smith-forge-fx-card.is-fail .smith-forge-fx-stage {
  aspect-ratio: 139 / 207;
  border-color: #742a2a;
  background:
    radial-gradient(circle at 50% 70%, rgba(245, 101, 101, 0.14), transparent 55%),
    linear-gradient(180deg, #1a1010 0%, #0c0808 100%);
}
.smith-forge-fx-card.is-repair .smith-forge-fx-stage {
  border-color: #2c5282;
  background:
    radial-gradient(circle at 50% 78%, rgba(99, 179, 237, 0.14), transparent 55%),
    linear-gradient(180deg, #101820 0%, #080c10 100%);
}
.smith-forge-fx-sprite {
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* legacy smith row (scribe reuses smith-money-row only) */
.smith-action {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #ed8936;
  background: rgba(237, 137, 54, 0.2);
  color: #fbd38d;
  cursor: pointer;
}

.smith-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.equip-cell.filled.is-broken,
.slot-cell.filled.is-broken {
  border-color: #fc8181;
  box-shadow: inset 0 0 0 1px rgba(252, 129, 129, 0.35);
}

.equip-cell.filled.is-broken:hover,
.slot-cell.filled.is-broken:hover,
.warehouse-slot-cell.filled.is-broken:hover {
  border-color: #fc8181;
}

.slot-dur {
  display: inline-block;
  font-size: 0.44rem;
  line-height: 1.1;
  padding: 0 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.75);
  color: #9ae6b4;
  white-space: nowrap;
  pointer-events: none;
}

.slot-dur.is-full {
  color: #9ae6b4;
}

.slot-dur.is-worn {
  color: #fbd38d;
}

.slot-dur.is-broken {
  color: #fc8181;
}

/* legacy dur badges (equip panel etc.) */
.warehouse-slot-cell .slot-dur {
  position: absolute;
  top: 2px;
  right: 2px;
}

.warehouse-money-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 12px 4px;
  flex-shrink: 0;
}

.warehouse-money-tap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 8px 10px;
  background: #1a2035;
  border: 1px solid #2d3748;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: 'Sarabun', sans-serif;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.warehouse-money-tap:hover:not(:disabled) {
  border-color: #d4a574;
  background: #1e2640;
}

.warehouse-money-tap:active:not(:disabled) {
  transform: scale(0.98);
}

.warehouse-money-tap:disabled {
  opacity: 0.45;
  cursor: default;
}

.warehouse-money-tap.is-deposit:not(:disabled) {
  border-color: #4a6741;
}

.warehouse-money-tap.is-withdraw:not(:disabled) {
  border-color: #5a4a72;
}

.warehouse-money-label {
  font-size: 0.68rem;
  color: #a0aec0;
  line-height: 1.2;
}

.warehouse-money-amount,
#warehouse-bag-money,
#warehouse-vault-money {
  color: #f6d365;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}

.warehouse-money-hint {
  margin: 0;
  padding: 0 12px 8px;
  font-size: 0.65rem;
  color: #718096;
  border-bottom: 1px solid #2d3748;
  flex-shrink: 0;
}

.warehouse-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 14px 16px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.warehouse-col h3 {
  color: #63b3ed;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.warehouse-slot-grid {
  grid-template-columns: repeat(auto-fill, 36px);
  gap: 2px;
}

.warehouse-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.warehouse-row-info {
  min-width: 0;
}

.warehouse-item-btn {
  flex-shrink: 0;
  background: #2b6cb0;
  border: 1px solid #63b3ed;
  color: #ebf8ff;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
}

@media (max-width: 640px) {
  .slot-grid,
  .warehouse-slot-grid {
    grid-template-columns: repeat(auto-fill, 32px);
    gap: 2px;
  }

  .warehouse-slot-grid {
    grid-template-columns: repeat(auto-fill, 32px);
    gap: 2px;
  }

  .slot-cell {
    width: 32px;
    height: 32px;
    max-height: none;
  }

  .slot-icon-btn {
    min-height: 32px;
  }

  .slot-icon-glyph {
    font-size: 0.85rem;
  }

  .slot-icon-img {
    width: 28px;
    height: 28px;
  }

  .equip-ro-layout {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 6px;
  }

  .equip-cell {
    width: 52px;
    height: 60px;
  }

  .equip-cell-dur {
    font-size: 0.58rem;
  }

  .warehouse-columns {
    grid-template-columns: 1fr;
  }

  #warehouse-panel {
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 112px);
  }

  .trade-sides {
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    padding: 8px 8px;
  }

  .trade-sides-divider {
    padding: 0 4px;
    transform: none;
    font-size: 0.85rem;
  }

  .trade-side {
    padding: 6px;
    gap: 5px;
  }

  .trade-side-badge {
    font-size: 0.72rem;
  }

  .trade-confirm-badge {
    font-size: 0.62rem;
    padding: 2px 5px;
  }

  .trade-offer-list {
    max-height: 72px;
    min-height: 36px;
  }

  .trade-bag-section {
    padding: 6px 8px 8px;
  }

  #trade-panel {
    width: min(calc(100vw - 16px), 380px);
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 112px);
  }
}

#mobile-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  /* à¹à¸«à¸à¸·à¸­à¹à¸à¸à¸ªà¸à¸´à¸¥ (#bottom-center-hud z=80) â à¸à¸±à¸ S1/S2 à¹à¸à¸à¸à¸±à¸à¸à¸à¹à¸¡à¹à¸à¸´à¸ */
  z-index: 90;
}

.mobile-item-hotbars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mobile-item-hotbar {
  position: absolute;
  width: 52px;
  height: 52px;
  pointer-events: auto;
}

.mobile-item-hotbar-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 2px solid rgba(99, 179, 237, 0.6);
  background: rgba(12, 16, 28, 0.82);
  color: #bee3f8;
  backdrop-filter: blur(2px);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  cursor: pointer;
  padding: 0;
}

.mobile-item-hotbar.has-item .mobile-item-hotbar-btn {
  border-color: rgba(104, 211, 145, 0.72);
}

.mobile-item-hotbar.is-empty .mobile-item-hotbar-btn {
  border-style: dashed;
  opacity: 0.78;
}

.mobile-item-hotbar.is-editing .mobile-item-hotbar-btn {
  border-color: rgba(246, 173, 85, 0.9);
  box-shadow: 0 0 0 2px rgba(246, 173, 85, 0.24);
}

.mobile-item-hotbar.is-deleting .mobile-item-hotbar-btn {
  border-color: rgba(252, 129, 129, 0.95);
  box-shadow: 0 0 0 2px rgba(252, 129, 129, 0.28);
}

.mobile-item-hotbar.is-out .mobile-item-hotbar-btn {
  opacity: 0.6;
  filter: grayscale(0.35);
}

.mobile-item-hotbar-key {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5rem;
  line-height: 1;
  color: #90cdf4;
  pointer-events: none;
}

.mobile-item-hotbar-empty {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 1.2rem;
  line-height: 1;
  color: #90cdf4;
  pointer-events: none;
}

.mobile-item-hotbar-btn .hotbar-mobile-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0 auto;
  pointer-events: none;
}

.mobile-item-hotbar-btn .hotbar-mobile-icon .slot-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.mobile-item-hotbar-btn .hotbar-mobile-qty {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 700;
  color: #c6f6d5;
  pointer-events: none;
}

.mobile-hotbar-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(252, 129, 129, 0.8);
  background: rgba(123, 30, 30, 0.95);
  color: #fff5f5;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.joystick-zone {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 120px;
  height: 120px;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(180, 140, 40, 0.22);
  border: 2px solid rgba(214, 158, 46, 0.55);
  position: relative;
  box-shadow: inset 0 0 18px rgba(214, 158, 46, 0.12);
}

.joystick-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(214, 158, 46, 0.45);
  border: 2px solid rgba(246, 224, 94, 0.7);
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -24px 0 0 -24px;
  transform: translate(0, 0);
  pointer-events: none;
  transition: transform 0.05s ease-out;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.mobile-actions {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 52px 60px;
  grid-template-rows: 52px 60px;
  gap: 8px;
  align-items: end;
  justify-items: end;
  pointer-events: auto;
}

.mobile-action-btn {
  width: 52px;
  height: 52px;
  font-size: 0.85rem;
  font-weight: bold;
  background: rgba(180, 140, 40, 0.28);
  border: 2px solid rgba(214, 158, 46, 0.5);
  color: #faf089;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(2px);
}

.mobile-action-btn:active:not(.mobile-btn-soon) {
  transform: scale(0.94);
  filter: brightness(1.15);
}

.mobile-attack-btn {
  width: 60px;
  height: 60px;
  font-size: 1.25rem;
  background: rgba(180, 50, 50, 0.55);
  border-color: rgba(252, 129, 129, 0.55);
  color: #fed7d7;
  grid-column: 2;
  grid-row: 2;
}

.mobile-skill-btn {
  position: relative;
  overflow: hidden;
  padding: 0;
}

.mobile-skill-btn .mobile-skill-key {
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  color: rgba(250, 240, 137, 0.85);
  pointer-events: none;
  z-index: 1;
}

.mobile-skill-btn .mobile-skill-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  margin-top: 0;
  pointer-events: none;
}

.mobile-skill-btn .mobile-skill-icon .skill-icon-img,
.mobile-skill-btn .mobile-skill-icon img {
  display: block;
  width: min(34px, 68%);
  height: min(34px, 68%);
  object-fit: contain;
  object-position: center center;
  image-rendering: auto;
}

.mobile-skill-btn .mobile-skill-icon .skill-icon-glyph {
  font-size: 1.1rem;
  line-height: 1;
}

.mobile-skill-btn.has-skill {
  border-color: rgba(104, 211, 145, 0.65);
  color: #c6f6d5;
}

.mobile-skill-btn.is-empty {
  opacity: 0.55;
}

.mobile-skill-btn.is-cooldown {
  opacity: 0.7;
  filter: grayscale(0.35);
}

.mobile-btn-soon {
  opacity: 0.4;
  font-size: 0.7rem;
  cursor: default;
}

#dev-panel {
  position: absolute;
  top: 210px;
  right: 12px;
  max-height: calc(100vh - 230px);
  max-width: min(280px, calc(100vw - 24px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.8);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #f6d365;
  z-index: 100;
  -webkit-overflow-scrolling: touch;
}

#dev-panel h3 {
  font-size: 0.85rem;
  color: #f6d365;
  margin-bottom: 8px;
}

.dev-char-level {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(246, 211, 101, 0.35);
}

.dev-char-level h4 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: #f6d365;
}

#dev-panel button {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 6px;
  cursor: pointer;
  background: #2d3748;
  color: #e2e8f0;
  border: 1px solid #4a5568;
  border-radius: 4px;
}

#dev-panel select {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 6px;
  background: #1a202c;
  color: #e2e8f0;
  border: 1px solid #4a5568;
  border-radius: 4px;
}

.dev-skill-reset {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(246, 211, 101, 0.35);
}

.dev-skill-reset h4 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: #f6d365;
}

.dev-skill-reset p {
  margin: 0 0 8px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: rgba(226, 232, 240, 0.82);
}

#help-bar {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
  .desktop-hint { display: none; }
  .mobile-hint { display: inline !important; }
  #mobile-controls { display: block !important; }
  #minimap-wrap {
    top: max(8px, env(safe-area-inset-top));
    right: max(14px, calc(env(safe-area-inset-right) + 6px));
  }
  /* à¹à¸à¸à¸à¸µà¹à¹à¸¥à¸: à¸«à¹à¸­à¸à¸²à¸¡à¸£à¸¹à¸ Â· à¸¥à¸à¸à¸­à¸à¸à¸³à¸à¹à¸²à¸¢à¸à¸§à¸² */
  #world-map-panel {
    width: max-content;
    max-width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 8px;
  }
  #world-map-panel .player-menu-header {
    padding: 6px 10px;
  }
  #world-map-panel .player-menu-header h2 {
    font-size: 0.85rem;
  }
  #world-map-body {
    padding: 2px 4px 6px;
  }
  #world-map-img {
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 56px);
  }
  /* à¸¡à¸·à¸­à¸à¸·à¸­: à¸à¸¸à¹à¸¡à¹à¸à¹à¸¡à¸à¸­à¸­à¸¢à¸¹à¹à¹à¸à¹à¸à¸§à¸à¸·à¹à¸­ â à¸à¸¢à¸²à¸¢à¸à¸·à¹à¸à¸à¸µà¹à¹à¸à¸° */
  #fullscreen-btn:not(.hidden) {
    position: static;
    transform: none;
    margin-top: 0;
    padding: 2px 5px;
    font-size: 0.52rem;
    font-weight: 600;
    color: #faf089;
    background: rgba(8, 12, 18, 0.45);
    border: 1px solid rgba(214, 158, 46, 0.55);
    border-radius: 4px;
    backdrop-filter: blur(2px);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  #fullscreen-btn[aria-pressed='true'] {
    color: #9ae6b4;
    border-color: rgba(104, 211, 145, 0.65);
  }
  #dev-panel {
    top: 200px;
    max-height: calc(100vh - 220px);
  }
  /* HUD à¸à¹à¸²à¸¢ â à¸ªà¸±à¸à¸ªà¹à¸§à¸à¸¡à¸·à¸­à¸à¸·à¸­ (à¸¢à¹à¸­à¸à¸²à¸à¹à¸à¸ªà¸à¹à¸à¹à¸­à¸) */
  #hud {
    top: max(6px, env(safe-area-inset-top));
    left: max(6px, env(safe-area-inset-left));
  }
  .hud-block {
    min-width: 0;
    max-width: min(132px, 40vw);
    padding: 3px 5px;
    border-radius: 4px;
  }
  .hud-title-row {
    gap: 3px;
    margin-bottom: 2px;
  }
  #player-name {
    font-size: 0.6rem;
  }
  .bar-row {
    grid-template-columns: 22px 1fr auto;
    gap: 3px;
    margin-bottom: 1px;
  }
  .bar {
    height: 5px;
    border-radius: 2px;
  }
  .bar-label,
  .bar-value {
    font-size: 0.5rem;
  }
  .bar-value {
    min-width: 30px;
  }
  .hud-meta {
    margin-top: 1px;
    line-height: 1.15;
  }
  #map-info {
    font-size: 0.52rem;
    margin-top: 0;
  }
  #logout-btn {
    margin-top: 3px;
    padding: 1px 5px;
    font-size: 0.52rem;
  }
  #chat-panel {
    bottom: max(140px, calc(16px + env(safe-area-inset-bottom) + 120px));
    width: min(260px, 52vw);
    padding: 4px 5px;
    gap: 3px;
  }
  #chat-logs,
  .chat-log {
    max-height: 80px;
    height: 80px;
    font-size: 0.65rem;
    line-height: 1.2;
  }
  #chat-tabs button {
    padding: 2px 5px;
    font-size: 0.62rem;
  }
  #chat-tap-hint {
    font-size: 0.6rem;
  }
  #chat-compose input,
  #chat-input {
    font-size: 0.72rem;
  }

  /* à¹à¸à¸à¹à¸à¸¡à¸à¸µà¸¡à¸·à¸­à¸à¸·à¸­ â à¸à¸²à¸ +40% à¹à¸¥à¹à¸§à¸¥à¸à¸­à¸µà¸ 10% */
  .mobile-actions {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    grid-template-columns: 66px 76px;
    grid-template-rows: 66px 76px;
    gap: 10px;
  }
  .mobile-item-hotbar,
  .mobile-item-hotbar-btn {
    width: 66px;
    height: 66px;
  }
  .mobile-item-hotbar-btn {
    border-radius: 16px;
  }
  .mobile-item-hotbar-btn .hotbar-mobile-icon {
    width: 34px;
    height: 34px;
    margin: 0 auto;
  }
  .mobile-item-hotbar-btn .hotbar-mobile-icon .slot-icon-img {
    width: 34px;
    height: 34px;
  }
  .mobile-item-hotbar-btn .hotbar-mobile-qty {
    right: 8px;
    bottom: 6px;
    font-size: 0.8rem;
  }
  .mobile-item-hotbar-key {
    top: 4px;
    font-size: 0.58rem;
  }
  .mobile-action-btn {
    width: 66px;
    height: 66px;
    font-size: 1.05rem;
  }
  .mobile-attack-btn {
    width: 76px;
    height: 76px;
    font-size: 1.55rem;
  }
  .mobile-btn-soon {
    font-size: 0.85rem;
  }

  #right-dock {
    top: max(148px, calc(env(safe-area-inset-top) + 140px));
    right: max(10px, calc(env(safe-area-inset-right) + 4px));
    max-width: min(240px, 52vw);
    gap: 4px;
  }
  #menu-dock {
    gap: 4px;
  }
  #menu-dock button {
    padding: 4px 7px;
    font-size: 0.62rem;
    border-radius: 5px;
  }
  #audio-settings-overlay {
    z-index: 94;
  }
  #audio-settings-panel {
    z-index: 95;
    top: max(52px, calc(env(safe-area-inset-top) + 44px));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(232px, calc(100vw - 28px));
    border-radius: 7px;
  }
  .audio-settings-header {
    padding: 7px 10px 4px;
  }
  .audio-settings-header h2 {
    font-size: 0.8rem;
  }
  .audio-settings-body {
    padding: 8px 10px 10px;
    gap: 10px;
  }
  .audio-settings-row {
    gap: 4px;
  }
  .audio-settings-label {
    font-size: 0.72rem;
  }
  .audio-settings-pct {
    font-size: 0.68rem;
  }
  .audio-mute-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0.82rem;
    border-radius: 6px;
  }
  .status-alert {
    padding: 4px 6px;
    font-size: 0.55rem;
    border-radius: 3px;
  }
  .status-alert strong {
    font-size: 0.58rem;
  }
  .broken-gear-doll {
    width: 24px;
    height: 40px;
  }
  #broken-gear-banner {
    gap: 5px;
  }

  #minimap-wrap {
    transform: scale(0.88);
    transform-origin: top right;
  }

  #bottom-center-hud {
    gap: 10px;
    bottom: max(48px, calc(8px + env(safe-area-inset-bottom)));
    max-width: calc(100vw - 12px);
  }

  /* Skill / ammo bar â à¸¢à¹à¸­à¹à¸«à¹à¸à¸­à¸à¸µà¸à¸­à¹à¸à¸£à¸¨à¸±à¸à¸à¹ */
  #skill-bar-hud {
    gap: 4px;
  }
  .ammo-hud {
    height: 40px;
    padding: 0 7px;
    font-size: 11px;
    border-radius: 6px;
  }
  #skill-bar-page-btn {
    width: 34px;
    height: 40px;
    flex-basis: 34px;
    border-radius: 6px;
    font-size: 0.75rem;
  }
  .skill-slot-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    max-width: 40px;
    flex-basis: 40px;
    border-radius: 6px;
  }

  /* NPC dialog */
  #npc-dialog {
    width: min(320px, calc(100vw - 16px));
    padding: 7px 9px 15px;
    border-radius: 8px;
  }
  #npc-dialog-close {
    top: 4px;
    right: 4px;
    font-size: 1rem;
    padding: 1px 4px;
  }
  .npc-dialog-body {
    min-height: 72px;
    gap: 6px;
  }
  #npc-dialog.has-portrait .npc-dialog-portrait-col {
    width: 72px;
  }
  .npc-dialog-portrait {
    width: 64px;
    height: 64px;
  }
  .npc-dialog-role {
    font-size: 0.62rem;
    margin-bottom: 2px;
  }
  #npc-dialog-text {
    font-size: 0.75rem;
    line-height: 1.35;
    min-height: 2.2em;
    margin: 0 0 6px;
  }
  .npc-dialog-nameplate {
    left: 8px;
    padding: 3px 10px 4px;
    border-radius: 5px;
  }
  #npc-dialog-name {
    font-size: 0.75rem;
  }
  #npc-dialog-action,
  #npc-dialog-next {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  /* Character menu — dual Status/Bag มือถือ (ไม่ทับแถบสkill) */
  #player-menu {
    top: 42%;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 112px);
    border-radius: 8px;
    border-width: 1px;
  }
  #player-menu:not(.is-dual-layout) {
    width: min(252px, calc(100vw - 16px));
  }
  #player-menu.theme-round-gold {
    border-radius: 10px;
    border-width: 2px;
  }
  #player-menu.theme-round-gold:not(.is-dual-layout) {
    width: fit-content;
    max-width: min(480px, calc(100vw - 16px));
  }
  #player-menu.theme-round-gold.is-dual-layout {
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    min-height: 0;
    overflow: hidden;
  }
  #player-menu.is-dual-layout .player-menu-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }
  #player-menu.is-dual-layout .menu-dual-layout {
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
    align-items: stretch;
  }
  #player-menu.is-dual-layout .menu-equip-column,
  #player-menu.is-dual-layout .menu-detail-column {
    width: auto;
    min-width: 0;
    max-width: none;
    overflow: hidden;
  }
  #player-menu.is-dual-layout .menu-detail-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #player-menu.is-dual-layout .menu-detail-panel:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    min-width: 0;
  }
  #player-menu.is-dual-layout .stat-grid.panel-scroll {
    flex: 1 1 auto;
    min-height: 120px;
    overflow-y: auto;
  }
  #player-menu.is-dual-layout .inv-panel {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
  }
  #player-menu.is-dual-layout .inv-scroll-wrap {
    flex: 1 1 auto;
    min-height: 88px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  #player-menu.is-dual-layout .equip-ro-layout,
  #player-menu.is-dual-layout .equip-costume-preview-layout {
    grid-template-columns: 28px minmax(0, 1fr) 28px;
    column-gap: 3px;
    row-gap: 2px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  #player-menu.is-dual-layout .equip-char.equip-char-floating {
    width: 100%;
    max-width: 88px;
    justify-self: center;
  }
  #player-menu.is-dual-layout .equip-cell {
    width: 28px;
    height: 28px;
    max-width: 100%;
    padding: 1px;
    font-size: 0.55rem;
  }
  #player-menu.is-dual-layout .equip-cell.is-empty .equip-cell-label {
    font-size: 0.55rem;
    font-weight: 600;
    -webkit-font-smoothing: auto;
  }
  #player-menu.is-dual-layout .slot-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 2px;
    box-sizing: border-box;
  }
  #player-menu.is-dual-layout .slot-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    min-width: 0;
    max-width: none;
  }
  #player-menu.is-dual-layout .slot-icon-btn {
    min-height: 0;
    width: 100%;
    height: 100%;
  }
  #player-menu.is-dual-layout .slot-icon-img {
    width: min(24px, 88%);
    height: min(24px, 88%);
  }
  #player-menu.is-dual-layout .stat-row {
    font-size: 0.72rem;
    padding: 4px 5px;
  }
  #player-menu.is-dual-layout .inv-summary,
  #player-menu.is-dual-layout .bag-footer {
    font-size: 0.68rem;
  }
  #player-menu.is-dual-layout .inv-cat-btn,
  #player-menu.is-dual-layout .equip-view-btn {
    font-size: 0.68rem;
  }
  #player-menu.is-dual-layout .col-title,
  #player-menu.is-dual-layout .col-title-row .col-title {
    font-size: 0.72rem;
  }
  #player-menu.is-dual-layout .inv-sort-btn {
    font-size: 0.65rem;
    padding: 2px 7px;
  }
  #player-menu.is-dual-layout .equip-bonus {
    font-size: 0.62rem;
    margin-top: 3px;
  }
  #player-menu.is-dual-layout .equip-costume-locked-banner {
    font-size: 0.65rem;
    padding: 4px 6px;
  }
  #player-menu.is-dual-layout .equip-costume-hint {
    font-size: 0.6rem;
  }
  .player-menu-header {
    padding: 5px 7px;
  }
  .player-menu-header h2 {
    font-size: 0.72rem;
    letter-spacing: 0.3px;
  }
  .menu-close-btn {
    width: 22px;
    height: 22px;
    font-size: 0.85rem;
    border-radius: 4px;
  }
  .player-menu-tabs {
    gap: 2px;
    padding: 4px 5px;
  }
  .player-menu-tabs button {
    padding: 3px 5px;
    font-size: 0.55rem;
    border-radius: 4px;
  }
  #player-menu.theme-round-gold .player-menu-tabs button {
    font-size: 0.68rem;
    padding: 4px 8px;
  }
  #player-menu:not(.is-dual-layout) .player-menu-body {
    padding: 5px 7px 8px;
  }
  .stat-row {
    gap: 5px;
    padding: 3px 4px;
    font-size: 0.58rem;
  }
  .inv-summary {
    font-size: 0.55rem;
    margin-bottom: 4px;
  }
  .inv-cat-tabs {
    gap: 3px;
    margin-bottom: 5px;
  }
  .inv-cat-btn {
    padding: 2px 5px;
    font-size: 0.52rem;
  }
  .menu-placeholder,
  .trade-social-hint {
    font-size: 0.58rem;
  }
  #player-menu.theme-round-gold .menu-full-panel .menu-placeholder,
  #player-menu.theme-round-gold .menu-full-panel .menu-empty {
    font-size: 0.78rem;
  }
  #player-menu.theme-round-gold .menu-full-panel > .menu-placeholder {
    font-size: 0.85rem;
  }
  #player-menu.theme-round-gold .trade-social-hint {
    font-size: 0.85rem;
  }
  #player-menu:not(.is-dual-layout) .slot-grid,
  #player-menu .warehouse-slot-grid {
    grid-template-columns: repeat(auto-fill, 28px);
    gap: 2px;
  }
  #player-menu:not(.is-dual-layout) .slot-cell {
    width: 28px;
    height: 28px;
  }
  #player-menu:not(.is-dual-layout) .slot-icon-btn {
    min-height: 28px;
  }
  #player-menu:not(.is-dual-layout) .slot-icon-img {
    width: 24px;
    height: 24px;
  }
  #player-menu:not(.is-dual-layout) .equip-ro-layout {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 4px;
  }
  #player-menu:not(.is-dual-layout) .equip-cell {
    width: 40px;
    height: 48px;
  }

  /* à¹à¸à¸ NPC / à¸£à¸°à¸à¸à¸à¸µà¹à¸¢à¸²à¸§ â à¸à¸­à¸à¸¥à¹à¸²à¸à¸­à¸¢à¸¹à¹à¹à¸«à¸à¸·à¸­à¹à¸à¸à¸ªà¸à¸´à¸¥ */
  /* มือถือ — ยังไม่ใช้ portrait/tagline แบบ Torin (เฉพาะ smith) */
  #warehouse-panel.theme-forge .smith-portrait-img,
  #warehouse-panel.theme-forge .smith-portrait-fallback,
  #warehouse-panel.theme-forge .smith-tagline,
  #scribe-panel.theme-forge .smith-portrait-img,
  #scribe-panel.theme-forge .smith-portrait-fallback,
  #scribe-panel.theme-forge .smith-tagline,
  #market-panel.theme-forge .smith-portrait-img,
  #market-panel.theme-forge .smith-portrait-fallback,
  #market-panel.theme-forge .smith-tagline,
  #premium-panel.theme-forge .smith-portrait-img,
  #premium-panel.theme-forge .smith-portrait-fallback,
  #premium-panel.theme-forge .smith-tagline,
  #vendor-panel.theme-forge .smith-portrait-img,
  #vendor-panel.theme-forge .smith-portrait-fallback,
  #vendor-panel.theme-forge .smith-tagline,
  #dungeon-panel.theme-forge .smith-portrait-img,
  #dungeon-panel.theme-forge .smith-portrait-fallback,
  #dungeon-panel.theme-forge .smith-tagline {
    display: none !important;
  }

  #warehouse-panel,
  #smith-panel,
  #scribe-panel,
  #market-panel,
  #mail-panel,
  #premium-panel,
  #vendor-panel,
  #warp-pick-panel,
  #trade-panel,
  #dungeon-panel {
    width: min(294px, calc(100vw - 16px));
    top: 42%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 112px);
    border-radius: 7px;
  }
  #warehouse-panel {
    width: min(calc(100vw - 16px), 320px);
  }

  /* ตลาด Lia มือถือแนวตั้ง — ปุ่มฝากขายติดล่าง · กว้างตามแผงมาตรฐาน (ไม่ขยาย) */
  #market-panel {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    border-color: #68d391;
  }
  #market-panel .market-panel-header {
    flex-shrink: 0;
    padding: 8px 40px 8px 10px;
  }
  #market-panel .market-panel-header h2 {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: #9ae6b4;
  }
  #market-panel .market-money-row {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  #market-panel .market-money-row strong {
    font-size: 0.78rem;
  }
  #market-panel .market-hint {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 0.68rem;
    line-height: 1.35;
  }
  #market-panel .market-status {
    flex-shrink: 0;
    font-size: 0.7rem;
    padding: 5px 10px;
  }
  #market-panel .market-cat-tabs {
    gap: 4px;
    padding: 6px 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #market-panel .market-cat-tabs::-webkit-scrollbar {
    display: none;
  }
  #market-panel .market-cat {
    flex: 0 0 auto;
    font-size: 0.68rem;
    padding: 6px 10px;
    min-height: 30px;
  }
  #market-panel .market-list-scroll {
    min-height: 0;
    max-height: none;
    padding: 6px 8px;
  }
  #market-panel .market-row {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 7px 8px;
    margin-bottom: 5px;
    border-radius: 7px;
  }
  #market-panel .market-row-icon {
    width: 32px;
    height: 32px;
  }
  #market-panel .market-row-icon .slot-icon-img {
    width: 28px;
    height: 28px;
  }
  #market-panel .market-row-title {
    font-size: 0.78rem;
    line-height: 1.25;
  }
  #market-panel .market-row-sub {
    font-size: 0.62rem;
  }
  #market-panel .market-row-price {
    font-size: 0.7rem;
  }
  #market-panel .market-footer {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.35);
  }
  #market-panel .market-footer-btn {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    padding: 11px 12px;
    min-height: 44px;
    border-width: 2px;
    background: linear-gradient(180deg, rgba(104, 211, 145, 0.35), rgba(56, 161, 105, 0.28));
    color: #f0fff4;
  }
  #market-panel .market-sell-head {
    padding: 6px 8px;
    font-size: 0.75rem;
    gap: 8px;
  }
  #market-panel .market-back-btn {
    font-size: 0.7rem;
    padding: 6px 8px;
    min-height: 32px;
  }
  #market-panel .market-price-row {
    flex-wrap: wrap;
    padding: 6px 8px;
    font-size: 0.72rem;
    gap: 5px;
  }
  #market-panel .market-price-row input {
    width: 52px;
    font-size: 0.85rem;
    padding: 6px 6px;
    min-height: 34px;
  }
  #market-panel .market-sell-tip {
    font-size: 0.65rem;
    padding: 4px 8px 6px;
    line-height: 1.35;
  }
  #market-panel .market-bag-scroll {
    max-height: none;
  }
  #market-panel .slot-grid {
    grid-template-columns: repeat(auto-fill, 34px);
    gap: 3px;
  }
  #market-panel .slot-cell {
    width: 34px;
    height: 34px;
  }
  #market-panel .slot-icon-btn {
    min-height: 34px;
  }
  #market-panel .slot-storage-cell .slot-action-btn {
    display: none;
  }
  #market-panel .market-empty {
    font-size: 0.75rem;
    padding: 14px 8px;
  }

  /* ตลาด Lia มือถือ — tagline ค่าธรรมเนียมแทน desc · ลบแถว hint (Desktop ไม่แตะ) */
  #market-panel .market-tagline-desc {
    display: none !important;
  }
  #market-panel .market-tagline-fee {
    display: block !important;
  }
  #market-panel .market-tagline-fee.hidden {
    display: block !important;
  }
  #market-panel #market-hint {
    display: none !important;
  }
  #vendor-panel #vendor-hint {
    display: none !important;
  }

  /* Eira มือถือ — ฟอนต์อ่านได้เท่า Lia (ทับ 0.58rem ของ money-row ร่วม) */
  #scribe-panel {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    border-color: #9ae6b4;
  }
  #scribe-panel .player-menu-header {
    flex-shrink: 0;
    padding: 8px 40px 8px 10px;
  }
  #scribe-panel .player-menu-header h2 {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: #9ae6b4;
  }
  #scribe-panel .smith-money-row,
  #scribe-panel .scribe-money-row {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  #scribe-panel .smith-money-row strong,
  #scribe-panel .scribe-money-row strong {
    font-size: 0.78rem;
  }
  #scribe-panel .scribe-status {
    flex-shrink: 0;
    font-size: 0.7rem;
    padding: 5px 10px;
  }
  #scribe-body {
    padding: 6px 8px 10px;
    font-size: 0.78rem;
  }
  #scribe-panel .scribe-tabs {
    gap: 4px;
    margin-bottom: 8px;
  }
  #scribe-panel .scribe-tab {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.68rem;
    padding: 6px 8px;
    min-height: 30px;
  }
  #scribe-panel .scribe-fuse-header,
  #scribe-panel .scribe-hint,
  #scribe-panel .scribe-subhead,
  #scribe-panel .scribe-stub {
    font-size: 0.68rem;
    line-height: 1.35;
  }
  #scribe-panel .scribe-tome-text,
  #scribe-panel .scribe-skill-info {
    font-size: 0.78rem;
  }
  #scribe-panel .scribe-tome-qty,
  #scribe-panel .scribe-skill-info p,
  #scribe-panel .scribe-lv,
  #scribe-panel .scribe-kind {
    font-size: 0.68rem;
  }
  #scribe-panel .scribe-cost,
  #scribe-panel .scribe-fuse-count,
  #scribe-panel .scribe-fuse-cost,
  #scribe-panel .scribe-fuse-chance,
  #scribe-panel .scribe-cost-gate {
    font-size: 0.7rem;
  }
  #scribe-panel .scribe-skill-row button,
  #scribe-panel .scribe-fuse-row button {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.68rem;
    padding: 6px 10px;
    min-height: 30px;
  }
  #scribe-panel .scribe-tome-empty {
    font-size: 0.75rem;
  }

  /* เทรดมือถือ — กว้างพอ · body scroll · สองฝั่งเคียงกัน · ช่องไม่ทับปุ่ม */
  #trade-panel {
    width: min(calc(100vw - 12px), 400px);
    top: 46%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 112px);
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  }
  #trade-panel .trade-panel-header h2 {
    font-size: 0.9rem;
  }
  #trade-panel .trade-status {
    font-size: 0.7rem;
    padding: 5px 8px;
    line-height: 1.35;
  }
  #trade-panel .trade-sides {
    grid-template-columns: 1fr 14px 1fr;
    padding: 6px;
    gap: 0;
  }
  #trade-panel .trade-sides-divider {
    padding: 0;
    font-size: 0.8rem;
    transform: none;
  }
  #trade-panel .trade-side {
    padding: 5px;
    gap: 4px;
    min-width: 0;
  }
  #trade-panel .trade-side-head {
    gap: 3px;
  }
  #trade-panel .trade-side-badge {
    font-size: 0.7rem;
  }
  #trade-panel .trade-confirm-badge {
    font-size: 0.58rem;
    padding: 1px 4px;
  }
  #trade-panel .trade-side-copper {
    font-size: 0.65rem;
    padding: 3px 4px;
  }
  #trade-panel .trade-side-copper strong {
    font-size: 0.7rem;
  }
  #trade-panel .trade-offer-list {
    max-height: 68px;
    min-height: 32px;
  }
  #trade-panel .trade-offer-empty {
    font-size: 0.62rem;
    padding: 8px 4px;
  }
  #trade-panel .trade-side-actions button {
    font-size: 0.72rem;
    padding: 6px 6px;
    min-height: 32px;
  }
  #trade-panel .trade-bag-head {
    font-size: 0.65rem;
    margin-bottom: 4px;
  }
  #trade-panel .trade-bag-head span:first-child {
    line-height: 1.3;
  }
  #trade-panel .trade-bag-money-actions {
    gap: 4px;
  }
  #trade-panel .trade-bag-money-actions input,
  #trade-panel .trade-bag-money-actions .mobile-kbd-row {
    flex: 1 1 100%;
    min-width: 0;
  }
  #trade-panel .trade-bag-money-actions button {
    flex: 1 1 auto;
    font-size: 0.68rem;
    padding: 6px 8px;
    min-height: 32px;
  }
  /* ช่องเทรด — อย่าบังคับ 28px (ปุ่มเสนอทับไอคอน); ซ่อนปุ่มในช่อง ใช้แตะเปิด detail */
  #trade-panel .slot-grid {
    grid-template-columns: repeat(auto-fill, 34px);
    gap: 3px;
  }
  #trade-panel .slot-cell {
    width: 34px;
    height: 34px;
  }
  #trade-panel .slot-icon-btn {
    min-height: 34px;
  }
  #trade-panel .slot-icon-img {
    width: 28px;
    height: 28px;
  }
  #trade-panel .slot-storage-cell .slot-action-btn {
    display: none;
  }
  #trade-panel .slot-qty {
    bottom: 1px;
    right: 1px;
    font-size: 0.5rem;
  }

  #warehouse-panel .warehouse-panel-close {
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }

  #warehouse-panel .warehouse-panel-header {
    padding: 8px 38px 8px 8px;
  }

  .warehouse-money-row {
    gap: 6px;
    padding: 6px 8px 2px;
    flex-shrink: 0;
  }

  .warehouse-money-tap {
    padding: 6px 8px;
    min-height: 44px;
  }

  .warehouse-money-label {
    font-size: 0.64rem;
  }

  .warehouse-money-amount,
  #warehouse-bag-money,
  #warehouse-vault-money {
    font-size: 0.74rem;
  }

  .warehouse-money-hint {
    font-size: 0.6rem;
    padding: 0 8px 6px;
  }

  .warehouse-columns {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 6px 8px 10px;
  }

  .warehouse-col h3 {
    font-size: 0.72rem;
    margin-bottom: 4px;
  }
  /* Bren/Kael — กว้างเท่า Lia (#market-panel ในกลุ่ม shared ด้านบน) อย่าย่อแยก */
  #death-panel {
    width: min(210px, calc(100vw - 28px));
    padding: 8px 10px;
    border-radius: 7px;
  }
  #dungeon-queue-ready,
  #dungeon-share-confirm {
    min-width: 0;
    width: min(196px, calc(100vw - 28px));
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 0.72rem;
  }

  .social-invite-dialog.theme-forge,
  #trade-invite.theme-forge,
  #party-invite.theme-forge,
  #duel-invite.theme-forge {
    width: min(248px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    padding: 8px 10px;
    gap: 6px;
    border-radius: 10px;
  }

  .social-invite-dialog.theme-forge .npc-dialog-header > div > div:first-child,
  #trade-invite.theme-forge .npc-dialog-header > div > div:first-child,
  #party-invite.theme-forge .npc-dialog-header > div > div:first-child,
  #duel-invite.theme-forge .npc-dialog-header > div > div:first-child {
    font-size: 0.8rem;
  }

  .social-invite-dialog.theme-forge .trade-invite-sub,
  #trade-invite.theme-forge .trade-invite-sub,
  #party-invite.theme-forge .trade-invite-sub,
  #duel-invite.theme-forge .trade-invite-sub {
    font-size: 0.7rem;
  }

  .social-invite-dialog.theme-forge .npc-dialog-actions button,
  #trade-invite.theme-forge .npc-dialog-actions button,
  #party-invite.theme-forge .npc-dialog-actions button,
  #duel-invite.theme-forge .npc-dialog-actions button {
    padding: 5px 6px;
    font-size: 0.66rem;
    border-width: 1px;
    border-radius: 6px;
  }

  .social-invite-dialog.theme-forge .trade-accept-btn,
  #trade-invite.theme-forge .trade-accept-btn,
  #party-invite.theme-forge .trade-accept-btn,
  #duel-invite.theme-forge .trade-accept-btn {
    border-width: 1px !important;
  }
  .smith-money-row,
  .market-money-row {
    padding: 4px 7px;
    font-size: 0.58rem;
  }
  /* scribe ใช้ฟอนต์ชุด #scribe-panel ด้านล่าง — อย่าบังคับ 0.58rem ที่นี่ */
  .market-hint,
  .death-hint {
    padding: 3px 7px;
    font-size: 0.55rem;
  }
  #smith-body {
    padding: 5px 7px 7px;
  }
  /* Torin — กว้างเท่า Lia (กลุ่ม shared 294) · อย่าย่อ/ขยายแยก */
  #smith-panel.theme-forge .smith-panel-header {
    padding: 8px 38px 8px 8px;
  }
  #smith-panel.theme-forge .smith-panel-header .menu-close-btn {
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
  }
  .smith-portrait-img,
  .smith-portrait-fallback {
    width: 36px;
    height: 36px;
  }
  .smith-header-text h2 {
    font-size: 0.82rem;
  }
  .smith-tagline,
  .smith-hint {
    font-size: 0.72rem;
  }
  .smith-tab {
    font-size: 0.75rem;
    padding: 7px 8px;
  }
  .smith-layout-c {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 6px;
  }
  /* Torin มือถือ — ไม่มีพรีวิว · แถวไอเทม + ปุ่มท้ายแถว */
  #smith-panel .smith-preview-pane {
    display: none !important;
  }
  #smith-panel .smith-layout-c.is-mobile-list {
    display: block;
  }
  #smith-panel .smith-layout-c.is-mobile-list .smith-list-pane {
    max-height: none;
    overflow: visible;
  }
  #smith-panel .smith-gear-card.is-mobile-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    cursor: default;
  }
  #smith-panel .smith-gear-card.is-mobile-row.is-selected {
    border-color: #3d3428;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.35);
  }
  #smith-panel .smith-row-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 2px;
    min-width: 58px;
    max-width: 72px;
  }
  #smith-panel .smith-row-actions .smith-forge-btn {
    width: 100%;
    padding: 6px 4px;
    font-size: 0.68rem;
    border-radius: 6px;
    border-width: 1px;
  }
  #smith-panel .smith-row-actions .smith-forge-btn-sub {
    font-size: 0.52rem;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    color: #a0aec0;
  }
  #smith-panel .smith-gear-icon-wrap {
    width: 32px;
    height: 32px;
    overflow: hidden;
  }
  #smith-panel .smith-gear-icon-wrap .slot-icon-img {
    width: 24px;
    height: 24px;
  }
  #smith-panel .smith-gear-name {
    font-size: 0.72rem;
    margin-bottom: 2px;
  }
  #smith-panel .smith-chip {
    font-size: 0.58rem;
    padding: 0 4px;
  }
  #smith-panel .smith-forge-btn {
    font-size: 0.72rem;
    padding: 7px 8px;
  }
  #smith-panel .smith-forge-fx-card {
    width: min(112px, 36vw);
    padding: 4px;
    border-radius: 10px;
  }
  #scribe-panel .smith-forge-fx-card {
    width: min(112px, 36vw);
    padding: 4px;
    border-radius: 10px;
  }
  #smith-panel .smith-section-title {
    font-size: 0.68rem;
    margin-bottom: 4px;
  }
  .premium-row {
    gap: 5px;
    padding: 5px 7px;
  }
  .premium-row-title {
    font-size: 0.62rem;
  }
  .premium-row-icon {
    width: 28px;
    height: 28px;
  }
  .premium-row-icon .slot-icon-img {
    width: 24px;
    height: 24px;
  }
  .dungeon-list {
    padding: 4px 6px 7px;
  }
  .dungeon-group-title {
    font-size: 0.68rem;
  }
  .dungeon-diff-row {
    padding: 4px;
    margin-bottom: 3px;
    border-radius: 5px;
    font-size: 0.62rem;
  }
  #warehouse-panel .slot-grid,
  #warehouse-panel .warehouse-slot-grid,
  #smith-panel .slot-grid,
  #mail-panel .slot-grid {
    grid-template-columns: repeat(auto-fill, 28px);
    gap: 2px;
  }
  #warehouse-panel .slot-cell,
  #smith-panel .slot-cell,
  #mail-panel .slot-cell {
    width: 28px;
    height: 28px;
  }

  /* Qty / item detail */
  #item-detail-dialog {
    width: min(196px, calc(100vw - 28px));
    padding: 7px 8px;
    border-radius: 7px;
  }
  #item-detail-title {
    font-size: 0.72rem;
  }
  .item-detail-icon {
    width: 88px;
    height: 88px;
  }
  #qty-dialog {
    width: min(260px, calc(100vw - 28px));
    padding: 8px 10px;
    border-radius: 7px;
  }

  #qty-dialog .qty-dialog-close {
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    font-size: 0.95rem;
  }

  .qty-dialog-header {
    padding-right: 32px;
  }

  #qty-dialog-title {
    font-size: 0.78rem;
  }

  #qty-dialog-hint {
    font-size: 0.65rem;
  }

  #qty-dialog-input {
    font-size: 0.9rem;
    padding: 7px 8px;
  }

  #qty-dialog-max {
    font-size: 0.68rem;
    padding: 6px 8px;
  }

  #qty-dialog-confirm {
    font-size: 0.72rem;
    padding: 5px 12px;
  }

  #help-bar {
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    text-align: center;
    max-width: 90vw;
    font-size: 0.58rem;
  }

  /* à¸à¸²à¸£à¹à¸à¸µà¹ HUD â à¸¢à¹à¸­à¸à¸±à¹à¸à¹à¸à¸à¸ªà¸³à¸«à¸£à¸±à¸à¸¡à¸·à¸­à¸à¸·à¸­à¹à¸à¸§à¸à¸±à¹à¸ */
  #party-hud {
    top: max(6px, env(safe-area-inset-top));
    left: max(122px, env(safe-area-inset-left) + 116px);
    min-width: 0;
    max-width: min(120px, 36vw);
    max-height: min(110px, 22vh);
    padding: 3px 4px;
    border-radius: 5px;
    font-size: 0.55rem;
  }
  .party-hud-header {
    margin-bottom: 1px;
  }
  .party-hud-title {
    font-size: 0.58rem;
  }
  .party-hud-close-btn {
    font-size: 0.75rem;
    padding: 0;
  }
  .party-hud-row {
    padding: 0;
    line-height: 1.2;
  }
  .party-hud-share {
    margin-top: 2px;
    padding-top: 2px;
    gap: 1px;
  }
  .party-share-toggle {
    gap: 2px;
    padding: 1px 2px;
    font-size: 0.5rem;
  }
  .party-share-toggle-caret {
    font-size: 0.48rem;
  }
  .party-share-toggle-lock {
    font-size: 0.48rem;
  }
  .party-share-body {
    gap: 1px;
    padding-top: 0;
  }
  .party-share-lock {
    font-size: 0.48rem;
    margin-bottom: 0;
  }
  .party-share-row {
    gap: 2px;
  }
  .party-share-label {
    width: 18px;
    font-size: 0.48rem;
  }
  .party-share-btns {
    gap: 2px;
  }
  .party-share-btns button {
    font-size: 0.48rem;
    padding: 3px 1px;
    min-height: 22px;
    border-radius: 3px;
  }
  .party-hud-actions {
    gap: 3px;
    margin-top: 2px;
  }
  .party-hud-actions button {
    font-size: 0.5rem;
    padding: 3px 2px;
    min-height: 22px;
    border-radius: 3px;
  }
  #party-hud-toggle {
    top: max(6px, env(safe-area-inset-top));
    left: max(122px, env(safe-area-inset-left) + 116px);
    font-size: 0.72rem;
    padding: 2px 4px;
    border-radius: 4px;
  }
}

/* ââ à¸¡à¸·à¸­à¸à¸·à¸­à¹à¸à¸§à¸à¸­à¸: à¸¢à¹à¸­ UI à¹à¸«à¹à¸­à¸¢à¸¹à¹à¹à¸à¸à¸§à¸²à¸¡à¸ªà¸¹à¸à¸à¸­ ââ */
@media (orientation: landscape) and (max-height: 500px) {
  #mobile-controls {
    display: block !important;
  }

  .desktop-hint {
    display: none;
  }

  .mobile-hint {
    display: none !important;
  }

  /* à¹à¸à¸à¸à¸µà¹à¹à¸¥à¸à¹à¸à¸§à¸à¸­à¸à¸ªà¸±à¹à¸: à¸«à¹à¸­à¸à¸²à¸¡à¸à¸§à¸²à¸¡à¸ªà¸¹à¸ Â· à¹à¸¡à¹à¸¢à¸·à¸à¹à¸à¸à¹à¸à¹à¸¡à¸à¸§à¸²à¸¡à¸à¸§à¹à¸²à¸ */
  #world-map-panel {
    max-width: calc(100vw - 8px);
    max-height: calc(100dvh - 8px);
  }
  #world-map-panel .player-menu-header {
    padding: 4px 8px;
  }
  #world-map-panel .player-menu-header h2 {
    font-size: 0.78rem;
  }
  #world-map-body {
    padding: 2px 4px 4px;
  }
  #world-map-img {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 44px);
  }

  #help-bar {
    display: none;
  }

  #audio-settings-overlay {
    z-index: 94;
  }
  #audio-settings-panel {
    z-index: 95;
    top: max(40px, calc(env(safe-area-inset-top) + 32px));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(220px, calc(100vw - 24px));
  }
  .audio-settings-header {
    padding: 6px 8px 3px;
  }
  .audio-settings-header h2 {
    font-size: 0.76rem;
  }
  .audio-settings-body {
    padding: 6px 8px 8px;
    gap: 8px;
  }
  .audio-settings-label {
    font-size: 0.72rem;
  }
  .audio-mute-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
  }

  #hud {
    top: max(4px, env(safe-area-inset-top));
    left: max(4px, env(safe-area-inset-left));
  }

  .hud-block {
    min-width: 120px;
    max-width: 42vw;
    padding: 4px 6px;
  }

  #player-name {
    font-size: 0.7rem;
    margin-bottom: 2px;
  }

  .bar-row {
    gap: 4px;
    margin-bottom: 2px;
  }

  .bar-label,
  .bar-value {
    font-size: 0.58rem;
  }

  .hud-meta {
    font-size: 0.58rem;
    line-height: 1.2;
  }

  #logout-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 6px;
    font-size: 0.58rem;
  }

  #fullscreen-btn:not(.hidden) {
    position: static;
    left: auto;
    right: auto;
    transform: none;
    z-index: auto;
    margin-top: 0;
    padding: 3px 7px;
    font-size: 0.58rem;
    font-weight: 600;
    color: #faf089;
    background: rgba(8, 12, 18, 0.45);
    border: 1px solid rgba(214, 158, 46, 0.55);
    border-radius: 4px;
  }

  #minimap-wrap {
    top: max(6px, calc(env(safe-area-inset-top) + 2px));
    right: max(18px, calc(env(safe-area-inset-right) + 10px));
    transform: scale(0.72);
    transform-origin: top right;
  }

  #right-dock {
    top: max(4px, env(safe-area-inset-top));
    right: max(118px, calc(env(safe-area-inset-right) + 110px));
    max-width: min(220px, 40vw);
  }

  #minimap-legend {
    display: none;
  }

  #menu-dock {
    gap: 4px;
  }

  #menu-dock button {
    padding: 3px 6px;
    font-size: 0.65rem;
  }

  /* à¸à¸¢à¸±à¸à¹à¸à¹à¸²à¸à¸²à¸à¸à¸­à¸à¸à¸­ â à¹à¸¡à¹à¸à¸´à¸ rim à¹à¸à¸´à¸à¹à¸ */
  .joystick-zone {
    left: max(18px, calc(env(safe-area-inset-left) + 10px));
    bottom: max(14px, calc(env(safe-area-inset-bottom) + 6px));
    width: 80px;
    height: 80px;
  }

  .joystick-thumb {
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
  }

  .mobile-actions {
    /* à¹à¸à¹à¸²à¸¡à¸²à¸à¸²à¸à¸à¸­à¸à¸à¸§à¸²à¸¡à¸²à¸à¸à¸§à¹à¸²à¸à¸­à¸¢à¸à¸´à¸ â à¸à¸£à¸´à¸à¸à¸§à¹à¸²à¸à¸à¸§à¹à¸²à¸§à¸à¸à¸­à¸¢ à¸à¸¶à¸à¸à¸´à¸ rim à¸à¸§à¹à¸²à¸à¹à¸²à¹à¸à¹à¸à¹à¸²à¹à¸à¹à¸²à¸à¸±à¸ */
    right: max(22px, calc(env(safe-area-inset-right) + 14px));
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 4px));
    grid-template-columns: 50px 58px;
    grid-template-rows: 50px 58px;
    gap: 7px;
  }
  .mobile-item-hotbar,
  .mobile-item-hotbar-btn {
    width: 50px;
    height: 50px;
  }
  .mobile-item-hotbar-btn {
    border-radius: 14px;
  }
  .mobile-item-hotbar-btn .hotbar-mobile-icon {
    width: 26px;
    height: 26px;
    margin: 0 auto;
  }
  .mobile-item-hotbar-btn .hotbar-mobile-icon .slot-icon-img {
    width: 26px;
    height: 26px;
  }
  .mobile-hotbar-remove {
    width: 20px;
    height: 20px;
    font-size: 0.85rem;
  }

  .mobile-action-btn {
    width: 50px;
    height: 50px;
    font-size: 0.85rem;
  }

  .mobile-attack-btn {
    width: 58px;
    height: 58px;
    font-size: 1.25rem;
    grid-column: 2;
    grid-row: 2;
  }

  .mobile-btn-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.45;
    font-size: 0.75rem;
  }

  #chat-panel {
    bottom: max(100px, calc(14px + env(safe-area-inset-bottom) + 86px));
    left: max(12px, env(safe-area-inset-left));
    width: min(240px, 38vw);
    padding: 3px 5px;
    gap: 2px;
  }

  #chat-logs,
  .chat-log {
    min-height: 40px;
    max-height: 56px;
    height: 56px;
    font-size: 0.6rem;
    line-height: 1.15;
  }

  #chat-tabs button {
    padding: 2px 5px;
    font-size: 0.62rem;
  }

  #chat-tap-hint {
    font-size: 0.6rem;
  }

  #npc-dialog {
    max-width: min(420px, 70vw);
  }

  #bottom-center-hud {
    gap: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  #npc-dialog.has-portrait .npc-dialog-portrait-col {
    width: 72px;
  }

  .npc-dialog-portrait {
    width: 64px;
    height: 64px;
  }

  .npc-dialog-body {
    min-height: 72px;
    gap: 6px;
  }

  #npc-dialog-text {
    font-size: 0.82rem;
    min-height: 2.2em;
  }

  /* แผงยาวแนวนอน — ไม่ทับแถบสkill · dual layout ต้องเห็นครบ */
  #player-menu {
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: calc(100vw - 12px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 88px);
  }
  #player-menu.theme-round-gold:not(.is-dual-layout) {
    width: fit-content;
    max-width: calc(100vw - 12px);
  }
  #player-menu.theme-round-gold.is-dual-layout {
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 12px));
    max-width: calc(100vw - 12px);
    min-height: 0;
    overflow: hidden;
  }
  #player-menu.is-dual-layout .player-menu-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  #player-menu.is-dual-layout .menu-dual-layout {
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
    align-items: stretch;
  }
  #player-menu.is-dual-layout .menu-equip-column,
  #player-menu.is-dual-layout .menu-detail-column {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 4px 5px 6px;
    overflow: hidden;
  }
  #player-menu.is-dual-layout .menu-detail-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #player-menu.is-dual-layout .menu-detail-panel:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
  }
  #player-menu.is-dual-layout .stat-grid.panel-scroll {
    flex: 1 1 auto;
    min-height: 96px;
    overflow-y: auto;
  }
  #player-menu.is-dual-layout .inv-scroll-wrap {
    flex: 1 1 auto;
    min-height: 72px;
  }
  #player-menu.is-dual-layout .equip-view-tabs {
    margin-bottom: 2px;
  }
  #player-menu.is-dual-layout .equip-view-btn {
    padding: 2px 6px;
    font-size: 0.65rem;
  }
  #player-menu.is-dual-layout .equip-ro-layout,
  #player-menu.is-dual-layout .equip-costume-preview-layout {
    grid-template-columns: 26px minmax(0, 1fr) 26px;
    column-gap: 3px;
    row-gap: 2px;
    width: 100%;
    max-width: 100%;
  }
  #player-menu.is-dual-layout .equip-cell {
    width: 26px;
    height: 26px;
    padding: 1px;
    font-size: 0.5rem;
  }
  #player-menu.is-dual-layout .equip-cell.is-empty .equip-cell-label {
    font-size: 0.5rem;
    -webkit-font-smoothing: auto;
  }
  #player-menu.is-dual-layout .equip-cell-icon {
    width: 18px;
    height: 18px;
  }
  #player-menu.is-dual-layout .equip-cell-icon .slot-icon-img {
    width: 16px;
    height: 16px;
  }
  #player-menu.is-dual-layout .equip-char.equip-char-floating {
    width: 100%;
    max-width: 82px;
  }
  #player-menu.is-dual-layout .equip-char-floating .equip-char-sprite,
  #player-menu.is-dual-layout .equip-char-floating .equip-char-silhouette.is-fallback {
    transform: scale(1.05);
  }
  #player-menu.is-dual-layout .equip-bonus {
    font-size: 0.58rem;
    margin-top: 3px;
  }
  #player-menu.is-dual-layout .col-title,
  #player-menu.is-dual-layout .col-title-row .col-title {
    font-size: 0.65rem;
    margin-bottom: 3px;
  }
  #player-menu.is-dual-layout .stat-row {
    font-size: 0.68rem;
    padding: 3px 4px;
  }
  #player-menu.is-dual-layout .inv-summary,
  #player-menu.is-dual-layout .bag-footer {
    font-size: 0.62rem;
  }
  #player-menu.is-dual-layout .inv-cat-btn {
    padding: 2px 5px;
    font-size: 0.62rem;
  }
  #player-menu.is-dual-layout .slot-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 2px;
  }
  #player-menu.is-dual-layout .slot-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    min-width: 0;
  }
  #player-menu.is-dual-layout .slot-icon-btn {
    min-height: 0;
    width: 100%;
    height: 100%;
  }
  #player-menu.is-dual-layout .slot-icon-img {
    width: min(22px, 88%);
    height: min(22px, 88%);
  }
  .player-menu-header {
    padding: 3px 6px;
    flex-shrink: 0;
  }
  .player-menu-header h2 {
    font-size: 0.68rem;
  }
  .player-menu-tabs {
    padding: 2px 4px;
    gap: 2px;
    flex-shrink: 0;
  }
  .player-menu-tabs button {
    padding: 2px 5px;
    font-size: 0.6rem;
  }
  #player-menu.theme-round-gold .player-menu-tabs button {
    font-size: 0.6rem;
    padding: 2px 6px;
  }
  .player-menu-body {
    padding: 0;
  }
  #player-menu:not(.is-dual-layout) .player-menu-body {
    padding: 4px 6px 6px;
    overflow: hidden;
  }
  .stat-row {
    padding: 2px 4px;
    font-size: 0.55rem;
  }
  #warehouse-panel,
  #smith-panel,
  #scribe-panel,
  #market-panel,
  #mail-panel,
  #premium-panel,
  #vendor-panel,
  #warp-pick-panel,
  #trade-panel,
  #dungeon-panel {
    width: min(336px, calc(100vw - 16px));
    top: 40%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 88px);
  }
  /* Bren/Lia/Sera/Kael แนวนอน — ย้ำความกว้างเท่ากันหลังกฎฐาน (กัน cascade ทับ) */
  #market-panel,
  #vendor-panel,
  #premium-panel,
  #dungeon-panel {
    width: min(336px, calc(100vw - 16px));
    top: 40%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 88px);
  }

  /* Eira แนวนอน — ฟอนต์เท่า Lia (ความกว้างจอมัก >768 จึงต้องย้ำที่นี่) */
  #scribe-panel {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  }
  #scribe-panel .player-menu-header h2 {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: #9ae6b4;
  }
  #scribe-panel .smith-money-row,
  #scribe-panel .scribe-money-row {
    font-size: 0.68rem;
    padding: 4px 8px;
  }
  #scribe-panel .smith-money-row strong {
    font-size: 0.72rem;
  }
  #scribe-panel .scribe-status {
    font-size: 0.65rem;
    padding: 4px 8px;
  }
  #scribe-body {
    padding: 5px 7px 8px;
    font-size: 0.72rem;
  }
  #scribe-panel .scribe-tab {
    font-size: 0.62rem;
    padding: 5px 6px;
    min-height: 26px;
  }
  #scribe-panel .scribe-fuse-header,
  #scribe-panel .scribe-hint,
  #scribe-panel .scribe-subhead {
    font-size: 0.62rem;
  }
  #scribe-panel .scribe-tome-text,
  #scribe-panel .scribe-skill-info {
    font-size: 0.7rem;
  }
  #scribe-panel .scribe-tome-qty,
  #scribe-panel .scribe-skill-info p {
    font-size: 0.62rem;
  }
  #scribe-panel .scribe-cost,
  #scribe-panel .scribe-fuse-count,
  #scribe-panel .scribe-fuse-cost,
  #scribe-panel .scribe-fuse-chance {
    font-size: 0.65rem;
  }
  #scribe-panel .scribe-skill-row button,
  #scribe-panel .scribe-fuse-row button {
    font-size: 0.62rem;
    padding: 5px 8px;
    min-height: 26px;
  }

  #trade-panel {
    width: min(calc(100vw - 24px), 520px);
    top: 48%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 88px);
  }
  #trade-panel .trade-offer-list {
    max-height: 56px;
  }
  #trade-panel .trade-bag-money-actions input,
  #trade-panel .trade-bag-money-actions .mobile-kbd-row {
    flex: 1 1 140px;
  }

  #market-panel .market-footer-btn {
    min-height: 40px;
    font-size: 0.82rem;
    padding: 8px 10px;
  }
  #market-panel .market-cat {
    font-size: 0.65rem;
    padding: 5px 8px;
    min-height: 28px;
  }

  /* ตลาด Lia มือถือแนวนอน — tagline ค่าธรรมเนียม · ลบแถว hint */
  #market-panel .market-tagline-desc {
    display: none !important;
  }
  #market-panel .market-tagline-fee,
  #market-panel .market-tagline-fee.hidden {
    display: block !important;
  }
  #market-panel #market-hint {
    display: none !important;
  }
  #vendor-panel #vendor-hint {
    display: none !important;
  }

  /* ตลาด Lia แนวนอน (มือถือความกว้าง >768 ก็เข้า) — browse: ซ้ายเมนู+ฝากขาย / ขวารายการ */
  #market-panel #market-browse-wrap:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(78px, 0.88fr) minmax(0, 1.32fr);
    /* แถวล่าง auto = ปุ่มฝากขายไม่ถูกตัด · แถวบนกินที่เหลือให้รายการ */
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      'tabs list'
      'sell list';
    gap: 0;
    min-height: 0;
    flex: 1 1 auto;
  }
  #market-panel #market-browse-wrap .market-cat-tabs {
    grid-area: tabs;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 3px;
    padding: 4px 5px 2px;
    overflow: hidden;
    border-bottom: none;
    border-right: 1px solid #2d3748;
    min-height: 0;
  }
  #market-panel #market-browse-wrap .market-cat {
    width: 100%;
    text-align: center;
    font-size: 0.62rem;
    padding: 5px 4px;
    min-height: 26px;
    border-radius: 6px;
  }
  #market-panel #market-browse-wrap #market-listings.market-list-scroll {
    grid-area: list;
    min-height: 0;
    max-height: none;
    padding: 3px 5px 4px;
  }
  #market-panel #market-browse-wrap .market-footer {
    grid-area: sell;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    align-self: stretch;
    border-top: none;
    border-right: 1px solid #2d3748;
    padding: 0 5px 4px;
    box-shadow: none;
    background: transparent;
  }
  /* ปุ่มฝากขายขนาดเท่าแท็บหมวด — คอลัมน์ซ้ายไม่ต้อง scroll */
  #market-panel #market-browse-wrap .market-footer-btn {
    width: 100%;
    min-height: 26px;
    height: auto;
    max-height: none;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 5px 4px;
    line-height: 1.15;
    white-space: nowrap;
    border-radius: 6px;
    border-width: 1px;
  }
  #market-panel #market-browse-wrap .market-row-compact {
    gap: 4px;
    padding: 2px 4px;
    margin-bottom: 2px;
  }
  #market-panel #market-browse-wrap .market-row-compact .market-row-icon {
    width: 22px;
    height: 22px;
  }
  #market-panel #market-browse-wrap .market-row-compact .market-row-icon .slot-icon-img {
    width: 18px;
    height: 18px;
  }
  #market-panel #market-browse-wrap .market-row-compact .market-row-title {
    font-size: 0.62rem;
  }
  #market-panel #market-browse-wrap .market-row-compact .market-row-time {
    font-size: 0.52rem;
  }
  #market-panel #market-browse-wrap .market-row-compact .market-row-price {
    font-size: 0.58rem;
  }
  #market-panel #market-browse-wrap .market-row-line {
    gap: 3px;
  }

  #warehouse-panel .warehouse-panel-close {
    top: 5px;
    right: 5px;
    width: 26px;
    height: 26px;
  }

  #warehouse-panel .warehouse-panel-header {
    padding: 6px 36px 6px 7px;
  }

  #smith-panel.theme-forge .smith-panel-header {
    padding: 6px 36px 6px 7px;
  }
  .smith-layout-c {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  #smith-panel .smith-preview-pane {
    display: none !important;
  }
  #smith-panel .smith-layout-c.is-mobile-list {
    display: block;
  }
  #smith-panel .smith-layout-c.is-mobile-list .smith-list-pane {
    max-height: none;
    overflow: visible;
  }
  #smith-panel .smith-gear-card.is-mobile-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
    padding: 4px 5px;
  }
  #smith-panel .smith-row-actions {
    min-width: 54px;
    max-width: 68px;
  }
  #smith-panel .smith-row-actions .smith-forge-btn {
    padding: 5px 3px;
    font-size: 0.62rem;
  }
  #smith-panel .smith-row-actions .smith-forge-btn-sub {
    font-size: 0.48rem;
  }
  #smith-panel .smith-forge-fx-card {
    width: min(96px, 28vw);
    padding: 3px;
  }
  #scribe-panel .smith-forge-fx-card {
    width: min(96px, 28vw);
    padding: 3px;
  }

  .warehouse-money-row {
    gap: 5px;
    padding: 5px 7px 2px;
  }

  .warehouse-money-tap {
    padding: 5px 7px;
    min-height: 40px;
  }

  .warehouse-money-amount,
  #warehouse-bag-money,
  #warehouse-vault-money {
    font-size: 0.72rem;
  }

  .warehouse-money-hint {
    font-size: 0.58rem;
    padding: 0 7px 5px;
  }

  .warehouse-columns {
    gap: 5px;
    padding: 5px 7px 8px;
  }

  #item-detail-dialog,
  #qty-dialog {
    max-height: calc(100dvh - 16px);
  }
  #skill-bar-hud {
    gap: 3px;
  }
  .ammo-hud {
    height: 36px;
    padding: 0 6px;
    font-size: 10px;
  }
  #skill-bar-page-btn {
    width: 30px;
    height: 36px;
    flex-basis: 30px;
  }
  .skill-slot-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    max-width: 36px;
    flex-basis: 36px;
  }

  #party-hud {
    top: max(4px, env(safe-area-inset-top));
    left: max(110px, env(safe-area-inset-left) + 100px);
    min-width: 0;
    max-width: min(108px, 24vw);
    max-height: min(72px, 36vh);
    padding: 2px 3px;
    border-radius: 4px;
    font-size: 0.5rem;
  }
  .party-hud-header {
    margin-bottom: 0;
  }
  .party-hud-title {
    font-size: 0.52rem;
  }
  .party-hud-close-btn {
    font-size: 0.7rem;
  }
  .party-hud-row {
    padding: 0;
    line-height: 1.15;
  }
  .party-hud-share {
    margin-top: 1px;
    padding-top: 1px;
    gap: 0;
  }
  .party-share-toggle {
    gap: 2px;
    padding: 0 1px;
    font-size: 0.45rem;
  }
  .party-share-toggle-caret,
  .party-share-toggle-lock {
    font-size: 0.42rem;
  }
  .party-share-body {
    gap: 1px;
  }
  .party-share-lock {
    font-size: 0.42rem;
  }
  .party-share-label {
    width: 16px;
    font-size: 0.42rem;
  }
  .party-share-btns button {
    font-size: 0.42rem;
    padding: 2px 1px;
    min-height: 20px;
  }
  .party-hud-actions {
    gap: 2px;
    margin-top: 1px;
  }
  .party-hud-actions button {
    font-size: 0.45rem;
    padding: 2px 1px;
    min-height: 20px;
  }
  #party-hud-toggle {
    top: max(4px, env(safe-area-inset-top));
    left: max(110px, env(safe-area-inset-left) + 100px);
    font-size: 0.72rem;
    padding: 2px 4px;
  }

  #hotbar-hud {
    display: none;
  }

  #dev-panel {
    top: 48px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    font-size: 0.75rem;
  }
}

/* ตลาด Lia — จอแนวนอนสูงกว่า 500px เล็กน้อย (ยังเป็นมือถือ) ก็แบ่งซ้าย/ขวาเหมือนกัน */
@media (orientation: landscape) and (min-height: 501px) and (max-height: 560px) {
  #market-panel,
  #vendor-panel,
  #premium-panel,
  #dungeon-panel {
    width: min(336px, calc(100vw - 16px));
    top: 40%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 88px);
  }

  /* ตลาด Lia มือถือแนวนอน — tagline ค่าธรรมเนียม · ลบแถว hint */
  #market-panel .market-tagline-desc {
    display: none !important;
  }
  #market-panel .market-tagline-fee,
  #market-panel .market-tagline-fee.hidden {
    display: block !important;
  }
  #market-panel #market-hint {
    display: none !important;
  }
  #vendor-panel #vendor-hint {
    display: none !important;
  }

  #market-panel #market-browse-wrap:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(78px, 0.88fr) minmax(0, 1.32fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      'tabs list'
      'sell list';
    gap: 0;
    min-height: 0;
    flex: 1 1 auto;
  }
  #market-panel #market-browse-wrap .market-cat-tabs {
    grid-area: tabs;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 3px;
    padding: 4px 5px 2px;
    overflow: hidden;
    border-bottom: none;
    border-right: 1px solid #2d3748;
    min-height: 0;
  }
  #market-panel #market-browse-wrap .market-cat {
    width: 100%;
    text-align: center;
  }
  #market-panel #market-browse-wrap #market-listings.market-list-scroll {
    grid-area: list;
    min-height: 0;
    max-height: none;
  }
  #market-panel #market-browse-wrap .market-footer {
    grid-area: sell;
    position: relative;
    z-index: 2;
    border-top: none;
    border-right: 1px solid #2d3748;
    box-shadow: none;
    background: transparent;
    padding: 0 5px 4px;
  }
  #market-panel #market-browse-wrap .market-footer-btn {
    width: 100%;
    min-height: 26px;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 5px 4px;
    line-height: 1.15;
    white-space: nowrap;
    border-radius: 6px;
    border-width: 1px;
  }
}
@media (min-width: 769px) and (min-height: 520px) {
  #mobile-controls { display: none !important; }
}

#premium-overlay,
#vendor-overlay,
#warp-pick-overlay,
#death-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 95;
}

#raid-clear-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 108;
}

#raid-clear-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 120px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #2e2418, #14100c);
  border: 1px solid #6b4a28;
  border-radius: 10px;
  z-index: 109;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
}

#raid-clear-panel .raid-clear-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(107, 74, 40, 0.55);
}

#raid-clear-panel #raid-clear-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #fbd38d;
  line-height: 1.35;
  padding-right: 4px;
}

#raid-clear-panel .menu-close-btn {
  flex-shrink: 0;
}

.raid-clear-slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 36px);
  gap: 4px;
  justify-content: center;
  padding: 14px 16px 18px;
  box-sizing: border-box;
}

.raid-clear-slot-grid .raid-clear-slot {
  pointer-events: none;
}

.raid-clear-slot-grid .raid-clear-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 36px;
}

.raid-clear-slot-grid .slot-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

@media (max-width: 768px) {
  #raid-clear-panel {
    width: min(294px, calc(100vw - 16px));
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 112px);
  }

  #raid-clear-panel #raid-clear-title {
    font-size: 0.92rem;
  }

  .raid-clear-slot-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    gap: 2px;
    padding: 12px 12px 16px;
  }

  .raid-clear-slot-grid .slot-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    min-width: 0;
    max-width: none;
  }

  .raid-clear-slot-grid .raid-clear-icon {
    min-height: 0;
    width: 100%;
    height: 100%;
  }

  .raid-clear-slot-grid .slot-icon-img {
    width: min(24px, 88%);
    height: min(24px, 88%);
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  #raid-clear-panel {
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 88px);
  }
}

#premium-panel,
#warp-pick-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 16px));
  max-height: min(560px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  background: rgba(12, 16, 28, 0.97);
  border: 1px solid #f6ad55;
  border-radius: 10px;
  z-index: 100;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* Sera — กว้างเท่า Lia · ย้ำหลังกฎฐาน 480px (กัน cascade ทับเหมือน Bren) */
@media (max-width: 768px) {
  #premium-panel {
    width: min(294px, calc(100vw - 16px));
    top: 42%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 112px);
    border-radius: 7px;
  }
}
@media (orientation: landscape) and (max-height: 560px) {
  #premium-panel {
    width: min(336px, calc(100vw - 16px));
    top: 40%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 88px);
  }
}

#warp-pick-panel {
  border-color: #90cdf4;
}

.premium-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #2d3748;
}

.premium-row-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
}

.premium-row-icon .slot-icon-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: auto;
}

.premium-row-icon .slot-icon-glyph {
  font-size: 1.1rem;
  line-height: 1;
}

.premium-row-main {
  flex: 1;
  min-width: 0;
}

.premium-row-title {
  color: #edf2f7;
  font-weight: 600;
  font-size: 0.92rem;
}

.premium-row-desc {
  color: #a0aec0;
  font-size: 0.75rem;
  margin-top: 4px;
  line-height: 1.35;
}

.vendor-sell-dur.is-worn {
  color: #ecc94b;
}

.vendor-sell-dur.is-broken {
  color: #fc8181;
}

.premium-row-buy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.premium-price {
  color: #f6ad55;
  font-size: 0.8rem;
  white-space: nowrap;
}

.premium-buy-btn {
  background: #c05621;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.8rem;
}

.premium-buy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.premium-buy-btn:not(:disabled):hover {
  background: #dd6b20;
}

.vendor-tabs {
  display: flex;
  gap: 8px;
  padding: 0 14px 8px;
}

.vendor-tab {
  flex: 1;
  background: #1a202c;
  color: #a0aec0;
  border: 1px solid #4a5568;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.vendor-tab.is-active {
  color: #f7fafc;
  border-color: #68d391;
  background: #22543d;
}

.warp-pick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 16px;
  overflow-y: auto;
}

.warp-pick-btn {
  background: #2a4365;
  color: #ebf8ff;
  border: 1px solid #4299e1;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
}

.warp-pick-btn:hover {
  background: #2c5282;
}

#death-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 24px));
  background: rgba(20, 10, 14, 0.96);
  border: 1px solid #fc8181;
  border-radius: 12px;
  z-index: 110;
  padding: 20px 18px 16px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.death-title {
  color: #fc8181;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.death-hint {
  color: #e2e8f0;
  font-size: 0.85rem;
  margin: 0 0 16px;
  line-height: 1.4;
}

.death-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.death-actions button {
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  cursor: pointer;
}

#death-revive-spawn {
  background: #4a5568;
  color: #fff;
}

#death-revive-here {
  background: #c05621;
  color: #fff;
}

#death-revive-here:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}


/* ââ Party / Dungeon (3.4) ââ */
#party-hud {
  position: absolute;
  top: 12px;
  left: 200px;
  z-index: 40;
  background: rgba(15, 20, 30, 0.85);
  border: 1px solid #4a5568;
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 140px;
  max-width: 260px;
  max-height: 220px;
  overflow-y: auto;
  color: #e2e8f0;
  font-size: 0.8rem;
}
.party-hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.party-hud-title {
  font-weight: 700;
  color: #f6e05e;
}
.party-hud-close-btn {
  background: none;
  border: none;
  color: #a0aec0;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.party-hud-close-btn:hover { color: #fff; }
#party-hud-toggle {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 900;
  background: rgba(26,32,44,0.85);
  border: 1px solid rgba(246,211,101,0.5);
  border-radius: 6px;
  color: #f6e05e;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1;
  padding: 4px 9px;
  cursor: pointer;
}
.party-social-modes {
  color: #a0aec0;
  font-size: 0.85em;
}
.party-hud-share {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #4a5568;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.party-share-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 3px 4px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #e2e8f0;
  font-size: 0.7rem;
  cursor: pointer;
  text-align: left;
}
.party-share-toggle:hover {
  background: rgba(74, 85, 104, 0.45);
}
.party-share-toggle-caret {
  flex-shrink: 0;
  color: #a0aec0;
  font-size: 0.65rem;
  width: 0.85em;
}
.party-share-toggle-summary {
  flex: 1;
  min-width: 0;
  color: #cbd5e0;
}
.party-share-toggle-lock {
  flex-shrink: 0;
  font-size: 0.65rem;
  color: #fc8181;
}
.party-share-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}
.party-share-body.is-collapsed {
  display: none;
}
.party-share-lock {
  font-size: 0.68rem;
  color: #fc8181;
  margin-bottom: 2px;
}
.party-share-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.party-share-label {
  width: 28px;
  flex-shrink: 0;
  color: #a0aec0;
  font-size: 0.68rem;
}
.party-share-btns {
  display: flex;
  gap: 4px;
  flex: 1;
}
.party-share-btns button {
  flex: 1;
  font-size: 0.65rem;
  padding: 3px 4px;
  border: 1px solid #4a5568;
  border-radius: 4px;
  background: #2d3748;
  color: #cbd5e0;
  cursor: pointer;
}
.party-share-btns button.is-active {
  background: #2b6cb0;
  border-color: #63b3ed;
  color: #fff;
}
.party-share-btns button:disabled {
  opacity: 0.75;
  cursor: default;
}
.party-hud-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.party-hud-actions button {
  flex: 1;
  font-size: 0.72rem;
  padding: 4px 6px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: #4a5568;
  color: #fff;
}
#party-hud-disband { background: #9b2c2c; }

#party-invite-overlay,
#duel-invite-overlay,
#dungeon-overlay,
#dungeon-queue-ready-overlay,
#dungeon-share-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 96;
}
#dungeon-queue-ready,
#dungeon-share-confirm {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  z-index: 97;
  background: #1a202c;
  border: 1px solid #718096;
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 280px;
  color: #e2e8f0;
}

/* High-contrast primary action for the party share confirmation dialog. */
#dungeon-share-ok {
  border: 1px solid #6ee7a0 !important;
  background: linear-gradient(180deg, #238552 0%, #14653c 100%);
  color: #ffffff !important;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 2px 5px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

#dungeon-share-ok:hover:not(:disabled),
#dungeon-share-ok:focus-visible {
  border-color: #bbf7d0 !important;
  background: linear-gradient(180deg, #2fa867 0%, #197549 100%);
  color: #ffffff !important;
  outline: 2px solid rgba(187, 247, 208, 0.55);
  outline-offset: 2px;
}

#dungeon-share-ok:active:not(:disabled) {
  background: #105c35;
  transform: translateY(1px);
}

#dungeon-share-ok:disabled {
  border-color: #4a6656 !important;
  background: #30453a;
  color: #a9b9b0 !important;
  text-shadow: none;
  box-shadow: none;
  cursor: not-allowed;
}

.dungeon-share-pick {
  margin: 10px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#dungeon-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 16px));
  max-height: min(560px, calc(100vh - 24px));
  display: flex;
  flex-direction: column;
  z-index: 97;
  background: #1a202c;
  border: 1px solid #553c9a;
  border-radius: 10px;
  color: #e2e8f0;
  overflow: hidden;
}

/* Kael — กว้างเท่า Lia · ย้ำหลังกฎฐาน 480px (กัน cascade ทับเหมือน Bren/Sera) */
@media (max-width: 768px) {
  #dungeon-panel {
    width: min(294px, calc(100vw - 16px));
    top: 42%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 112px);
    border-radius: 7px;
  }
}
@media (orientation: landscape) and (max-height: 560px) {
  #dungeon-panel {
    width: min(336px, calc(100vw - 16px));
    top: 40%;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 88px);
  }
}

.dungeon-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 12px;
}
.dungeon-group-title {
  margin: 8px 0 6px;
  font-size: 0.95rem;
  color: #d6bcfa;
}
.dungeon-diff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  margin-bottom: 6px;
  background: rgba(45, 27, 61, 0.5);
  border-radius: 8px;
  border: 1px solid #553c9a;
}
.dungeon-diff-row.is-disabled { opacity: 0.45; }
.dungeon-diff-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
}
.dungeon-diff-status { color: #a0aec0; font-size: 0.75rem; }
.dungeon-clear-count { font-weight: normal; opacity: 0.85; font-size: 0.85em; }
.dungeon-enter-btn {
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  background: #6b46c1;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
.dungeon-enter-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.dungeon-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #2d3748;
}
.dungeon-footer button {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 8px;
  background: #4a5568;
  color: #fff;
  cursor: pointer;
}
.trade-nearby-actions {
  display: flex;
  gap: 4px;
}
.party-invite-btn { background: #6b46c1 !important; }
.party-social-line {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: #faf089;
}

/* à¸¡à¸·à¸­à¸à¸·à¸­à¹à¸à¹à¸¡à¸à¸­: à¸à¸±à¸à¸¡à¸´à¸à¸´à¹à¸¡à¸à¹à¸à¹à¸²à¸à¸²à¸à¸à¸­à¸à¸à¸§à¸²/à¸à¸ à¸à¸±à¸à¸¡à¸¸à¸¡à¸à¸­à¸«à¸£à¸·à¸­ inset à¸à¸±à¸ */
:fullscreen #minimap-wrap,
:-webkit-full-screen #minimap-wrap {
  top: max(12px, calc(env(safe-area-inset-top) + 6px));
  right: max(18px, calc(env(safe-area-inset-right) + 10px));
}

@media (orientation: landscape) and (max-height: 500px) {
  :fullscreen #minimap-wrap,
  :-webkit-full-screen #minimap-wrap {
    top: max(8px, calc(env(safe-area-inset-top) + 4px));
    right: max(22px, calc(env(safe-area-inset-right) + 14px));
  }

  :fullscreen #right-dock,
  :-webkit-full-screen #right-dock {
    right: max(124px, calc(env(safe-area-inset-right) + 116px));
  }
}

/*  Warp loading overlay (¾ÃÕÇÔÇ tools/warp_loading_preview.html)  */
#warp-loading {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 45% at 50% 38%, rgba(42, 58, 82, 0.45), transparent 62%),
    radial-gradient(ellipse 90% 70% at 50% 100%, rgba(18, 24, 36, 0.95), #020308 55%),
    #05070c;
  overflow: hidden;
  image-rendering: pixelated;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(201, 162, 39, 0.18);
  pointer-events: auto;
}
#warp-loading.hidden { display: none !important; }
#warp-loading.is-done { border-color: rgba(104, 211, 145, 0.35); }
#warp-loading.is-fading { opacity: 0; transition: opacity 0.32s ease; }

.warp-loading-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 55% 50% at 50% 42%, transparent 35%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}
.warp-loading-corners {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(240, 230, 200, 0.08);
  border-radius: 6px;
  pointer-events: none;
}
.warp-loading-corners::before,
.warp-loading-corners::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: rgba(201, 162, 39, 0.55);
  border-style: solid;
}
.warp-loading-corners::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}
.warp-loading-corners::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
}
.warp-loading-motes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.warp-loading-mote {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(240, 230, 200, 0.55);
  animation: warp-mote-rise linear infinite;
  opacity: 0;
}
.warp-loading-mote:nth-child(1) { left: 18%; animation-duration: 5.5s; animation-delay: 0s; }
.warp-loading-mote:nth-child(2) { left: 32%; width: 2px; height: 2px; animation-duration: 7s; animation-delay: 1.2s; }
.warp-loading-mote:nth-child(3) { left: 48%; animation-duration: 6.2s; animation-delay: 0.4s; }
.warp-loading-mote:nth-child(4) { left: 62%; width: 2px; height: 2px; animation-duration: 8s; animation-delay: 2.1s; }
.warp-loading-mote:nth-child(5) { left: 74%; animation-duration: 5.8s; animation-delay: 0.8s; }
.warp-loading-mote:nth-child(6) { left: 86%; width: 2px; height: 2px; animation-duration: 6.8s; animation-delay: 1.6s; }
@keyframes warp-mote-rise {
  0% { bottom: 8%; opacity: 0; transform: translateX(0); }
  15% { opacity: 0.7; }
  100% { bottom: 78%; opacity: 0; transform: translateX(12px); }
}
.warp-loading-brand {
  position: absolute;
  top: 8%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: Cinzel, Georgia, serif;
  font-size: clamp(0.7rem, 1.8vw, 0.82rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(201, 162, 39, 0.7);
  pointer-events: none;
}
.warp-loading-hint {
  position: absolute;
  top: 14%;
  left: 8%;
  right: 8%;
  text-align: center;
  color: rgba(232, 236, 244, 0.78);
  font-size: clamp(0.9rem, 2.4vw, 1.12rem);
  letter-spacing: 0.02em;
  pointer-events: none;
  line-height: 1.35;
}
.warp-loading-hint strong {
  display: inline-block;
  color: #f3e6c0;
  font-weight: 600;
  text-shadow: 0 0 18px rgba(201, 162, 39, 0.25);
}
.warp-loading-rule {
  display: block;
  width: min(160px, 36%);
  height: 1px;
  margin: 10px auto 0;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.65), transparent);
}
.warp-loading-ground {
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(280px, 58vw);
  height: 28px;
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse at center, rgba(91, 141, 239, 0.2), transparent 68%),
    radial-gradient(ellipse at center, rgba(20, 28, 42, 0.9), transparent 72%);
  border-radius: 50%;
  pointer-events: none;
}
.warp-loading-ring {
  position: absolute;
  left: 50%;
  top: 57%;
  width: min(200px, 42vw);
  height: 16px;
  transform: translateX(-50%);
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(201, 162, 39, 0.12);
  pointer-events: none;
  animation: warp-ring-pulse 1.8s ease-in-out infinite;
}
@keyframes warp-ring-pulse {
  0%, 100% { opacity: 0.45; transform: translateX(-50%) scaleX(1); }
  50% { opacity: 0.85; transform: translateX(-50%) scaleX(1.06); }
}
.warp-loading-runner {
  position: absolute;
  left: 50%;
  top: 40%;
  width: min(220px, 42vw);
  height: min(220px, 42vw);
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  pointer-events: none;
  animation: warp-run-bob 0.35s ease-in-out infinite alternate;
}
.warp-loading-runner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 12px 0 rgba(0, 0, 0, 0.6));
}
@keyframes warp-run-bob {
  from { transform: translate(-50%, -50%) translateY(0); }
  to { transform: translate(-50%, -50%) translateY(4px); }
}
.warp-loading-dust {
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(150px, 30vw);
  height: 14px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.28), transparent 70%);
  animation: warp-dust 0.45s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes warp-dust {
  from { opacity: 0.35; transform: translateX(-50%) scaleX(0.85); }
  to { opacity: 0.75; transform: translateX(-50%) scaleX(1.2); }
}
.warp-loading-ui {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 8%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(12, 16, 26, 0.55), rgba(8, 10, 16, 0.82));
  border: 1px solid rgba(240, 230, 200, 0.1);
  pointer-events: none;
}
.warp-loading-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.84rem;
  color: rgba(232, 236, 244, 0.85);
}
.warp-loading-pct {
  font-variant-numeric: tabular-nums;
  color: #f0d78c;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.warp-loading-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.warp-loading-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8a6a1e, #c9a227 45%, #f0d78c);
  box-shadow: 0 0 14px rgba(201, 162, 39, 0.35);
  transition: width 0.08s linear;
}

@media (max-width: 768px) {
  #quest-tracker {
    top: max(100px, calc(env(safe-area-inset-top) + 94px));
    left: max(6px, env(safe-area-inset-left));
    width: min(260px, calc(100vw - 12px));
    font-size: 0.65rem;
    line-height: 1.2;
  }
}

/* Pet Collection — mobile follows the Character/Quests panel sizing rules. */
@media (max-width: 768px) {
  #pet-book {
    top: 42%;
    width: min(294px, calc(100vw - 16px));
    height: min(560px, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 112px));
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 112px);
    border-radius: 10px;
  }

  #pet-book .player-menu-header {
    min-height: 34px;
    padding: 5px 7px;
  }

  #pet-book .player-menu-header h2 {
    min-width: 0;
    overflow: hidden;
    font-size: .68rem;
    letter-spacing: .45px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #pet-book .menu-close-btn {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    font-size: .82rem;
  }

  .pet-book-body {
    padding: 8px 30px 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .pet-portrait {
    width: 84px;
    height: 84px;
  }

  .pet-book-page h3 {
    font-size: .88rem;
  }

  .pet-book-page h4 {
    font-size: .76rem;
  }

  .pet-book-page p,
  .pet-book-page small {
    font-size: .7rem;
    line-height: 1.3;
  }

  .pet-book-page section,
  .pet-evo-box {
    margin: 6px 0;
    padding: 6px 7px;
  }

  .pet-page-arrow {
    top: 46%;
    width: 34px;
    min-height: 44px;
    padding: 4px;
    font-size: 25px;
    touch-action: manipulation;
  }

  .pet-page-prev { left: 2px; }
  .pet-page-next { right: 2px; }

  .pet-main-action button,
  .pet-evo-box button {
    min-width: 128px;
    min-height: 34px;
    padding: 5px 10px;
    font-size: .72rem;
    touch-action: manipulation;
  }

  #pet-confirm-dialog {
    width: min(294px, calc(100vw - 16px));
    max-height: calc(100dvh - 24px);
    padding: 13px 14px;
    overflow-y: auto;
    font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
  }

  .pet-confirm-header {
    margin-bottom: 8px;
    padding-right: 32px;
  }

  #pet-confirm-title {
    font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
    font-size: .82rem;
    line-height: 1.3;
  }

  #pet-confirm-subtitle {
    font-size: .66rem;
    line-height: 1.25;
  }

  .pet-confirm-message {
    padding: 8px 9px;
    font-size: .72rem;
    line-height: 1.4;
  }

  .pet-confirm-actions {
    gap: 6px;
    margin-top: 9px;
  }

  .pet-confirm-actions button {
    min-height: 32px;
    padding: 5px 11px;
    font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
    font-size: .7rem;
  }

  #pet-confirm-dialog .pet-confirm-close {
    width: 26px;
    height: 26px;
    font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
    font-size: .78rem;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #pet-book {
    top: 42%;
    width: min(336px, calc(100vw - 16px));
    height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 88px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 88px);
  }

  #pet-book .player-menu-header {
    min-height: 28px;
    padding: 3px 6px;
  }

  #pet-book .player-menu-header h2 {
    font-size: .64rem;
  }

  #pet-book .menu-close-btn {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .pet-book-body {
    padding: 5px 28px 8px;
  }

  .pet-portrait {
    width: 72px;
    height: 72px;
  }

  .pet-book-page h3 {
    margin-top: 2px;
    font-size: .8rem;
  }

  .pet-book-page h4 {
    font-size: .7rem;
  }

  .pet-book-page p,
  .pet-book-page small {
    font-size: .64rem;
    line-height: 1.2;
  }

  .pet-book-page section,
  .pet-evo-box {
    margin: 4px 0;
    padding: 4px 6px;
  }

  .pet-page-arrow {
    top: 42%;
    min-height: 40px;
    font-size: 22px;
  }

  .pet-main-action button,
  .pet-evo-box button {
    min-height: 30px;
    padding: 3px 9px;
    font-size: .66rem;
  }

  #pet-confirm-dialog {
    width: min(336px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    padding: 9px 11px;
  }

  #pet-confirm-title {
    font-size: .76rem;
  }

  #pet-confirm-subtitle {
    font-size: .62rem;
  }

  .pet-confirm-message {
    padding: 6px 8px;
    font-size: .68rem;
    line-height: 1.3;
  }

  .pet-confirm-actions {
    margin-top: 7px;
  }

  .pet-confirm-actions button {
    min-height: 30px;
    padding: 4px 9px;
    font-size: .66rem;
  }
}

/* Character Status/Bag — compact landscape needs a complete height chain
   so the inner stat list can become the scroll container. */
@media (orientation: landscape) and (max-height: 560px) {
  #player-menu.theme-round-gold.is-dual-layout {
    height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 88px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 88px);
  }

  #player-menu.is-dual-layout .player-menu-body {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }

  #player-menu.is-dual-layout .menu-dual-layout {
    height: 100%;
    min-height: 0;
    flex: 1 1 0;
    overflow: hidden;
  }

  #player-menu.is-dual-layout .menu-equip-column,
  #player-menu.is-dual-layout .menu-detail-column {
    height: 100%;
    min-height: 0;
  }

  #player-menu.is-dual-layout #menu-status-body:not(.hidden) {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #player-menu.is-dual-layout #menu-status-body .stat-grid.panel-scroll {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }
}

/* Mobile: quest progress is checked from Character > Quests.
   Hide the HUD tracker to keep the playfield clear. */
@media (max-width: 768px) {
  #quest-tracker {
    display: none !important;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  #quest-tracker {
    display: none !important;
  }
}

/* Player HUD — portrait + stacked vitals, inspired by classic MMORPG HUDs. */
#hud {
  top: 12px;
  left: 12px;
  font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
}

#hud .hud-block {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.hud-portrait-frame {
  position: relative;
  z-index: 2;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  overflow: hidden;
  border: 3px solid #9a7430;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%,#4a3924 0%,#21170f 68%,#0d0906 100%);
  box-shadow: 0 0 0 2px #2a190c,0 0 0 3px rgba(201,162,39,.32),inset 0 0 12px rgba(0,0,0,.72),0 4px 10px rgba(0,0,0,.5);
}

.hud-portrait-frame::before,
.hud-portrait-frame::after {
  display: none;
}

.hud-player-portrait {
  position: absolute;
  left: 50%;
  top: 25%;
  width: 230%;
  height: 230%;
  object-fit: contain;
  object-position: center;
  transform: translate(-50%,-22%) scale(1.05);
  transform-origin: center 20%;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.75));
}

.hud-level-badge {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  min-width: 38px;
  padding: 1px 5px;
  border: 1px solid #a47b31;
  border-radius: 999px;
  background: linear-gradient(180deg,#3b2818 0%,#17100b 100%);
  color: #f0d78c;
  font-size: .62rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.75);
}

.hud-main {
  position: relative;
  z-index: 1;
  width: 260px;
  margin-left: -7px;
  padding: 5px 7px 5px 16px;
  box-sizing: border-box;
  border: 2px solid #6b4a28;
  border-radius: 16px 12px 12px 16px;
  background: linear-gradient(180deg,rgba(47,31,20,.95) 0%,rgba(19,14,10,.93) 100%);
  box-shadow: 0 0 0 1px #120c08,inset 0 1px 0 rgba(255,220,140,.11),0 5px 15px rgba(0,0,0,.48);
}

.hud-main::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -13px;
  top: 50%;
  width: 24px;
  height: 42px;
  transform: translateY(-50%);
  border-top: 2px solid #6b4a28;
  border-bottom: 2px solid #6b4a28;
  background: linear-gradient(180deg,#42291a 0%,#17100b 100%);
  box-shadow: 0 0 0 1px #120c08;
}

#hud .hud-title-row {
  min-height: 20px;
  gap: 5px;
  margin: -5px -7px 4px -16px;
  padding: 2px 6px 2px 17px;
  border-bottom: 1px solid #7a4e23;
  border-radius: 14px 10px 3px 3px;
  background: linear-gradient(180deg,#67251e 0%,#351510 100%);
  box-shadow: inset 0 1px 0 rgba(255,218,150,.14);
}

#hud #player-name {
  margin: 0;
  color: #f7e5b1;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 1px 1px 1px #000;
}

#hud .bar-row {
  display: grid;
  grid-template-columns: 27px minmax(0,1fr);
  gap: 4px;
  margin-bottom: 3px;
}

#hud .bar-label {
  color: #d5c29a;
  font-size: .62rem;
  font-weight: 700;
  line-height: 12px;
  text-align: right;
  text-shadow: 1px 1px 1px #000;
}

#hud .bar {
  position: relative;
  height: 12px;
  overflow: hidden;
  border: 1px solid #17100b;
  border-radius: 999px;
  background: #171b20;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.85),0 0 0 1px rgba(176,132,48,.32);
}

#hud #hp-fill,
#hud #mp-fill,
#hud #exp-fill {
  position: absolute;
  inset: 0 auto 0 0;
}

#hud #hp-fill { background: linear-gradient(180deg,#f15042 0%,#b51216 54%,#65070c 100%); }
#hud #mp-fill { background: linear-gradient(180deg,#55bafa 0%,#1768c8 54%,#0b357b 100%); }
#hud #exp-fill { background: linear-gradient(180deg,#a8ea5b 0%,#55a72a 54%,#285d18 100%); }

#hud .bar-value {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: #fff7e8;
  font-size: .58rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-shadow: -1px 0 #000,0 1px #000,1px 0 #000,0 -1px #000;
}

#hud .hud-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-top: 2px;
  padding-left: 2px;
}

#hud .hud-meta {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  opacity: 1;
}

#hud #map-info {
  margin: 0;
  overflow: hidden;
  color: #b8a888;
  font-size: .62rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hud #logout-btn,
#hud #mail-hud-btn {
  flex: 0 0 auto;
  margin: 0;
  padding: 2px 5px;
  border: 1px solid #5b4529;
  border-radius: 5px;
  background: linear-gradient(180deg,#2d241b 0%,#17110d 100%);
  color: #b8a888;
  font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
  font-size: .58rem;
  line-height: 1.15;
}

#hud #mail-hud-btn {
  color: #f0d78c;
  border-color: #80662c;
}

#hud #fullscreen-btn:not(.hidden) {
  position: static;
  flex: 0 0 auto;
  margin: 0;
  padding: 1px 5px;
  border: 1px solid #9b7530;
  border-radius: 5px;
  background: rgba(18,11,8,.5);
  color: #f0d78c;
  font-family: "Sarabun","Segoe UI",Tahoma,sans-serif;
  font-size: .58rem;
  line-height: 1.25;
  transform: none;
}

@media (max-width: 768px) {
  #hud {
    top: max(6px,env(safe-area-inset-top));
    left: max(6px,env(safe-area-inset-left));
  }

  .hud-portrait-frame {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
    border-width: 3px;
  }

  .hud-level-badge {
    min-width: 31px;
    padding: 1px 4px;
    font-size: .6rem;
  }

  .hud-main {
    width: min(190px,calc(100vw - 52px));
    margin-left: -5px;
    padding: 4px 5px 4px 12px;
  }

  #hud .hud-title-row {
    min-height: 17px;
    margin: -4px -5px 3px -12px;
    padding: 2px 4px 2px 13px;
  }

  #hud #player-name {
    font-size: .72rem;
  }

  #hud .bar-row {
    grid-template-columns: 23px minmax(0,1fr);
    gap: 3px;
    margin-bottom: 2px;
  }

  #hud .bar-label {
    font-size: .62rem;
    line-height: 9px;
  }

  #hud .bar {
    height: 9px;
  }

  #hud .bar-value,
  #hud #logout-btn,
  #hud #mail-hud-btn,
  #hud #fullscreen-btn:not(.hidden) {
    font-size: .6rem;
  }

  #hud #map-info {
    font-size: .64rem;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  #hud {
    top: max(4px,env(safe-area-inset-top));
    left: max(4px,env(safe-area-inset-left));
  }

  .hud-portrait-frame {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .hud-level-badge {
    min-width: 31px;
    font-size: .55rem;
  }

  .hud-main {
    width: 176px;
    margin-left: -4px;
    padding: 3px 4px 3px 11px;
  }

  #hud .hud-title-row {
    min-height: 15px;
    margin: -3px -4px 2px -11px;
    padding: 1px 3px 1px 12px;
  }

  #hud #player-name {
    font-size: .72rem;
  }

  #hud .bar-row {
    grid-template-columns: 21px minmax(0,1fr);
    margin-bottom: 1px;
  }

  #hud .bar-label,
  #hud #map-info {
    font-size: .62rem;
  }

  #hud .bar {
    height: 8px;
  }

  #hud .bar-value,
  #hud #logout-btn,
  #hud #mail-hud-btn,
  #hud #fullscreen-btn:not(.hidden) {
    font-size: .6rem;
  }

  #hud .hud-footer {
    margin-top: 1px;
  }
}
.menu-dock-icon,
.menu-dock-key {
  display: none;
}

@media (min-width: 769px) and (any-pointer: fine) {
  #right-dock {
    top: 168px;
    right: 14px;
    max-width: none;
    gap: 7px;
  }

  #menu-dock {
    position: static;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
    max-width: none;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #menu-dock::before,
  #menu-dock::after {
    content: none;
  }

  #menu-dock button,
  #menu-dock #audio-settings-btn.audio-settings-gear {
    position: relative;
    min-width: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    display: grid;
    place-items: center;
    overflow: visible;
    border: 2px solid #6b4a28;
    border-radius: 9px;
    color: #f1ce63;
    background: linear-gradient(180deg,rgba(58,38,24,.96) 0%,rgba(20,14,10,.94) 100%);
    box-shadow: 0 0 0 1px #120c08,inset 0 1px 0 rgba(255,220,140,.13),0 3px 9px rgba(0,0,0,.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    cursor: pointer;
    transition: transform .12s ease,color .15s ease,border-color .15s ease,background .15s ease,box-shadow .15s ease;
  }

  #menu-dock button::after {
    content: none;
  }

  #menu-dock button:hover:not(:disabled) {
    transform: translateY(-2px);
    color: #fff3bd;
    border-color: #c99535;
    background: linear-gradient(180deg,rgba(103,55,29,.98) 0%,rgba(39,23,14,.96) 100%);
    box-shadow: 0 0 0 1px #241307,inset 0 1px 0 rgba(255,225,150,.22),0 0 10px color-mix(in srgb,currentColor 48%,transparent),0 4px 9px rgba(0,0,0,.55);
  }

  #menu-dock button:active:not(:disabled) {
    transform: translateY(1px) scale(.96);
    box-shadow: inset 0 2px 6px rgba(0,0,0,.68);
  }

  #menu-dock .menu-dock-icon {
    display: block;
    width: 30px;
    height: 30px;
    object-fit: contain;
    image-rendering: auto;
    filter: saturate(1.12) drop-shadow(0 1px 2px rgba(0,0,0,.85));
  }


  #menu-dock .menu-dock-label,
  #menu-dock .menu-dock-key {
    display: none;
  }

  #menu-dock #audio-settings-btn.audio-settings-gear {
    font-size: 1rem;
    line-height: 1;
  }
}
@media (min-width: 769px) and (any-pointer: fine) {
  #game-canvas.world-cursor-combat {
    cursor: url('/assets/icons/cursors/sword.svg') 3 3, crosshair;
  }

  #game-canvas.world-cursor-talk {
    cursor: url('/assets/icons/cursors/talk.svg') 6 6, pointer;
  }
}
