/* 小蘑菇World
 * 版面：視窗式。上方「視窗」列；三欄：左「角色狀態」、中「冒險紀錄」（紀錄、戰鬥、工具列、聊天）、右「地圖」「任務」；
 * 其他功能（背包、技能、商店……）用彈出視窗。每個視窗有標題列、方角細框，裡面再用細框分區。
 * 配色見下面 :root。設定裡可換亮色。
 */
/* 配色「黑白」：黑底白字、灰階按鈕與內框；只有主視窗的外框線（--frame）是琥珀色。
 * HP/MP/EXP 血條、裝備稀有度、聊天頻道保留顏色，因為是用顏色分辨的資訊 */
:root {
  --bg: #000000;
  --panel: #0d0d0d;
  --panel-2: #121212;
  --head: #171717;
  --line: #3a3a3a;
  --line-2: #262626;
  --text: #f2f2f2;
  --muted: #a3a3a3;
  --dim: #6b6b6b;
  --accent: #f2f2f2;
  --accent-2: #ffffff;
  --accent-bg: #262626;
  --accent-ink: #000000;
  --frame: #e3a23f;
  --hp: #e0604f;
  --mp: #5fa8d3;
  --exp: #ebc66e;
  --crit: #f2b866;
  --good: #8ccf8f;
  --bad: #e0604f;
  --common: #d8cfc2;
  --rare: #73b5e0;
  --epic: #c9a0e0;
  --legend: #ebc66e;
  --scrim: rgba(0, 0, 0, 0.72);
  --hit-flash: #3a2020;
  --map-ink: #6b6b6b;
  --ch-world: #f2f2f2; --ch-guild: #c9a0e0; --ch-party: #7ec8c0; --ch-system: #ebc66e; --ch-whisper: #f09aa8;
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  --num: "Segoe UI", "Helvetica Neue", Arial, var(--font);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #e9ecf0; --panel: #ffffff; --panel-2: #f5f6f8; --head: #e6e9ee; --line: #c3cbd6; --line-2: #dbe0e7;
    --text: #18202c; --muted: #5a6474; --dim: #8a93a1; --accent: #18202c; --accent-2: #000000; --accent-bg: #e3e6ea; --accent-ink: #ffffff; --frame: #c77a14;
    --hp: #c94a4b; --mp: #2f78c9; --exp: #b98c18; --crit: #c66a1c; --good: #2e9a5e; --bad: #c94a4b;
    --common: #4a5361; --rare: #2f78c9; --epic: #7a52c9; --legend: #a87a12;
    --scrim: rgba(20, 24, 30, 0.45); --hit-flash: #f6dedb; --map-ink: #8a93a1;
    --ch-world: #18202c; --ch-guild: #7a52c9; --ch-party: #2f78c9; --ch-system: #a87a12; --ch-whisper: #c4466f;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #e9ecf0; --panel: #ffffff; --panel-2: #f5f6f8; --head: #e6e9ee; --line: #c3cbd6; --line-2: #dbe0e7;
  --text: #18202c; --muted: #5a6474; --dim: #8a93a1; --accent: #18202c; --accent-2: #000000; --accent-bg: #e3e6ea; --accent-ink: #ffffff; --frame: #c77a14;
  --hp: #c94a4b; --mp: #2f78c9; --exp: #b98c18; --crit: #c66a1c; --good: #2e9a5e; --bad: #c94a4b;
  --common: #4a5361; --rare: #2f78c9; --epic: #7a52c9; --legend: #a87a12;
  --scrim: rgba(20, 24, 30, 0.45); --hit-flash: #f6dedb; --map-ink: #8a93a1;
  --ch-world: #18202c; --ch-guild: #7a52c9; --ch-party: #2f78c9; --ch-system: #a87a12; --ch-whisper: #c4466f;
  color-scheme: light;
}
/* GM 標誌：名字前面的金色小方塊 */
.gm-tag { display: inline-block; margin-right: 4px; padding: 0 4px; border-radius: 3px; background: #e3a23f; color: #1a1200;
  font: 700 10px/1.5 var(--num); letter-spacing: 0.5px; vertical-align: 1px; }

/* 上班模式：白底灰字、全部去色，看起來像一般文件 */
:root[data-theme="work"] {
  --bg: #ffffff; --panel: #ffffff; --panel-2: #fafafa; --head: #f3f3f3; --line: #d4d4d4; --line-2: #e6e6e6;
  --text: #333333; --muted: #6f6f6f; --dim: #9a9a9a; --accent: #333333; --accent-2: #111111; --accent-bg: #ededed; --accent-ink: #ffffff; --frame: #d4d4d4;
  --hp: #8a8a8a; --mp: #a8a8a8; --exp: #bdbdbd; --crit: #555555; --good: #555555; --bad: #555555;
  --common: #333333; --rare: #333333; --epic: #333333; --legend: #333333;
  --scrim: rgba(0, 0, 0, 0.2); --hit-flash: #f3f3f3; --map-ink: #9a9a9a;
  --ch-world: #333333; --ch-guild: #333333; --ch-party: #333333; --ch-system: #555555; --ch-whisper: #333333;
  color-scheme: light;
}
:root[data-theme="work"] body { filter: grayscale(1); }
:root[data-theme="work"] .brand { visibility: hidden; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 13.5px/1.55 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.r-common { color: var(--common); } .r-rare { color: var(--rare); } .r-epic { color: var(--epic); } .r-legend { color: var(--legend); font-weight: 700; }
h3 { margin: 0 0 6px; font-size: 13px; font-weight: 500; color: var(--accent); }
/* 視窗裡的分區標題：—— 角色 —— */
.sec-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; color: var(--accent); font-size: 12.5px; letter-spacing: 0.15em; }
.sec-title::before, .sec-title::after { content: ""; flex: 1; border-top: 1px solid var(--line-2); }

/* ───── 頂欄 ───── */
/* 頂欄：置中的遊戲名稱，左邊是線上人數與遊戲時間（純文字） */
.topbar {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 16px; min-height: 36px;
  /* 跟下面置中的遊戲同寬（最寬 1280px、左右各留 6px），橘線兩端往上收成一個框 */
  padding: 4px 12px;
  margin-left: max(6px, env(safe-area-inset-left, 0px), calc((100% - 1268px) / 2)); margin-right: max(6px, env(safe-area-inset-right, 0px), calc((100% - 1268px) / 2));
  background: var(--head); border: 1px solid var(--frame); border-top: 0;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: 0.08em; color: var(--accent); display: inline-flex; align-items: center; gap: 8px; }
/* 標題旁的 Discord 群組連結 */
.dc-link { display: inline-flex; color: #5865f2; }
.dc-link:hover { color: #7983f5; }
/* 視窗按鈕那一列：左邊線上人數與遊戲時間（寬度跟左欄一樣）、中間按鈕（從冒險紀錄左邊開始）、右邊跑馬燈公告 */
.topline { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 6px 0; padding-left: max(6px, env(safe-area-inset-left, 0px)); padding-right: max(6px, env(safe-area-inset-right, 0px)); }
.marquee { height: 26px; border: 1px solid var(--frame); border-radius: 2px; background: var(--panel); font-size: 12.5px; }
.top-info { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.top-info b { color: var(--text); font-weight: 500; }
.mail-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 0 4px; font-size: 20px; line-height: 1; color: var(--accent); cursor: pointer; }
.mail-btn:hover { color: var(--text); }
.mail-btn .dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
/* 本圖玩家（路線圖的位置）：右欄比較窄，名字和按鈕放不下就換行 */
.map-players { padding: 6px; display: grid; gap: 6px; }
.map-players h3 { font-size: 13px; }
.map-players .mp-row { flex-wrap: nowrap; align-items: center; gap: 4px; padding: 4px 6px; }
.map-players .mp-name { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.map-players .mp-row .btn { flex: none; padding: 1px 6px; }
.map-players .mp-row > .muted { flex: none; font-size: 12px; }
/* 列表右上角的小標（商店買的、轉職送的裝備「無法熔煉」） */
.row.corner { position: relative; padding-top: 18px; }
.set-tag { color: var(--legend); font-weight: 700; margin-right: 4px; }
.no-smelt { position: absolute; top: 3px; right: 8px; font-size: 11px; line-height: 1.2; color: var(--bad); }
.mail-meta { display: flex; justify-content: space-between; gap: 8px; }
.mail-body { white-space: pre-wrap; font-size: 12.5px; margin: 4px 0; }
.marquee { flex: 1 1 0; min-width: 0; position: relative; overflow: hidden; }
.marquee:empty { visibility: hidden; }
.marquee span { position: absolute; top: 50%; white-space: nowrap; color: var(--exp); animation: marquee linear infinite; }
@keyframes marquee { from { left: 100%; transform: translate(0, -50%); } to { left: 0; transform: translate(-100%, -50%); } }
@media (prefers-reduced-motion: reduce) { .marquee span { animation: none; left: 10px; transform: translateY(-50%); } }

/* ───── 視窗 ───── */
.win { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; }
.win-title {
  flex: none; display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 8px;
  background: var(--head); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden;
}
.win-title b { font-weight: 500; color: var(--accent); }
.win-title .title-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12.5px; }
.win-title .title-btn { margin-left: auto; }
.win-title .title-btn:not(.hidden) ~ .title-btn { margin-left: 4px; } /* 兩個按鈕並排靠右（本圖玩家、世界地圖） */
.win-x { margin-left: auto; width: 26px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 2px; background: var(--panel-2); cursor: pointer; color: var(--muted); }
.win-x:hover { border-color: var(--bad); color: var(--bad); }
.win-body { padding: 8px; overflow-y: auto; min-height: 0; }
.box { border: 1px solid var(--line-2); padding: 8px 10px; display: grid; gap: 6px; }
.box + .box { margin-top: 8px; }

/* ───── 遊戲版面：上方視窗列 + 三欄，整個畫面不捲動，內容在各視窗裡捲動 ───── */
/* 整個遊戲置中，不撐滿大螢幕：最寬 1280px、最高 900px */
.game { display: flex; flex-direction: column; width: 100%; max-width: 1280px; margin: 0 auto; height: min(calc(100dvh - 37px), 900px); }
/* 只有按鈕，沒有底色和底線；外框跟主視窗一樣用 --frame */
.winbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.winbar button {
  position: relative; padding: 2px 11px; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--frame); border-radius: 2px; background: var(--head); color: var(--text);
}
.winbar button:hover { background: var(--accent-bg); }
.winbar button.on { background: var(--accent-bg); color: var(--accent-2); font-weight: 700; }
.winbar .dot { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
/* 任務視窗的分頁（主線／支線／日常），能領獎的有紅點 */
.quest-tabs { padding-bottom: 8px; border-bottom: 1px solid var(--line-2); }
.quest-tabs .btn { position: relative; min-width: 72px; padding: 3px 12px; font-size: 13px; }
.quest-tabs .num { margin-left: 4px; opacity: 0.75; }
.quest-tabs .dot { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.desk {
  flex: 1; min-height: 0; display: grid; gap: 6px; padding: 6px;
  padding-left: max(6px, env(safe-area-inset-left, 0px)); padding-right: max(6px, env(safe-area-inset-right, 0px));
  grid-template-columns: 260px minmax(0, 1fr) 280px;
}
.col-r { display: flex; flex-direction: column; gap: 6px; min-height: 0; min-width: 0; }
/* 只有外框線有顏色：冒險紀錄、角色狀態、地圖、背包、彈出視窗 */
.w-main, .w-char, .w-map, .w-bag { border-color: var(--frame); }
.w-map { flex: 1 1 60%; }
.w-bag { flex: 1 1 40%; }
#charHead:empty, #charSkills:empty, #charStats:empty { display: none; }
.w-char .win-body > * + * { margin-top: 6px; }
.w-char .box { padding: 6px 10px; gap: 4px; }
.w-char .sec-title { margin-bottom: 2px; }
#questBox .q-row { font-size: 12.5px; }
/* 右欄背包比較窄：名稱和「使用」按鈕排在同一行 */
#bagBox .row .info { flex: 1 1 110px; }
#bagBox .list { gap: 3px; }
#bagBox .nm { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
#bagBox .nm .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bagBox .nm .num { flex: none; }
#bagBox .row { padding: 4px 7px; font-size: 12.5px; gap: 4px 8px; }
#bagBox .row .stats { font-size: 11.5px; line-height: 1.45; }
@media (max-width: 1100px) {
  .desk { grid-template-columns: 250px minmax(0, 1fr); }
  .col-r { grid-column: 1 / -1; flex-direction: row; }
  .col-r .win { flex: 1 1 0; max-height: 320px; }
  .game { height: auto; }
  .desk { grid-template-rows: minmax(560px, calc(100dvh - 80px)) auto; }
}
@media (max-width: 760px) {
  .topline { flex-wrap: wrap; }
  .marquee { flex: 1 1 100%; }
  /* 手機：線上人數放到遊戲名稱下面一行，不跟名稱疊在一起 */
  .top-info { position: static; transform: none; flex: 1 1 100%; order: 1; text-align: center; }
  .marquee { order: 1; }
  /* 視窗按鈕在手機上換行，不要把整頁撐寬 */
  .topline .winbar { flex: 1 1 100%; min-width: 0; }
  .desk { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  /* 最少佔畫面 82%，內容比較多（矮的手機、橫放、隊伍人多）就跟著變高，不會溢出去蓋到下面的角色視窗、擋住聊天輸入框 */
  .w-main { order: -1; height: auto; min-height: 82dvh; }
  .w-char { max-height: none; }
  .col-r { flex-direction: column; }
  /* 直排時地圖、背包用固定高度（照比例分高度會被壓成 0），內容在視窗裡捲動 */
  .col-r .win { flex: none; max-height: none; }
  .w-map { height: 440px; }
  .w-bag { height: 380px; }
}

/* ───── 共用元件 ───── */
.btn {
  border: 1px solid var(--line); background: var(--head); padding: 4px 12px; border-radius: 2px; cursor: pointer; white-space: nowrap; color: var(--text);
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn.sm { padding: 1px 9px; font-size: 12px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; font-size: 11px; padding: 0 5px; border-radius: 2px; border: 1px solid var(--line); background: var(--panel-2); margin-left: 4px; color: var(--muted); }
.tag.red { color: var(--bad); border-color: var(--bad); }
.tag.gold { color: var(--legend); border-color: var(--legend); }

.bar { position: relative; height: 14px; border-radius: 2px; background: var(--panel-2); border: 1px solid var(--line-2); overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; display: block; transition: width 0.2s linear; }
.bar > span { position: relative; display: block; text-align: center; font: 600 11px/13px var(--num); text-shadow: 0 0 3px var(--bg); }
.bar.hp > i { background: var(--hp); } .bar.mp > i { background: var(--mp); } .bar.exp > i { background: var(--exp); }
.bar.cast > i { background: var(--crit); }
.bar.travel > i { background: var(--accent); }
.bar.big { height: 18px; } .bar.big > span { line-height: 17px; font-size: 12px; }
.bar .marker { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: 0.5; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }

.list { display: grid; gap: 4px; }
.row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px;
  padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 2px; background: var(--panel-2);
}
.row .info { min-width: 0; flex: 1 1 200px; }
.row .stats { font-size: 12px; color: var(--muted); }
.up { color: var(--good); } .down { color: var(--bad); }
.stats .scr { color: var(--rare); font-weight: 700; } /* 卷軸加的數值 */
.lock-mark { margin-right: 3px; }
.shop-meso { padding: 2px 10px; border: 1px solid var(--frame); border-radius: 2px; color: var(--text); font-weight: 400; }
.shop-meso b { color: var(--exp); }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.field { padding: 5px 8px; border-radius: 2px; border: 1px solid var(--line); background: var(--bg); width: 100%; }
textarea.field { min-height: 90px; font: 12px monospace; }

/* ───── 左：角色狀態 ───── */
.who { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.who .name { font-weight: 700; font-size: 16px; }
.vitals { display: grid; gap: 4px; }
/* 角色框：HP/MP/EXP 和能力數值切換時高度一樣 */
.char-body { height: 86px; align-content: start; }
.stat-pairs.char-body { gap: 1px 14px; line-height: 1.5; }
/* 戰鬥區最下面：異常狀態（固定一行高，有沒有都不會讓下面跳動） */
.effect-line { flex: none; display: flex; flex-wrap: wrap; gap: 4px; height: 22px; overflow: hidden; }
.effect-line .tag { margin: 0; }
.effect-line .eff-l, .effect-line .eff-r { display: flex; flex-wrap: wrap; gap: 4px; }
.effect-line .eff-r { margin-left: auto; justify-content: flex-end; }
.tag.good { color: var(--good); border-color: var(--good); }
.foe .debuffs .tag { margin: 3px 0 0; }
.stat-pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 14px; font-size: 12.5px; }
.stat-pairs .kv span:first-child { color: var(--muted); }
/* 能力欄窄：名稱和數值都不換行（傷害 6,081~8,687 這種長數值不會把「傷害」擠成兩行） */
.stat-pairs .kv { gap: 6px; }
.stat-pairs .kv span { white-space: nowrap; }
.stat-pairs .kv span:first-child { flex-shrink: 0; }
.gear-list { display: grid; gap: 0; font-size: 12.5px; line-height: 1.35; }
.gear-list button { display: flex; gap: 8px; width: 100%; padding: 1px 4px; text-align: left; border: 1px solid transparent; background: none; cursor: pointer; border-radius: 2px; }
.gear-list button:hover { border-color: var(--line); background: var(--panel-2); }
.gear-list .slot-name { flex: none; width: 30px; color: var(--dim); }
.gear-list .gear-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-list .kv { font-size: 12.5px; }
.stats-head { display: flex; justify-content: space-between; align-items: baseline; }
.stat-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 24px; }
.stat-cols .kv { border-bottom: 1px dashed var(--line-2); }

/* 背包視窗裡的身上裝備 */
.equip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.slot { text-align: left; border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 2px; padding: 4px 8px; cursor: pointer; min-width: 0; }
.slot:hover { border-color: var(--accent); }
.slot small { display: block; font-size: 11px; color: var(--muted); }
.slot b { display: block; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.empty b { color: var(--dim); font-weight: 400; }

/* ───── 中：冒險紀錄 ───── */
.toolbar { flex: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 8px; border-bottom: 1px solid var(--line-2); }
.toolbar button { padding: 1px 10px; font-size: 12px; cursor: pointer; border: 1px solid var(--line); border-radius: 2px; background: var(--head); color: var(--text); }
.toolbar button.on { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-2); }
.toolbar .count { margin-left: 4px; color: var(--accent); font-family: var(--num); }
.stage-head { display: flex; gap: 10px; min-width: 0; }
/* 地點和出沒怪物：放得下就同一行，放不下換行時兩行左邊對齊 */
#stageHead { display: flex; flex-wrap: wrap; column-gap: 12px; row-gap: 0; line-height: 1.35; }
.title-sub .place { color: var(--text); }
.title-sub .who { color: var(--muted); }
/* 紀錄與聊天在最下面，用掉戰鬥、組隊剩下的高度 */
.log { flex: 1 1 0; min-height: 110px; overflow-y: auto; margin: 6px 8px; padding: 6px 12px; border: 1px solid var(--line-2); background: var(--bg); font-size: 13px; line-height: 1.65; }
.log p { margin: 0; display: flex; gap: 10px; }
.log p .t { flex: none; color: var(--dim); font: 11.5px/1.7 var(--num); padding-top: 1px; }
.log p .m { min-width: 0; overflow-wrap: anywhere; }
.log .c-warn { color: var(--bad); }
.log .c-loot { color: var(--exp); }
.log .c-quest { color: var(--accent-2); font-weight: 500; }
.log .c-system { color: var(--ch-system); }
.log .c-battle { color: var(--text); }
.log .ch-world { color: var(--ch-world); }
.log .ch-guild { color: var(--ch-guild); }
.log .ch-party { color: var(--ch-party); }
.log .ch-system { color: var(--ch-system); }
.log .ch-whisper { color: var(--ch-whisper); }
.log .chn { font-weight: 500; }
.log .empty { color: var(--muted); }

/* 目前的戰鬥：狀態列 + 場上的怪物（純文字，不用任何遊戲圖片） */
.battle { flex: none; margin: 8px 8px 0; border: 1px solid var(--line-2); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
/* 狀態列三格：左狀態、中間頭目蓄力的招式（黃字）、右最近一次攻擊 */
.status-line { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, max-content) minmax(0, 1fr); align-items: center; gap: 0 12px; height: 20px; overflow: hidden; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.status-line .cast { color: var(--exp); font-weight: 700; font-size: 13.5px; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.status-line .last { color: var(--text); font-weight: 700; justify-self: end; white-space: nowrap; }
.status-line .crit { color: var(--crit); }
/* 高度固定：最高的情況是頭目一列加 5 隻小怪兩列（177px），一般 6 隻、移動中、沒怪時都一樣高，
 * 下面的按鈕、組隊、聊天才不會跳動 */
.stage { height: 180px; overflow-y: auto; }
/* 組隊挑戰結算（頭目房間、頭目下面）：名字、打掉的血、佔全隊的比例 */
.raid-result:empty { display: none; }
.raid-result { display: grid; grid-template-columns: 1fr auto auto; gap: 1px 14px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-2); font-size: 12.5px; }
.raid-result .rr-title { grid-column: 1 / -1; color: var(--exp); font-weight: 500; }
.raid-result .rr-row { display: contents; }
/* 頭目戰結算：虛線框，上面傷害表、下面戰利品 */
/* 好友名字：可以點（看裝備），看起來像文字 */
.link-btn { font: inherit; color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.link-btn:hover { color: var(--accent); }
.set-eff { display: grid; gap: 1px; font-size: 12.5px; padding: 6px 8px; margin-top: 8px; border: 1px solid var(--line-2); border-radius: 2px; }
.set-eff > b { color: var(--legend); font-weight: 500; }
/* 好友的裝備：左邊格子、右邊套裝效果，窄螢幕上下排 */
.friend-gear { display: flex; gap: 8px; align-items: flex-start; }
.friend-gear .equip-grid { flex: 1 1 0; min-width: 0; }
.friend-gear .slot { cursor: default; }
.friend-gear .slot:hover { border-color: var(--line-2); }
.friend-sets { flex: 0 1 220px; min-width: 0; }
.friend-sets:empty { display: none; }
.friend-sets .set-eff:first-child { margin-top: 0; }
@media (max-width: 600px) { .friend-gear { flex-direction: column; align-items: stretch; } .friend-sets { flex-basis: auto; } }
.foe.boss.has-result { border: 0; background: none; padding: 0; }
.foe.boss.has-result > :not(.raid-result) { display: none; }
.foe.boss.has-result .raid-result { margin: 0; padding: 0; border: 0; }
.boss-result { grid-column: 1 / -1; border: 1px dashed var(--line); padding: 8px 10px; display: grid; gap: 8px; font-size: 12.5px; }
.br-table { width: 100%; border-collapse: collapse; }
.br-table th { font-weight: 500; color: var(--muted); text-align: right; padding: 2px 6px; border-bottom: 1px solid var(--line-2); }
.br-table td { padding: 3px 6px; border-bottom: 1px solid var(--line-2); text-align: right; }
.br-table td:first-child { text-align: left; }
.br-table tr.me td { font-weight: 700; background: var(--panel-2); }
.br-loot { display: grid; gap: 2px; }
/* 組隊：戰鬥和聊天中間一條，顯示隊友的等級、地圖、在不在線 */
.party-strip { flex: none; display: flex; flex-direction: column; gap: 6px; margin: 6px 8px 0; padding: 6px 10px 8px; border: 1px solid var(--line-2); background: var(--panel-2); font-size: 13px; }
.party-strip:empty { display: none; }
.party-strip .ps-head { display: flex; align-items: center; gap: 10px; min-height: 24px; }
.party-strip .ps-title { color: var(--ch-party); font-weight: 600; }
.party-strip .ps-bonus { color: var(--exp); }
.party-strip .ps-act { margin-left: auto; }
/* 隊友一人一列，最多 6 人，寬的時候排兩欄 */
.party-strip .ps-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 8px; }
/* 隊員卡片兩行：上面「名字 職業等級」，下面位置 ＋ 右邊血條（比較長） */
.party-strip .mate { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 5px 10px; border: 1px solid var(--line); border-radius: 2px; background: var(--head); }
.party-strip .mate.same { border-color: var(--ch-party); }
.party-strip .mate-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.party-strip .mate .on { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.party-strip .mate .on.yes { background: var(--good); }
.party-strip .mate-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 16px; position: relative; }
.party-strip .mate-bottom .revive { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); padding: 1px 12px; }
.party-strip .mate .where { flex: 1 1 auto; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.party-strip .mate.same .where { color: var(--ch-party); }
.party-strip .mate .bar { flex: 0 0 55%; }
/* 名字、隊長標籤、血條不縮；職業太長（大魔導士（冰、雷））就截成「…」，不擠出框 */
.party-strip .mate-top > b, .party-strip .mate-top > .tag { flex: none; white-space: nowrap; }
.party-strip .mate-top > .muted { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* 組隊共打的狀態列（集合中、進行中、打倒了） */
.party-strip .ps-raid { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 4px 10px; border: 1px solid var(--frame); border-radius: 2px; color: var(--exp); font-weight: 500; }
.party-strip .ps-raid.good { color: var(--good); }
.party-strip .ps-raid.bad { color: var(--bad); }
.toolbar { margin-top: 6px; border-top: 1px solid var(--line-2); }
/* 一次最多 6 隻：固定三欄兩列；頭目戰時頭目佔一整列，召喚的小怪排在下面 */
.foes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.foes .foe.boss { grid-column: 1 / -1; }
.foes.with-boss .foe:not(.boss) { padding: 3px 8px; }
.foe { position: relative; display: grid; gap: 3px; padding: 5px 8px; border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 2px; min-width: 0; }
.foe.boss { border-color: var(--hp); }
.foe.hit { background: var(--hit-flash); }
.foe.dead { opacity: 0.4; }
.foe-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foe-name b { font-weight: 500; }
/* 移動中：目的地和進度條放在戰鬥區正中間 */
.idle { color: var(--muted); font-size: 13px; display: grid; gap: 8px; height: 100%; align-content: center; justify-items: center; text-align: center; }
.idle .bar { width: min(360px, 80%); }
.fx { position: absolute; inset: 0; pointer-events: none; }
.float {
  position: absolute; top: 10%; transform: translate(-50%, 0); white-space: nowrap;
  font: 800 16px var(--num); color: var(--accent-2); text-shadow: 0 0 3px var(--bg), 0 1px 0 var(--bg);
  animation: rise 0.9s ease-out forwards;
}
.float.crit { color: var(--crit); font-size: 21px; }
.float.heal { color: var(--good); }
.float.miss { color: var(--muted); font-size: 13px; }
@keyframes rise { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -32px); } }
@keyframes fade { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .float { animation: fade 0.9s forwards; } .bar > i { transition: none; } }

/* 工具列：道具、狩獵／頭目、技能 */
/* 道具和狩獵／挑戰按鈕排成一排；真的放不下（例如手機）才把右邊那組換到下一行，不會疊在一起 */
.controls { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px 0; }
.controls .items, .controls .main { display: flex; flex-wrap: wrap; gap: 4px; }
.controls .main { margin-left: auto; }
.controls .btn { white-space: nowrap; flex: none; }
.btn.item { padding: 3px 9px; background: var(--head); }
.btn.item .num { margin-left: 3px; color: var(--muted); }
.btn.hunt { min-width: 88px; }
.btn.hunt.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-2); font-weight: 500; }
.btn.hunt .lbl-off { display: none; }
.btn.hunt.on:hover .lbl-on { display: none; }
.btn.hunt.on:hover .lbl-off { display: inline; color: var(--bad); }
.skill-bar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px 0; }
.skill-bar:empty { display: none; }
/* 技能設置：「怪物多於 N 隻時優先」 */
.skill-min { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.skill-min select { padding: 1px 4px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 2px; }
.btn.sm.on { border-color: var(--frame); }
.skill-bar::before { content: "技能"; color: var(--muted); font-size: 12px; margin-right: 2px; }
.skill-tag { position: relative; overflow: hidden; font-size: 12px; padding: 1px 8px; border: 1px solid var(--line); border-radius: 2px; background: var(--panel-2); }
.skill-tag.cd { opacity: 0.45; }
/* 冷卻讀條：半透明，從左邊蓋過來，冷卻時間越少越短（從右往左縮） */
.btn.item { position: relative; overflow: hidden; }
.skill-tag .cd-bar, .btn.item .cd-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--text); opacity: 0.35; pointer-events: none; transition: width 0.2s linear; }

/* 聊天輸入：選頻道 + 訊息 */
.chat-bar { flex: none; }
.chat-form { display: flex; gap: 6px; padding: 6px 8px 8px; margin-top: 6px; border-top: 1px solid var(--line-2); }
.chat-form select { flex: none; padding: 4px 6px; border-radius: 2px; border: 1px solid var(--line); background: var(--head); }
.chat-form .field { padding: 4px 8px; min-width: 0; }
.chat-form .chat-to { flex: 0 0 96px; }
.chat-form select.ch-party { color: var(--ch-party); } .chat-form select.ch-guild { color: var(--ch-guild); }
.chat-form select.ch-whisper { color: var(--ch-whisper); } .chat-form select.ch-world { color: var(--ch-world); }

/* ───── 右：路線圖、任務 ───── */
#routeMap { flex: 1 1 0; }
.q-chapter { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.q-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 13px; }
.q-row .q-text { min-width: 0; }
.q-row .now { font-weight: 700; }
.q-hint { font-size: 12px; margin: 0 0 4px 14px; }
.quest-step { padding: 1px 0; }
.quest-step.done { color: var(--muted); text-decoration: line-through; }
.quest-step.now { font-weight: 700; color: var(--accent-2); }

.world-svg { display: block; max-width: 100%; height: auto; }
.world-svg .link { fill: none; stroke: var(--line); stroke-width: 2.5; }
.world-svg .link.done { stroke: var(--accent); opacity: 0.65; }
.world-svg .st .dot { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.world-svg .st .no { fill: var(--text); font: 700 12px var(--num); text-anchor: middle; dominant-baseline: central; }
.world-svg .st .name { fill: var(--text); font-size: 14px; font-weight: 700; dominant-baseline: central; }
.world-svg .st .sub { fill: var(--muted); font-size: 12px; dominant-baseline: central; }
.world-svg .st.quest .sub { fill: var(--exp); }
.world-svg .st .qring { fill: none; stroke: var(--exp); stroke-width: 2; stroke-dasharray: 3 3; }
.world-svg .st.locked .dot { stroke: var(--map-ink); stroke-dasharray: 3 3; }
.world-svg .st.locked .no, .world-svg .st.locked .name { fill: var(--muted); font-weight: 400; }
.world-svg .st.here .dot { fill: var(--accent); stroke: var(--accent-2); }
.world-svg .st.here .no { fill: var(--accent-ink); }
.world-svg .st.here .name { fill: var(--accent-2); font-weight: 800; }
.world-svg .st .pulse { fill: none; stroke: var(--accent); stroke-width: 2; animation: pulse 1.6s ease-out infinite; transform-origin: center; transform-box: fill-box; }
.world-svg [data-act] { cursor: pointer; }
.world-svg [data-act]:hover .dot { stroke-width: 3; }
.world-svg [data-act]:hover .name { fill: var(--accent-2); }
.route-svg { display: block; max-width: 100%; height: auto; }
.route-svg .edge { stroke: var(--line); stroke-width: 3; fill: none; }
.route-svg .edge.dash { stroke-dasharray: 5 5; }
.route-svg .node circle.dot { fill: var(--panel-2); stroke: var(--line); stroke-width: 2; }
.route-svg .node.go { cursor: pointer; }
.route-svg .node.go:hover circle.dot { stroke: var(--accent); }
.route-svg .node.here circle.dot { fill: var(--accent); stroke: var(--accent-2); }
.route-svg .node.boss circle.dot { stroke: var(--hp); }
.route-svg .node.hidden circle.dot { stroke: var(--bad); stroke-dasharray: 3 3; }
.route-svg .node.locked { opacity: 0.45; }
.route-svg .icon { fill: var(--text); font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.route-svg .node.here .icon { fill: var(--accent-ink); }
.route-svg .node.boss .icon { fill: var(--hp); }
.route-svg .label { fill: var(--text); font-size: 15px; font-weight: 700; }
.route-svg .node.here .label { fill: var(--accent-2); }
.route-svg .sub { fill: var(--muted); font-size: 12.5px; }
.route-svg .cnt { fill: var(--muted); font-size: 12px; text-anchor: end; } /* 地圖名稱右邊：這張地圖有幾個線上玩家 */
.route-svg .quest { fill: var(--exp); font-size: 12px; font-weight: 700; }
.route-svg .qtag rect { fill: none; stroke: var(--good); stroke-width: 1.2; }
.route-svg .pulse { fill: none; stroke: var(--accent); stroke-width: 2; animation: pulse 1.6s ease-out infinite; transform-origin: center; transform-box: fill-box; }
.route-svg #travelDot { fill: var(--exp); stroke: var(--panel); stroke-width: 2; }
@keyframes pulse { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(1.8); } }
@media (prefers-reduced-motion: reduce) { .route-svg .pulse, .world-svg .st .pulse { animation: none; opacity: 0.5; } }

/* ───── 彈出視窗 ───── */
.overlay { position: fixed; inset: 0; z-index: 10; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay.top { z-index: 20; }
.popup { width: min(780px, 100%); max-height: 86dvh; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); border-color: var(--frame); }
.popup > .win-title { min-height: 32px; }
.popup.wide { width: min(1140px, 100%); height: 86dvh; }
.tab-body { padding: 8px; overflow-y: auto; min-height: 0; display: grid; gap: 8px; align-content: start; }
.tab-body > div > h3 { padding-bottom: 4px; border-bottom: 1px solid var(--line-2); }
/* 背包：左邊身上裝備，右邊分類與道具清單（清單在視窗裡捲動） */
.tab-body.tab-bag { flex: 1; overflow: hidden; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-content: stretch; }
.tab-bag > :first-child { grid-row: span 2; overflow-y: auto; }
.tab-bag > :nth-child(3) { min-height: 0; overflow-y: auto; padding-right: 4px; }
/* 商店：左邊商品，右邊自己的背包（直接賣） */
.tab-body.tab-shop { flex: 1; overflow: hidden; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-content: stretch; }
.tab-shop > div { min-height: 0; overflow-y: auto; border: 1px solid var(--line-2); padding: 8px; display: grid; gap: 8px; align-content: start; }
.tab-shop .pane-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--accent); }
.tab-shop .pane-title.bag { color: var(--rare); }
.bag-tabs { display: grid; gap: 6px; }
.smelt-head { display: grid; gap: 6px; }
.smelt-head .smelt-acts { display: flex; gap: 4px; margin-left: auto; }
.tab-smelt .smelt-head { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2); }
.slot-bar .btn { padding: 1px 8px; }
.slot-bar .num { color: inherit; opacity: 0.7; }
.bag-group { margin-top: 4px; font-size: 12px; color: var(--accent); letter-spacing: 0.08em; }
.bag-group:first-child { margin-top: 0; }
@media (max-width: 760px) {
  .tab-body.tab-bag, .tab-body.tab-shop { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; overflow-y: auto; }
  .tab-bag > :first-child { grid-row: auto; }
  .tab-shop > div { overflow: visible; }
}
.modal-card { background: var(--panel); border: 1px solid var(--frame); border-radius: 3px; padding: 14px 16px; max-width: 560px; width: 100%; max-height: 90dvh; overflow-y: auto; display: grid; gap: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); }
.modal-card h2 { margin: 0; font-size: 16px; font-weight: 700; }
.scroll-res { font-size: 15px; font-weight: 700; padding: 6px 10px; border: 1px solid; border-radius: 2px; text-align: center; animation: scroll-res 0.5s ease-out; }
.scroll-res.ok { color: var(--good); border-color: var(--good); }
.scroll-res.fail { color: var(--bad); border-color: var(--bad); }
@keyframes scroll-res { from { transform: scale(1.12); opacity: 0.3; } to { transform: none; opacity: 1; } }
.choice { cursor: pointer; }
.choice:hover { border-color: var(--accent); }
.setting { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 5px 0; border-bottom: 1px dashed var(--line-2); }
.setting select, .setting input[type=number] { padding: 3px 6px; border-radius: 2px; border: 1px solid var(--line); background: var(--panel-2); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px 18px; }
.qs { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 10px; font-size: 13px; }
.qs input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.qs input[type=number] { width: 70px; padding: 2px 6px; border-radius: 2px; border: 1px solid var(--line); background: var(--panel-2); }
.qs output { font-family: var(--num); font-weight: 700; }
/* 設定視窗排緊一點 */
.tab-set { gap: 4px; }
.tab-set > div > h3 { margin-bottom: 2px; padding-bottom: 2px; }
.tab-set .setting { padding: 2px 0; }
.tab-set .setting select { padding: 1px 6px; }
.tab-set .quick { gap: 0 18px; }
.tab-set .muted { font-size: 12px; }
.inline-form { display: flex; gap: 8px; max-width: 380px; }
.inline-form .field { min-width: 0; }

/* ───── 建立角色、登入 ───── */
.create { display: flex; justify-content: center; padding-block: 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.create-card { max-width: 440px; width: 100%; border-color: var(--frame); }
.create-card .win-body { padding: 16px; display: grid; gap: 10px; }
.create-card .check { display: flex; gap: 6px; align-items: center; }

/* 提示放在畫面中間偏上一點（戰鬥區技能列附近），原本在最下面常被擋住看不到 */
/* 黑框、紅底、白字（各主題都一樣，要明顯） */
.toast.ok { background: #2e7d32; }
.toast { position: fixed; left: 50%; top: 35%; transform: translate(-50%, -50%); text-align: center; background: #c62828; color: #fff; border: 2px solid #000; padding: 8px 18px; border-radius: 2px; z-index: 30; font-size: 14px; font-weight: 700; max-width: calc(100% - 32px); }
