/* 暗黑像素 ARPG - 像素暗黑风样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0e14;
  color: #ccc;
  font-family: "Courier New", monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

#wrap {
  position: relative;
  width: 960px;
  height: 540px;
  border: 2px solid #2a3;
  box-shadow: 0 0 30px rgba(0,0,0,0.8);
  image-rendering: pixelated;
}

canvas#game {
  width: 100%;
  height: 100%;
  display: block;
  background: #0d1117;
  cursor: crosshair;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 13px;
  color: #ddd;
  text-shadow: 1px 1px 2px #000;
  z-index: 10;
}

#hud .hud-left span { margin-right: 16px; }
#hud-level { color: #ffd700; font-weight: bold; }
#hud-hp { color: #f88; }
#hud-exp { color: #8cf; }
#hud-atk { color: #ffb74d; }

/* HUD 顶部按钮 */
.hud-btn {
  background: rgba(20,30,45,0.75);
  border: 1px solid #3a5a7a;
  color: #ffd700;
  font-family: "Courier New", monospace;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 8px;
  pointer-events: auto;
}
.hud-btn:hover { background: rgba(40,60,85,0.85); }

/* ---------- 面板 ---------- */
.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 720px;
  max-width: 92%;
  background: rgba(10, 14, 20, 0.95);
  border: 2px solid #3a4a5a;
  border-radius: 6px;
  z-index: 20;
  box-shadow: 0 0 30px rgba(0,0,0,0.9);
  color: #ccc;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #2a3a4a;
  font-weight: bold;
  color: #ffd700;
  font-size: 15px;
}

.close-btn {
  background: #1a2a3a;
  border: 1px solid #3a5a7a;
  color: #fff;
  font-size: 16px;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}
.close-btn:hover { background: #2a3a4a; }

.panel-body {
  display: flex;
  gap: 16px;
  padding: 14px;
  max-height: 70vh;
  overflow-y: auto;
}

.eq-area, .inv-area { flex: 1; }
.eq-area h3, .inv-area h3 {
  font-size: 13px;
  color: #8cf;
  margin-bottom: 8px;
  border-bottom: 1px dashed #2a3a4a;
  padding-bottom: 4px;
}

/* 装备格 */
.eq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.eq-slot {
  background: #10161f;
  border: 1px solid #3a4a5a;
  border-radius: 4px;
  padding: 8px;
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.eq-slot:hover { background: #182230; }
.eq-slot .eq-icon { font-size: 22px; }
.eq-slot .eq-icon.dim { opacity: 0.3; }
.eq-slot .eq-name { font-size: 12px; color: #ddd; word-break: break-all; }

/* 背包格 */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

/* 背包工具栏（排序/筛选/批量分解） */
.inv-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  align-items: center;
}
.inv-tool-label {
  font-size: 11px;
  color: #888;
}
.inv-sort-btn {
  padding: 2px 8px;
  background: #0a0f18;
  border: 1px solid #2a3a4a;
  color: #888;
  font-family: "Courier New", monospace;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
}
.inv-sort-btn:hover { background: #16202e; color: #ddd; }
.inv-sort-btn.active { border-color: #ffd700; color: #ffd700; }
.batch-dismantle-btn {
  padding: 2px 8px;
  background: #0a1a0a;
  border: 1px solid #4caf50;
  color: #4caf50;
  font-family: "Courier New", monospace;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
}
.batch-dismantle-btn:hover { background: #162016; }

.inv-slot {
  border: 1px solid #3a4a5a;
  border-radius: 4px;
  padding: 6px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  background: #0a0f18;
  font-size: 11px;
  text-align: center;
}
.inv-slot:hover { background: #16202e; }
.inv-slot.selected { box-shadow: 0 0 0 2px #ffd700; }
.inv-slot .eq-icon { font-size: 18px; }
.inv-slot .eq-name { color: #ccc; word-break: break-all; }
.inv-slot .eq-lv { color: #888; }

/* 装备详情（选中后显示，含强化按钮） */
.eq-detail {
  margin-top: 10px;
  padding: 8px;
  background: #0a0f18;
  border: 1px solid #2a3a4a;
  border-radius: 4px;
  font-size: 12px;
  color: #bbb;
  min-height: 40px;
  max-height: 180px;
  overflow-y: auto;
}
.eq-detail .detail-title { color: #ffd700; font-weight: bold; margin-bottom: 4px; }
.eq-detail .up-btn {
  margin-top: 8px;
  padding: 5px 12px;
  background: #1a2a3a;
  border: 1px solid #ffd700;
  color: #ffd700;
  font-family: "Courier New", monospace;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}
.eq-detail .up-btn:hover { background: #2a3a4a; }
.eq-detail .up-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: #555; color: #888; }
.eq-detail .up-cost { color: #ffb74d; }

/* 角色属性面板 */
.stat-body { padding: 14px; max-height: 70vh; overflow-y: auto; }
.stat-info { font-size: 14px; line-height: 1.8; color: #ddd; }
.stat-info .sp { color: #ffd700; font-weight: bold; }
.stat-btns { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.stat-btn {
  padding: 8px 14px;
  background: #1a2a3a;
  border: 1px solid #3a5a7a;
  color: #8cf;
  font-family: "Courier New", monospace;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  flex: 1 1 40%;
  min-width: 120px;
}
.stat-btn:hover:not(:disabled) { background: #2a3a4a; }
.stat-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stat-btn .plus { color: #ffd700; }

/* 商店面板 */
.shop-body { padding: 14px; max-height: 70vh; overflow-y: auto; }
.shop-gold { font-size: 15px; color: #ffd700; margin-bottom: 12px; }
.shop-goods { display: flex; flex-direction: column; gap: 10px; }
.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0a0f18;
  border: 1px solid #2a3a4a;
  border-radius: 4px;
  padding: 10px 12px;
}
.shop-item .shop-name { color: #fff; font-size: 14px; }
.shop-item .shop-desc { color: #888; font-size: 11px; margin-top: 2px; }
.shop-btn {
  padding: 6px 16px;
  background: #1a2a3a;
  border: 1px solid #4caf50;
  color: #4caf50;
  font-family: "Courier New", monospace;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}
.shop-btn:hover:not(:disabled) { background: #243a2e; }
.shop-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: #555; color: #888; }

/* 排行榜 */
.rank-list { padding: 10px 14px; max-height: 60vh; overflow-y: auto; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px dashed #1a2a3a;
  font-size: 14px;
}
.rank-no { width: 26px; color: #888; }
.rank-row:first-child .rank-no { color: #ffd700; }
.rank-name { flex: 1; color: #fff; }
.rank-info { color: #8cf; font-size: 12px; }
.rank-empty { padding: 20px; text-align: center; color: #666; }

/* ---------- 命名弹窗 ---------- */
#name-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 12, 0.85);
  z-index: 30;
}

.name-box {
  background: rgba(10, 14, 20, 0.96);
  border: 2px solid #3a4a5a;
  border-radius: 6px;
  padding: 26px 36px;
  text-align: center;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
}

.name-box h2 {
  color: #ffd700;
  font-size: 18px;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

#name-input {
  width: 220px;
  padding: 8px 10px;
  background: #0a0f18;
  border: 1px solid #3a5a7a;
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 16px;
  text-align: center;
  border-radius: 4px;
  outline: none;
}
#name-input:focus { border-color: #ffd700; }

#name-start {
  display: block;
  margin: 16px auto 0;
  padding: 8px 28px;
  background: #1a2a3a;
  border: 1px solid #3a5a7a;
  color: #ffd700;
  font-family: "Courier New", monospace;
  font-size: 15px;
  border-radius: 4px;
  cursor: pointer;
}
#name-start:hover { background: #2a3a4a; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #2a3a4a; border-radius: 4px; }
::-webkit-scrollbar-track { background: #0a0f18; }

/* ============================================================
   祝福选择弹窗
   ============================================================ */
.boon-box {
  background: rgba(10, 14, 20, 0.96);
  border: 2px solid #ffd700;
  border-radius: 8px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.15);
}
.boon-box h2 {
  color: #ffd700;
  font-size: 20px;
  margin-bottom: 18px;
  letter-spacing: 2px;
}
.boon-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.boon-card {
  background: #0a0f18;
  border: 2px solid #3a4a5a;
  border-radius: 6px;
  padding: 18px 16px;
  width: 160px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}
.boon-card:hover {
  transform: translateY(-4px);
  border-color: #ffd700;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.2);
}
.boon-card.boon-common { border-color: #4caf50; }
.boon-card.boon-rare   { border-color: #2196f3; }
.boon-card.boon-epic   { border-color: #9c27b0; }
.boon-card.boon-common:hover { border-color: #66bb6a; box-shadow: 0 4px 20px rgba(76, 175, 80, 0.25); }
.boon-card.boon-rare:hover   { border-color: #42a5f5; box-shadow: 0 4px 20px rgba(33, 150, 243, 0.25); }
.boon-card.boon-epic:hover   { border-color: #ab47bc; box-shadow: 0 4px 20px rgba(156, 39, 176, 0.25); }

.boon-icon { font-size: 32px; margin-bottom: 8px; }
.boon-name { font-size: 15px; font-weight: bold; color: #fff; margin-bottom: 6px; }
.boon-desc { font-size: 12px; color: #aaa; line-height: 1.5; margin-bottom: 8px; }
.boon-rarity { font-size: 11px; color: #666; text-transform: uppercase; }

/* ============================================================
   事件房弹窗
   ============================================================ */
.event-box {
  background: rgba(10, 14, 20, 0.96);
  border: 2px solid #4fc3f7;
  border-radius: 8px;
  padding: 28px 36px;
  text-align: center;
  box-shadow: 0 0 40px rgba(79, 195, 247, 0.15);
  max-width: 420px;
}
.event-icon { font-size: 48px; margin-bottom: 10px; }
.event-name { font-size: 20px; font-weight: bold; color: #4fc3f7; margin-bottom: 8px; }
.event-desc { font-size: 14px; color: #aaa; margin-bottom: 16px; }
.event-result { font-size: 15px; color: #ffd700; margin-bottom: 18px; line-height: 1.6; }
.event-btn {
  display: block;
  margin: 0 auto;
  padding: 10px 32px;
  background: #1a2a3a;
  border: 1px solid #4fc3f7;
  color: #4fc3f7;
  font-family: "Courier New", monospace;
  font-size: 15px;
  border-radius: 4px;
  cursor: pointer;
}
.event-btn:hover { background: #1a3040; }

/* ============================================================
   触屏操控（手机端）
   ============================================================ */
#touch-controls {
  display: none;  /* 默认隐藏，移动端显示 */
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

#joy-zone {
  position: absolute;
  left: 0; bottom: 0;
  width: 46%; height: 55%;
  pointer-events: auto;
  touch-action: none;
}

#joy-base {
  position: absolute;
  left: 34px; bottom: 34px;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 16px rgba(0,0,0,0.5);
}

#joy-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 52px; height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  border: 2px solid rgba(255,255,255,0.6);
}

#btn-zone {
  position: absolute;
  right: 14px; bottom: 20px;
  width: 170px; height: 200px;
  pointer-events: auto;
}

.tbtn {
  position: absolute;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  color: #fff;
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  background: rgba(20,30,45,0.55);
  box-shadow: 0 0 12px rgba(0,0,0,0.5);
  cursor: pointer;
}
.tbtn:active { transform: scale(0.92); background: rgba(255,215,0,0.3); }

/* 技能按钮（右排） */
.tbtn-skill { border-color: rgba(79,195,247,0.7); color: #4fc3f7; }
#btn-slash  { right: 0;   bottom: 0; }
#btn-whirl  { right: 62px; bottom: 8px; }
#btn-dash   { right: 16px; bottom: 92px; }

/* 药水按钮（左侧竖排） */
.tbtn-potion { width: 44px; height: 44px; font-size: 13px; border-color: rgba(255,140,0,0.7); color: #ffb74d; }
#btn-hp     { right: 148px; bottom: 28px; }
#btn-mp     { right: 148px; bottom: 84px; }

/* 攻击按钮（大） */
.tbtn-attack {
  width: 74px; height: 74px;
  right: 92px; bottom: 0;
  background: rgba(244,67,54,0.35);
  border-color: rgba(255,120,100,0.85);
  color: #ff8a80;
  font-size: 18px;
}

/* 手机端布局：画布铺满全屏 */
@media (max-width: 820px), (pointer: coarse) {
  body { overflow: hidden; }
  #wrap {
    width: 100vw;
    height: 100vh;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }
  canvas#game { width: 100%; height: 100%; }
  #touch-controls { display: block; }
  #hud { font-size: 12px; }
  .panel { width: 92vw; max-width: 400px; }
  .panel-body { flex-direction: column; }
  .stat-btn { min-width: 90px; }
}

/* ============================================================
   装备品质光晕动画（史诗/传说/神话）
   ============================================================ */
@keyframes glow-epic {
  0%, 100% { box-shadow: 0 0 4px rgba(156, 39, 176, 0.4); }
  50%      { box-shadow: 0 0 12px rgba(156, 39, 176, 0.7); }
}
@keyframes glow-legendary {
  0%, 100% { box-shadow: 0 0 4px rgba(255, 152, 0, 0.5); }
  50%      { box-shadow: 0 0 16px rgba(255, 152, 0, 0.8); }
}
@keyframes glow-mythic {
  0%, 100% { box-shadow: 0 0 6px rgba(233, 30, 99, 0.6); }
  50%      { box-shadow: 0 0 20px rgba(233, 30, 99, 0.9); }
}
@keyframes glow-rare {
  0%, 100% { box-shadow: 0 0 2px rgba(33, 150, 243, 0.3); }
  50%      { box-shadow: 0 0 8px rgba(33, 150, 243, 0.5); }
}

/* 装备栏格品质光效 */
.eq-slot.q-rare      { animation: glow-rare 3s ease-in-out infinite; }
.eq-slot.q-epic      { animation: glow-epic 2.5s ease-in-out infinite; }
.eq-slot.q-legendary { animation: glow-legendary 2s ease-in-out infinite; }
.eq-slot.q-mythic    { animation: glow-mythic 1.5s ease-in-out infinite; }

/* 背包格品质光效 */
.inv-slot.q-rare      { animation: glow-rare 3s ease-in-out infinite; }
.inv-slot.q-epic      { animation: glow-epic 2.5s ease-in-out infinite; }
.inv-slot.q-legendary { animation: glow-legendary 2s ease-in-out infinite; }
.inv-slot.q-mythic    { animation: glow-mythic 1.5s ease-in-out infinite; }

/* 神话品质额外边框加强 */
.eq-slot.q-mythic, .inv-slot.q-mythic {
  border-width: 2px;
}
.eq-slot.q-legendary, .inv-slot.q-legendary {
  border-width: 2px;
}

/* ============================================================
   天赋树面板
   ============================================================ */
.talent-body { padding: 14px; max-height: 70vh; overflow-y: auto; }

.talent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.talent-card {
  background: #0a0f18;
  border: 1px solid #2a3a4a;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  transition: all 0.15s;
}
.talent-card:hover { border-color: #3a5a7a; background: #121a28; }
.talent-card.maxed { border-color: #ffd700; }
.talent-card.locked { opacity: 0.5; }

.talent-icon { font-size: 28px; margin-bottom: 6px; }
.talent-name { font-size: 14px; font-weight: bold; color: #ffd700; margin-bottom: 4px; }
.talent-desc { font-size: 11px; color: #888; line-height: 1.4; margin-bottom: 6px; }
.talent-rank { font-size: 12px; color: #4fc3f7; margin-bottom: 4px; letter-spacing: 1px; }
.talent-cost { font-size: 11px; color: #ffb74d; margin-bottom: 8px; }

.talent-btn {
  padding: 5px 16px;
  background: #1a2a3a;
  border: 1px solid #ffd700;
  color: #ffd700;
  font-family: "Courier New", monospace;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}
.talent-btn:hover:not(:disabled) { background: #2a3a4a; }
.talent-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: #555; color: #666; }

/* ============================================================
   成就面板
   ============================================================ */
.ach-body { padding: 14px; max-height: 70vh; overflow-y: auto; }

.ach-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0a0f18;
  border: 1px solid #2a3a4a;
  border-radius: 6px;
  padding: 10px 14px;
  transition: all 0.15s;
}
.ach-card.unlocked { border-color: #4caf50; background: #0a1a0a; }
.ach-card.locked { opacity: 0.6; }

.ach-icon { font-size: 28px; }
.ach-info { flex: 1; }
.ach-name { font-size: 14px; font-weight: bold; color: #ddd; }
.ach-desc { font-size: 11px; color: #888; margin-top: 2px; }
.ach-reward { font-size: 11px; color: #ffd700; margin-top: 2px; }
.ach-status { font-size: 13px; color: #666; white-space: nowrap; }
.ach-card.unlocked .ach-status { color: #4caf50; }

/* ============================================================
   BGM 按钮
   ============================================================ */
#btn-bgm { color: #4fc3f7; border-color: #3a5a7a; }
#btn-bgm:hover { background: rgba(40,60,85,0.85); }

/* 手机端适配天赋/成就面板 */
@media (max-width: 820px), (pointer: coarse) {
  .talent-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
  .talent-card { padding: 8px; }
  .talent-icon { font-size: 22px; }
  .talent-name { font-size: 12px; }
  .talent-desc { font-size: 10px; }
  .ach-card { padding: 8px 10px; gap: 8px; }
  .ach-icon { font-size: 22px; }
  .ach-name { font-size: 12px; }
  .ach-desc { font-size: 10px; }
}