/* ============ 暗渊 · DARK DESCENT — 全局样式 ============ */
:root {
  --gold: #e8b93a;
  --gold-dim: #8a6d1f;
  --panel-bg: rgba(14, 11, 16, 0.94);
  --panel-border: #4a3a22;
  --text: #cfc6b8;
  --text-dim: #8f8578;
  --red: #c33b2c;
  --blue: #3d6fd8;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  user-select: none;
  -webkit-user-select: none;
}
#game-canvas {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  cursor: none;
  image-rendering: auto;
  touch-action: none;
}
#ui-root { position: absolute; inset: 0; pointer-events: none; }
#ui-root > * { pointer-events: auto; }

/* ============ 通用按钮 ============ */
.btn {
  display: inline-block;
  min-width: 220px;
  padding: 12px 26px;
  margin: 8px;
  background: linear-gradient(180deg, #2a2016, #191208);
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.8), 0 2px 10px rgba(0,0,0,.7);
  font-family: inherit;
  font-size: 17px;
  letter-spacing: 4px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  text-shadow: 0 1px 2px #000;
}
.btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #3d2e1a, #241a0c);
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px #000, 0 0 14px rgba(232,185,58,.35);
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-small { min-width: 120px; padding: 8px 16px; font-size: 14px; letter-spacing: 2px; }
.btn-danger { color: #e07a6a; border-color: #6a3a2a; }
.btn-danger:hover:not(:disabled) { border-color: #e07a6a; box-shadow: inset 0 0 0 1px #000, 0 0 14px rgba(224,122,106,.35); }

/* ============ 全屏画面（菜单/选职业/死亡/胜利等） ============ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(40,26,18,.88), rgba(6,4,8,.96));
  z-index: 100;
}
.screen.hidden { display: none; }
.screen-title {
  font-size: 64px;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(232,185,58,.4), 0 3px 6px #000;
  letter-spacing: 18px;
  margin-bottom: 6px;
}
.screen-sub {
  font-size: 18px;
  color: var(--text-dim);
  letter-spacing: 8px;
  margin-bottom: 34px;
}
.screen-footer {
  position: absolute;
  bottom: 14px;
  color: #5d5548;
  font-size: 12px;
  letter-spacing: 2px;
}
.screen-desc { color: var(--text); max-width: 560px; text-align: center; line-height: 1.7; font-size: 15px; margin: 18px 0; }

/* ============ 职业选择卡片 ============ */
.class-cards { display: flex; gap: 22px; margin: 20px 0 10px; flex-wrap: wrap; justify-content: center; }
.class-card {
  width: 250px;
  min-height: 310px;
  padding: 18px;
  background: linear-gradient(180deg, #1c1510, #0e0a08);
  border: 1px solid #3a2f1e;
  cursor: pointer;
  transition: all .18s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.class-card:hover, .class-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 22px rgba(232,185,58,.3);
  transform: translateY(-4px);
}
.class-icon { font-size: 58px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.8)); }
.class-name { font-size: 26px; letter-spacing: 6px; }
.class-en { font-size: 12px; color: var(--text-dim); letter-spacing: 3px; margin-top: -6px; }
.class-desc { font-size: 13px; color: var(--text); line-height: 1.6; flex: 1; }
.class-stats { font-size: 12px; color: var(--text-dim); line-height: 1.7; text-align: left; width: 100%; }
.class-stats b { color: var(--gold); font-weight: normal; }

/* ============ 面板（背包/角色/技能） ============ */
.panel {
  position: absolute;
  z-index: 50;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 0 0 1px #000, 0 0 26px rgba(0,0,0,.85);
  color: var(--text);
  padding: 14px;
  min-width: 320px;
}
.panel-title {
  font-size: 20px;
  letter-spacing: 6px;
  color: var(--gold);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-title .close { cursor: pointer; color: var(--text-dim); font-size: 16px; }
.panel-title .close:hover { color: var(--red); }
.panel.hidden { display: none; }

/* 装备栏（角色面板左侧） */
.equip-grid { display: grid; grid-template-columns: repeat(3, 52px); gap: 6px; margin: 6px auto; width: max-content; }
/* 背包格子 */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(10, 44px);
  gap: 3px;
  width: max-content;
  margin: 8px auto;
}
.slot {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(140,120,90,.35);
  box-shadow: inset 0 0 6px rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  position: relative;
  cursor: pointer;
}
.slot.equip-slot { width: 52px; height: 52px; font-size: 24px; background: rgba(232,185,58,.06); border-color: rgba(232,185,58,.35); }
.slot.empty-slot { color: #6a5f4e; font-size: 18px; }
.slot.dragging { opacity: .35; }
.slot:hover { border-color: var(--gold); box-shadow: inset 0 0 8px rgba(232,185,58,.15); }
.slot .lvl-badge {
  position: absolute; right: 2px; bottom: 1px;
  font-size: 10px; color: var(--text-dim);
}
.slot .rarity-bar { position:absolute; left:0; right:0; bottom:0; height:3px; }

/* 角色面板数据 */
.stat-list { list-style: none; font-size: 14px; line-height: 1.9; }
.stat-list li { display: flex; justify-content: space-between; }
.stat-list .k { color: var(--text-dim); }
.stat-list .v { color: var(--text); }
.stat-list .v.hot { color: var(--gold); }

/* 技能面板 */
.skill-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(140,120,90,.2);
  margin-bottom: 8px;
  background: rgba(0,0,0,.25);
}
.skill-ico { width: 48px; height: 48px; font-size: 26px; display:flex; align-items:center; justify-content:center; border:1px solid #3a2f1e; background: rgba(255,255,255,.05); flex: none; }
.skill-info { flex: 1; }
.skill-name { color: var(--gold); font-size: 16px; letter-spacing: 2px; }
.skill-lvl { color: var(--text-dim); font-size: 13px; }
.skill-desc { font-size: 12px; color: var(--text); margin-top: 3px; line-height: 1.5; }
.skill-btn {
  width: 46px; height: 34px;
  background: linear-gradient(180deg, #2a2016, #191208);
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  font-size: 18px;
  cursor: pointer;
}
.skill-btn:hover:not(:disabled) { border-color: var(--gold); }
.skill-btn:disabled { opacity: .3; cursor: default; }

/* ============ 提示框 ============ */
#tooltip {
  position: absolute;
  z-index: 200;
  max-width: 320px;
  background: rgba(10, 8, 12, 0.97);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 18px rgba(0,0,0,.9);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  pointer-events: none;
  display: none;
}
#tooltip.show { display: block; }
.tt-name { font-size: 16px; letter-spacing: 1px; margin-bottom: 4px; }
.tt-type { color: var(--text-dim); font-size: 12px; margin-bottom: 6px; }
.tt-stat { color: #b8d4e8; font-size: 12px; }
.tt-affix { color: #9fd4e0; }
.tt-socket { color: #7ad67a; }
.tt-flavor { color: #8f8578; font-style: italic; font-size: 12px; margin-top: 6px; }

/* ============ 提示消息 ============ */
#toasts {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: rgba(12, 9, 14, .92);
  border: 1px solid var(--panel-border);
  padding: 8px 18px;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text);
  animation: toastIn .25s ease-out;
  white-space: nowrap;
}
.toast.gold-text { color: var(--gold); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 操作说明 ============ */
.help-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 22px;
  font-size: 14px;
  color: var(--text);
  margin: 10px 0;
}
.help-grid .key { color: var(--gold); text-align: right; }
.help-grid .act { color: var(--text-dim); }

/* ============ 死亡 / 胜利 ============ */
.death-title { font-size: 72px; color: var(--red); text-shadow: 0 0 40px rgba(195,59,44,.5); letter-spacing: 16px; }
.victory-title { font-size: 60px; color: var(--gold); text-shadow: 0 0 40px rgba(232,185,58,.6); letter-spacing: 12px; }
.victory-stats { font-size: 15px; color: var(--text); line-height: 2; text-align: center; }
.victory-stats b { color: var(--gold); font-weight: normal; }

/* ============ 暂停 ============ */
.pause-overlay { background: rgba(0,0,0,.72); }

/* ============ 触屏控制（手机端） ============ */
#touch-ui {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  display: none;
  -webkit-tap-highlight-color: transparent;
}
#touch-ui.active { display: block; }
#joy-zone {
  position: absolute;
  left: 0; bottom: 0;
  width: 50%; height: 62%;
  pointer-events: auto;
  touch-action: none;
}
.joy-base {
  position: absolute;
  width: 116px; height: 116px;
  border-radius: 50%;
  border: 2px solid rgba(232,185,58,0.5);
  background: rgba(0,0,0,0.28);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.joy-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,220,150,0.95), rgba(232,185,58,0.75));
  box-shadow: 0 0 12px rgba(232,185,58,0.5);
}
.tbtn {
  position: absolute;
  width: 66px; height: 66px;
  border-radius: 50%;
  background: rgba(10,8,12,0.55);
  border: 1.5px solid rgba(232,185,58,0.45);
  color: #e8b93a;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tbtn:active { background: rgba(232,185,58,0.35); }
.tbtn .lbl {
  position: absolute;
  bottom: -18px;
  left: 0; width: 100%;
  font-size: 11px;
  color: #cfc6b8;
  text-align: center;
  letter-spacing: 1px;
  white-space: nowrap;
}
#btn-attack { right: 20px; bottom: 96px; width: 86px; height: 86px; font-size: 36px; }
#btn-skill2 { right: 108px; bottom: 200px; width: 60px; height: 60px; font-size: 26px; }
#btn-skill3 { right: 38px; bottom: 216px; width: 60px; height: 60px; font-size: 26px; }
#btn-skill4 { right: 108px; bottom: 128px; width: 60px; height: 60px; font-size: 26px; }
#btn-potion { right: 196px; bottom: 226px; width: 54px; height: 54px; font-size: 22px; }
#btn-dodge  { right: 196px; bottom: 158px; width: 54px; height: 54px; font-size: 22px; }

/* ============ 手机端面板适配 ============ */
@media (max-width: 900px) {
  .panel {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-width: 96vw;
    max-height: 88vh;
    overflow-y: auto;
  }
  #panel-character {
    top: auto !important;
    bottom: 10px !important;
    transform: translateX(-50%) !important;
    max-height: 42vh;
    min-width: 0;
  }
  .inv-grid { grid-template-columns: repeat(10, 30px); gap: 2px; }
  .slot { width: 30px; height: 30px; font-size: 15px; }
  .slot.equip-slot { width: 40px; height: 40px; font-size: 18px; }
  .screen-title { font-size: 40px; letter-spacing: 8px; }
  .class-cards { flex-direction: column; align-items: center; }
  .class-card { width: 260px; min-height: 0; }
  #tooltip { max-width: 220px; font-size: 12px; }
  .help-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  #btn-attack { right: 12px; bottom: 70px; }
  #btn-skill2 { right: 92px; bottom: 180px; }
  #btn-skill3 { right: 30px; bottom: 196px; }
  #btn-skill4 { right: 92px; bottom: 108px; }
  #btn-potion { right: 172px; bottom: 206px; }
  #btn-dodge  { right: 172px; bottom: 138px; }
  .class-card { width: 240px; }
}

/* ============ 触控体验 ============ */
html, body { overscroll-behavior: none; }
.tbtn, #joy-zone, .slot, .btn, .class-card { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
