html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #08090d;
  color: #e2e8f0;
  font-family: 'Cinzel', 'Segoe UI', system-ui, -apple-system, sans-serif;
  user-select: none;
}

#game {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

/* --- HUD Overlay --- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-interactive {
  pointer-events: auto;
}

/* Top Bar: Floor, Gold, Status, Audio, Inventory, Multiplayer buttons */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(10,12,18,0.85) 0%, rgba(10,12,18,0) 100%);
}

.floor-badge {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f1f5f9;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  gap: 8px;
}

.gold-badge {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fbbf24;
  text-shadow: 0 2px 6px rgba(251,191,36,0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(20,24,36,0.65);
  border: 1px solid rgba(251,191,36,0.3);
  padding: 4px 12px;
  border-radius: 20px;
}

.top-buttons {
  display: flex;
  gap: 8px;
}

.hud-btn {
  background: rgba(22, 27, 39, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(8px);
}

.hud-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: #60a5fa;
  color: #60a5fa;
  transform: translateY(-1px);
}

/* Boss Bar */
.boss-container {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: 440px;
  max-width: 90vw;
  background: rgba(15, 17, 26, 0.9);
  border: 1px solid #ef4444;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  padding: 8px 14px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.boss-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f87171;
  letter-spacing: 1px;
}

.boss-bar-bg {
  width: 100%;
  height: 12px;
  background: #1e1e24;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.boss-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #dc2626, #f87171);
  transition: width 0.15s ease-out;
}

/* Bottom Bar: Health globe, Abilities Hotbar, Mana globe, XP Bar */
.bottom-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  background: linear-gradient(0deg, rgba(8,9,13,0.92) 0%, rgba(8,9,13,0) 100%);
}

.xp-bar-container {
  width: 520px;
  max-width: 90vw;
  height: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width 0.3s ease;
}

.orb-and-hotbar {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* RPG Orbs / Bars */
.globe-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 76px;
  position: relative;
}

.globe {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid #334155;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.8), 0 4px 12px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.globe-fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 100%;
  transition: height 0.2s ease-out;
}

.globe-health .globe-fill {
  background: radial-gradient(circle at 50% 120%, #ef4444 0%, #b91c1c 70%, #7f1d1d 100%);
}

.globe-mana .globe-fill {
  background: radial-gradient(circle at 50% 120%, #3b82f6 0%, #1d4ed8 70%, #1e3a8a 100%);
}

.globe-text {
  position: relative;
  z-index: 2;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.globe-label {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 600;
  margin-top: 4px;
  text-transform: uppercase;
}

/* Hotbar Abilities */
.hotbar {
  display: flex;
  gap: 12px;
  background: rgba(15, 23, 42, 0.85);
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(8px);
}

.ability-slot {
  width: 54px;
  height: 54px;
  background: #1e293b;
  border: 1.5px solid #475569;
  border-radius: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ability-slot:hover {
  border-color: #60a5fa;
  transform: scale(1.05);
}

.ability-icon {
  font-size: 1.4rem;
}

.ability-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #94a3b8;
}

.ability-cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 6px;
  pointer-events: none;
  transition: height 0.05s linear;
}

.ability-cd-text {
  position: absolute;
  font-size: 0.8rem;
  font-weight: 800;
  color: #f87171;
  display: none;
  z-index: 3;
}

/* Modals (Class Select, Inventory, Multiplayer, Game Over) */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 6, 10, 0.82);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.modal-card {
  background: #111520;
  border: 1.5px solid #334155;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border-radius: 14px;
  padding: 24px 28px;
  max-width: 600px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 16px 0;
  text-align: center;
  letter-spacing: 0.5px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.3rem;
  cursor: pointer;
}
.modal-close:hover { color: #f87171; }

/* Class Selection Grid */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.class-card {
  background: #182030;
  border: 1.5px solid #334155;
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.class-card:hover, .class-card.selected {
  border-color: #60a5fa;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.3);
  transform: translateY(-2px);
}

.class-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.class-icon { font-size: 1.6rem; }
.class-name { font-size: 1.1rem; font-weight: 700; color: #f8fafc; }
.class-desc { font-size: 0.82rem; color: #94a3b8; line-height: 1.35; }
.class-stats { font-size: 0.78rem; color: #38bdf8; display: flex; flex-direction: column; gap: 2px; }

/* Inventory & Paperdoll */
.inv-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.paperdoll-panel {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(15, 23, 42, 0.6);
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #334155;
}

.paperdoll-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e293b;
  border: 1px dashed #475569;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.inv-slots-panel {
  flex: 2;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.inv-cell {
  width: 48px;
  height: 48px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.inv-cell:hover {
  border-color: #60a5fa;
  transform: scale(1.06);
}

/* Rarity border styles */
.rarity-common { border-color: #cbd5e1 !important; color: #f8fafc; }
.rarity-rare { border-color: #3b82f6 !important; color: #60a5fa; }
.rarity-epic { border-color: #a855f7 !important; color: #c084fc; }
.rarity-legendary { border-color: #eab308 !important; color: #fde047; box-shadow: 0 0 10px rgba(234, 179, 8, 0.4); }

/* Floating combat text */
.floating-text {
  position: absolute;
  pointer-events: none;
  font-weight: 800;
  font-size: 1.1rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  transition: transform 0.8s ease-out, opacity 0.8s ease-out;
  z-index: 50;
}

.dmg-normal { color: #f87171; }
.dmg-crit { color: #facc15; font-size: 1.4rem; }
.dmg-heal { color: #4ade80; }

/* Toast Notifications */
#toast {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #38bdf8;
  color: #f0f9ff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 60;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}
#toast.active { opacity: 1; }

.hidden { display: none !important; }
