/* ============ 修仙世界 · 雲遊篇 — 商業版 UI ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #d8b93a;
  --gold-light: #f0d878;
  --panel-bg: rgba(14, 14, 26, 0.78);
  --panel-border: rgba(216, 185, 58, 0.35);
  --text: #e8e4d8;
  --text-dim: #9a96b0;
}

html, body {
  height: 100%;
  background: #0a0a14;
  color: var(--text);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }
.gold { color: var(--gold); }
.dim { color: var(--text-dim); font-weight: normal; }

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.panel-title {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px 6px;
  border-bottom: 1px solid rgba(216, 185, 58, 0.15);
}

.auth-tabs { display: flex; gap: 4px; margin: 18px 0 10px; }
.auth-tabs button { flex: 1; padding: 9px; background: rgba(255,255,255,.05); color: var(--text-dim); border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.auth-tabs button.active { color: var(--gold-light); border-color: var(--panel-border); background: rgba(216,185,58,.12); }
.auth-form { display: grid; gap: 9px; }
.auth-form input { width: 100%; padding: 11px 13px; border: 1px solid rgba(216,185,58,.25); border-radius: 6px; background: rgba(0,0,0,.3); color: var(--text); outline: none; }
.auth-form input:focus { border-color: var(--gold); }
.auth-message { min-height: 20px; margin: 8px 0 0; color: #9bd6b1; font-size: 12px; }
.auth-message.error { color: #ed8b8b; }

/* ============ 載入畫面 ============ */
#loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1d1d33 0%, #0a0a14 70%);
}
.load-inner { text-align: center; width: 320px; }
.load-logo {
  font-size: 40px; letter-spacing: 14px; color: var(--gold);
  text-shadow: 0 0 24px rgba(216, 185, 58, 0.6);
  margin-bottom: 28px;
  animation: breathe 2.2s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }
.load-track {
  height: 8px; border-radius: 4px; overflow: hidden;
  background: #1c1c30; border: 1px solid #3a3a55;
}
#loadBar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #8a6a1a, var(--gold), var(--gold-light));
  box-shadow: 0 0 12px rgba(216, 185, 58, 0.7);
  transition: width 0.3s ease;
}
#loadText { margin-top: 12px; font-size: 13px; color: var(--text-dim); letter-spacing: 2px; }

/* ============ 登入畫面 ============ */
#login {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(60, 50, 120, 0.35), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(140, 100, 30, 0.25), transparent 50%),
    radial-gradient(ellipse at center, #1d1d33 0%, #0a0a14 75%);
  overflow: hidden;
}
.bg-orb {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: 0.5; pointer-events: none;
}
.bg-orb.o1 { width: 300px; height: 300px; background: #4a3a8a; top: 10%; left: 12%; animation: drift 14s ease-in-out infinite; }
.bg-orb.o2 { width: 240px; height: 240px; background: #8a6a1a; bottom: 12%; right: 15%; animation: drift 18s ease-in-out infinite reverse; }
.bg-orb.o3 { width: 160px; height: 160px; background: #2a5a7a; top: 55%; left: 60%; animation: drift 11s ease-in-out infinite; }
@keyframes drift {
  0%,100% { transform: translate(0, 0); }
  50% { transform: translate(40px, -30px); }
}
.login-box {
  position: relative; z-index: 1;
  text-align: center; padding: 44px 52px;
  background: rgba(16, 16, 30, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 0 60px rgba(216, 185, 58, 0.18), 0 20px 60px rgba(0, 0, 0, 0.6);
}
.login-emblem {
  font-size: 44px; margin-bottom: 6px;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(216, 185, 58, 0.8);
  animation: spin 24s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-box h1 {
  font-size: 46px; letter-spacing: 16px; text-indent: 16px;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(216, 185, 58, 0.5);
}
.login-box .sub { color: var(--text-dim); letter-spacing: 6px; margin: 8px 0 26px; font-size: 14px; }
.login-box input {
  display: block; width: 280px; margin: 0 auto 18px;
  padding: 12px 14px; font-size: 17px; text-align: center;
  color: var(--text); background: #0c0c18;
  border: 1px solid #4a4a66; border-radius: 8px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box input:focus { border-color: var(--gold); box-shadow: 0 0 16px rgba(216, 185, 58, 0.25); }
.login-box button {
  padding: 12px 46px; font-size: 19px; letter-spacing: 6px;
  color: #181410; font-weight: bold;
  background: linear-gradient(180deg, var(--gold-light), #b89a20);
  border: none; border-radius: 8px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(216, 185, 58, 0.35);
  transition: transform 0.12s, filter 0.2s;
}
.login-box button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.login-box button:active { transform: translateY(1px); }
.hint-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px;
  margin-top: 26px; font-size: 12px; color: var(--text-dim);
  text-align: left;
}
.hint-grid b { color: #c8c4d8; font-weight: normal; background: #22223a; padding: 1px 7px; border-radius: 4px; margin-right: 5px; border: 1px solid #3a3a55; }
.login-box .version { margin-top: 20px; font-size: 11px; color: #5a5670; letter-spacing: 2px; }

/* ============ 遊戲主畫面 ============ */
#game { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#nameplates, #floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

/* 名牌 */
.nameplate {
  position: absolute; left: 0; top: 0;
  text-align: center; white-space: nowrap;
  transition: opacity 0.25s;
  will-change: transform;
}
.nameplate .pname {
  display: block; font-size: 12px; color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 6px rgba(0, 0, 0, 0.8);
}
.nameplate .pname.self { color: var(--gold-light); font-weight: bold; }
.nameplate .prealm {
  display: block; font-size: 10px; color: #b8e8c8;
  text-shadow: 0 1px 3px #000;
}
.nameplate .mname {
  display: block; font-size: 11px; color: #ffb0a0;
  text-shadow: 0 1px 3px #000;
}
.nameplate .mhp {
  width: 46px; height: 4px; margin: 2px auto 0;
  background: rgba(0, 0, 0, 0.65); border-radius: 2px; overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.8);
}
.nameplate .mhp div { height: 100%; width: 100%; background: linear-gradient(90deg, #e04040, #ff7050); }

/* 傷害數字 */
.floater {
  position: absolute; left: 0; top: 0;
  font-size: 17px; font-weight: bold; color: #ffd040;
  text-shadow: 0 2px 3px #000, 0 0 8px rgba(0, 0, 0, 0.6);
  will-change: transform, opacity; pointer-events: none;
}
.floater.dmg { color: #ffd040; }
.floater.hurt { color: #ff6060; }
.floater.self { color: #ff4040; font-size: 20px; }
.floater.heal { color: #60e080; }

/* ---- 左上 HUD ---- */
#hud {
  position: absolute; top: 14px; left: 14px;
  display: flex; gap: 10px; align-items: center;
  padding: 10px 14px 10px 10px; min-width: 280px;
}
#hudPortrait {
  width: 56px; height: 56px; image-rendering: pixelated;
  border-radius: 8px; border: 2px solid var(--panel-border);
  background: #1c1c30;
}
.hud-main { flex: 1; }
#hud .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
#hud .row.small { margin: 5px 0 0; justify-content: flex-start; gap: 8px; }
#hudName { font-weight: bold; font-size: 15px; }
#hudRealm { font-size: 13px; }
.chip {
  font-size: 11px; color: #c8c4d8;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 10px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.1);
}
.bar {
  position: relative; height: 15px; margin-bottom: 5px;
  background: #181826; border: 1px solid #33334d;
  border-radius: 8px; overflow: hidden;
}
.bar div { height: 100%; width: 0%; transition: width 0.15s; border-radius: 7px; }
.bar.hp div { background: linear-gradient(180deg, #e05555, #982525); box-shadow: 0 0 8px rgba(224, 85, 85, 0.5); }
.bar.lingqi div { background: linear-gradient(180deg, #55c8e8, #2070a8); box-shadow: 0 0 8px rgba(85, 200, 232, 0.5); }
.bar.exp div { background: linear-gradient(180deg, #d6b84e, #8c641d); box-shadow: 0 0 8px rgba(214, 184, 78, 0.5); }
.bar span {
  position: absolute; inset: 0;
  font-size: 10px; line-height: 15px; text-align: center;
  color: #fff; text-shadow: 0 1px 2px #000; letter-spacing: 1px;
}

/* ---- 頂列 ---- */
#topbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center;
}
#areaName {
  padding: 7px 26px; font-size: 16px; letter-spacing: 6px;
  color: var(--gold-light);
  border-radius: 20px;
}
#onlineBox { padding: 7px 16px; font-size: 12px; color: var(--text-dim); border-radius: 20px; }
#onlineBox b { color: #fff; }
#questPanel { position: absolute; top: 88px; left: 18px; width: 245px; padding: 0 0 12px; z-index: 12; }
#questContent { padding: 12px; font-size: 12px; line-height: 1.8; }
#questAcceptBtn { margin: 0 12px; width: calc(100% - 24px); }
.social-content { padding: 10px 12px; color: var(--text-dim); font-size: 11px; line-height: 1.7; max-height: 72px; overflow: auto; }
.boss-name { color: #ffcf58; text-shadow: 0 0 8px #f00, 0 0 14px #d88b22; font-size: 15px; }

/* ---- 右側欄 ---- */
#sidePanel {
  position: absolute; top: 14px; right: 14px;
  width: 216px;
  display: flex; flex-direction: column; gap: 10px;
}
.minimap-panel { overflow: hidden; }
#minimap {
  display: block; width: 100%; image-rendering: pixelated;
  border-radius: 0 0 9px 9px;
}
.inv-panel { max-height: 46vh; overflow-y: auto; }
#invGrid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 5px; padding: 9px;
}
#invGrid .slot {
  position: relative; aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #3a3a55; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
#invGrid .slot:hover { border-color: var(--gold); background: rgba(216, 185, 58, 0.1); }
#invGrid .slot.empty { cursor: default; border-style: dashed; opacity: 0.45; }
#invGrid .slot.empty:hover { border-color: #3a3a55; background: rgba(255, 255, 255, 0.05); }
#invGrid .slot img { width: 82%; height: 82%; image-rendering: pixelated; pointer-events: none; }
#invGrid .slot.equipped { border-color: var(--gold); box-shadow: 0 0 8px rgba(216, 185, 58, 0.4); }
#invGrid .eqBadge {
  position: absolute; right: 1px; bottom: 1px;
  font-size: 9px; padding: 0 3px;
  background: var(--gold); color: #181410;
  border-radius: 3px; font-weight: bold;
}

/* ---- 擊殺快訊 ---- */
#killfeed {
  position: absolute; top: 64px; right: 244px;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
  pointer-events: none;
}
#killfeed div {
  font-size: 12px; color: #e8d8b0;
  background: rgba(14, 14, 26, 0.75);
  border: 1px solid rgba(216, 185, 58, 0.2);
  padding: 4px 12px; border-radius: 14px;
  animation: slideIn 0.25s ease;
  transition: opacity 1s;
}
#killfeed div.fade { opacity: 0; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- 左下聊天 ---- */
#chatPanel {
  position: absolute; left: 14px; bottom: 76px;
  width: 400px; max-width: 40vw;
  overflow: hidden;
}
#chatLog {
  list-style: none; max-height: 190px; overflow-y: auto;
  padding: 8px 12px; font-size: 13px;
}
#chatLog li { margin-bottom: 3px; line-height: 1.45; word-break: break-all; text-shadow: 0 1px 2px #000; }
#chatLog li .name { color: #7ab8e8; }
#chatLog li.system { color: var(--gold); }
#chatLog li.event { color: #9ac89a; font-style: italic; }
#chatInput {
  width: 100%; padding: 8px 12px; font-size: 13px;
  color: var(--text); background: rgba(10, 10, 20, 0.92);
  border: none; border-top: 1px solid var(--panel-border);
  outline: none;
}

/* ---- 底部快捷列 ---- */
#hotbar {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
#hotbar button {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 18px; font-size: 14px; color: var(--text);
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.15s, transform 0.1s;
  font-family: inherit;
}
#hotbar button:hover { border-color: var(--gold); transform: translateY(-2px); }
#hotbar button:active { transform: translateY(0); }
#hotbar .ico { font-size: 16px; }
#hotbar kbd {
  font-size: 10px; color: var(--text-dim);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: inherit;
}

/* ---- 打坐提示 ---- */
#meditateTag {
  position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%);
  padding: 8px 24px;
  background: rgba(20, 60, 90, 0.8);
  border: 1px solid #50b8d8; border-radius: 22px;
  font-size: 13px; letter-spacing: 2px; color: #c8ecff;
  box-shadow: 0 0 24px rgba(80, 184, 216, 0.35);
  animation: pulse 1.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }

/* ---- 提示 Toast ---- */
#toasts {
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 32px; font-size: 16px; letter-spacing: 2px;
  background: rgba(14, 14, 26, 0.88);
  border: 1px solid var(--panel-border); border-radius: 24px;
  color: var(--text);
  opacity: 0; transform: translateY(-12px) scale(0.95);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.show { opacity: 1; transform: none; }
.toast.gold { color: var(--gold-light); border-color: var(--gold); box-shadow: 0 0 24px rgba(216, 185, 58, 0.3); }
.toast.bad { color: #ff8080; border-color: #a04040; }

/* ---- ESC 選單 ---- */
#escMenu {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 12, 0.6); backdrop-filter: blur(3px);
}
.menu-box { width: 380px; padding: 26px 30px; }
.menu-box h2 {
  text-align: center; color: var(--gold);
  letter-spacing: 10px; font-size: 24px; margin-bottom: 20px;
}
.menu-settings { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.menu-settings label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; color: #c8c4d8; gap: 14px;
}
.menu-settings input[type="range"] { flex: 1; accent-color: var(--gold); }
.menu-settings .chk { justify-content: flex-start; cursor: pointer; }
.menu-settings input[type="checkbox"] { accent-color: var(--gold); width: 16px; height: 16px; }
.menu-btns { display: flex; flex-direction: column; gap: 9px; }
.menu-btns button {
  padding: 11px; font-size: 15px; letter-spacing: 4px;
  color: var(--text); background: rgba(255, 255, 255, 0.06);
  border: 1px solid #4a4a66; border-radius: 8px; cursor: pointer;
  font-family: inherit; transition: border-color 0.15s, background 0.15s;
}
.menu-btns button:hover { border-color: var(--gold); background: rgba(216, 185, 58, 0.12); }
#helpPanel {
  margin-top: 16px; padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3); border-radius: 8px;
  font-size: 13px; line-height: 1.9; color: #c8c4d8;
}
#helpPanel b { color: var(--gold-light); font-weight: normal; }

/* ---- 斷線 ---- */
#disconnect {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; letter-spacing: 4px; color: #ff8080;
  background: rgba(0, 0, 0, 0.75);
}

/* 捲軸美化 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a3a55; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
