:root {
  --bg-deep: #0b0907;
  --panel-bg: rgba(18, 14, 11, 0.92);
  --panel-border: #8b6a35;
  --gold: #f4c86a;
  --gold-dim: #b58d46;
  --crimson: #d93829;
  --sapphire: #2678d9;
  --jade: #38c96b;
  --text: #f3ead8;
  --muted: #a6987e;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg-deep); color: var(--text); font-family: "Microsoft YaHei", "PingFang SC", sans-serif; }
.hidden { display: none !important; }

/* 登录与建角 */
.overlay-screen { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 35%, #2b180e 0%, #0b0907 75%); }
.auth-card { position: relative; width: min(440px, 92vw); padding: 28px 26px; background: linear-gradient(180deg, rgba(28, 21, 16, 0.96), rgba(14, 11, 9, 0.98)); border: 1.5px solid var(--panel-border); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.85), inset 0 0 24px rgba(244, 200, 106, 0.08); }
.game-logo { text-align: center; margin-bottom: 20px; }
.game-logo .logo-sub { font-size: 12px; letter-spacing: 3px; color: var(--gold-dim); margin-bottom: 6px; }
.game-logo h1 { font-size: 34px; letter-spacing: 6px; background: linear-gradient(180deg, #fff3c4 0%, #f4b740 55%, #b85c14 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 2px 18px rgba(244, 140, 40, 0.35); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.tab-btn { padding: 9px; background: rgba(255,255,255,0.04); border: 1px solid #4a3922; color: var(--muted); border-radius: 6px; cursor: pointer; font-size: 14px; }
.tab-btn.active { background: linear-gradient(180deg, #4b3416, #2c1e0c); border-color: var(--gold); color: var(--gold); font-weight: 700; }
.field { margin-bottom: 12px; }
.field input { width: 100%; padding: 11px 13px; background: #100c09; border: 1px solid #524028; border-radius: 6px; color: var(--text); font-size: 14px; outline: none; user-select: text; }
.field input:focus { border-color: var(--gold); }
.err-msg { min-height: 20px; color: #ff6b57; font-size: 13px; margin-bottom: 8px; text-align: center; }
.btn-gold { padding: 10px 16px; background: linear-gradient(180deg, #e7b551, #9e6618); border: 1px solid #ffe09c; color: #1b0f03; font-weight: 800; font-size: 14px; border-radius: 6px; cursor: pointer; letter-spacing: 1px; transition: filter 0.15s; }
.btn-gold:hover { filter: brightness(1.12); }
.btn-gold:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-gold.full { width: 100%; padding: 12px; font-size: 15px; }
.btn-dark { padding: 7px 12px; background: #261e16; border: 1px solid #6b522c; color: var(--text); border-radius: 5px; cursor: pointer; font-size: 13px; }
.btn-dark:hover { border-color: var(--gold); color: var(--gold); }

.section-title { text-align: center; color: var(--gold); font-size: 14px; margin-bottom: 12px; letter-spacing: 2px; }
.job-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.job-card { padding: 10px 6px; text-align: center; background: #140f0b; border: 1px solid #46351f; border-radius: 8px; cursor: pointer; transition: all 0.15s; }
.job-card.active { border-color: var(--gold); background: linear-gradient(180deg, #3a2610, #1c130a); box-shadow: 0 0 14px rgba(244, 200, 106, 0.25); }
.job-card img { width: 44px; height: 44px; border-radius: 6px; border: 1px solid #806131; margin-bottom: 6px; }
.job-name { font-weight: 700; color: var(--gold); font-size: 14px; }
.job-tag { font-size: 11px; color: var(--muted); margin-top: 3px; }
.gender-row { display: flex; justify-content: center; gap: 10px; margin-bottom: 12px; }
.pill-btn { padding: 6px 20px; background: #16110c; border: 1px solid #4d3b22; color: var(--muted); border-radius: 20px; cursor: pointer; font-size: 13px; }
.pill-btn.active { border-color: var(--gold); color: var(--gold); background: #33220f; }

/* 游戏舞台与 HUD */
#game-shell { position: relative; width: 100%; height: 100%; overflow: hidden; }
#game-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

.hud-box { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.65); }

#hud-top-left { position: fixed; top: 10px; left: 10px; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.avatar-wrap { position: relative; width: 48px; height: 48px; flex-shrink: 0; }
.avatar-wrap img { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--gold); object-fit: cover; background: #1a130d; }
.lv-badge { position: absolute; bottom: -4px; right: -4px; background: linear-gradient(180deg, #e7b551, #8a5612); color: #1a0e02; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 10px; border: 1px solid #ffe4a8; }
.char-row { display: flex; align-items: center; gap: 6px; }
.char-name { font-weight: 700; font-size: 14px; color: #fff; }
.realm-badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(217, 56, 41, 0.25); border: 1px solid #d96429; color: #ffb47a; }
.power-row { display: flex; align-items: baseline; gap: 5px; margin-top: 2px; }
.power-label { font-size: 11px; color: var(--gold-dim); }
.power-num { font-size: 16px; font-weight: 800; color: var(--gold); text-shadow: 0 0 8px rgba(244, 180, 60, 0.45); }
.currency-row { display: flex; gap: 10px; margin-top: 3px; font-size: 12px; color: #e2d5bc; }
.cur b { color: var(--gold); font-weight: 600; }

#target-hud { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 20; width: min(290px, 50vw); padding: 7px 12px; }
.target-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; font-weight: 700; color: #ffcf8c; }
.bar-track { position: relative; height: 16px; background: #1c1410; border: 1px solid #594426; border-radius: 8px; overflow: hidden; }
.bar-fill.hp { height: 100%; background: linear-gradient(90deg, #9e1b14, #e53d2e); transition: width 0.12s; }
.bar-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }

#hud-top-right { position: fixed; top: 10px; right: 10px; z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.map-pill { padding: 6px 12px; cursor: pointer; text-align: right; }
.map-pill:hover { border-color: var(--gold); }
.map-title { font-size: 13px; font-weight: 700; color: var(--gold); }
.map-coords { font-size: 11px; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(4, 48px); gap: 6px; }
.qbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 48px; background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 16px; transition: all 0.12s; }
.qbtn span { font-size: 10px; color: var(--gold); }
.qbtn:hover { border-color: var(--gold); transform: translateY(-1px); }
.qbtn.gm { border-color: #a944ff; }
.qbtn.gm span { color: #d8a6ff; }

#chat-log { position: fixed; left: 10px; bottom: 102px; z-index: 15; width: min(320px, 46vw); max-height: 115px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; pointer-events: none; }
.log-line { font-size: 12px; line-height: 1.35; padding: 2px 7px; background: rgba(10, 8, 6, 0.58); border-radius: 4px; color: #e8dcc6; text-shadow: 0 1px 2px #000; }
.log-line.loot { color: #ffb84d; }
.log-line.boss { color: #ff6b6b; font-weight: 700; }
.log-line.sys { color: #7cd6ff; }

#banner-toast { position: fixed; top: 82px; left: 50%; transform: translateX(-50%); z-index: 40; padding: 8px 26px; background: linear-gradient(90deg, transparent, rgba(160, 42, 16, 0.92) 20%, rgba(160, 42, 16, 0.92) 80%, transparent); border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); color: #fff1b8; font-size: 16px; font-weight: 800; letter-spacing: 2px; text-shadow: 0 2px 6px #000; pointer-events: none; white-space: nowrap; }

/* 底部操作栏 */
#hud-bottom { position: fixed; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 25; display: flex; align-items: flex-end; gap: 10px; padding: 8px 12px; background: linear-gradient(180deg, rgba(24, 18, 13, 0.94), rgba(12, 9, 7, 0.96)); border: 1.5px solid var(--panel-border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); max-width: 98vw; }
.orb-group { display: flex; gap: 6px; flex-shrink: 0; }
.orb { position: relative; width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--panel-border); background: #140f0c; overflow: hidden; cursor: pointer; }
.orb-fill { position: absolute; bottom: 0; left: 0; right: 0; height: 100%; transition: height 0.15s; }
.hp-orb .orb-fill { background: linear-gradient(180deg, #e03728, #780f0a); }
.mp-orb .orb-fill { background: linear-gradient(180deg, #2d86eb, #103a7a); }
.orb-txt { position: relative; z-index: 2; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; text-shadow: 0 1px 3px #000; }
.orb-txt b { font-size: 11px; }
.orb-txt span { font-size: 9px; opacity: 0.85; }

.center-bar { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.exp-track { position: relative; height: 12px; background: #18120c; border: 1px solid #594527; border-radius: 6px; overflow: hidden; }
.exp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #288a45, #6bf08c); transition: width 0.2s; }
#exp-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; text-shadow: 0 1px 2px #000; }

.skill-strip { display: flex; align-items: center; gap: 6px; overflow-x: auto; }
.skill-group { display: flex; gap: 5px; }
.skill-divider { width: 1px; height: 42px; background: #5a4324; flex-shrink: 0; }
.skill-slot { position: relative; width: 46px; height: 46px; border-radius: 6px; border: 1.5px solid #7d5f32; background: #16100b; overflow: hidden; cursor: pointer; flex-shrink: 0; }
.skill-slot.xfire { border-color: #e65c19; }
.skill-slot.locked { opacity: 0.35; filter: grayscale(1); }
.skill-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.skill-key { position: absolute; top: 1px; left: 3px; font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.skill-cd { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: var(--gold); }

.action-group { display: flex; gap: 5px; flex-shrink: 0; }
.act-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 46px; height: 46px; background: #1e1610; border: 1px solid var(--panel-border); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 15px; }
.act-btn span { font-size: 10px; color: var(--gold); margin-top: 1px; }
.act-btn.active { background: linear-gradient(180deg, #633c0f, #381f06); border-color: #ffd97d; box-shadow: 0 0 10px rgba(255, 195, 70, 0.45); }

/* 弹窗 */
#modal-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.65); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal-box { width: min(760px, 96vw); max-height: 86vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #1b140f, #110d0a); border: 1.5px solid var(--panel-border); border-radius: 10px; box-shadow: 0 24px 60px rgba(0,0,0,0.9); overflow: hidden; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: linear-gradient(90deg, #2d1e10, #1b130c); border-bottom: 1px solid #594323; }
.modal-header h2 { font-size: 16px; color: var(--gold); letter-spacing: 2px; }
.modal-close { width: 28px; height: 28px; border-radius: 50%; border: 1px solid #6b522c; background: #221810; color: var(--gold); cursor: pointer; font-size: 14px; }
.modal-body { padding: 14px 16px; overflow-y: auto; flex: 1; }

/* 弹窗内部组件 */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: rgba(255, 255, 255, 0.03); border: 1px solid #49371f; border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.card.active-card { border-color: var(--gold); background: rgba(244, 200, 106, 0.08); }
.card-row { display: flex; align-items: center; gap: 10px; }
.card-icon { width: 42px; height: 42px; border-radius: 6px; border: 1px solid #75582e; object-fit: cover; flex-shrink: 0; background: #140f0b; }
.card-title { font-size: 14px; font-weight: 700; color: var(--gold); }
.card-sub { font-size: 12px; color: var(--muted); line-height: 1.4; }
.stat-tags { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.stat-tag { padding: 2px 7px; border-radius: 4px; background: rgba(255,255,255,0.06); color: #e5d8bf; }
.sub-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.equip-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.equip-slot { padding: 8px 6px; background: #15100b; border: 1px solid #4d3a20; border-radius: 6px; text-align: center; cursor: pointer; min-height: 82px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.equip-slot img { width: 34px; height: 34px; border-radius: 4px; }
.equip-slot .es-label { font-size: 10px; color: var(--muted); }
.equip-slot .es-name { font-size: 11px; font-weight: 700; word-break: break-all; }

.q-c1 { color: #e6e6e6; }
.q-c2 { color: #4ce87d; }
.q-c3 { color: #4aa8ff; }
.q-c4 { color: #c86bff; }
.q-c5 { color: #ffa63d; }
.q-c6, .q-c9 { color: #ff5454; }

.bag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.bag-item { padding: 8px; background: #140f0b; border: 1px solid #47361e; border-radius: 6px; display: flex; flex-direction: column; gap: 5px; }
.bag-item .bi-top { display: flex; align-items: center; gap: 7px; }
.bag-item img { width: 34px; height: 34px; border-radius: 4px; border: 1px solid #6b522c; flex-shrink: 0; }
.bag-item .bi-btns { display: flex; gap: 5px; margin-top: auto; }
.bag-item button { flex: 1; padding: 4px 6px; font-size: 11px; }

.rank-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rank-table th, .rank-table td { padding: 8px 10px; border-bottom: 1px solid #382a17; text-align: left; }
.rank-table th { color: var(--gold); }

@media (max-width: 780px) {
  #hud-top-left { padding: 6px 8px; gap: 6px; }
  .avatar-wrap, .avatar-wrap img { width: 38px; height: 38px; }
  .currency-row { font-size: 11px; gap: 6px; }
  .quick-grid { grid-template-columns: repeat(4, 42px); gap: 4px; }
  .qbtn { height: 42px; font-size: 14px; }
  #hud-bottom { bottom: 4px; padding: 6px 8px; gap: 6px; flex-wrap: wrap; justify-content: center; }
  .orb { width: 44px; height: 44px; }
  .skill-slot, .act-btn { width: 40px; height: 40px; }
  .equip-grid { grid-template-columns: repeat(2, 1fr); }
  #chat-log { display: none; }
}
