:root {
  --bg-deep: #14100d;
  --bg-panel: rgba(24, 19, 15, 0.95);
  --bg-card: rgba(40, 31, 24, 0.92);
  --bg-chip: rgba(32, 25, 19, 0.88);
  --border-gold: rgba(212, 169, 98, 0.45);
  --border-strong: rgba(232, 189, 114, 0.78);
  --text-main: #f5efe6;
  --text-sub: #c9bba7;
  --text-muted: #9a8c7a;
  --accent-gold: #e8b95c;
  --accent-warm: #d97736;
  --accent-hp: #3d9a6d;
  --accent-boss: #c9463d;
  --accent-magic: #7c6ae6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* 3D 畫布 */
#game-canvas-wrap {
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

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

/* 最頂端非官方聲明（永遠可見，不可被任何面板遮擋） */
#unofficial-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: calc(3px + var(--safe-top)) 10px 3px;
  background: linear-gradient(90deg, rgba(20, 15, 11, 0.94), rgba(45, 31, 20, 0.94), rgba(20, 15, 11, 0.94));
  border-bottom: 1px solid var(--border-gold);
  color: #f3dfb7;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0.02em;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 常駐 HUD 層 */
#hud-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

#hud-layer button,
#hud-layer .interactive {
  pointer-events: auto;
}

/* 左上角色狀態卡 */
#hud-player-card {
  position: fixed;
  top: calc(28px + var(--safe-top));
  left: calc(10px + var(--safe-left));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-chip);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  width: min(230px, 56vw);
  max-width: min(230px, 56vw);
  pointer-events: auto;
  cursor: pointer;
}

.avatar-badge {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.player-meta {
  min-width: 0;
  flex: 1;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-spec-sub {
  font-size: 11px;
  color: var(--accent-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hp-bar-track {
  margin-top: 3px;
  width: 100%;
  height: 7px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2f855a, #48bb78);
  transition: width 0.15s ease;
}

/* 左上角常駐網遊風格隊伍欄（緊接在角色狀態卡正下方） */
#hud-party-bar {
  position: fixed;
  top: calc(96px + var(--safe-top));
  left: calc(10px + var(--safe-left));
  width: min(230px, 56vw);
  z-index: 210;
  pointer-events: auto;
}

.party-cta-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.party-cta-btn {
  flex: 1;
  min-width: 0;
  justify-content: center;
  padding: 6px 8px;
  font-size: 12px;
  background: rgba(34, 25, 18, 0.88);
  border: 1px dashed var(--border-strong);
  color: #f6dca3;
}

.party-collapse-btn {
  display: none;
  appearance: none;
  border: 1px solid var(--border-gold);
  background: rgba(24, 18, 13, 0.9);
  color: var(--text-sub);
  border-radius: 7px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}

.party-mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(30, 22, 16, 0.92);
  border: 1px solid var(--border-strong);
  color: #f6dca3;
  border-radius: 99px;
  cursor: pointer;
}

.party-hud-panel {
  background: rgba(22, 17, 13, 0.88);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  overflow: hidden;
  backdrop-filter: blur(5px);
}

.party-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: rgba(44, 32, 22, 0.94);
  border-bottom: 1px solid rgba(212, 169, 98, 0.28);
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-gold);
  cursor: pointer;
}

.party-hud-member {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.12s;
}

.party-hud-member:last-child {
  border-bottom: none;
}

.party-hud-member:hover {
  background: rgba(232, 185, 92, 0.12);
}

.party-hud-member .avatar-badge {
  width: 26px;
  height: 26px;
  font-size: 14px;
  border-radius: 6px;
}

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

.party-member-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.party-member-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.party-member-spec {
  font-size: 10px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.party-hp-track {
  margin-top: 2px;
  height: 5px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.party-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #2b8a5b, #48bb78);
  transition: width 0.18s ease;
}

/* 點擊隊友展開快捷操作浮層 */
#party-quick-popover {
  display: none;
  position: fixed;
  top: calc(130px + var(--safe-top));
  left: calc(10px + var(--safe-left));
  width: min(220px, 60vw);
  z-index: 320;
  background: rgba(24, 18, 13, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.65);
}

#party-quick-popover.open {
  display: block;
}

.party-pop-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.party-pop-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.party-pop-actions .chip {
  width: 100%;
  justify-content: center;
}

/* 收到組隊邀請即時橫幅 */
#party-invite-banner {
  display: none;
  position: fixed;
  top: calc(74px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 88vw);
  z-index: 350;
  background: rgba(34, 24, 16, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

#party-invite-banner.open {
  display: flex;
}

body.drawer-open #hud-party-bar,
body.drawer-open #party-quick-popover,
body.chat-expanded #hud-party-bar,
body.chat-expanded #party-quick-popover {
  opacity: 0;
  pointer-events: none;
}

/* 中上 Boss 狀態條（僅試煉場顯示） */
#hud-boss-bar {
  position: fixed;
  top: calc(28px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 60vw);
  padding: 6px 12px;
  background: rgba(34, 15, 14, 0.9);
  border: 1px solid rgba(232, 118, 98, 0.65);
  border-radius: 10px;
  display: none;
}

#hud-boss-bar.active {
  display: block;
}

.boss-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #ffd7cf;
}

.boss-hp-track {
  margin-top: 4px;
  height: 10px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 99px;
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #9b2c2c, #e53e3e);
  transition: width 0.12s linear;
}

.boss-threat {
  margin-top: 3px;
  font-size: 11px;
  color: #f6c89f;
}

/* 右上功能選單列 */
#hud-rail {
  position: fixed;
  top: calc(28px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: calc(100vw - 260px);
}

.chip {
  appearance: none;
  border: 1px solid var(--border-gold);
  background: var(--bg-chip);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.chip:hover {
  background: rgba(58, 44, 32, 0.95);
  border-color: var(--border-strong);
}

.chip:active {
  transform: scale(0.96);
}

.chip:disabled {
  opacity: 0.45;
  filter: grayscale(0.45);
  cursor: not-allowed;
  transform: none;
}

.chip.primary {
  background: linear-gradient(180deg, #b87c32, #8c581c);
  border-color: #f0c97e;
  color: #fff8eb;
}

.chip.badge-dot::after {
  content: attr(data-badge);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: #d9483b;
  color: #fff;
  font-size: 10px;
  margin-left: 2px;
}

/* 互動提示按鈕（靠近傳送門／榮耀碑時出現） */
#hud-interact-btn {
  position: fixed;
  left: 50%;
  bottom: calc(175px + var(--safe-bottom));
  transform: translateX(-50%);
  display: none;
  padding: 10px 18px;
  border-radius: 99px;
  border: 1px solid #f5cf84;
  background: linear-gradient(180deg, rgba(168, 108, 42, 0.96), rgba(112, 68, 22, 0.96));
  color: #fffaf0;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  z-index: 250;
}

#hud-interact-btn.visible {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 動態浮動移動輪盤（平時完全隱藏，按壓螢幕下方操作區時才於觸碰點顯示，放開即消失） */
#mobile-joystick-zone {
  position: fixed;
  left: 0;
  top: 0;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 185, 92, 0.2), rgba(20, 15, 11, 0.45));
  border: 1.5px solid rgba(232, 185, 92, 0.55);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  touch-action: none;
  pointer-events: none;
  display: none;
  z-index: 215;
}

#mobile-joystick-zone.active {
  display: block;
}

#mobile-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f2cf88, #a66f28);
  border: 2px solid #fff0cc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* 右下：戰鬥技能盤（嚴格無閃避鈕；手機含普攻大鈕＋4 顆等大技能鈕，電腦無普攻鈕） */
#skill-cluster {
  position: fixed;
  right: calc(14px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.skill-bar-desktop {
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
}

.skill-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: radial-gradient(circle at 30% 25%, #4a3726, #231912);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s, filter 0.12s;
}

.skill-btn:active {
  transform: scale(0.93);
}

.skill-btn.on-cd {
  filter: brightness(0.48) grayscale(0.5);
  cursor: not-allowed;
}

.skill-btn .skill-key {
  position: absolute;
  top: -6px;
  left: -4px;
  background: #1a130e;
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 6px;
}

.skill-btn .skill-short {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  max-width: 52px;
}
.skill-btn.skill-btn-named .skill-short {
  font-size: 11px;
  white-space: normal;
  letter-spacing: 0;
}

.skill-btn .skill-cd {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(12, 9, 7, 0.68);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #ffd98a;
}

.skill-btn.on-cd .skill-cd {
  display: flex;
}

#btn-basic-attack {
  display: none;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 2px solid #f7d288;
  background: radial-gradient(circle at 35% 30%, #d98234, #7c3814);
  color: #fffaf0;
  font-size: 18px;
  font-weight: 800;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  pointer-events: auto;
}

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

/* 左下迷你聊天框（桌面）與聊天按鈕（手機） */
#chat-mini-box {
  position: fixed;
  left: calc(12px + var(--safe-left));
  bottom: calc(14px + var(--safe-bottom));
  width: 310px;
  max-height: 190px;
  display: flex;
  flex-direction: column;
  background: rgba(20, 15, 11, 0.8);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  overflow: hidden;
  pointer-events: auto;
}

#chat-mini-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: rgba(38, 28, 20, 0.92);
  border-bottom: 1px solid rgba(212, 169, 98, 0.28);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-gold);
  cursor: pointer;
}

.mini-header-btn {
  appearance: none;
  border: 1px solid rgba(212, 169, 98, 0.45);
  background: rgba(24, 18, 13, 0.88);
  color: var(--text-main);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

#chat-log {
  flex: 1;
  min-height: 76px;
  max-height: 120px;
  overflow-y: auto;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-sub);
  touch-action: pan-y;
  cursor: pointer;
}

#chat-log .chat-line,
.chat-modal-log .chat-line {
  margin-bottom: 4px;
  word-break: break-word;
  line-height: 1.45;
}

.ch-tag {
  font-weight: 800;
  margin-right: 4px;
}

.ch-tag-world { color: #f5c86b; }
.ch-tag-guild { color: #6ee7b7; }
.ch-tag-nearby { color: #7dd3fc; }
.ch-tag-whisper { color: #f472b6; }
.ch-tag-party { color: #fdba74; }

/* 展開式大聊天視窗（z-index 650 高於技能盤 200 與左抽屜 500） */
#chat-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 640;
  background: rgba(0, 0, 0, 0.42);
  display: none;
}

#chat-modal-backdrop.open {
  display: block;
}

#chat-modal {
  position: fixed;
  left: calc(12px + var(--safe-left));
  bottom: calc(14px + var(--safe-bottom));
  width: min(580px, calc(100vw - 24px));
  height: min(440px, 68vh);
  z-index: 650;
  background: rgba(22, 17, 13, 0.97);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.72);
  display: none;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
}

#chat-modal.open {
  display: flex;
}

.chat-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(42, 31, 22, 0.96);
  border-bottom: 1px solid var(--border-gold);
  flex-shrink: 0;
}

.chat-modal-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-gold);
}

.chat-modal-tabs {
  display: flex;
  gap: 6px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(212, 169, 98, 0.25);
  overflow-x: auto;
  flex-shrink: 0;
}

.chat-modal-tabs .tab-btn.badge-dot::after {
  content: attr(data-badge);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: #d9483b;
  color: #fff;
  font-size: 10px;
  margin-left: 4px;
}

.chat-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.chat-whisper-sidebar {
  display: none;
  width: 176px;
  flex-shrink: 0;
  border-right: 1px solid rgba(212, 169, 98, 0.25);
  background: rgba(16, 12, 9, 0.75);
  overflow-y: auto;
  padding: 6px;
  touch-action: pan-y;
}

#chat-modal.whisper-mode .chat-whisper-sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.whisper-peer-btn {
  appearance: none;
  width: 100%;
  border: 1px solid rgba(212, 169, 98, 0.25);
  background: rgba(32, 25, 19, 0.85);
  color: var(--text-main);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  text-align: left;
}

.whisper-peer-btn.active {
  background: rgba(164, 106, 36, 0.35);
  border-color: #f3ce84;
}

.peer-name-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.peer-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #6b7280;
}

.status-dot.online {
  background: #48bb78;
}

.unread-pill {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 99px;
  background: #d9483b;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-messages-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-whisper-header {
  display: none;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #f9a8d4;
  background: rgba(45, 24, 38, 0.5);
  border-bottom: 1px solid rgba(244, 114, 182, 0.25);
  flex-shrink: 0;
}

#chat-modal.whisper-mode .chat-whisper-header {
  display: block;
}

.chat-modal-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-main);
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.whisper-bubble {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.whisper-bubble.self {
  align-items: flex-end;
}

.whisper-bubble-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.whisper-bubble-text {
  max-width: 82%;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(48, 37, 29, 0.92);
  border: 1px solid rgba(212, 169, 98, 0.3);
  word-break: break-word;
}

.whisper-bubble.self .whisper-bubble-text {
  background: rgba(146, 91, 31, 0.45);
  border-color: rgba(240, 201, 126, 0.55);
}

.chat-modal-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid rgba(212, 169, 98, 0.3);
  background: rgba(15, 11, 8, 0.96);
  flex-shrink: 0;
}

.chat-channel-pill {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(232, 185, 92, 0.16);
  border: 1px solid rgba(232, 185, 92, 0.45);
  color: #f5d896;
  white-space: nowrap;
  flex-shrink: 0;
}

#chat-modal-input {
  flex: 1;
  min-width: 0;
  background: rgba(28, 22, 17, 0.95);
  border: 1px solid var(--border-gold);
  border-radius: 7px;
  color: var(--text-main);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}

#chat-modal-input:focus {
  border-color: var(--border-strong);
}

body.chat-expanded #chat-mini-box {
  display: none !important;
}

body.chat-expanded #mobile-chat-toggle {
  display: none !important;
}

#chat-input-row {
  display: flex;
  border-top: 1px solid rgba(212, 169, 98, 0.25);
  background: rgba(15, 11, 8, 0.9);
}

#chat-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 7px 8px;
  font-size: 12px;
  outline: none;
}

#chat-send-btn {
  border: none;
  background: rgba(184, 124, 50, 0.85);
  color: #fff;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

#mobile-chat-toggle {
  display: none;
  position: fixed;
  left: calc(12px + var(--safe-left));
  bottom: calc(176px + var(--safe-bottom));
  z-index: 230;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#mobile-chat-toggle.dragging {
  cursor: grabbing;
  opacity: 0.92;
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* 抽屜／主功能面板（桌面左側 460px，手機全螢幕） */
#drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.45);
  display: none;
}

#drawer-backdrop.open {
  display: block;
}

#main-drawer {
  position: fixed;
  top: calc(30px + var(--safe-top));
  left: calc(10px + var(--safe-left));
  bottom: calc(12px + var(--safe-bottom));
  width: min(460px, calc(100vw - 20px));
  z-index: 500;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#main-drawer.open {
  display: flex;
}

/* 裝備詳情小版面（桌面位於左抽屜右側並存；手機置中浮動卡片） */
#gear-detail-modal {
  display: none;
  position: fixed;
  top: calc(30px + var(--safe-top));
  left: calc(482px + var(--safe-left));
  width: 300px;
  max-height: calc(100vh - 50px);
  overflow-y: auto;
  z-index: 560;
  background: rgba(24, 18, 13, 0.98);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.72);
  pointer-events: auto;
}

#gear-detail-modal.open {
  display: block;
}

/* 職業教學技能面板（電腦版左選職業、右看技能；手機版滑出可關閉） */
#spec-skill-panel {
  display: none;
  position: fixed;
  top: calc(30px + var(--safe-top));
  left: calc(482px + var(--safe-left));
  bottom: calc(12px + var(--safe-bottom));
  width: min(440px, calc(100vw - 498px));
  z-index: 560;
  background: rgba(22, 17, 13, 0.98);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.72);
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
}

#spec-skill-panel.open {
  display: flex;
}

.spec-skill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(42, 31, 22, 0.96);
  border-bottom: 1px solid var(--border-gold);
  flex-shrink: 0;
}

.spec-skill-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 20px;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.spec-row-selectable {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.spec-row-selectable:hover {
  border-color: var(--border-strong);
}

.spec-row-selectable.selected {
  border-color: #f5cf84;
  background: rgba(164, 106, 36, 0.22);
}

.skill-guide-card {
  background: rgba(34, 26, 20, 0.92);
  border: 1px solid rgba(212, 169, 98, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.skill-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.skill-key-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(184, 124, 50, 0.32);
  border: 1px solid var(--border-strong);
  color: #ffe2a8;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.skill-cd-badge {
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(15, 11, 8, 0.78);
  border: 1px solid rgba(212, 169, 98, 0.4);
  color: #ffd98a;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.skill-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.skill-meta-chip {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-sub);
  font-size: 11px;
}

.skill-desc-text {
  font-size: 12.5px;
  color: var(--text-main);
  line-height: 1.55;
}

.gear-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(212, 169, 98, 0.3);
}

.gear-affix-list {
  margin: 8px 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 12px;
  color: #f3dfb7;
}

.chip.danger {
  background: rgba(168, 44, 38, 0.9);
  border-color: #f08a80;
  color: #fff;
}

.gear-delete-confirm {
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(120, 26, 22, 0.35);
  border: 1px solid rgba(240, 138, 128, 0.6);
  font-size: 12px;
  color: #ffd7cf;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(42, 31, 22, 0.96);
  border-bottom: 1px solid var(--border-gold);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-gold);
}

.drawer-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(212, 169, 98, 0.25);
  overflow-x: auto;
  flex-shrink: 0;
}

.tab-btn {
  appearance: none;
  border: 1px solid var(--border-gold);
  background: rgba(30, 23, 18, 0.9);
  color: var(--text-sub);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: #a46a24;
  border-color: #f3ce84;
  color: #fff;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 20px;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 面板共用卡片與網格 */
.section-card {
  background: var(--bg-card);
  border: 1px solid rgba(212, 169, 98, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-gold);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.24);
  border-radius: 6px;
  font-size: 13px;
}

.stat-label {
  color: var(--text-sub);
}

.stat-val {
  font-weight: 700;
  color: var(--text-main);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.slot-card {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(212, 169, 98, 0.32);
  background: rgba(20, 15, 11, 0.72);
  cursor: pointer;
  transition: border-color 0.15s;
}

.slot-card.selected,
.slot-card:hover {
  border-color: var(--accent-gold);
}

.slot-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.slot-item-name {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.slot-item-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--accent-gold);
}

.tag-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(232, 185, 92, 0.16);
  border: 1px solid rgba(232, 185, 92, 0.4);
  color: #f5d896;
  margin: 0 4px 4px 0;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(18, 14, 10, 0.7);
  border: 1px solid rgba(212, 169, 98, 0.22);
  margin-bottom: 6px;
}

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

.item-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.appearance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.appearance-card {
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid rgba(212, 169, 98, 0.28);
  background: rgba(18, 14, 10, 0.72);
  text-align: center;
  cursor: pointer;
}

.appearance-card.active {
  border-color: #f5cf84;
  background: rgba(164, 106, 36, 0.28);
}

.appearance-thumb {
  width: 44px;
  height: 44px;
  margin: 0 auto 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.appearance-thumb img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.form-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-gold);
  background: rgba(12, 9, 7, 0.85);
  color: var(--text-main);
  font-size: 13px;
  margin-bottom: 8px;
}

/* 吐司通知 */
#toast-stack {
  position: fixed;
  top: calc(74px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: min(360px, 88vw);
}

.toast-item {
  background: rgba(34, 24, 16, 0.96);
  border: 1px solid var(--border-strong);
  color: #fff3d6;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* 手機 9:16 直屏自適應 */
@media (max-width: 820px), (pointer: coarse) {
  /* 頂部聲明強制一行，避免擋住角色卡與其他 HUD */
  #unofficial-banner {
    font-size: 9.5px;
    letter-spacing: 0;
    padding: calc(2px + var(--safe-top)) 6px 2px;
  }

  /* 手機版：角色卡與組隊欄等寬（約 158px），組隊欄支援收起鈕與左滑收合 */
  #hud-player-card {
    width: 158px;
    max-width: 46vw;
    padding: 5px 8px;
  }

  #hud-party-bar {
    top: calc(90px + var(--safe-top));
    width: 158px;
    max-width: 46vw;
    touch-action: pan-x;
  }

  #hud-party-bar.collapsed {
    width: auto;
  }

  .party-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .party-cta-btn {
    font-size: 11px;
    padding: 5px 6px;
  }

  #btn-basic-attack {
    display: flex;
  }

  #skill-cluster {
    right: calc(14px + var(--safe-right));
    bottom: calc(16px + var(--safe-bottom));
    width: 224px;
    height: 224px;
    display: block;
  }

  #btn-basic-attack {
    position: absolute;
    width: 78px;
    height: 78px;
    right: 10px;
    bottom: 10px;
    font-size: 17px;
  }

  .skill-bar-desktop {
    position: absolute;
    inset: 0;
    display: block;
  }

  /* 4 顆等大 54px 技能鈕沿半徑 132px 的 90° 弧形分佈（180°/150°/120°/90°），相鄰淨空 ~14px，R 與 3 徹底分開且不貼邊 */
  .skill-bar-desktop .skill-btn {
    position: absolute;
    width: 54px;
    height: 54px;
  }

  .skill-bar-desktop .skill-btn .skill-short {
    font-size: 13px;
    line-height: 1.1;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }
  .skill-bar-desktop .skill-btn.skill-btn-named .skill-short {
    font-size: 10.5px;
    letter-spacing: 0;
    white-space: normal;
    max-width: 46px;
  }

  .skill-bar-desktop .skill-btn[data-key="1"] { right: 154px; bottom: 22px; }
  .skill-bar-desktop .skill-btn[data-key="2"] { right: 136px; bottom: 88px; }
  .skill-bar-desktop .skill-btn[data-key="3"] { right: 88px;  bottom: 136px; }
  .skill-bar-desktop .skill-btn[data-key="R"] { right: 22px;  bottom: 154px; }

  .skill-btn .skill-key {
    display: none;
  }

  #chat-mini-box {
    display: none;
  }

  #mobile-chat-toggle {
    display: inline-flex;
  }

  /* 手機展開大聊天視窗：高層級覆蓋，絕不被右下技能 3 鈕或浮動聊天鈕遮擋 */
  #chat-modal {
    top: calc(30px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    bottom: calc(10px + var(--safe-bottom));
    width: auto;
    height: auto;
    z-index: 650;
  }

  #chat-modal.whisper-mode .chat-modal-body {
    flex-direction: column;
  }

  #chat-modal.whisper-mode .chat-whisper-sidebar {
    width: 100%;
    max-height: 82px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid rgba(212, 169, 98, 0.25);
  }

  #chat-modal.whisper-mode .whisper-peer-btn {
    width: auto;
    min-width: 104px;
    flex-shrink: 0;
  }

  #hud-rail {
    flex-direction: column;
    align-items: flex-end;
    max-width: 112px;
  }

  #hud-rail .desktop-only {
    display: none;
  }

  body.drawer-open #hud-rail,
  body.drawer-open #skill-cluster,
  body.drawer-open #mobile-joystick-zone {
    opacity: 0;
    pointer-events: none;
  }

  #main-drawer {
    top: calc(28px + var(--safe-top));
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  #gear-detail-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(336px, 90vw);
    max-height: 82vh;
    z-index: 620;
  }

  #spec-skill-panel {
    top: calc(28px + var(--safe-top));
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    z-index: 620;
  }
}


/* ==========================================
   新手主城同圖比武場：比武實況列＋勝負橫幅＋左側可收合戰績小榜單
   ========================================== */
#hud-duel-live {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 52px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  min-width: 310px;
  max-width: min(500px, 92vw);
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(24, 18, 14, 0.84);
  border: 1px solid rgba(212, 164, 74, 0.55);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  color: #f6efe2;
  pointer-events: none;
  z-index: 45;
}
#hud-duel-live.visible { display: flex; }
.duel-side { flex: 1; min-width: 0; }
.duel-name-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
}
.duel-name-row span:first-child,
.duel-name-row span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}
.duel-hp-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.duel-hp-fill { height: 100%; transition: width 0.16s ease-out; }
.duel-fill-a { background: linear-gradient(90deg, #e05a54, #f59e0b); }
.duel-fill-b { background: linear-gradient(90deg, #38bdf8, #2dd4bf); margin-left: auto; }
.duel-center {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.duel-timer {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(212, 164, 74, 0.18);
  border: 1px solid rgba(212, 164, 74, 0.45);
  font-size: 14px;
  font-weight: 800;
  color: #fde68a;
}
.duel-dampening {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(224, 90, 84, 0.24);
  border: 1px solid rgba(248, 113, 113, 0.55);
  font-size: 10px;
  font-weight: 700;
  color: #fecaca;
  white-space: nowrap;
}

#hud-duel-banner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 116px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(24, 18, 14, 0.92);
  border: 1.5px solid #f5c451;
  color: #fef3c7;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 48;
  white-space: nowrap;
}
#hud-duel-banner.visible { display: block; }

#hud-duel-board {
  position: fixed;
  left: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 178px);
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  z-index: 46;
}
#hud-duel-board.near { display: flex; }
.duel-board-toggle {
  font-size: 12px;
  padding: 6px 10px;
  border-color: rgba(212, 164, 74, 0.65);
  background: rgba(26, 20, 16, 0.88);
  color: #f6e7c8;
}
.duel-board-body {
  display: none;
  width: 236px;
  max-width: 72vw;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(22, 18, 14, 0.92);
  border: 1px solid rgba(212, 164, 74, 0.48);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  color: #f5efe6;
  font-size: 12px;
  line-height: 1.45;
}
#hud-duel-board[data-open="true"] .duel-board-body { display: block; }
.duel-board-sec + .duel-board-sec {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.duel-board-title {
  font-size: 11px;
  font-weight: 800;
  color: #f5d896;
  margin-bottom: 4px;
}
.duel-board-streak { font-weight: 700; color: #fde68a; }
.duel-board-recent { display: flex; flex-direction: column; gap: 3px; max-height: 150px; overflow-y: auto; }
.duel-rec-row { font-size: 11.5px; color: #e8dfd2; }
.duel-rec-win { color: #fde68a; font-weight: 700; }
.duel-rec-draw { color: #93c5fd; font-weight: 700; }

/* ---- 標題／登入主選單（與現有深色古銅金 HUD 風格一致） ---- */
body.title-screen-open #hud-layer,
body.title-screen-open #main-drawer,
body.title-screen-open #drawer-backdrop,
body.title-screen-open #gear-detail-modal,
body.title-screen-open #spec-skill-panel,
body.title-screen-open #chat-modal,
body.title-screen-open #chat-modal-backdrop {
  display: none !important;
}

#title-screen {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(38px + var(--safe-top)) 16px calc(20px + var(--safe-bottom));
  background:
    radial-gradient(ellipse at 50% 24%, rgba(139, 90, 43, 0.34) 0%, rgba(30, 22, 16, 0.9) 52%, rgba(20, 16, 13, 0.97) 100%),
    var(--bg-deep);
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

body.title-screen-open #title-screen {
  display: flex;
}

.title-backdrop-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 80%, rgba(212, 169, 98, 0.08), transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(139, 90, 43, 0.14), transparent 48%);
}

.title-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px 24px 24px;
  background: linear-gradient(180deg, rgba(32, 24, 18, 0.97), rgba(20, 15, 11, 0.98));
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(139, 90, 43, 0.35) inset,
    0 1px 0 rgba(246, 220, 163, 0.22) inset;
  text-align: center;
}

.title-crest {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.title-crest-line {
  width: 56px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.title-crest-gem {
  font-size: 11px;
  color: var(--accent-gold);
  text-shadow: 0 0 8px rgba(232, 185, 92, 0.45);
}

.title-main {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #f6dca3;
  text-shadow: 0 2px 12px rgba(139, 90, 43, 0.55);
  line-height: 1.25;
}

.title-sub {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #c9a46c;
}

.title-tagline {
  margin: 8px 0 18px;
  font-size: 12px;
  color: var(--text-sub);
}

.title-account-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  text-align: left;
  background: rgba(14, 10, 7, 0.72);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
}

.title-account-box.connected {
  border-color: var(--border-strong);
  background: rgba(34, 25, 17, 0.86);
}

.title-account-box.checking {
  border-color: rgba(212, 169, 98, 0.65);
  background: rgba(28, 21, 15, 0.86);
}

.title-account-box.logging-in {
  border-color: #e8b95c;
  background: rgba(46, 32, 19, 0.92);
  box-shadow: 0 0 0 1px rgba(139, 90, 43, 0.45) inset;
}

.title-account-box.unauthenticated {
  border-color: rgba(212, 169, 98, 0.45);
  background: rgba(18, 13, 10, 0.84);
}

.title-avatar {
  width: 46px;
  height: 46px;
  font-size: 24px;
  border-radius: 10px;
}

.title-account-meta {
  min-width: 0;
  flex: 1;
}

.title-account-status {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.title-account-box.connected .title-account-status,
.title-account-box.logging-in .title-account-status {
  color: var(--accent-gold);
}

.title-account-box.checking .title-account-status {
  color: #e2c58a;
}

.title-account-box.unauthenticated .title-account-status {
  color: #d9a066;
}

.title-account-name {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-account-box.logging-in .title-account-name,
.title-account-box.checking .title-account-name {
  color: #f6dca3;
}

.title-account-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-progress {
  margin: -4px 0 16px;
  text-align: left;
}

.title-progress-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(20, 14, 10, 0.9);
  border: 1px solid rgba(212, 169, 98, 0.38);
  overflow: hidden;
}

.title-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #8B5A2B, #e8b95c, #f6dca3);
  box-shadow: 0 0 10px rgba(232, 185, 92, 0.45);
  transition: width 0.28s ease;
}

.title-progress-text {
  margin-top: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #c9a46c;
  letter-spacing: 0.02em;
}

.title-error-msg {
  margin-bottom: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(127, 29, 29, 0.32);
  border: 1px solid rgba(232, 118, 98, 0.55);
  color: #ffd7cf;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.title-btn {
  appearance: none;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-gold);
  background: var(--bg-chip);
  color: var(--text-main);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}

.title-btn:hover:not(:disabled) {
  background: rgba(58, 44, 32, 0.96);
  border-color: var(--border-strong);
}

.title-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.title-btn:disabled {
  opacity: 0.42;
  filter: grayscale(0.4);
  cursor: not-allowed;
}

.title-btn.primary {
  background: linear-gradient(180deg, #b87c32, #8B5A2B);
  border-color: #f0c97e;
  color: #fff8eb;
  box-shadow: 0 4px 14px rgba(139, 90, 43, 0.42);
}

.title-btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #c68739, #9a6430);
  border-color: #f8d896;
}

.title-btn-exit {
  color: var(--text-sub);
  border-color: rgba(212, 169, 98, 0.3);
  background: rgba(24, 18, 14, 0.85);
}

.title-btn-exit:hover:not(:disabled) {
  color: #ffd7cf;
  border-color: rgba(232, 118, 98, 0.55);
  background: rgba(46, 24, 20, 0.92);
}

.title-join-hint {
  margin-top: -4px;
  margin-bottom: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .title-card {
    padding: 22px 18px 20px;
  }
  .title-main {
    font-size: 27px;
  }
  .title-btn {
    padding: 11px 14px;
    font-size: 14px;
  }
}

.creation-lookup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 2px;
}

.creation-lookup-row {
  align-items: center;
  gap: 10px;
}

/* ---- 測試服單一總開關樣式（由 body.test-server / IS_TEST_SERVER 控制） ---- */
.test-server-only {
  display: none;
}

body.test-server .test-server-only {
  display: inline;
}

.test-server-banner-tag {
  margin-right: 4px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(139, 90, 43, 0.72);
  border: 1px solid rgba(240, 201, 126, 0.7);
  color: #fff6df;
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

.test-server-title-tag {
  margin-left: 4px;
  font-size: 0.56em;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #f6dca3;
  vertical-align: middle;
  padding: 2px 7px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(184, 124, 50, 0.42), rgba(139, 90, 43, 0.52));
  border: 1px solid rgba(240, 201, 126, 0.65);
}

.test-server-sub-tag {
  color: #e8b95c;
  font-weight: 800;
  letter-spacing: 0.14em;
}

@media (max-width: 480px) {
  .test-server-banner-tag {
    padding: 0 4px;
    font-size: 10px;
  }
  .test-server-title-tag {
    display: inline-block;
    margin-top: 2px;
    font-size: 0.52em;
    padding: 1px 6px;
  }
}


.current-look {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--border-gold);
  background: rgba(14, 10, 7, 0.72);
}
.current-look-badge {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  font-size: 28px;
}
.current-look-badge img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}
.current-look-label {
  font-size: 11px;
  color: var(--text-muted);
}
.current-look-name {
  font-size: 14px;
  font-weight: 700;
  color: #f6dca3;
}
.appearance-search-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.appearance-search-row .text-input {
  flex: 1;
  margin-bottom: 0;
}
