/* 餘燼裂隙 — HD-2D 奇幻 UI 主題（仙境傳說風的視窗：深夜藍玻璃面板 + 古金邊框）。
 * 尺寸一律用 rem：根字級隨解析度縮放（最低 1280×720）。
 * 元件（對應 client/ui/kit.js）：.panel .btn .tabs .bar .orb .slot/.hotbar .cell/.grid .tooltip .modal .toast .chat
 * 稀有度 .r0~.r4（設定 color 與 --rc）；傷害類型 .dt-<type>（color 與 --dc）；聖物 .rel-<rarity>。
 * 快捷列冷卻：.slot 設 --cd（0..1 = 剩餘比例）→ .cd 用 conic-gradient 掃描。
 * CONTRACT-EXT: 設計代號（:root）名稱沿用 v2（ui.css 與其他模組會用），v3 只改數值並新增：
 *   --azure --azure-hi --azure-lo --azure-dk（天藍強調色）、--panel-glass、--parch（羊皮紙文字色）、--dt-holy、--sp（= --mp）、
 *   --mmap（小地圖畫布邊長，rem；背包面板靠右時讓出這個寬度）。
 * CONTRACT-EXT: 本檔後半段是 client-ui-v3-b 各面板的樣式（背包 / 商店 / 倉庫 / 交易所 / 選單 / 說明 / 隊伍 / 聊天 / 聖物 / 小地圖 / 大地圖），
 *   一律以 #ui 開頭提高權重（ui.css 較晚載入，同權重時會蓋過本檔）。
 */

/* ── 設計代號 ───────────────────────────────────────── */
:root {
  --font-title: "Noto Serif TC", "Microsoft JhengHei", "PMingLiU", serif;
  --font-body: "Microsoft JhengHei", sans-serif;

  --bg: #070a12;
  --panel: #111829;
  --panel-2: #1b2542;
  --panel-glass: rgba(15, 21, 37, 0.94);
  --inset: #0a0f1c;
  --inset-2: #0e1526;
  --line: #2e3b5c;
  --gold: #d4b06a;
  --gold-hi: #f7e2a8;
  --gold-lo: #7f6432;
  --gold-dk: #3a2e18;
  --azure: #5aa7ea;
  --azure-hi: #b3dcff;
  --azure-lo: #2b5c96;
  --azure-dk: #12284a;
  --blood: #6b1a24;
  --blood-2: #9e2632;
  --blood-hi: #d4383f;
  --parch: #f1e6cc;
  --text: #eee8da;
  --text-dim: #a9b1c6;
  --text-mute: #717c98;
  --good: #8be04f;
  --bad: #ff5a5a;
  --warn: #ffc247;
  --info: #7fd4ff;

  --hp: #d4383f;
  --hp-dk: #5a0f18;
  --mp: #3f7ae0;
  --sp: var(--mp);
  --mp-dk: #0f1a4a;
  --xp: #d4b06a;
  --shield-c: #c7d0dc;

  /* 稀有度（= RARITY_COLORS） */
  --r0: #e6e1d6; --r1: #6f9cff; --r2: #ffd84a; --r3: #ff9a2e; --r4: #ff3d5a;
  /* 傷害類型（= DMG_TYPE_COLORS） */
  --dt-phys: #f2eee6; --dt-fire: #ff8a2e; --dt-cold: #7fd4ff; --dt-lightning: #fff36b; --dt-poison: #8be04f; --dt-arcane: #d27bff; --dt-holy: #fff1a8;
  /* 聖物稀有度（= RELIC_RARITY_COLORS） */
  --rel-common: #e6e1d6; --rel-rare: #6f9cff; --rel-epic: #c77dff; --rel-legendary: #ff9a2e;

  --shadow: 0 0.6rem 1.8rem rgba(0, 0, 0, 0.6);
  --frame: 0 0 0 1px #000, inset 0 0 0 1px rgba(247, 226, 168, 0.16);
  --radius: 5px;
  --slot: 3.4rem;
  --cell: 2.9rem;
  --orb: 7.2rem;
  --mmap: 14.6rem; /* 小地圖畫布邊長（1280×720 時 ≈ 176px；跟著 rem 縮放） */

  color-scheme: dark;
}

/* 解析度縮放：所有 rem 尺寸跟著變 */
html { font-size: 15px; }
@media (max-width: 1600px), (max-height: 900px) { html { font-size: 14px; } }
@media (max-width: 1440px), (max-height: 820px) { html { font-size: 13px; } }
@media (max-width: 1320px), (max-height: 740px) { html { font-size: 12px; } }

/* ── 基礎 ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
[hidden], .hidden { display: none !important; }

#game {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  background: var(--bg);
}
#ui {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text);
}
/* 會接收滑鼠的 UI 元件 */
#ui .panel, #ui .modal-back, #ui .hotbar, #ui .orb, #ui .screen, #ui .pe, #ui button, #ui input, #ui select, #ui textarea { pointer-events: auto; }

h1, h2, h3, h4, .title { font-family: var(--font-title); color: var(--gold-hi); font-weight: 700; letter-spacing: 0.06em; margin: 0 0 0.5rem; text-shadow: 0 2px 0 #000; }
h1 { font-size: 2rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--gold-hi); }
hr, .sep { border: 0; height: 1px; margin: 0.6rem 0; background: linear-gradient(90deg, transparent, var(--gold-lo), transparent); }

img.icon, .icon, canvas.icon { image-rendering: pixelated; image-rendering: crisp-edges; display: inline-block; vertical-align: middle; }
.icon-missing { background: repeating-linear-gradient(45deg, #2a3d6a 0 4px, #141d36 4px 8px); outline: 1px solid #5aa7ea; }

/* ── 捲軸 ───────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--gold-lo) var(--inset); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--inset); border-left: 1px solid #000; }
::-webkit-scrollbar-thumb { background: linear-gradient(90deg, #4a3a1c, var(--gold-lo) 50%, #4a3a1c); border: 1px solid #000; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(90deg, #5e4a24, var(--gold) 50%, #5e4a24); }
::-webkit-scrollbar-corner { background: var(--inset); }

/* ── 表單元素（低優先權，任何 class 都能覆寫） ──────────── */
:where(#ui, .modal, .panel) input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
:where(#ui, .modal, .panel) select,
:where(#ui, .modal, .panel) textarea {
  font: inherit;
  color: var(--text);
  background: var(--inset);
  border: 1px solid var(--gold-lo);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
  border-radius: var(--radius);
  padding: 0.35rem 0.55rem;
  outline: none;
  user-select: text;
}
:where(#ui, .modal, .panel) input:focus, :where(#ui, .modal, .panel) select:focus, :where(#ui, .modal, .panel) textarea:focus {
  border-color: var(--gold);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(90, 167, 234, 0.45);
}
input[type="range"] { accent-color: var(--gold); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--azure); }
::placeholder { color: var(--text-mute); }

/* ── 按鈕 ───────────────────────────────────────────── */
:where(#ui) button, .btn {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--gold-hi);
  background: linear-gradient(180deg, #37507f 0%, #223459 52%, #172442 100%);
  border: 1px solid var(--gold-lo);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(179, 220, 255, 0.28), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  padding: 0.4rem 1rem;
  cursor: pointer;
  text-shadow: 0 1px 0 #000;
  transition: filter 0.08s, transform 0.05s, border-color 0.08s;
  white-space: nowrap;
}
:where(#ui) button:hover, .btn:hover { filter: brightness(1.22); border-color: var(--gold); }
:where(#ui) button:active, .btn:active { transform: translateY(1px); filter: brightness(0.95); }
:where(#ui) button:disabled, .btn:disabled, .btn.disabled {
  cursor: default; filter: grayscale(0.85) brightness(0.7); transform: none; color: var(--text-mute);
}
.btn-primary { background: linear-gradient(180deg, #5b95e2 0%, #2f62b4 50%, #1c3d7a 100%); border-color: var(--gold); color: #fffaf0; }
.btn-gold { background: linear-gradient(180deg, #ecc97c 0%, #b08a40 52%, #6e5226 100%); border-color: var(--gold-hi); color: #1a1208; text-shadow: 0 1px 0 rgba(255, 240, 200, 0.5); }
.btn-danger { background: linear-gradient(180deg, #8f2a34 0%, #5a111a 100%); color: #ffd4cc; }
.btn-ghost { background: rgba(10, 15, 28, 0.35); box-shadow: none; border-color: var(--line); color: var(--text-dim); }
.btn-small { font-size: 0.8rem; padding: 0.2rem 0.55rem; }
.btn-icon { padding: 0.2rem; line-height: 0; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ── 面板 ───────────────────────────────────────────── */
.panel {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  min-width: 16rem;
  max-width: calc(100vw - 1rem);
  max-height: calc(100vh - 9rem);
  background:
    radial-gradient(ellipse at 50% -12%, rgba(90, 167, 234, 0.18), transparent 58%),
    linear-gradient(180deg, rgba(29, 40, 70, 0.97), rgba(16, 22, 39, 0.97) 34%, rgba(10, 14, 26, 0.98));
  border: 1px solid var(--gold-lo);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px #000, 0 0 0 3px rgba(10, 14, 26, 0.92), 0 0 0 4px var(--gold-dk), inset 0 0 0 1px rgba(247, 226, 168, 0.1), var(--shadow);
  color: var(--text);
}
/* 四角古金裝飾 */
.panel::before, .panel::after, .modal::before, .modal::after {
  content: "";
  position: absolute;
  width: 0.95rem; height: 0.95rem;
  border: 2px solid var(--gold);
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9));
}
.panel::before, .modal::before { left: -5px; top: -5px; border-right: 0; border-bottom: 0; }
.panel::after, .modal::after { right: -5px; bottom: -5px; border-left: 0; border-top: 0; }
.panel.dragging { opacity: 0.94; }
.panel-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.3rem;
  padding: 0.3rem 0.5rem 0.3rem 0.9rem;
  background:
    linear-gradient(90deg, transparent, rgba(247, 226, 168, 0.08) 50%, transparent),
    linear-gradient(180deg, #30477a 0%, #1c2b50 55%, #131e39 100%);
  border-bottom: 1px solid var(--gold-lo);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: inset 0 -1px 0 #000, inset 0 1px 0 rgba(179, 220, 255, 0.22);
  flex: 0 0 auto;
}
.drag-handle { cursor: grab; }
.dragging .drag-handle { cursor: grabbing; }
.panel-title {
  flex: 1;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold-hi);
  text-shadow: 0 0 8px rgba(247, 210, 130, 0.35), 0 2px 0 #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-title::before { content: "✦ "; color: var(--gold); font-size: 0.8em; }
.panel-x, :where(#ui) .panel-x {
  width: 1.7rem; height: 1.7rem;
  padding: 0;
  line-height: 1;
  font-size: 1.2rem;
  font-family: var(--font-body);
  background: linear-gradient(180deg, #2a3b63, #141d36);
  border: 1px solid var(--gold-lo);
  border-radius: 50%;
  color: var(--gold);
}
.panel-x:hover { color: #fff; background: linear-gradient(180deg, #8f2a34, #4a0f17); }
.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.75rem 0.9rem 0.9rem;
}
.panel-foot {
  flex: 0 0 auto;
  display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center;
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--gold-dk);
  background: rgba(0, 0, 0, 0.22);
}
/* 預設靠邊放置的面板（owner 可選用） */
.panel.dock-left { left: 1rem; top: 1rem; transform: none; }
.panel.dock-right { left: auto; right: 1rem; top: 1rem; transform: none; }
.panel.wide { width: min(64rem, calc(100vw - 2rem)); }

/* 區塊 / 內嵌框 */
.box, .inset {
  background: var(--inset);
  border: 1px solid #000;
  box-shadow: inset 0 0 0 1px var(--line), inset 0 2px 6px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
}
.section-title {
  font-family: var(--font-title);
  color: var(--gold);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  margin: 0.6rem 0 0.35rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.section-title::before { content: "◆"; font-size: 0.6em; color: var(--azure); }
.section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-lo), transparent); }

/* 屬性列（角色面板） */
.stat-row, .kv { display: flex; justify-content: space-between; gap: 1rem; padding: 0.12rem 0.2rem; border-bottom: 1px dashed rgba(127, 100, 50, 0.25); }
.stat-row > :first-child, .kv > :first-child { color: var(--text-dim); }
.stat-row > :last-child, .kv > :last-child { color: var(--text); font-variant-numeric: tabular-nums; }

/* 工具 class */
.row { display: flex; gap: 0.5rem; align-items: center; }
.col { display: flex; flex-direction: column; gap: 0.5rem; }
.spacer { flex: 1; }
.muted, .dim { color: var(--text-dim); }
.mute { color: var(--text-mute); }
.gold { color: var(--gold-hi); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.center { text-align: center; }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }

/* ── 分頁 ───────────────────────────────────────────── */
.tabs { display: flex; flex-direction: column; min-height: 0; }
.tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--gold-lo); padding: 0 0.25rem; flex: 0 0 auto; }
.tab, :where(#ui) .tab {
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: var(--text-dim);
  background: linear-gradient(180deg, #1c2744, #111a30);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: none;
  padding: 0.35rem 0.9rem;
  margin-bottom: -1px;
}
.tab:hover { color: var(--gold-hi); filter: none; }
.tab.active {
  color: var(--gold-hi);
  background: linear-gradient(180deg, #34508a, var(--panel));
  border-color: var(--gold-lo);
  border-bottom: 1px solid var(--panel);
  text-shadow: 0 0 6px rgba(247, 210, 130, 0.4);
}
.tab-body { padding-top: 0.6rem; min-height: 0; overflow: auto; }

/* ── 數值條 ─────────────────────────────────────────── */
.bar {
  --fill: 1;
  position: relative;
  height: 1.1rem;
  min-width: 6rem;
  background: linear-gradient(180deg, #05070d, #111827);
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--gold-lo), inset 0 1px 3px rgba(0, 0, 0, 0.9);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 100%;
  background: linear-gradient(180deg, #d8d2c6, #8f8878);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.3);
  transition: width 0.15s linear;
}
.bar-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 3px #000;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.bar-hp .bar-fill { background: linear-gradient(180deg, #ff7a6a, var(--hp) 45%, #7a1420); }
.bar-mp .bar-fill, .bar-sp .bar-fill { background: linear-gradient(180deg, #8fb6ff, var(--mp) 45%, #16307a); }
.bar-xp { height: 0.8rem; }
.bar-xp .bar-fill { background: linear-gradient(180deg, #ffe7a8, var(--xp) 50%, #6e5429); }
.bar-jxp .bar-fill { background: linear-gradient(180deg, #c8f0ff, var(--azure) 50%, #1d4c80); }
.bar-xp .bar-text, .bar-jxp .bar-text { font-size: 0.6rem; line-height: 1; opacity: 0.85; }
.bar-shield .bar-fill { background: linear-gradient(180deg, #ffffff, var(--shield-c) 50%, #5d6878); }
.bar-cast .bar-fill { background: linear-gradient(180deg, #fff6c8, #f0b24a 50%, #7a4a0e); transition: none; }
.bar-boss {
  height: 1.5rem;
  min-width: 24rem;
  border: 1px solid #000;
  box-shadow: 0 0 0 2px var(--gold-lo), 0 0 0 3px #000, 0 0 14px rgba(212, 56, 63, 0.35), inset 0 1px 3px #000;
}
.bar-boss .bar-fill { background: linear-gradient(180deg, #ff4a4a, #9e2632 45%, #3b0f17); }
.bar-boss .bar-text { font-family: var(--font-title); font-size: 0.9rem; letter-spacing: 0.1em; }
.bar-ally .bar-fill { background: linear-gradient(180deg, #a8e070, #2f7a3a); }

/* ── 血球 / 法力球 ──────────────────────────────────── */
.orb {
  --fill: 1;
  position: relative;
  width: var(--orb); height: var(--orb);
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 55%, #141c30, #04060b 70%);
  border: 3px solid var(--gold-lo);
  box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--gold-dk), inset 0 0 1.2rem rgba(0, 0, 0, 0.95), var(--shadow);
}
.orb-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--fill) * 100%);
  transition: height 0.18s ease-out;
}
.orb-hp .orb-fill { background: radial-gradient(circle at 40% 20%, #ff7a6a, #c21f2c 35%, #5a0710 85%); box-shadow: inset 0 2px 0 rgba(255, 180, 160, 0.6); }
.orb-mp .orb-fill { background: radial-gradient(circle at 40% 20%, #8fb6ff, #2d58c4 35%, #0b1650 85%); box-shadow: inset 0 2px 0 rgba(180, 200, 255, 0.6); }
.orb-glass {
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 45% 28% at 38% 22%, rgba(255, 255, 255, 0.35), transparent 70%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}
.orb-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.orb.low .orb-fill { animation: orb-pulse 0.8s ease-in-out infinite alternate; }
@keyframes orb-pulse { from { filter: brightness(1); } to { filter: brightness(1.6); } }

/* ── 快捷列 / 技能格 ────────────────────────────────── */
.hotbar {
  display: flex;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  background: linear-gradient(180deg, rgba(29, 40, 70, 0.94), rgba(9, 13, 24, 0.96));
  border: 1px solid var(--gold-lo);
  border-radius: var(--radius);
  box-shadow: var(--frame), 0 0 0 3px rgba(10, 14, 26, 0.9), 0 0 0 4px var(--gold-dk), var(--shadow);
}
:where(.slot) { --cd: 0; --rc: var(--gold-lo); }  /* 預設值零優先權：.r* / .rel-* 一定能覆寫 */
.slot {
  position: relative;
  width: var(--slot); height: var(--slot);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #1e2a48, #070a14 75%);
  border: 1px solid #000;
  box-shadow: 0 0 0 1px var(--rc), inset 0 0 0.6rem rgba(0, 0, 0, 0.9);
  border-radius: 3px;
  overflow: hidden;
  padding: 0;
}
.slot > img.icon, .slot > canvas { width: 80%; height: 80%; object-fit: contain; }
.slot:hover { box-shadow: 0 0 0 1px var(--gold-hi), inset 0 0 0.6rem rgba(0, 0, 0, 0.9); }
.slot.empty { opacity: 0.55; }
.slot .cd {
  position: absolute; inset: 0;
  background: conic-gradient(from 0deg, rgba(3, 5, 12, 0.78) calc(var(--cd) * 360deg), transparent 0);
  pointer-events: none;
}
.slot .cd-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
  color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
  pointer-events: none;
}
.slot .key {
  position: absolute; left: 2px; bottom: 1px;
  font-size: 0.65rem; font-weight: 700;
  color: var(--gold-hi);
  text-shadow: 0 1px 0 #000, 0 0 2px #000;
  pointer-events: none;
}
.slot .count {
  position: absolute; right: 2px; bottom: 1px;
  font-size: 0.7rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 2px #000;
  pointer-events: none;
}
.slot.ready-flash { animation: slot-ready 0.35s ease-out; }
@keyframes slot-ready { from { box-shadow: 0 0 0 2px #fff, 0 0 12px #fff; } to { box-shadow: 0 0 0 1px var(--rc); } }
.slot.on { box-shadow: 0 0 0 1px var(--gold-hi), 0 0 10px rgba(255, 210, 110, 0.7), inset 0 0 0.6rem rgba(255, 170, 60, 0.35); }
.slot.nomana::after { content: ""; position: absolute; inset: 0; background: rgba(40, 70, 200, 0.4); pointer-events: none; }
.slot.locked { filter: grayscale(1) brightness(0.5); }

/* 增益 / 減益圖示 */
.buffs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.buff {
  position: relative;
  width: 2rem; height: 2rem;
  border: 1px solid #000;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--good);
  background: #070a14;
}
.buff.debuff { box-shadow: 0 0 0 1px var(--bad); }
.buff > img, .buff > canvas { width: 100%; height: 100%; }
.buff .t {
  position: absolute; left: 0; right: 0; bottom: -0.1rem;
  font-size: 0.6rem; text-align: center; color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 2px #000;
}

/* ── 物品格 ─────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(var(--cols, 8), var(--cell)); gap: 2px; }
:where(.cell) { --rc: transparent; }
.cell {
  position: relative;
  width: var(--cell); height: var(--cell);
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #0f1628, #070a14);
  border: 1px solid #000;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px #23304f;
  cursor: pointer;
  padding: 0;
}
.cell > img.icon, .cell > canvas { width: 86%; height: 86%; }
.cell.has-item { background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--rc) 22%, transparent), #070a14 75%); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rc) 70%, #000); }
.cell:hover { box-shadow: inset 0 0 0 1px var(--gold-hi); }
.cell.drop-ok { box-shadow: inset 0 0 0 2px var(--good); }
.cell.drop-bad { box-shadow: inset 0 0 0 2px var(--bad); }
.cell.selected { box-shadow: inset 0 0 0 2px var(--gold-hi), 0 0 8px rgba(247, 226, 168, 0.5); }
.cell.cant { background: linear-gradient(180deg, rgba(150, 20, 30, 0.5), rgba(70, 8, 14, 0.55)); }
.cell .slot-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; color: var(--text-mute); pointer-events: none; }

/* ── 稀有度 / 傷害類型 / 聖物 ───────────────────────── */
.r0 { color: var(--r0); --rc: var(--r0); }
.r1 { color: var(--r1); --rc: var(--r1); }
.r2 { color: var(--r2); --rc: var(--r2); }
.r3 { color: var(--r3); --rc: var(--r3); text-shadow: 0 0 6px rgba(255, 154, 46, 0.35); }
.r4 { color: var(--r4); --rc: var(--r4); text-shadow: 0 0 8px rgba(255, 61, 90, 0.5); }
.cell.r0, .slot.r0 { --rc: #56617c; }
.cell.r3.has-item, .slot.r3 { animation: glow-leg 2.4s ease-in-out infinite alternate; }
.cell.r4.has-item, .slot.r4 { animation: glow-myth 1.6s ease-in-out infinite alternate; }
@keyframes glow-leg { from { filter: none; } to { filter: drop-shadow(0 0 3px rgba(255, 154, 46, 0.7)); } }
@keyframes glow-myth { from { filter: drop-shadow(0 0 2px rgba(255, 61, 90, 0.5)); } to { filter: drop-shadow(0 0 5px rgba(255, 61, 90, 0.9)); } }

.dt-phys { color: var(--dt-phys); --dc: var(--dt-phys); }
.dt-fire { color: var(--dt-fire); --dc: var(--dt-fire); }
.dt-cold { color: var(--dt-cold); --dc: var(--dt-cold); }
.dt-lightning { color: var(--dt-lightning); --dc: var(--dt-lightning); }
.dt-poison { color: var(--dt-poison); --dc: var(--dt-poison); }
.dt-arcane { color: var(--dt-arcane); --dc: var(--dt-arcane); }
.dt-holy { color: var(--dt-holy); --dc: var(--dt-holy); }

.rel-common { color: var(--rel-common); --rc: var(--rel-common); }
.rel-rare { color: var(--rel-rare); --rc: var(--rel-rare); }
.rel-epic { color: var(--rel-epic); --rc: var(--rel-epic); }
.rel-legendary { color: var(--rel-legendary); --rc: var(--rel-legendary); text-shadow: 0 0 6px rgba(255, 154, 46, 0.4); }

/* 卡片（聖物選擇 / 轉職） */
:where(.card) { --rc: var(--gold-lo); }
.card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  width: 13rem;
  padding: 0.9rem 0.8rem;
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--rc) 16%, transparent), transparent 65%),
    linear-gradient(180deg, #1b2542, #0b1020);
  border: 1px solid #000;
  box-shadow: 0 0 0 2px var(--rc), inset 0 0 1.5rem rgba(0, 0, 0, 0.7), var(--shadow);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  text-align: center;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--rc), 0 0 16px color-mix(in srgb, var(--rc) 60%, transparent), var(--shadow); }
.card .card-title { font-family: var(--font-title); font-size: 1.05rem; color: var(--rc); }
.card .card-desc { font-size: 0.85rem; color: var(--text); }

/* ── 提示框（深藍玻璃 + 古金細框） ───────────────────── */
.tooltip {
  position: fixed;
  left: 0; top: 0;
  z-index: 10000;
  max-width: 24rem;
  min-width: 12rem;
  padding: 0.55rem 0.75rem 0.6rem;
  pointer-events: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.4;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(90, 167, 234, 0.16), transparent 70%),
    linear-gradient(180deg, rgba(24, 33, 58, 0.97) 0%, rgba(12, 17, 31, 0.98) 100%);
  border: 1px solid var(--gold-lo);
  border-radius: 4px;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(247, 226, 168, 0.1), 0 0.5rem 1.5rem rgba(0, 0, 0, 0.75);
  text-align: center;
}
.tt-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.tt-line:empty { height: 0.45rem; }
.tt-title { font-family: var(--font-title); font-size: 1.1rem; font-weight: 700; letter-spacing: 0.05em; text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 1px 0 #000; }
.tt-sep { height: 1px; margin: 0.35rem 0.2rem; background: linear-gradient(90deg, transparent, var(--gold-lo), transparent); }
.tt-dim, .tt-hint { color: var(--text-dim); font-size: 0.82rem; }
.tt-hint { font-style: italic; margin-top: 0.25rem; }
.tt-good { color: var(--good); }
.tt-bad { color: var(--bad); }
.tt-price { color: var(--warn); }
.tt-flavor { color: #d6b27a; font-style: italic; font-size: 0.85rem; }
.tt-compare-head { color: var(--text-dim); font-size: 0.8rem; letter-spacing: 0.15em; }
.tt-left { text-align: left; }

/* ── 對話框 ─────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0;
  z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(8, 14, 30, 0.5), rgba(0, 0, 0, 0.78));
  pointer-events: auto;
  animation: fade-in 0.12s ease-out;
}
.modal {
  position: relative;
  min-width: 20rem;
  max-width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(90, 167, 234, 0.2), transparent 60%),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-lo);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px #000, 0 0 0 3px rgba(10, 14, 26, 0.92), 0 0 0 4px var(--gold-dk), var(--shadow);
  padding: 1rem 1.2rem;
  animation: pop-in 0.14s ease-out;
}
.modal-title { font-family: var(--font-title); font-size: 1.25rem; color: var(--gold-hi); letter-spacing: 0.1em; text-align: center; margin-bottom: 0.6rem; text-shadow: 0 2px 0 #000; }
.modal-body { min-height: 0; overflow: auto; }  /* 捲動放在內層：外框四角裝飾才不會撐出捲軸 */
.modal-text { text-align: center; white-space: pre-wrap; }
.modal-foot { display: flex; gap: 0.6rem; justify-content: center; margin-top: 0.9rem; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 提示訊息 ───────────────────────────────────────── */
.toast-stack {
  position: fixed;
  left: 50%; top: 14%;
  transform: translateX(-50%);
  z-index: 6000;
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  pointer-events: none;
}
.toast {
  min-width: 14rem;
  max-width: min(40rem, calc(100vw - 2rem));
  padding: 0.45rem 1.2rem;
  text-align: center;
  font-family: var(--font-title);
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--text);
  background: linear-gradient(90deg, transparent, rgba(12, 18, 34, 0.92) 12%, rgba(12, 18, 34, 0.92) 88%, transparent);
  border-top: 1px solid var(--k, var(--gold-lo));
  border-bottom: 1px solid var(--k, var(--gold-lo));
  text-shadow: 0 1px 0 #000, 0 0 6px #000;
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.out { opacity: 0; transform: translateY(-0.5rem); }
.toast-info { --k: var(--gold-lo); }
.toast-warn { --k: var(--warn); color: var(--warn); }
.toast-err { --k: var(--bad); color: #ffb0a8; }
.toast-loot { --k: var(--r3); color: var(--r3); }
.toast-level { --k: var(--gold-hi); color: var(--gold-hi); font-size: 1.35rem; text-shadow: 0 0 10px rgba(255, 210, 110, 0.6), 0 2px 0 #000; }
.toast-relic { --k: var(--rel-epic); color: #e8c4ff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.6rem) scale(0.96); } to { opacity: 1; transform: none; } }

/* ── 聊天（基本；v3 細節在後半段） ─────────────────── */
.chat {
  position: absolute;
  left: 0.8rem; bottom: 0.8rem;
  width: min(30rem, 36vw);
  display: flex; flex-direction: column;
  pointer-events: none;
}
.chat-log {
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  background: linear-gradient(180deg, transparent, rgba(6, 10, 20, 0.6) 25%);
  border-radius: var(--radius);
  pointer-events: auto;
  user-select: text;
}
/* 聊天容器本身永遠讓點擊穿透；閒置（.idle）時連紀錄也穿透，不擋左下角的戰鬥點擊 */
.chat.idle .chat-log { background: transparent; scrollbar-width: none; pointer-events: none; }
.chat.idle .chat-log::-webkit-scrollbar { display: none; }
.chat-line { text-shadow: 0 1px 0 #000, 0 0 3px #000; overflow-wrap: anywhere; }
.chat-line .from { color: var(--gold-hi); font-weight: 700; }
.chat-line.ch-world { color: #eee8da; }
.chat-line.ch-party { color: #7fd4ff; }
.chat-line.ch-zone { color: #b8e09a; }
.chat-line.ch-system { color: var(--warn); font-style: italic; }
.chat-line.ch-err { color: var(--bad); }
.chat-line.fade { opacity: 0.45; }
.chat-input-row { display: flex; gap: 0.3rem; margin-top: 0.3rem; pointer-events: auto; }
.chat-input-row select { flex: 0 0 auto; padding: 0.25rem 0.3rem; }
.chat-input, :where(#ui) .chat-input { flex: 1; min-width: 0; background: rgba(6, 10, 20, 0.9); }

/* ── 全螢幕畫面（登入 / 選角） ──────────────────────── */
.screen {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(90, 167, 234, 0.22), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(240, 170, 80, 0.18), transparent 55%),
    linear-gradient(180deg, #111a33, #05070d);
  pointer-events: auto;
}
.logo {
  font-family: var(--font-title);
  font-size: 3.6rem;
  font-weight: 900;
  letter-spacing: 0.35em;
  color: var(--gold-hi);
  background: linear-gradient(180deg, #fff6d0, #f0b24a 55%, #b0541e);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #000) drop-shadow(0 0 18px rgba(240, 178, 74, 0.35));
}

/* 小地圖 / HUD 容器外框（hud 可選用） */
.frame {
  background: rgba(10, 14, 26, 0.86);
  border: 1px solid var(--gold-lo);
  border-radius: var(--radius);
  box-shadow: var(--frame), 0 0 0 3px rgba(10, 14, 26, 0.85), 0 0 0 4px var(--gold-dk), var(--shadow);
}

/* 清單（交易所 / 隊伍） */
.list { display: flex; flex-direction: column; gap: 2px; }
.list-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}
.list-item:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.list-item:hover { border-color: var(--gold-lo); background: rgba(90, 167, 234, 0.08); }
.list-item.active { border-color: var(--gold); background: rgba(90, 167, 234, 0.16); }

table.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.table th { font-family: var(--font-title); color: var(--gold); text-align: left; font-weight: 700; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--gold-lo); }
table.table td { padding: 0.25rem 0.4rem; border-bottom: 1px solid rgba(46, 59, 92, 0.6); }
table.table tr:hover td { background: rgba(90, 167, 234, 0.06); }

/* 等待中的點數提示 */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.2rem; height: 1.2rem; padding: 0 0.3rem;
  font-size: 0.7rem; font-weight: 700;
  color: #1a1208;
  background: radial-gradient(circle at 40% 30%, #fff6c8, #d4b06a);
  border: 1px solid #000;
  border-radius: 999px;
}
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { filter: none; } 50% { filter: brightness(1.5) drop-shadow(0 0 4px rgba(255, 210, 110, 0.8)); } }

/* ── 小螢幕（1280×720） ─────────────────────────────── */
@media (max-width: 1320px), (max-height: 740px) {
  .panel { max-height: calc(100vh - 7rem); }
  .chat { width: min(26rem, 34vw); }
  .chat-log { max-height: 8.5rem; }
  .bar-boss { min-width: 18rem; }
  :root { --orb: 6.2rem; --slot: 3.1rem; --cell: 2.7rem; }
}
@media (max-height: 640px) {
  :root { --orb: 5rem; --slot: 2.7rem; --cell: 2.4rem; }
}

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

/* ═════════════════════════ client-ui-v3-b 面板 ═════════════════════════ */
/* PANELS-B-START（下面由 client-ui-v3-b 維護） */

/* 共用：面板內的招呼語 / 價格 / 可點擊元素 */
#ui .npc-greet { font-style: italic; color: #d6b27a; font-size: 0.88rem; margin: 0 0 0.45rem; line-height: 1.45; }
#ui .cell .count {
  position: absolute; right: 2px; bottom: 0;
  font-size: 0.72rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #000, 0 0 3px #000; pointer-events: none;
}
#ui .cell .cell-grade {
  position: absolute; right: 2px; top: 0; font-size: 0.6rem; font-weight: 700; color: var(--text-dim);
  text-shadow: 0 1px 0 #000; pointer-events: none;
}
#ui .cell.cant { background: linear-gradient(180deg, rgba(160, 24, 34, 0.55), rgba(70, 8, 14, 0.6)); outline: 1px solid rgba(255, 90, 90, 0.55); outline-offset: -2px; }
#ui .cell.cant.has-item > img.icon { filter: saturate(0.7) brightness(0.9); }

/* ── 背包 ───────────────────────────────────────────── */
#ui .inv-panel { width: auto; min-width: 0; }
/* 靠右的背包讓出右上角小地圖的位置 */
#ui .panel.inv-panel.dock-right { right: calc(var(--mmap) + 2.4rem); top: 0.8rem; }
#ui .inv-doll3 {
  display: grid;
  grid-template-columns: var(--cell) 1fr var(--cell);
  gap: 0.5rem;
  align-items: stretch;
  padding: 0.45rem 0.6rem;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(90, 167, 234, 0.2), transparent 62%),
    linear-gradient(180deg, rgba(8, 12, 24, 0.6), rgba(8, 12, 24, 0.2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 0 1.2rem rgba(0, 0, 0, 0.6);
}
#ui .eq-col { display: flex; flex-direction: column; gap: 0.3rem; }
#ui .eq-col .cell { width: var(--cell); height: var(--cell); }
#ui .doll-cell .slot-label { font-size: 0.62rem; letter-spacing: 0.05em; }
#ui .inv-preview { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.15rem; min-width: 9rem; }
#ui .inv-preview-stage {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex; align-items: flex-end; justify-content: center;
  background: radial-gradient(ellipse 60% 18% at 50% 92%, rgba(247, 226, 168, 0.18), transparent 70%);
}
#ui .inv-preview-canvas { width: 8rem; height: 7rem; image-rendering: pixelated; image-rendering: crisp-edges; }
#ui .inv-preview-rot { display: flex; gap: 0.3rem; }
#ui .inv-preview-rot .rot-btn { padding: 0 0.45rem; font-size: 0.7rem; line-height: 1.3rem; }
#ui .inv-preview-name { font-family: var(--font-title); color: var(--gold-hi); font-weight: 700; letter-spacing: 0.08em; text-shadow: 0 1px 0 #000; }
#ui .inv-preview-job { color: var(--azure-hi); }
#ui .inv-inactive {
  margin-top: 0.4rem; padding: 0.3rem 0.5rem;
  font-size: 0.8rem; color: #ffb0a8;
  background: rgba(120, 16, 26, 0.3); border: 1px solid rgba(255, 90, 90, 0.35); border-radius: var(--radius);
}
#ui .inv-bag, #ui .inv-cart { justify-content: center; }
#ui .inv-cart-box { margin-top: 0.2rem; }
#ui .inv-cart-box .section-title::before { content: "⛟"; font-size: 0.9em; color: var(--gold); }
#ui .inv-cart .cell { background: linear-gradient(180deg, #1a1710, #0b0906); box-shadow: inset 0 0 0 1px #3a3020; }
#ui .inv-cart .cell.has-item { background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--rc) 22%, transparent), #0b0906 75%); }
#ui .inv-cart-box.cart-locked .inv-cart { opacity: 0.75; }
#ui .cart-note { margin: -0.1rem 0 0.3rem; }
#ui .inv-foot { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
#ui .inv-pots { display: flex; gap: 0.35rem; }
#ui .pot-cell { cursor: grab; }
#ui .pot-cell.pot-hp { --rc: #ff7a6a; }
#ui .pot-cell.pot-mp { --rc: #7fa8ff; }
#ui .pot-cell.empty > img.icon { filter: grayscale(1) brightness(0.6); }
#ui .inv-gold { display: flex; align-items: center; gap: 0.3rem; font-weight: 700; }
#ui .inv-gold img.icon { width: 1.4rem; height: 1.4rem; }

/* ── 商店 ───────────────────────────────────────────── */
#ui .shop-panel { width: 24rem; }
#ui .shop-head {
  display: flex; flex-direction: column; gap: 0.3rem;
  padding: 0.5rem 0.6rem 0.4rem;
  background: linear-gradient(180deg, rgba(90, 167, 234, 0.12), rgba(10, 14, 26, 0.2));
  border: 1px solid var(--line); border-radius: var(--radius);
}
#ui .shop-npc-name { font-family: var(--font-title); color: var(--gold-hi); font-size: 1.05rem; letter-spacing: 0.1em; }
#ui .shop-head .npc-greet { margin: 0; }
#ui .shop-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; }
#ui .shop-gold { display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 700; margin-right: auto; }
#ui .shop-gold img.icon { width: 1.3rem; height: 1.3rem; }
#ui .shop-mod { font-size: 0.75rem; padding: 0.05rem 0.4rem; border: 1px solid rgba(139, 224, 79, 0.45); border-radius: 999px; background: rgba(139, 224, 79, 0.08); white-space: nowrap; }
#ui .shop-pots { display: flex; flex-direction: column; gap: 0.35rem; }
#ui .shop-pot-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 0.6rem; row-gap: 0.1rem; align-items: center;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: var(--radius);
}
#ui .shop-pot-row > .pot-icon { grid-row: 1 / 3; }
#ui .shop-pot-row > .btn { justify-self: end; }
#ui .shop-pot-row.full { opacity: 0.7; }
#ui .shop-pot-row .pot-icon { --rc: var(--gold-lo); }
#ui .shop-pot-row.pot-hp .pot-icon { --rc: #ff7a6a; }
#ui .shop-pot-row.pot-mp .pot-icon { --rc: #7fa8ff; }
#ui .shop-pot-name { font-family: var(--font-title); color: var(--text); }
#ui .shop-pot-desc { min-width: 0; }
#ui .shop-pot-price { font-weight: 700; color: var(--warn); font-variant-numeric: tabular-nums; display: inline-flex; gap: 0.3rem; align-items: baseline; justify-self: end; }
#ui .shop-grid { grid-template-columns: repeat(var(--cols, 4), calc(var(--cell) * 1.4)); gap: 0.3rem; justify-content: center; }
#ui .shop-grid .cell { width: calc(var(--cell) * 1.4); height: calc(var(--cell) * 1.4); }
#ui .shop-grid .cell > img.icon { width: 64%; height: 64%; margin-bottom: 0.7rem; }
#ui .shop-grid .cell.poor .cell-price { color: var(--bad); }
#ui .shop-grid .cell.sold { opacity: 0.45; cursor: default; }
#ui .cell-price {
  position: absolute; left: 0; right: 0; bottom: 1px;
  display: flex; justify-content: center; gap: 0.25rem; align-items: baseline;
  font-size: 0.7rem; font-weight: 700; color: var(--warn); font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #000, 0 0 3px #000; pointer-events: none;
}
#ui .discounted { color: var(--good); }
#ui .too-much { color: var(--bad); }
#ui s.was { color: var(--text-mute); font-weight: 400; font-size: 0.85em; }
#ui .shop-empty { padding: 1rem 0; text-align: center; }
#ui .shop-tip { margin-top: 0.35rem; }
#ui .sell-zone {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3.2rem; padding: 0.5rem;
  text-align: center; font-size: 0.85rem; color: var(--text-dim);
  border: 1px dashed var(--gold-lo); border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, rgba(247, 226, 168, 0.03) 0 8px, transparent 8px 16px);
}
#ui .sell-zone .sell-icon { font-size: 1.3rem; color: var(--gold); }
#ui .sell-zone.drop-ok { border-color: var(--good); color: var(--good); background: rgba(80, 160, 60, 0.12); }
#ui .sell-zone.drop-bad { border-color: var(--bad); color: var(--bad); }

/* ── 倉庫 / 交易所 ──────────────────────────────────── */
#ui .stash-panel { width: auto; }
#ui .stash-grid { justify-content: center; }
#ui .stash-foot { margin-top: 0.5rem; }
#ui .market-panel { width: min(42rem, calc(100vw - 2rem)); }
#ui .mk-filters { flex-wrap: wrap; margin-bottom: 0.4rem; }
#ui .mk-q { flex: 1; min-width: 8rem; }
#ui .mk-results, #ui .mk-mine { max-height: 22rem; overflow: auto; }
#ui .mk-table .cell { width: 2.1rem; height: 2.1rem; }
#ui .mk-name { font-family: var(--font-title); }
#ui .mk-pager { justify-content: center; margin-top: 0.4rem; }
#ui .mk-empty { padding: 1.5rem 0; }
#ui .mk-sell { display: flex; flex-direction: column; gap: 0.6rem; }
#ui .sell-pick { width: calc(var(--cell) * 1.4); height: calc(var(--cell) * 1.4); border: 1px dashed var(--gold-lo); }
#ui .mk-sell-name { font-family: var(--font-title); }
#ui .mk-price { width: 10rem; }

/* ── 系統選單 / 裂隙之門 ────────────────────────────── */
#ui .menu-panel { width: 25rem; }
#ui .menu-btns { margin-bottom: 0.3rem; }
#ui .menu-btns .btn { width: 100%; }
#ui .menu-bottom { margin-top: 0.8rem; }
#ui .seg { display: flex; gap: 0; border: 1px solid var(--gold-lo); border-radius: var(--radius); overflow: hidden; box-shadow: 0 0 0 1px #000; }
#ui .seg .seg-btn {
  flex: 1; border: 0; border-radius: 0; box-shadow: none; padding: 0.3rem 0.8rem;
  background: linear-gradient(180deg, #1c2744, #111a30); color: var(--text-dim);
}
#ui .seg .seg-btn + .seg-btn { border-left: 1px solid var(--line); }
#ui .seg .seg-btn.active { background: linear-gradient(180deg, #5b95e2, #2a5aa8 60%, #1c3d7a); color: #fffaf0; text-shadow: 0 1px 0 #000; }
#ui .seg-controls .seg-btn { padding: 0.45rem 0.8rem; font-size: 0.95rem; }
#ui .set-row { display: grid; grid-template-columns: 1fr 9rem 3rem; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
#ui .set-row.set-seg { grid-template-columns: 1fr auto; }
#ui .set-row.set-check { grid-template-columns: 1fr auto; }
#ui .set-row input[type="checkbox"] { justify-self: end; width: 1.1rem; height: 1.1rem; }
#ui .set-note { margin: 0.2rem 0 0.1rem; line-height: 1.4; }
#ui .set-val { text-align: right; }
#ui .portal-panel { width: min(42rem, calc(100vw - 2rem)); }
#ui .portal-intro { margin-bottom: 0.6rem; }
#ui .diff-list { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
#ui .diff-card {
  display: flex; flex-direction: column; gap: 0.4rem; width: 12rem; padding: 0.7rem 0.8rem;
  background: linear-gradient(180deg, #1b2542, #0b1020); border: 1px solid #000; border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--gold-lo), inset 0 0 1rem rgba(0, 0, 0, 0.6);
}
#ui .diff-card ul { margin: 0; padding-left: 1.1rem; color: var(--text-dim); }
#ui .diff-card .card-title { font-family: var(--font-title); font-size: 1.2rem; color: var(--gold-hi); }
#ui .diff-card.diff-1 { box-shadow: 0 0 0 2px #8f4a2a, inset 0 0 1rem rgba(0, 0, 0, 0.6); }
#ui .diff-card.diff-1 .card-title { color: #ff9a6e; }
#ui .diff-card.diff-2 { box-shadow: 0 0 0 2px #9e2632, 0 0 14px rgba(212, 56, 63, 0.35); }
#ui .diff-card.diff-2 .card-title { color: #ff5a5a; }
#ui .diff-card.locked { opacity: 0.5; filter: grayscale(0.8); }

/* ── 說明 ───────────────────────────────────────────── */
/* 置中的長面板往上挪、限高：下緣不蓋到底部的快捷列 */
#ui .help-panel { width: min(38rem, calc(100vw - 2rem)); top: calc(50% - 2.5rem); max-height: calc(100vh - 12rem); }
#ui .help-mode { color: var(--azure-hi); margin-bottom: 0.4rem; }
#ui .help-keys td.hk { white-space: nowrap; color: var(--gold-hi); font-weight: 700; }
#ui .help-tips { margin: 0; padding-left: 1.2rem; color: var(--text-dim); font-size: 0.88rem; }
#ui .help-tips li { margin-bottom: 0.25rem; }

/* ── 隊伍 ───────────────────────────────────────────── */
#ui .party-panel { width: 25rem; }
#ui .party-row { cursor: default; align-items: center; }
#ui .party-row.offline { opacity: 0.55; }
#ui .pr-lead { width: 1.2rem; color: var(--gold-hi); text-align: center; }
#ui .pr-main { flex: 1; gap: 0.15rem; min-width: 0; }
#ui .pr-top { display: flex; align-items: baseline; gap: 0.35rem; }
#ui .pr-name { font-family: var(--font-title); font-weight: 700; color: var(--text); }
#ui .pr-near { color: var(--good); border: 1px solid rgba(139, 224, 79, 0.4); border-radius: 999px; padding: 0 0.35rem; font-size: 0.7rem; }
#ui .pr-sub { display: flex; gap: 0.6rem; color: var(--text-dim); }
#ui .pr-job { color: var(--azure-hi); }
#ui .pr-map::before { content: "⌖ "; color: var(--gold-lo); }
#ui .party-row .bar { height: 0.6rem; min-width: 0; }
#ui .party-panel .row input { flex: 1; }
#ui .party-hint { margin-top: 0.4rem; }
#ui .party-empty { padding: 0.5rem 0; }
#ui .invite-stack { position: absolute; left: 50%; bottom: 12rem; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 0.4rem; z-index: 950; }
#ui .invite-pop {
  pointer-events: auto; padding: 0.6rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem; animation: pop-in 0.15s ease-out;
  background: linear-gradient(180deg, rgba(34, 52, 94, 0.96), rgba(12, 17, 31, 0.96));
}

/* ── 聊天（公告） ───────────────────────────────────── */
#ui .chat-line .tag { color: var(--text-mute); font-size: 0.8em; }
#ui .chat-line.ch-system .tag, #ui .chat-line.ch-err .tag { color: inherit; }
#ui .chat-line.ch-announce {
  color: #bfe3ff; font-weight: 700; font-style: normal;
  padding: 0.05rem 0.35rem; margin: 0.1rem 0;
  background: linear-gradient(90deg, rgba(90, 167, 234, 0.28), transparent);
  border-left: 2px solid var(--azure);
}
#ui .chat-line.ch-announce .tag { color: var(--azure-hi); }
#ui .chat-line.ch-mvp {
  color: #ffd9a0;
  background: linear-gradient(90deg, rgba(255, 154, 46, 0.32), transparent);
  border-left-color: var(--r3);
  text-shadow: 0 0 6px rgba(255, 154, 46, 0.5), 0 1px 0 #000;
}
#ui .chat-line.ch-mvp .tag { color: var(--r3); }
#ui .chat-ch { font-size: 0.8rem; }

/* ── 聖物 ───────────────────────────────────────────── */
#ui .relic-panel { width: min(46rem, calc(100vw - 2rem)); top: 40%; }
#ui .relic-sub { margin-bottom: 0.7rem; }
#ui .relic-cards { display: flex; gap: 0.9rem; justify-content: center; flex-wrap: wrap; padding: 0.3rem 0.2rem 0.5rem; }
#ui .relic-card { min-height: 14rem; }
#ui .relic-icon { padding: 0.3rem; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--rc) 30%, transparent), transparent 70%); }
#ui .relic-icon img.icon { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--rc) 80%, transparent)); }
#ui .relic-rar { color: var(--rc); letter-spacing: 0.15em; }
#ui .relic-target { margin-top: auto; }
#ui .relic-foot { margin-top: 0.3rem; }

/* ── 小地圖（右上） ─────────────────────────────────── */
#ui .mmap {
  position: absolute; top: 0.8rem; right: 0.8rem;
  width: calc(var(--mmap) + 1rem);
  padding: 0.3rem 0.5rem 0.35rem;
  background: linear-gradient(180deg, rgba(29, 40, 70, 0.9), rgba(9, 13, 24, 0.9));
  border: 1px solid var(--gold-lo);
  border-radius: 8px;
  box-shadow: 0 0 0 1px #000, 0 0 0 3px rgba(10, 14, 26, 0.85), 0 0 0 4px var(--gold-dk), var(--shadow);
  pointer-events: auto;
  z-index: 5;
}
#ui .mmap::before, #ui .mmap::after {
  content: ""; position: absolute; width: 0.7rem; height: 0.7rem; border: 2px solid var(--gold); pointer-events: none;
}
#ui .mmap::before { left: -5px; top: -5px; border-right: 0; border-bottom: 0; }
#ui .mmap::after { right: -5px; bottom: -5px; border-left: 0; border-top: 0; }
#ui .mmap-head { display: flex; align-items: center; gap: 0.3rem; margin-bottom: 0.25rem; }
#ui .mmap-title {
  font-family: var(--font-title); font-weight: 700; font-size: 0.92rem; letter-spacing: 0.08em; color: var(--gold-hi);
  text-shadow: 0 0 6px rgba(247, 210, 130, 0.3), 0 1px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#ui .mmap-btn { width: 1.35rem; height: 1.35rem; padding: 0; line-height: 1; font-size: 0.8rem; border-radius: 50%; }
#ui .mmap-stage { position: relative; width: var(--mmap); height: var(--mmap); border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px #000, inset 0 0 12px rgba(0, 0, 0, 0.8); }
#ui .mmap-canvas { display: block; width: 100%; height: 100%; }
#ui .mmap-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(247, 226, 168, 0.25), inset 0 0 18px rgba(0, 0, 0, 0.55); border-radius: 4px; }
#ui .mmap-north {
  position: absolute; top: 3px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-title); font-size: 0.7rem; font-weight: 900; color: var(--gold-hi);
  text-shadow: 0 1px 0 #000, 0 0 3px #000; pointer-events: none;
}
#ui .mmap-tools { position: absolute; right: 3px; bottom: 3px; display: flex; flex-direction: column; gap: 3px; opacity: 0.55; transition: opacity 0.15s; }
#ui .mmap-stage:hover .mmap-tools { opacity: 1; }
#ui .mmap-foot { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.2rem; font-size: 0.75rem; color: var(--text-dim); text-shadow: 0 1px 0 #000; }
/* §V3.19.7：多了「· 伺服器 3 ms」放不下時換到第二行、靠右（minimap.js 文字長度變了會重算 --minimap-bottom） */
#ui .mmap-foot { flex-wrap: wrap; row-gap: 0; }
#ui .mmap-foot .mmap-ping { margin-left: auto; cursor: help; }
#ui .mmap-ping.bad { color: var(--bad); }
#ui .mmap.collapsed .mmap-stage, #ui .mmap.collapsed .mmap-foot { display: none; }
#ui .mmap.collapsed { width: auto; min-width: 9rem; }

/* ── 大地圖（M） ────────────────────────────────────── */
#ui .bigmap {
  position: absolute; inset: 0; z-index: 950;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(8, 14, 30, 0.45), rgba(0, 0, 0, 0.7));
  pointer-events: auto;
  animation: fade-in 0.12s ease-out;
}
#ui .bigmap-box {
  position: relative;
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.6rem 0.8rem 0.6rem;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(90, 167, 234, 0.18), transparent 60%),
    linear-gradient(180deg, rgba(29, 40, 70, 0.97), rgba(10, 14, 26, 0.98));
  border: 1px solid var(--gold-lo); border-radius: 8px;
  box-shadow: 0 0 0 1px #000, 0 0 0 3px rgba(10, 14, 26, 0.92), 0 0 0 4px var(--gold-dk), var(--shadow);
  animation: pop-in 0.14s ease-out;
}
#ui .bigmap-box::before, #ui .bigmap-box::after {
  content: ""; position: absolute; width: 1rem; height: 1rem; border: 2px solid var(--gold); pointer-events: none;
}
#ui .bigmap-box::before { left: -5px; top: -5px; border-right: 0; border-bottom: 0; }
#ui .bigmap-box::after { right: -5px; bottom: -5px; border-left: 0; border-top: 0; }
#ui .bigmap-head { display: flex; align-items: center; gap: 0.6rem; }
#ui .bigmap-title { font-family: var(--font-title); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.14em; color: var(--gold-hi); text-shadow: 0 0 8px rgba(247, 210, 130, 0.35), 0 2px 0 #000; }
#ui .bigmap-title::before { content: "✦ "; color: var(--gold); font-size: 0.8em; }
#ui .bigmap-sub { color: var(--azure-hi); }
#ui .bigmap-x { width: 1.8rem; height: 1.8rem; padding: 0; border-radius: 50%; font-size: 1.1rem; }
#ui .bigmap-stage { position: relative; line-height: 0; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px #000, 0 0 0 2px var(--gold-dk); }
#ui .bigmap-canvas { display: block; }
#ui .bigmap-foot { display: flex; align-items: center; gap: 0.6rem; }
#ui .bigmap-legend { display: flex; gap: 0.8rem; flex-wrap: wrap; color: var(--text-dim); }
#ui .bigmap-legend .lg { display: inline-flex; align-items: center; gap: 0.3rem; }
#ui .bigmap-legend .lg i { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; box-shadow: 0 0 0 1px #000; }
#ui .lg-warp i { background: #c77dff; }
#ui .lg-npc i { background: #ffd84a; border-radius: 2px !important; }
#ui .lg-party i { background: #7cf07a; }
#ui .lg-player i { background: #9fc8ff; }
#ui .lg-monster i { background: #ff5a4a; border-radius: 1px !important; }
#ui .lg-self i { background: #fff; clip-path: polygon(50% 0, 100% 100%, 50% 75%, 0 100%); border-radius: 0 !important; box-shadow: none !important; }

@media (max-width: 1320px), (max-height: 740px) {
  #ui .menu-panel, #ui .party-panel { width: 23rem; }
  #ui .shop-panel { width: 25rem; }
}
/* PANELS-B-END */
