/* ============================================================================
 * 三國天命 v5.0 — 現代 MMORPG 版面 (v5.css，覆寫 v4.css)
 * 頂部半透明資訊列｜左側任務追蹤｜右上雷達 + 功能條｜快捷欄上方多頻道聊天室
 * ========================================================================== */
:root { --chat-h: 78px; --glass: rgba(6, 5, 4, 0.42); --glass2: rgba(6, 5, 4, 0.62); }

/* ---------- 頂部半透明資訊列 ---------- */
body .pl-plate {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.36) 62%, rgba(0, 0, 0, 0) 100%) !important;
  border: none !important; box-shadow: none !important; border-radius: 40px 0 0 40px; padding-right: 34px;
  backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px);
}
body .pl-bar { box-shadow: inset 0 1px 2px #000, 0 0 0 1px rgba(160, 128, 70, 0.22); background: rgba(10, 6, 5, 0.55); }
#buff-bar .buff { background: rgba(0, 0, 0, 0.45); border-color: rgba(176, 140, 76, 0.4); }

/* ---------- 目標框：頂部置中 ---------- */
body #target-lock-hud { top: 10px !important; bottom: auto !important; left: 50% !important; transform: translateX(-50%) !important; width: min(330px, 34vw) !important;
  background: rgba(8, 5, 4, 0.55) !important; backdrop-filter: blur(2px); border-color: rgba(170, 60, 40, 0.55) !important; }

/* ---------- 右上：雷達 + 功能條 ---------- */
#func-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; width: 100%; }
.fs-item { position: relative; min-width: 0; overflow: hidden; height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer;
  background: var(--glass); border: 1px solid rgba(176, 140, 76, 0.32); border-radius: 6px; color: var(--txt); font-family: var(--font); padding: 0; }
.fs-item:hover { border-color: var(--g2); background: var(--glass2); }
.fs-item img { width: 26px; height: 26px; border-radius: 4px; }
.fs-item span { font-size: 10px; line-height: 1; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.fs-dot { position: absolute; top: 3px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 6px #ef4444; display: none; }
.fs-dot.on { display: block; }
body #world-boss-pill { position: relative; flex-direction: column; gap: 1px; padding: 0; border-radius: 6px; font-size: 10px; width: auto; min-width: 0; height: 48px; background: rgba(60, 10, 8, 0.5) !important; border-color: rgba(220, 90, 70, 0.45) !important; }
body #world-boss-pill span { font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; color: #fecaca; font-family: Arial, var(--font); }
body #zoom-control-pill { align-self: center; background: var(--glass); }

/* ---------- 左側：任務追蹤 ---------- */
#left-dock { display: none !important; }
#quest-tracker { position: fixed; left: 6px; top: 116px; width: 236px; z-index: 25; pointer-events: auto; }
.qt-head { display: flex; align-items: center; gap: 5px; padding: 3px 8px; font-size: 11.5px; color: var(--g1); cursor: pointer; background: linear-gradient(90deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0)); border-left: 2px solid var(--g2); }
.qt-head b { margin-left: auto; margin-right: 30%; color: var(--dim); }
#qt-body { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.qt-item { position: relative; padding: 4px 8px 5px 8px; cursor: pointer; background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.12)); border-left: 2px solid rgba(176, 140, 76, 0.35);
  display: grid; grid-template-columns: auto 1fr auto; column-gap: 6px; align-items: center; font-size: 11.5px; }
.qt-item:hover { background: linear-gradient(90deg, rgba(40, 30, 14, 0.7), rgba(0, 0, 0, 0.15)); }
.qt-item b { color: #f3e6c4; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.qt-item em { font-style: normal; color: #f7d98a; font-family: Arial, var(--font); font-size: 11px; text-shadow: 0 1px 2px #000; }
.qt-item small { grid-column: 1 / -1; font-size: 10.5px; color: #c9bb9c; text-shadow: 0 1px 2px #000; margin-top: 1px; }
.qt-item.done { border-left-color: #facc15; animation: qtglow 1.6s infinite; }
.qt-item.done em { color: #4ade80; font-weight: 900; }
@keyframes qtglow { 50% { background: linear-gradient(90deg, rgba(120, 90, 20, 0.6), rgba(0, 0, 0, 0.1)); } }
.qt-tag { font-size: 9.5px; padding: 0 4px; border-radius: 2px; background: #7a5a1c; color: #fff4d0; }
.qt-tag.d { background: #2c4c7a; }

/* ---------- 聊天室 (快捷欄上方) ---------- */
body #bottom-strip-container { display: none !important; }
#chat-panel { position: fixed; left: 8px; bottom: calc(var(--nav-h) + var(--exp-h) + var(--safe-b) + 8px); width: min(400px, 36vw); z-index: 26;
  display: flex; flex-direction: column; background: rgba(5, 4, 3, 0.5); border: 1px solid rgba(176, 140, 76, 0.28); border-radius: 6px; backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px); transition: height .2s; height: var(--chat-h); overflow: hidden; }
#chat-panel.open { height: min(340px, 48vh); background: rgba(5, 4, 3, 0.82); z-index: 50; }
.chat-head { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-bottom: 1px solid rgba(176, 140, 76, 0.18); flex-shrink: 0; }
.chat-tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tabs button { font-family: var(--font); font-size: 10.5px; padding: 1px 8px; color: var(--dim); background: transparent; border: 1px solid transparent; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.chat-tabs button.active { color: #fff0c8; border-color: rgba(201, 164, 92, 0.6); background: rgba(80, 60, 20, 0.45); }
.chat-toggle { width: 26px; height: 20px; flex-shrink: 0; font-size: 10px; color: var(--g1); background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line2); border-radius: 4px; cursor: pointer; }
.chat-list { flex: 1; overflow-y: auto; padding: 2px 6px; font-size: 11.5px; line-height: 1.45; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; cursor: pointer; }
#chat-panel.open .chat-list { cursor: auto; }
.chat-list .cm { color: #e8dcc0; text-shadow: 0 1px 2px #000; word-break: break-all; }
.chat-list .cm-ch { margin-right: 3px; font-size: 10.5px; }
.chat-list .cm b { font-weight: 700; }
.chat-list .cm i { font-style: normal; color: rgba(200, 180, 140, 0.45); font-size: 9.5px; margin-left: 4px; font-family: Arial, sans-serif; }
.chat-list .ch-BATTLE .cm-t { color: #f5c6b8; } .chat-list .ch-SYS .cm-t { color: #c7d7f0; }
.chat-input-row { display: none; gap: 4px; padding: 4px; border-top: 1px solid rgba(176, 140, 76, 0.2); flex-shrink: 0; }
#chat-panel.open .chat-input-row { display: flex; }
#chat-ch { font-family: var(--font); font-size: 12px; background: #120e0b; color: var(--txt); border: 1px solid var(--line2); border-radius: 3px; }
#chat-input { flex: 1; min-width: 0; font-family: var(--font); font-size: 13px; padding: 5px 8px; color: #f6e7c1; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line2); border-radius: 3px; outline: none; user-select: text; -webkit-user-select: text; }
#chat-input:focus { border-color: var(--g2); }
.chat-input-row .v4-btn { padding: 4px 10px; font-size: 12px; }

/* 搖桿位於聊天室上方 */
body #joystick-zone { bottom: calc(var(--nav-h) + var(--exp-h) + var(--safe-b) + var(--chat-h) + 22px) !important; left: 22px !important; }

/* ---------- 下方：快捷欄 / 主選單更輕量 ---------- */
#quick-bar { background: rgba(6, 5, 4, 0.5) !important; border-color: rgba(176, 140, 76, 0.3) !important; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6) !important; }
body #bottom-nav { background: linear-gradient(180deg, rgba(14, 11, 9, 0.82), rgba(4, 3, 2, 0.95)) !important; border-top: 1px solid rgba(176, 140, 76, 0.35) !important; }

/* ---------- 整合選單 ---------- */
#mega-menu { position: fixed; inset: 0; z-index: 65; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
#mega-menu.open { display: flex; }
.mm-box { width: min(520px, 92vw); padding: 12px; background: linear-gradient(180deg, rgba(28, 22, 17, 0.97), rgba(10, 8, 6, 0.98)); border: 1px solid #7a5f2e; box-shadow: 0 18px 60px #000; }
.mm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mm-head b { font-size: 16px; color: #f3dca0; letter-spacing: 3px; }
.mm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mm-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; cursor: pointer; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line2); border-radius: 6px; color: var(--txt); font-family: var(--font); font-size: 12px; }
.mm-item:hover { border-color: var(--g2); background: rgba(60, 46, 20, 0.4); }
.mm-item img { width: 44px; height: 44px; }
.mm-item .dot { position: absolute; top: 6px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 6px #ef4444; }

/* ---------- 任務 / 首領 / 排行 / 簽到 視窗 ---------- */
.qlist > *, .boss-list > *, .rk-list > * { flex-shrink: 0; }
.qlist, .boss-list, .rk-list { display: flex; flex-direction: column; gap: 5px; max-height: 58vh; overflow-y: auto; }
.qrow { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line2); overflow: hidden; }
.qrow .qn { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; color: #fff4d0; background: #4a3818; flex-shrink: 0; }
.qrow .qi { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; position: relative; }
.qrow .qi b { font-size: 13.5px; color: #f6e7c1; } .qrow .qi span { font-size: 11.5px; color: #c9bb9c; } .qrow .qi em { font-size: 11px; color: #f7d98a; font-style: normal; }
.qrow .qs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); white-space: nowrap; position: relative; font-family: Arial, var(--font); }
.qrow.done { opacity: .55; } .qrow.lock { opacity: .4; }
.qrow.cur { border-color: rgba(201, 164, 92, 0.6); } .qrow.ready { border-color: #facc15; box-shadow: inset 0 0 18px rgba(250, 204, 21, 0.15); }
.qrow .qbar { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, rgba(120, 90, 30, 0.25), rgba(120, 90, 30, 0.08)); }
.boss-cur { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 8px; background: rgba(80, 10, 6, 0.4); border: 1px solid rgba(220, 80, 60, 0.5); }
.boss-cur img { width: 40px; height: 40px; } .boss-cur div { flex: 1; display: flex; flex-direction: column; } .boss-cur b { color: #fecaca; font-size: 14px; } .boss-cur span { font-size: 11px; color: #d8cbb0; } .boss-cur em { font-style: normal; color: #fca5a5; font-family: Arial, var(--font); }
.boss-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: rgba(0, 0, 0, 0.32); border: 1px solid var(--line2); }
.boss-row.alive { border-color: rgba(239, 68, 68, 0.6); background: rgba(80, 10, 6, 0.25); }
.br-name { flex: 1; min-width: 0; display: flex; flex-direction: column; } .br-name b { font-size: 13px; color: #f6e7c1; } .br-name small { font-size: 10.5px; color: var(--dim); }
.br-time { font-size: 12px; color: #d8cbb0; font-family: Arial, var(--font); white-space: nowrap; } .br-time i { font-style: normal; color: #ef4444; font-weight: 900; }
.rk-mine { margin-left: auto; font-size: 12px; color: var(--dim); align-self: center; } .rk-mine b { color: #fde047; font-size: 15px; }
.rk-row { display: grid; grid-template-columns: 34px 24px 1fr 46px 52px 90px; align-items: center; gap: 6px; padding: 5px 8px; font-size: 12.5px; background: rgba(0, 0, 0, 0.3); border: 1px solid transparent; }
.rk-row.me { border-color: var(--g2); background: rgba(80, 60, 20, 0.35); }
.rk-row em { font-style: normal; text-align: center; font-weight: 900; color: var(--dim); font-family: Arial, var(--font); }
.rk-row em.top1 { color: #fde047; font-size: 15px; } .rk-row em.top2 { color: #e5e7eb; } .rk-row em.top3 { color: #f59e0b; }
.rk-row img { width: 22px; height: 22px; } .rk-row b { color: #f6e7c1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .rk-row span { color: #c9bb9c; font-size: 11.5px; } .rk-row i { font-style: normal; text-align: right; color: #f3c969; font-family: Arial, var(--font); }
.att-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.att-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line2); text-align: center; }
.att-cell span { font-size: 11px; color: var(--dim); } .att-cell img { width: 46px; height: 46px; } .att-cell b { font-size: 10.5px; color: #e8dcc0; line-height: 1.2; } .att-cell em { font-style: normal; font-size: 12px; color: #f7d98a; }
.att-cell.got { opacity: .45; } .att-cell.got::after { content: '已領'; font-size: 10px; color: #86efac; }
.att-cell.ready { border-color: #facc15; box-shadow: inset 0 0 16px rgba(250, 204, 21, 0.25); }
.bag-tools { display: flex; gap: 5px; } .bag-tools .v4-btn { padding: 4px 9px; font-size: 11.5px; }

/* ============================================================ 響應式 ============================================================ */
@media (max-aspect-ratio: 1/1) {
  :root { --chat-h: 70px; }
  body .pl-plate { padding-right: 20px; }
  #radar-panel { width: 120px; }
  #func-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
  .fs-item, body #world-boss-pill { height: 42px; } .fs-item img { width: 22px; height: 22px; }
  body #zoom-control-pill { display: none !important; }
  body #target-lock-hud { top: 122px !important; left: 6px !important; transform: none !important; width: calc(100vw - 142px) !important; }
  #quest-tracker { top: 172px; width: 48vw; }
  .qt-item small { display: none; }
  #chat-panel { left: 6px; right: 6px; width: auto; bottom: calc(var(--nav-h) + var(--exp-h) + var(--qb-s) + var(--safe-b) + 14px); }
  #chat-panel.open { height: 44vh; }
  #action-cluster { bottom: calc(var(--nav-h) + var(--exp-h) + var(--qb-s) + var(--chat-h) + var(--safe-b) + 18px) !important; }
  body #joystick-zone { bottom: calc(var(--nav-h) + var(--exp-h) + var(--qb-s) + var(--chat-h) + var(--safe-b) + 26px) !important; left: 12px !important; }
  .mm-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; } .mm-item img { width: 38px; height: 38px; }
  .rk-row { grid-template-columns: 28px 20px 1fr 38px 44px 70px; font-size: 11.5px; }
  .att-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  :root { --chat-h: 52px; }
  #quest-tracker { top: 114px; width: 196px; } .qt-item small { display: none; } .qt-item:nth-child(n+3) { display: none; }
  body #joystick-zone { bottom: calc(var(--nav-h) + var(--exp-h) + var(--safe-b) + var(--chat-h) + 12px) !important; }
  #func-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } .fs-item, body #world-boss-pill { height: 36px; } .fs-item span { display: none; }
  #chat-panel { width: 30vw; }
  #chat-panel.open { height: 70vh; }
  body #joystick-zone { left: 40px !important; }
  body #target-lock-hud { width: 30vw !important; }
}
