:root {
  --bg-void: #050508;
  --gold-dark: #7a5c28;
  --gold-bright: #c89b45;
  --iron-dark: #16161c;
  --iron-border: #3a342c;
  --crimson: #b31217;
  --crimson-bright: #ff2e36;
  --plasma: #0d6efd;
  --plasma-bright: #38d9ff;
  --font-gothic: 'Cinzel', Georgia, serif;
  --font-tech: 'Share Tech Mono', Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-void);
  font-family: var(--font-gothic);
  color: #d6cbb5;
  cursor: crosshair;
}

#game-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* Vignette overlay for extra grimdark atmosphere */
#game-container::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 48%, rgba(2, 2, 5, 0.78) 100%);
}

/* Floating Damage Numbers */
#damage-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  overflow: hidden;
}

.damage-num {
  position: absolute;
  font-family: var(--font-gothic);
  font-weight: 900;
  font-size: 20px;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0, 0, 0, 0.9);
  transform: translate(-50%, -50%);
  animation: floatUpFade 0.95s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  white-space: nowrap;
}

.damage-num.melee {
  color: #f5d78e;
}

.damage-num.plasma {
  color: #4de4ff;
  text-shadow: 0 0 10px rgba(56, 217, 255, 0.8), 0 2px 4px #000;
}

.damage-num.crit {
  font-size: 26px;
  color: #ff9f1c;
  text-shadow: 0 0 12px rgba(255, 140, 0, 0.9), 0 2px 4px #000;
}

.damage-num.player-hit {
  color: #ff3b3b;
  font-size: 22px;
}

.damage-num.heal {
  color: #44e37c;
  font-size: 21px;
}

@keyframes floatUpFade {
  0% {
    opacity: 1;
    transform: translate(-50%, -40%) scale(0.85);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -80%) scale(1.12);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -185%) scale(0.95);
  }
}

/* Top HUD */
#top-hud {
  position: fixed;
  top: 14px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 20;
}

.gothic-badge {
  background: linear-gradient(180deg, rgba(24, 20, 22, 0.92), rgba(10, 8, 12, 0.95));
  border: 1px solid var(--gold-dark);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.85), inset 0 0 8px rgba(179, 18, 23, 0.25);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #d8c6a0;
}

.skull-icon {
  color: #b52424;
  font-size: 16px;
}

/* Enemy Target Bar (Diablo 2 top-center style) */
#enemy-target-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  width: 340px;
  text-align: center;
  transition: opacity 0.15s ease;
}

#enemy-target-bar.hidden {
  opacity: 0;
  visibility: hidden;
}

#enemy-target-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #e6d3a7;
  text-shadow: 0 2px 6px #000;
  margin-bottom: 4px;
}

.enemy-hp-frame {
  height: 12px;
  background: #0b090c;
  border: 1px solid #59462b;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.9), inset 0 0 4px #000;
  padding: 1px;
}

#enemy-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #6e0a0e, #cc181f, #8f0e13);
  transition: width 0.12s ease-out;
}

#enemy-target-type {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #9b8e78;
  letter-spacing: 1.5px;
  margin-top: 3px;
}

/* Controls Hint */
#controls-hint {
  background: rgba(12, 11, 15, 0.84);
  border: 1px solid #332c24;
  padding: 8px 12px;
  font-family: var(--font-tech);
  font-size: 12px;
  color: #9e9381;
  line-height: 1.6;
}

#controls-hint .key {
  display: inline-block;
  background: #231f26;
  border: 1px solid var(--gold-dark);
  color: var(--gold-bright);
  padding: 0 5px;
  margin-right: 4px;
  font-size: 11px;
}

.hud-mute-btn {
  margin-top: 6px;
  width: 100%;
  background: rgba(25, 22, 30, 0.92);
  border: 1px solid var(--gold-dark);
  color: var(--gold-bright);
  font-family: var(--font-tech);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  letter-spacing: 0.8px;
  transition: background 0.15s, border-color 0.15s;
}

.hud-mute-btn:hover {
  background: rgba(58, 45, 24, 0.85);
  border-color: var(--gold-bright);
}

.hud-mute-btn.muted {
  color: #a97070;
  border-color: #6b2a2a;
}

.buff-bar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.buff-pill {
  font-family: var(--font-tech);
  font-size: 11px;
  letter-spacing: 0.8px;
  padding: 4px 10px;
  background: rgba(12, 14, 20, 0.9);
  border: 1px solid #38d9ff;
  color: #8ceeff;
  box-shadow: 0 0 10px rgba(56, 217, 255, 0.25);
}

.buff-pill.damage {
  border-color: #ff6b2b;
  color: #ffb18a;
  box-shadow: 0 0 10px rgba(255, 107, 43, 0.28);
}

.wave-ready-btn {
  margin-top: 10px;
  padding: 9px 16px;
  font-size: 12px;
  letter-spacing: 1px;
  border-color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(212, 168, 79, 0.35);
  pointer-events: auto;
}

.wave-ready-btn.hidden,
.buff-bar.hidden,
.highscore-entry.hidden,
.highscore-saved-msg.hidden {
  display: none;
}

/* Bottom Diablo HUD */
#bottom-hud {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 145px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
  z-index: 25;
  padding-bottom: 10px;
}

/* Orbs */
.orb-wrapper {
  position: relative;
  width: 126px;
  height: 126px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.left-orb {
  margin-right: -12px;
}

.right-orb {
  margin-left: -12px;
}

.orb-globe {
  position: relative;
  width: 114px;
  height: 114px;
  border-radius: 50%;
  background: #080608;
  border: 3px solid #4c3b24;
  box-shadow:
    0 0 22px rgba(0, 0, 0, 0.95),
    inset 0 0 18px rgba(0, 0, 0, 0.95),
    0 0 0 2px #1c1815;
  overflow: hidden;
}

.orb-liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  transition: height 0.18s ease-out;
}

.hp-orb .orb-liquid {
  background: linear-gradient(180deg, #d91c24 0%, #8a0b10 55%, #4a0407 100%);
  box-shadow: 0 -4px 16px rgba(255, 45, 55, 0.65);
}

.energy-orb .orb-liquid {
  background: linear-gradient(180deg, #25b8ff 0%, #0b5ed7 55%, #062866 100%);
  box-shadow: 0 -4px 16px rgba(56, 217, 255, 0.65);
}

.orb-swirl {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.16), transparent 55%);
  animation: orbPulse 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes orbPulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.7; }
  50% { transform: scale(1.06) rotate(12deg); opacity: 1; }
}

.orb-glass {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.06) 24%, transparent 52%),
    radial-gradient(circle at center, transparent 58%, rgba(0, 0, 0, 0.75) 100%);
  pointer-events: none;
}

.orb-label {
  position: absolute;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-shadow: 0 1px 4px #000, 0 0 6px #000;
  pointer-events: none;
}

.orb-title {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #cbbba0;
  opacity: 0.85;
}

.orb-value {
  font-family: var(--font-tech);
  font-size: 14px;
  font-weight: bold;
  color: #fff;
}

/* Gothic Action Bar */
#action-bar {
  pointer-events: auto;
  z-index: 2;
}

.action-bar-frame {
  background: linear-gradient(180deg, #1b181d 0%, #0d0b0f 100%);
  border: 2px solid #4d3c26;
  border-bottom-width: 3px;
  box-shadow:
    0 -4px 20px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(200, 155, 69, 0.25),
    inset 0 0 14px rgba(0, 0, 0, 0.85);
  padding: 6px 18px 8px;
  min-width: 380px;
}

.xp-bar-container {
  height: 5px;
  background: #070609;
  border: 1px solid #3b3022;
  margin-bottom: 8px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b5a1b, #e0a63b);
  transition: width 0.3s ease;
}

.slots-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.skill-slot {
  position: relative;
  width: 58px;
  height: 58px;
  background: radial-gradient(circle at center, #211d24 0%, #0c0a0e 100%);
  border: 2px solid #4a3a26;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.skill-slot:hover {
  border-color: var(--gold-bright);
}

.skill-slot.active {
  border-color: #c89b45;
  box-shadow: inset 0 0 12px rgba(200, 155, 69, 0.28), 0 0 10px rgba(200, 155, 69, 0.2);
}

.skill-slot:active {
  transform: scale(0.96);
}

.slot-icon {
  font-size: 22px;
  line-height: 1;
}

.sword-icon { color: #e2c275; }
.plasma-icon { color: #38d9ff; text-shadow: 0 0 8px rgba(56, 217, 255, 0.7); }
.stim-icon { color: #e03c42; text-shadow: 0 0 6px rgba(224, 60, 66, 0.6); }
.ward-icon { color: #f0a830; text-shadow: 0 0 8px rgba(240, 168, 48, 0.6); }
.inv-icon { color: #c89b45; text-shadow: 0 0 6px rgba(200, 155, 69, 0.45); }

.slot-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-family: var(--font-tech);
  font-size: 10px;
  color: #a99b84;
}

.slot-name {
  font-size: 8px;
  letter-spacing: 0.5px;
  color: #b5a78e;
  margin-top: 4px;
  text-transform: uppercase;
}

.slot-cost {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-family: var(--font-tech);
  font-size: 10px;
  color: #38d9ff;
}

.slot-badge {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-family: var(--font-tech);
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  background: rgba(140, 18, 22, 0.85);
  padding: 0 4px;
  border-radius: 2px;
}

.slot-cooldown {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-tech);
  font-size: 14px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
}

.slot-cooldown.active {
  opacity: 1;
}

.slot-divider {
  width: 2px;
  height: 46px;
  background: linear-gradient(180deg, transparent, #5a462b, transparent);
  margin: 0 4px;
}

/* Modal Overlay */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 2, 5, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#modal-overlay.hidden {
  display: none;
}

.gothic-modal {
  background: linear-gradient(180deg, #171419 0%, #09080b 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 45px rgba(0, 0, 0, 0.95), inset 0 0 24px rgba(140, 14, 20, 0.25);
  padding: 36px 48px;
  text-align: center;
  max-width: 460px;
}

.modal-crest {
  font-size: 38px;
  color: var(--gold-bright);
  margin-bottom: 10px;
}

#modal-title {
  font-size: 28px;
  letter-spacing: 3px;
  color: #d62828;
  margin-bottom: 12px;
  text-shadow: 0 2px 10px rgba(214, 40, 40, 0.5);
}

#modal-title.victory {
  color: var(--gold-bright);
  text-shadow: 0 2px 12px rgba(200, 155, 69, 0.55);
}

#modal-subtitle {
  font-family: var(--font-tech);
  font-size: 14px;
  color: #b8aa93;
  margin-bottom: 26px;
  line-height: 1.5;
}

.gothic-btn {
  background: linear-gradient(180deg, #5e1014 0%, #33070a 100%);
  border: 1px solid var(--gold-bright);
  color: #f3e6cc;
  font-family: var(--font-gothic);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 12px 28px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gothic-btn:hover {
  background: linear-gradient(180deg, #87161b 0%, #4d0a0e 100%);
  box-shadow: 0 0 16px rgba(214, 40, 40, 0.5);
}

/* Ground Loot Labels */
#loot-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 16;
}

.loot-tag {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(8, 7, 11, 0.92);
  border: 1px solid #59462b;
  padding: 3px 9px;
  font-family: var(--font-tech);
  font-size: 12px;
  letter-spacing: 0.8px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.rarity-scrap {
  color: #e6c16a;
  border-color: rgba(212, 164, 70, 0.55);
}

.rarity-ammo {
  color: #5ee2ff;
  border-color: rgba(56, 217, 255, 0.6);
}

.rarity-armor {
  color: #ff7062;
  border-color: rgba(224, 82, 68, 0.65);
}

/* Gothic Grid Inventory */
#inventory-panel {
  position: fixed;
  right: 22px;
  bottom: 158px;
  width: 344px;
  background: linear-gradient(180deg, #19161c 0%, #0b0a0e 100%);
  border: 2px solid #5c482c;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.95), inset 0 0 18px rgba(0, 0, 0, 0.9);
  padding: 12px 14px;
  z-index: 35;
}

#inventory-panel.hidden {
  display: none;
}

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3c3022;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.inv-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gold-bright);
}

.inv-close-btn {
  background: #241e26;
  border: 1px solid #5c482c;
  color: #d6cbb5;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 12px;
}

.inv-close-btn:hover {
  border-color: var(--gold-bright);
  color: #fff;
}

.inv-held-hint {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #f5d78e;
  background: rgba(140, 100, 30, 0.22);
  border: 1px solid #7a5c28;
  padding: 4px 8px;
  margin-bottom: 8px;
}

.inv-held-hint.hidden {
  display: none;
}

.inv-grid-wrapper {
  position: relative;
  width: 312px; /* 6 * 52px */
  height: 208px; /* 4 * 52px */
  background: #070609;
  border: 1px solid #4d3c26;
}

#inventory-grid {
  display: grid;
  grid-template-columns: repeat(6, 52px);
  grid-template-rows: repeat(4, 52px);
}

.inv-cell {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(90, 74, 52, 0.28);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.85);
}

.inv-cell.preview-valid {
  background: rgba(56, 217, 255, 0.18);
  border-color: #38d9ff;
}

.inv-cell.preview-invalid {
  background: rgba(224, 60, 66, 0.22);
  border-color: #e03c42;
}

#inventory-items-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.inv-item {
  position: absolute;
  pointer-events: auto;
  background: radial-gradient(circle at center, rgba(45, 40, 48, 0.92), rgba(14, 12, 18, 0.96));
  border: 1px solid #6b5434;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 1px;
}

.inv-item.rarity-scrap {
  border-color: #b88b35;
  background: radial-gradient(circle at center, rgba(72, 54, 22, 0.88), rgba(18, 14, 10, 0.96));
}

.inv-item.rarity-ammo {
  border-color: #29a8cc;
  background: radial-gradient(circle at center, rgba(16, 62, 82, 0.88), rgba(10, 18, 24, 0.96));
}

.inv-item.rarity-armor {
  border-color: #b8372e;
  background: radial-gradient(circle at center, rgba(78, 24, 24, 0.88), rgba(20, 10, 12, 0.96));
}

.inv-item:hover {
  filter: brightness(1.22);
  z-index: 2;
}

.inv-item-icon {
  font-size: 24px;
  line-height: 1;
}

.inv-item-size {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-family: var(--font-tech);
  font-size: 9px;
  opacity: 0.7;
}

.inv-footer {
  margin-top: 8px;
  font-family: var(--font-tech);
  font-size: 11px;
  color: #8f8472;
  text-align: center;
}

.inv-tooltip {
  position: absolute;
  left: -228px;
  top: 12px;
  width: 216px;
  background: rgba(10, 9, 14, 0.96);
  border: 1px solid #6e5735;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.95);
  padding: 10px 12px;
  pointer-events: none;
}

.inv-tooltip.hidden {
  display: none;
}

.tt-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 3px;
}

.tt-meta {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #9e9381;
  margin-bottom: 6px;
}

.tt-desc {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #d6cbb5;
  line-height: 1.4;
}


/* Badge separator & Credits */
.badge-sep {
  margin: 0 8px;
  color: var(--gold-dark);
}

#credits-counter {
  color: var(--gold-bright);
  font-weight: 700;
}

/* Post-Wave Armory / Weapon Shop Modal */
#armory-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 4, 8, 0.84);
  backdrop-filter: blur(5px);
}

#armory-overlay.hidden {
  display: none;
}

.armory-modal {
  width: min(860px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(22, 20, 28, 0.98) 0%, rgba(10, 9, 14, 0.99) 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95), inset 0 0 28px rgba(122, 92, 40, 0.16);
  padding: 24px 28px;
  color: #d6cbb5;
}

.armory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #3a3225;
  padding-bottom: 14px;
  margin-bottom: 18px;
  gap: 16px;
}

.armory-kicker {
  font-family: var(--font-tech);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold-bright);
  margin-bottom: 4px;
}

.armory-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #efe2c6;
  text-shadow: 0 2px 10px rgba(200, 155, 69, 0.25);
}

.armory-credits-box {
  background: rgba(12, 11, 16, 0.9);
  border: 1px solid var(--gold-dark);
  padding: 8px 16px;
  text-align: right;
  min-width: 155px;
}

.credits-label {
  display: block;
  font-family: var(--font-tech);
  font-size: 10px;
  color: #9e9381;
  letter-spacing: 0.1em;
}

.credits-value {
  font-size: 20px;
  font-weight: 900;
  color: var(--gold-bright);
}

.armory-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 18px;
}

@media (max-width: 720px) {
  .armory-columns {
    grid-template-columns: 1fr;
  }
}

.armory-col-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  border-bottom: 1px solid #2f2920;
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.armory-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.weapon-card {
  background: rgba(16, 15, 22, 0.92);
  border: 1px solid #3a342c;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.weapon-card.equipped {
  border-color: var(--gold-bright);
  background: radial-gradient(circle at top right, rgba(122, 92, 40, 0.22), rgba(16, 15, 22, 0.96));
}

.weapon-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.weapon-name {
  font-size: 15px;
  font-weight: 700;
  color: #f0e3c9;
}

.weapon-badge {
  font-family: var(--font-tech);
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid #524634;
  color: var(--gold-bright);
  text-transform: uppercase;
}

.weapon-desc {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #9e9381;
  line-height: 1.35;
}

.weapon-stats {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #cbbba0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.weapon-action-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.weapon-btn {
  font-family: var(--font-gothic);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 14px;
  border: 1px solid var(--gold-dark);
  background: linear-gradient(180deg, #2d2417 0%, #19140d 100%);
  color: var(--gold-bright);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.weapon-btn:hover:not(:disabled) {
  filter: brightness(1.22);
}

.weapon-btn.equip-btn {
  border-color: #3a7ca5;
  background: linear-gradient(180deg, #163042 0%, #0d1c26 100%);
  color: #7cd4ff;
}

.weapon-btn.equipped-btn {
  border-color: var(--gold-bright);
  background: rgba(200, 155, 69, 0.18);
  color: #f5deb3;
  cursor: default;
}

.weapon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.armory-supplies {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid #2f2920;
  border-bottom: 1px solid #2f2920;
  margin-bottom: 18px;
}

.armory-supply-btn {
  flex: 1;
  min-width: 220px;
  font-family: var(--font-tech);
  font-size: 12px;
  padding: 9px 14px;
  border: 1px solid #493f32;
  background: rgba(24, 22, 30, 0.9);
  color: #dfd3bc;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.armory-supply-btn:hover:not(:disabled) {
  border-color: var(--gold-bright);
  background: rgba(44, 36, 24, 0.9);
}

.armory-supply-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.armory-footer {
  display: flex;
  justify-content: center;
}

.armory-next-btn {
  min-width: 260px;
}


/* Inventory Expansion: Sort Button, Equipment Slots & Relic Rarity */
.inv-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inv-sort-btn {
  font-family: var(--font-tech);
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(28, 25, 34, 0.92);
  border: 1px solid var(--gold-dark);
  color: var(--gold-bright);
  cursor: pointer;
}

.inv-sort-btn:hover {
  filter: brightness(1.2);
}

.inv-equipment {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(98px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.equip-slot {
  background: rgba(12, 11, 16, 0.92);
  border: 1px solid #493e30;
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.equip-slot.relic-slot {
  border-color: #6b4c9a;
  cursor: pointer;
}

.equip-slot.relic-slot.filled {
  background: radial-gradient(circle at center, rgba(66, 36, 98, 0.55), rgba(14, 11, 20, 0.95));
  border-color: #a974ff;
}

.equip-slot.relic-slot.filled.rarity-armor {
  background: radial-gradient(circle at center, rgba(78, 24, 24, 0.65), rgba(20, 10, 12, 0.95));
  border-color: #b8372e;
}

.equip-slot.relic-slot.filled.rarity-rare {
  background: radial-gradient(circle at center, rgba(22, 54, 92, 0.7), rgba(10, 14, 22, 0.95));
  border-color: #4ea8ff;
}

.equip-slot.relic-slot.filled.rarity-masterwork {
  background: radial-gradient(circle at center, rgba(64, 28, 98, 0.7), rgba(14, 10, 22, 0.95));
  border-color: #b46cff;
}

.equip-slot.relic-slot.filled.rarity-legendary {
  background: radial-gradient(circle at center, rgba(96, 68, 22, 0.78), rgba(18, 13, 8, 0.96));
  border-color: #f2c66d;
  box-shadow: 0 0 10px rgba(242, 198, 109, 0.3);
}

.equip-slot-label {
  font-family: var(--font-tech);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: #9e9381;
}

.equip-slot-val {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #efe2c6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-item.rarity-relic {
  border-color: #a974ff;
  background: radial-gradient(circle at center, rgba(68, 34, 104, 0.88), rgba(16, 10, 24, 0.96));
}

.inv-actions-row {
  margin-top: 8px;
  display: flex;
}

.inv-drop-btn {
  width: 100%;
  font-family: var(--font-tech);
  font-size: 11px;
  padding: 5px 10px;
  background: rgba(58, 22, 22, 0.85);
  border: 1px solid #8a3434;
  color: #f2c2c2;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.inv-drop-btn:hover:not(:disabled) {
  filter: brightness(1.22);
}

.inv-drop-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Main Menu / Pause Overlay */
#main-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(16, 12, 20, 0.82) 0%, rgba(3, 3, 6, 0.94) 100%);
  backdrop-filter: blur(6px);
}

#main-menu-overlay.hidden {
  display: none;
}

.main-menu-modal {
  width: min(440px, 90vw);
  background: linear-gradient(180deg, rgba(22, 20, 28, 0.98) 0%, rgba(9, 8, 13, 0.99) 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 65px rgba(0, 0, 0, 0.95), inset 0 0 30px rgba(122, 92, 40, 0.18);
  padding: 32px 30px 26px;
  text-align: center;
}

.menu-kicker {
  font-family: var(--font-tech);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.menu-title {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #f3e6cb;
  text-shadow: 0 3px 16px rgba(200, 155, 69, 0.3);
  line-height: 1.05;
}

.menu-subtitle {
  font-size: 14px;
  letter-spacing: 0.28em;
  color: #a82b2e;
  font-weight: 700;
  margin-bottom: 24px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.menu-btn {
  width: 100%;
}

.menu-btn.hidden {
  display: none;
}

.menu-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.menu-save-info {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #9e9381;
  min-height: 16px;
}

.menu-record-info {
  font-family: var(--font-tech);
  font-size: 11px;
  color: var(--gold-bright);
  margin-top: 6px;
  letter-spacing: 0.8px;
}

.highscore-entry {
  margin: 14px 0 18px;
  padding: 12px 14px;
  background: rgba(16, 14, 20, 0.92);
  border: 1px solid var(--gold-dark);
}

.highscore-label {
  display: block;
  font-family: var(--font-tech);
  font-size: 11px;
  color: var(--gold-bright);
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.highscore-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

#highscore-name-input {
  width: 170px;
  padding: 8px 10px;
  background: #0c0b10;
  border: 1px solid var(--gold-dark);
  color: #f3e5c0;
  font-family: var(--font-tech);
  font-size: 14px;
  letter-spacing: 1px;
  text-align: center;
  outline: none;
}

#highscore-name-input:focus {
  border-color: var(--gold-bright);
}

.highscore-save-btn {
  padding: 8px 14px;
  font-size: 12px;
}

.highscore-saved-msg {
  margin-top: 8px;
  font-family: var(--font-tech);
  font-size: 11px;
  color: #6ce89c;
}

.armory-footer {
  gap: 12px;
  flex-wrap: wrap;
}

.armory-save-btn {
  flex: 0 0 auto;
  min-width: 170px;
}

/* Armory Armor Upgrade Banner */
.armory-armor-upgrade {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: radial-gradient(circle at left, rgba(122, 92, 40, 0.2), rgba(14, 13, 19, 0.94));
  border: 1px solid var(--gold-dark);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.armor-upgrade-title {
  font-size: 14px;
  font-weight: 700;
  color: #f3e4c3;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.armor-upgrade-desc {
  font-family: var(--font-tech);
  font-size: 11px;
  color: #b7aa93;
}

.armor-upgrade-btn {
  padding: 8px 16px;
  font-size: 12px;
}

.inv-item.rarity-heal {
  border-color: #44e37c;
  background: radial-gradient(circle at center, rgba(20, 76, 42, 0.88), rgba(10, 20, 14, 0.96));
}

/* Heraldry / Armor Color Customization Modal */
#heraldry-overlay {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 20px 4vw;
  background: rgba(6, 5, 10, 0.12);
}

#heraldry-overlay.hidden {
  display: none;
}

.heraldry-modal {
  width: min(500px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(22, 20, 28, 0.98) 0%, rgba(10, 9, 14, 0.99) 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.95), inset 0 0 24px rgba(122, 92, 40, 0.16);
  padding: 20px 24px;
  color: #d6cbb5;
}

.heraldry-parts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.heraldry-part-row {
  background: rgba(14, 13, 19, 0.85);
  border: 1px solid #352d22;
  padding: 10px 12px;
}

.heraldry-part-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 10px;
}

.heraldry-part-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #f3e4c3;
}

.heraldry-active-name {
  font-family: var(--font-tech);
  font-size: 11px;
  color: var(--gold-bright);
}

.heraldry-swatches {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}

.heraldry-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #2b2620;
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  padding: 0;
}

.heraldry-swatch:hover {
  transform: scale(1.12);
  border-color: #d6cbb5;
}

.heraldry-swatch.active {
  border-color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(242, 198, 109, 0.7);
  transform: scale(1.1);
}

.heraldry-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #3a3225;
  padding-top: 14px;
}

/* Action Bar Customization */
.skill-slot.custom-slot.empty-slot {
  opacity: 0.52;
}

.action-slot-picker {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 92vw);
  background: linear-gradient(180deg, rgba(22, 20, 28, 0.98) 0%, rgba(10, 9, 14, 0.99) 100%);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.92), inset 0 0 20px rgba(122, 92, 40, 0.16);
  padding: 12px 14px;
  z-index: 45;
  color: #d6cbb5;
  pointer-events: auto;
}

.action-slot-picker.hidden {
  display: none;
}

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
}

.picker-slot-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.picker-tab {
  flex: 1;
  background: rgba(18, 16, 24, 0.9);
  border: 1px solid #3c3327;
  color: #b7aa93;
  font-family: var(--font-tech);
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
}

.picker-tab.active {
  border-color: var(--gold-bright);
  color: #f3e4c3;
  background: rgba(122, 92, 40, 0.25);
}

.picker-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.picker-option-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: rgba(14, 13, 19, 0.92);
  border: 1px solid #352d22;
  color: #d6cbb5;
  padding: 8px 10px;
  cursor: pointer;
  font-family: var(--font-tech);
  font-size: 12px;
  text-align: left;
}

.picker-option-btn:hover {
  border-color: #9e8150;
  background: rgba(40, 32, 24, 0.9);
}

.picker-option-btn.active {
  border-color: var(--gold-bright);
  box-shadow: inset 0 0 12px rgba(242, 198, 109, 0.16);
}

.picker-option-sub {
  font-size: 10px;
  color: #9a8d77;
}

/* Mobile & Touch Controls */
#game-container,
#touch-controls,
#touch-joystick,
.touch-btn {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#touch-controls {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 32;
  pointer-events: none;
}

body.touch-enabled #touch-controls {
  display: block;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 48;
  width: 44px;
  height: 44px;
  border: 2px solid var(--gold-dark);
  background: rgba(14, 13, 19, 0.9);
  color: var(--gold-bright);
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
}

body.touch-enabled .mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

body.touch-enabled #controls-hint {
  display: none;
}

#touch-joystick {
  position: fixed;
  left: 22px;
  bottom: 112px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 2px solid rgba(212, 164, 70, 0.55);
  background: radial-gradient(circle, rgba(22, 20, 28, 0.45) 0%, rgba(10, 9, 14, 0.72) 100%);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.7);
  pointer-events: auto;
}

#touch-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin-left: -23px;
  margin-top: -23px;
  border-radius: 50%;
  border: 2px solid var(--gold-bright);
  background: radial-gradient(circle, rgba(212, 164, 70, 0.65) 0%, rgba(122, 92, 40, 0.85) 100%);
  box-shadow: 0 0 12px rgba(242, 198, 109, 0.45);
  pointer-events: none;
}

#touch-action-buttons {
  position: fixed;
  right: 18px;
  bottom: 112px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--gold-dark);
  background: radial-gradient(circle, rgba(30, 24, 34, 0.88) 0%, rgba(10, 9, 14, 0.94) 100%);
  color: #f3e4c3;
  font-size: 24px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-btn.active,
.touch-btn:active {
  transform: scale(0.93);
  border-color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(242, 198, 109, 0.55);
}

.touch-melee-btn {
  border-color: #a83232;
}

.touch-ranged-btn {
  border-color: #2f98c4;
}

.touch-dash-btn {
  border-color: #d4a446;
}

.touch-grenade-btn {
  border-color: #e06b24;
}

@media (max-width: 820px) {
  .orb-wrapper {
    transform: scale(0.72);
    transform-origin: bottom center;
  }

  #action-bar {
    transform: scale(0.8);
    transform-origin: bottom center;
  }

  .gothic-badge {
    font-size: 11px;
    padding: 5px 10px;
  }
}

/* Item Rarities & Weapon Upgrade Button */
.inv-item.rarity-rare,
.loot-tag.rarity-rare {
  border-color: #4ea8ff;
}
.inv-item.rarity-rare {
  background: radial-gradient(circle at center, rgba(22, 54, 92, 0.88), rgba(10, 14, 22, 0.96));
}
.tt-title.rarity-rare {
  color: #6bc0ff;
}

.inv-item.rarity-masterwork,
.loot-tag.rarity-masterwork {
  border-color: #b46cff;
}
.inv-item.rarity-masterwork {
  background: radial-gradient(circle at center, rgba(64, 28, 98, 0.88), rgba(14, 10, 22, 0.96));
}
.tt-title.rarity-masterwork {
  color: #cb94ff;
}

.inv-item.rarity-legendary,
.loot-tag.rarity-legendary {
  border-color: #f2c66d;
  box-shadow: 0 0 12px rgba(242, 198, 109, 0.35);
}
.inv-item.rarity-legendary {
  background: radial-gradient(circle at center, rgba(96, 68, 22, 0.9), rgba(18, 13, 8, 0.97));
}
.tt-title.rarity-legendary {
  color: #f7d98b;
}

.weapon-upgrade-btn {
  margin-top: 6px;
  width: 100%;
  background: rgba(34, 28, 18, 0.92);
  border: 1px solid var(--gold-dark);
  color: #f3e4c3;
  font-family: var(--font-tech);
  font-size: 11px;
  padding: 5px 8px;
  cursor: pointer;
}

.weapon-upgrade-btn:hover:not(:disabled) {
  border-color: var(--gold-bright);
  background: rgba(88, 66, 30, 0.55);
}

.weapon-upgrade-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.inv-item-rarity {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  color: inherit;
}

.inv-item.rarity-rare .inv-item-rarity,
.loot-tag.rarity-rare {
  color: #6bc0ff;
}

.inv-item.rarity-masterwork .inv-item-rarity,
.loot-tag.rarity-masterwork {
  color: #cb94ff;
}

.inv-item.rarity-legendary .inv-item-rarity,
.loot-tag.rarity-legendary {
  color: #f7d98b;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(242, 198, 109, 0.75);
}

.tt-compare {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #3a3225;
}

.tt-compare-title {
  font-size: 10px;
  color: #b7aa93;
  margin-bottom: 3px;
}

.tt-compare-diffs {
  font-family: var(--font-tech);
  font-size: 11px;
  line-height: 1.4;
}

.tt-diff-up {
  color: #56f08c;
  font-weight: 700;
}

.tt-diff-down {
  color: #ff6262;
  font-weight: 700;
}

.tt-diff-eq {
  color: #9a8d77;
}
