:root {
  --bg-dark: #0b0704;
  --panel-bg: rgba(20, 12, 6, 0.94);
  --bronze-dark: #3a2210;
  --bronze-border: #7c4a22;
  --bronze-light: #e6be75;
  --bronze-gold: #d4af37;
  --blood-red: #b91c1c;
  --mana-blue: #0284c7;
  --q-common: #9ca3af;
  --q-magic: #60a5fa;
  --q-rare: #facc15;
  --q-epic: #c084fc;
  --q-legendary: #fbbf24;
}

/* ═════════════════════════════════════════════════════════
   GÓC TRÊN TRÁI: PLAYER FRAME CHUẨN VÕ LÂM KINH ĐIỂN
   ═════════════════════════════════════════════════════════ */
.top-left-hud {
  position: absolute;
  top: 12px; left: 14px;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: auto;
}

.player-frame {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(28, 17, 9, 0.96), rgba(14, 9, 4, 0.98));
  border: 2px solid var(--bronze-border);
  border-radius: 10px;
  padding: 8px 14px 8px 8px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.85);
  position: relative;
}
.player-frame::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--bronze-light), transparent);
}

.avatar-wrapper {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 2px solid var(--bronze-gold);
  background: #090e17;
  box-shadow: 0 0 15px rgba(212,175,55,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.level-badge {
  position: absolute;
  bottom: -3px; right: -3px;
  background: linear-gradient(135deg, #c29b38, #78350f);
  border: 1px solid #fef08a;
  color: #fff;
  font-size: 0.68rem;
  font-weight: bold;
  padding: 0 5px;
  border-radius: 8px;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 210px;
}
.player-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1px;
}
.player-name {
  font-size: 0.88rem;
  font-weight: bold;
  color: var(--bronze-light);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pk-mode {
  font-size: 0.65rem;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid #22c55e;
  padding: 0 5px;
  border-radius: 3px;
  font-weight: bold;
}

/* Thanh HP */
.bar-wrap-hp {
  position: relative;
  width: 100%; height: 16px;
  background: #0d0603;
  border: 1px solid #852222;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.9);
}
.bar-fill-hp {
  height: 100%;
  background: linear-gradient(90deg, #991b1b, #ef4444);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
  transition: width 0.25s ease;
  width: 100%;
}
.bar-text-hp {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: bold; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.95);
  letter-spacing: 0.3px;
}

/* Thanh MP */
.bar-wrap-mp {
  position: relative;
  width: 100%; height: 14px;
  background: #03080e;
  border: 1px solid #144b6e;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.9);
}
.bar-fill-mp {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
  transition: width 0.25s ease;
  width: 100%;
}
.bar-text-mp {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: bold; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.95);
  letter-spacing: 0.3px;
}

/* ══════════════════════════════════════════════════════════
   CENTRAL ACTION DOCK (ĐÁY MÀN HÌNH, 70PX)
   ══════════════════════════════════════════════════════════ */
.central-dock {
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, rgba(28, 17, 9, 0.98) 0%, rgba(14, 9, 4, 0.99) 100%);
  border: 2px solid var(--bronze-border);
  border-radius: 12px;
  padding: 6px 12px 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.9), 0 0 20px rgba(212,175,55,0.25);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}
.central-dock::before {
  content: "";
  position: absolute;
  top: -2px; left: 15%; right: 15%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--bronze-gold), transparent);
}

.skills-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 3 Dược Phẩm [F1, F2, F3] */
.potion-group {
  display: flex;
  gap: 5px;
  background: rgba(0,0,0,0.4);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--bronze-dark);
}
.potion-slot {
  width: 44px; height: 44px;
  background: #140b05;
  border: 1px solid #5a381a;
  border-radius: 6px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.potion-slot:hover { border-color: var(--bronze-gold); transform: translateY(-2px); }
.potion-icon-img { width: 32px; height: 32px; object-fit: contain; }
.potion-count {
  position: absolute;
  bottom: 1px; right: 3px;
  font-size: 0.65rem; font-weight: bold; color: #fef08a;
  text-shadow: 0 1px 2px #000;
}

/* 5 Kỹ Năng [1-5] */
.skill-group {
  display: flex;
  gap: 6px;
}
.action-slot {
  width: 52px; height: 52px;
  background: #190e06;
  border: 2px solid var(--bronze-border);
  border-radius: 8px;
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  overflow: hidden;
}
.action-slot:hover {
  border-color: var(--bronze-gold);
  box-shadow: 0 0 10px rgba(212,175,55,0.4);
  transform: translateY(-2px);
}
.action-slot:active { transform: translateY(0); }
.slot-icon-img { width: 36px; height: 36px; object-fit: contain; }
.slot-key {
  position: absolute;
  top: 2px; left: 3px;
  font-size: 0.65rem; font-weight: bold; color: #e2e8f0;
  background: rgba(0,0,0,0.6);
  padding: 0 4px; border-radius: 3px;
  line-height: 1.1;
}
.slot-title {
  position: absolute;
  bottom: 2px;
  font-size: 0.58rem; color: var(--bronze-light);
  white-space: nowrap; text-align: center;
}

/* 4 Phím Tiện Ích [Q, E, C, B] */
.utility-group {
  display: flex;
  gap: 5px;
  border-left: 1px solid var(--bronze-dark);
  padding-left: 8px;
}
.util-btn {
  width: 44px; height: 44px;
  background: #140b05;
  border: 1px solid #5a381a;
  border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}
.util-btn:hover { border-color: var(--bronze-gold); transform: translateY(-2px); }
.util-icon { font-size: 1.1rem; line-height: 1; }
.util-title { font-size: 0.58rem; color: #94a3b8; margin-top: 1px; }

/* Thanh EXP Đáy */
.exp-bar-wrap {
  width: 100%; height: 4px;
  background: #000;
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.exp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #059669, #34d399);
  width: 0%;
}

/* ═════════════════════════════════════════════════════════
   MODAL POPUP 2 CÁNH (CÁNH TRÁI: C, Q | CÁNH PHẢI: B, E)
   ═════════════════════════════════════════════════════════ */
.modal-window {
  position: absolute;
  top: 75px;
  z-index: 75;
  background: linear-gradient(180deg, rgba(28, 17, 9, 0.98) 0%, rgba(14, 9, 4, 0.99) 100%);
  border: 2px solid var(--bronze-border);
  border-radius: 12px;
  box-shadow: 0 15px 50px rgba(0,0,0,0.95), 0 0 30px rgba(212,175,55,0.3);
  padding: 16px 20px;
  display: none;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.modal-window.wing-left {
  left: 25px;
  animation: slideInLeft 0.25s ease-out forwards;
}
.modal-window.wing-right {
  right: 25px;
  animation: slideInRight 0.25s ease-out forwards;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #4a3018;
  margin-bottom: 12px;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--bronze-light);
  display: flex; align-items: center; gap: 8px;
}
.btn-close-modal {
  background: #2a1508;
  border: 1px solid #633f1c;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: bold;
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-close-modal:hover { color: #fff; border-color: #ef4444; background: #991b1b; }

/* Layout Bảng Nhân Vật (Phím C) */
.char-modal-body { display: flex; gap: 18px; }
.paperdoll-col {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; width: 200px;
}
.paperdoll-hero-preview {
  width: 140px; height: 160px;
  background: radial-gradient(circle, #24140a 0%, #0d0804 100%);
  border: 1px solid #5a381a;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.paperdoll-hero-preview img { width: 130px; height: 130px; object-fit: contain; }
.equip-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; width: 100%;
}
.equip-slot {
  width: 58px; height: 58px;
  background: #140b05; border: 1px solid #5a381a;
  border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; position: relative; transition: all 0.15s;
}
.equip-slot:hover { border-color: var(--bronze-gold); box-shadow: 0 0 12px rgba(212,175,55,0.4); }
.equip-slot-icon { width: 40px; height: 40px; object-fit: contain; }
.equip-slot-label { font-size: 0.6rem; color: #94a3b8; }

.stats-col { width: 250px; display: flex; flex-direction: column; gap: 6px; }
.section-subhead {
  font-size: 0.78rem; font-weight: bold; color: var(--bronze-light);
  border-bottom: 1px solid #3d2412; padding-bottom: 2px; margin-top: 4px;
}
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem;
}
.stat-name { color: #94a3b8; }
.stat-val { font-weight: bold; color: #e2e8f0; }

/* Layout Rương Đồ Hành Trang (Phím B) */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}
.inv-slot {
  width: 64px; height: 64px;
  background: #140b05;
  border: 1px solid #4a2c13;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.15s;
}
.inv-slot:hover { border-color: var(--bronze-gold); background: #221208; }
.inv-slot img { width: 46px; height: 46px; object-fit: contain; }
.inv-slot-count {
  position: absolute; bottom: 2px; right: 4px;
  font-size: 0.65rem; font-weight: bold; color: #fef08a; text-shadow: 0 1px 2px #000;
}
.inv-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 8px; border-top: 1px solid #4a3018;
  font-size: 0.82rem;
}
.gold-val { color: #facc15; font-weight: bold; display: flex; align-items: center; gap: 4px; }
