@font-face {
  font-family: 'Pixelify';
  src: url('../assets/fonts/PixelifyPS-400.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Pixelify';
  src: url('../assets/fonts/PixelifyPS-700.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}

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

:root {
  --retro-green: #6ef55a;
  --retro-green-bright: #96ff85;
  --retro-green-dim: #328526;
  --retro-green-bg: #112a0d;
  --retro-black: #050805;

  /* Cursor Retro Pixel Art Personalizado (Escala 2x para nitidez y visibilidad óptima) */
  --retro-cursor: url('../assets/cursor/png_2x/cursor_retro_2x.png') 14 4, auto;
  --retro-cursor-pointer: url('../assets/cursor/png_2x/cursor_retro_2x.png') 14 4, pointer;

  /* Tonos morados del cofre */
  --retro-purple: #b43cff;
  --retro-purple-bright: #d47aff;
  --retro-purple-dim: #641996;
  --retro-purple-bg: #220836;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--retro-black);
  font-family: 'Pixelify', 'Courier New', Courier, monospace;
  color: var(--retro-green);
  text-rendering: pixelated;
  cursor: var(--retro-cursor);
}

*, *::before, *::after {
  cursor: var(--retro-cursor) !important;
}

button,
[role="button"],
.icon-btn,
.btn-start-game,
.title-sub-btn,
.btn-retro,
.upgrade-card,
.hero-card,
.shop-card,
.retro-btn,
.chest-btn,
.modal-close-btn,
a,
input,
select {
  cursor: var(--retro-cursor-pointer) !important;
}

.hero-card.locked {
  cursor: not-allowed !important;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* OVERLAY DE SCANLINES CRT RETRO */
.crt-scanlines {
  position: relative;
  pointer-events: none;
}

.crt-scanlines::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.45) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.03));
  z-index: 10;
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
}

.crt-scanlines::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.45) 100%);
  z-index: 11;
  pointer-events: none;
}

canvas#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-color: #000000;
}

/* PANTALLA DE INICIO (TITLE SCREEN) */
#title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 150;
  pointer-events: auto;
  padding: 16px;
}

.title-top-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.title-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: rgba(5, 8, 5, 0.85);
  border: 2px solid var(--retro-green);
  color: var(--retro-green);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(110, 245, 90, 0.35);
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.icon-btn:hover, .icon-btn:active {
  background: var(--retro-green);
  color: var(--retro-black);
  transform: scale(1.08);
}

.menu-coins-display {
  background: rgba(5, 8, 5, 0.85);
  border: 2px solid var(--retro-green);
  padding: 0 12px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--retro-green-bright);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(110, 245, 90, 0.35);
  letter-spacing: 1px;
  box-sizing: border-box;
}

.coin-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url('../assets/pickups/coins/coin_skull_1x.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  vertical-align: middle;
  filter: drop-shadow(0 0 4px rgba(255, 222, 60, 0.6));
}

.token-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url('../assets/pickups/tokens/token_1x.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  vertical-align: middle;
  filter: drop-shadow(0 0 5px rgba(255, 51, 153, 0.75));
}

.menu-balances-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heroes-balance-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--retro-green-bright);
  letter-spacing: 1px;
  margin: 6px 0 14px 0;
  background: rgba(5, 8, 5, 0.85);
  padding: 6px 14px;
  border: 1px solid var(--retro-green-dim);
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(255, 51, 153, 0.35);
}

.title-logo-container {
  width: min(92vw, 560px);
  height: clamp(160px, 34vh, 260px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.title-logo-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 16px rgba(110, 245, 90, 0.6));
  animation: logoPulse 2.4s infinite ease-in-out;
}

@keyframes logoPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 16px rgba(110, 245, 90, 0.5));
  }
  50% {
    transform: scale(1.03);
    filter: drop-shadow(0 0 24px rgba(150, 255, 133, 0.8));
  }
}

.title-action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.title-sub-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.title-sub-btn {
  background: var(--retro-black);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
  color: var(--retro-green);
  padding: 10px 18px;
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 1.5px;
  box-shadow: 0 0 10px rgba(110, 245, 90, 0.3);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.title-sub-btn:hover, .title-sub-btn:active {
  background: var(--retro-green);
  color: var(--retro-black);
  transform: scale(1.05);
  outline-color: var(--retro-black);
}

.btn-start-game {
  background: var(--retro-black);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -4px;
  color: var(--retro-green);
  padding: 12px 28px;
  font-size: clamp(15px, 4vw, 20px);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 2px;
  box-shadow: 0 0 16px rgba(110, 245, 90, 0.45);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-start-game:hover, .btn-start-game:active {
  background: var(--retro-green);
  color: var(--retro-black);
  transform: scale(1.06);
  outline-color: var(--retro-black);
}

/* BARRA DE EXPERIENCIA FULLSCREEN (ARRIBA DEL TODO) */
#xp-bar-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: rgba(17, 42, 13, 0.9);
  border-bottom: 1px solid var(--retro-green-dim);
  z-index: 100;
}

#xp-bar-inner {
  height: 100%;
  width: 0%;
  background: var(--retro-green-bright);
  box-shadow: 0 0 8px var(--retro-green);
  transition: width 0.12s ease-out;
}

/* UI SUPERPUESTA RETRO EN PARTIDA */
#ui-layer {
  position: absolute;
  top: 6px;
  left: 0;
  width: 100%;
  height: calc(100% - 6px);
  pointer-events: none;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) env(safe-area-inset-right, 10px) calc(env(safe-area-inset-bottom, 0px) + 10px) env(safe-area-inset-left, 10px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  z-index: 130;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 38px;
  z-index: 50;
  gap: 8px;
  position: relative;
  pointer-events: none;
}

/* Elemento común del HUD con la misma altura (38px), borde y estética de los botones de acción */
.hud-item {
  background: rgba(5, 8, 5, 0.85);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(110, 245, 90, 0.35);
  box-sizing: border-box;
  pointer-events: auto;
  font-family: inherit;
  color: var(--retro-green);
  transition: all 0.15s ease;
}

/* Panel de Vida con icono de corazón */
.hp-hud-panel {
  padding: 0 10px;
  gap: 8px;
  flex-shrink: 0;
}

.heart-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url('../assets/pickups/hearts/heart_1x.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255, 55, 75, 0.7));
}

.hp-bar-outer {
  width: clamp(80px, 15vw, 130px);
  height: 12px;
  background: var(--retro-green-bg);
  border: 1px solid var(--retro-green-dim);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.hp-bar-inner {
  height: 100%;
  width: 100%;
  background: var(--retro-green);
  transition: width 0.15s ease-out;
  box-shadow: 0 0 6px var(--retro-green-bright);
}

.hp-label-val {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  min-width: 54px;
  text-align: right;
  color: var(--retro-green-bright);
}

/* Grupo central de estadísticas y temporizador */
.hud-center-group {
  display: flex;
  align-items: center;
  gap: 6px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
}

.hud-stat-badge {
  padding: 0 10px;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.hud-label {
  font-size: 11px;
  opacity: 0.85;
}

.hud-val {
  color: var(--retro-green-bright);
  font-size: 13px;
}

.hud-timer-badge {
  padding: 0 14px;
  min-width: 76px;
}

.hud-timer-val {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--retro-green-bright);
  text-shadow: 0 0 8px rgba(110, 245, 90, 0.6);
}

.top-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  pointer-events: auto;
}

/* BARRA INFERIOR DE ARMAS (WEAPONS HUD) */
.weapons-hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  pointer-events: none;
  z-index: 50;
  margin-bottom: 2px;
}

.weapon-slot {
  width: 38px;
  height: 38px;
  position: relative;
  overflow: hidden;
  padding: 0;
  cursor: default;
}

.weapon-slot.empty {
  border-color: rgba(110, 245, 90, 0.3);
  box-shadow: none;
  outline-color: rgba(17, 42, 13, 0.3);
  opacity: 0.65;
}

.weapon-slot.evolved {
  border-color: #ffd23f;
  outline-color: rgba(180, 140, 20, 0.6);
  box-shadow: 0 0 10px rgba(255, 210, 63, 0.45);
}

.weapon-slot.fused {
  border-color: #b43cff;
  outline-color: rgba(140, 40, 200, 0.6);
  box-shadow: 0 0 10px rgba(180, 60, 255, 0.5);
}

.weapon-slot-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.weapon-slot-cd {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: rgba(5, 8, 5, 0.65);
  pointer-events: none;
  transition: height 0.05s linear;
}

.weapon-slot-tag {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 9px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.5px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.weapon-slot.normal .weapon-slot-tag {
  color: #96ff85;
}

.weapon-slot.evolved .weapon-slot-tag {
  color: #ffd23f;
}

.weapon-slot.fused .weapon-slot-tag {
  color: #d47aff;
}

/* BOTONES DE LA TOP BAR ESTILIZADOS EN RETRO PIXEL */
.btn-retro {
  pointer-events: auto;
  background: rgba(5, 8, 5, 0.92);
  border: 2px solid var(--retro-green);
  color: var(--retro-green);
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 6px rgba(110, 245, 90, 0.3);
  transition: all 0.1s ease;
  white-space: nowrap;
  touch-action: manipulation;
  height: 28px;
  min-width: 32px;
}

.btn-retro:hover, .btn-retro:active {
  background: var(--retro-green);
  color: var(--retro-black);
}

.btn-retro .btn-short {
  display: none;
}

/* MODALES RETRO RESPONSIVE */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 200;
  padding: 12px;
}

.hidden {
  display: none !important;
}

/* ===================================================
   DISEÑO TEMÁTICO: ARCANO / RÚNICO CON DOBLE CANAL DE ENERGÍA
   =================================================== */

.retro-box {
  background: var(--retro-black);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -5px;
  padding: clamp(16px, 4vw, 28px);
  text-align: center;
  box-shadow: 0 0 24px rgba(110, 245, 90, 0.4), inset 0 0 14px rgba(17, 42, 13, 0.6);
  width: min(94vw, 760px);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--retro-green-dim) #050805;
}

/* Scrollbar retro estilizada e integrada */
.retro-box::-webkit-scrollbar {
  width: 6px;
}

.retro-box::-webkit-scrollbar-track {
  background: #050805;
  border-left: 1px solid var(--retro-green-dim);
}

.retro-box::-webkit-scrollbar-thumb {
  background: var(--retro-green-dim);
  border: 1px solid var(--retro-green);
  border-radius: 2px;
}

.retro-box::-webkit-scrollbar-thumb:hover {
  background: var(--retro-green);
  box-shadow: 0 0 8px var(--retro-green);
}

.modal-close-btn {
  position: sticky;
  top: 8px;
  margin-left: auto;
  margin-right: 0;
  margin-bottom: -32px;
  background: var(--retro-black);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
  color: var(--retro-green);
  font-size: 20px;
  font-weight: 700;
  width: 32px;
  height: 32px;
  line-height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(110, 245, 90, 0.4);
  transition: all 0.15s ease;
  z-index: 50;
}

.modal-close-btn:hover, .modal-close-btn:active {
  background: var(--retro-green);
  color: var(--retro-black);
}

.shop-balance-bar {
  font-size: 15px;
  font-weight: 700;
  color: var(--retro-green-bright);
  background: rgba(17, 42, 13, 0.85);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -4px;
  padding: 8px 14px;
  margin-bottom: 12px;
  letter-spacing: 1px;
  width: 100%;
  box-sizing: border-box;
}

/* CONTENEDOR HEROE EN LA TIENDA */
.shop-hero-preview-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  box-sizing: border-box;
}

.shop-hero-card {
  background: rgba(17, 42, 13, 0.95);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -4px;
  padding: 12px 16px;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  box-shadow: 0 0 16px rgba(110, 245, 90, 0.25), inset 0 0 10px rgba(0, 0, 0, 0.7);
  box-sizing: border-box;
}

.shop-hero-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.shop-hero-avatar-frame {
  width: 64px;
  height: 64px;
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
  background: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 8px rgba(110, 245, 90, 0.4);
}

.shop-hero-avatar-img {
  width: 52px;
  height: 52px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.shop-hero-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.shop-hero-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px dashed var(--retro-green-dim);
  padding-bottom: 4px;
}

.shop-hero-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--retro-green-bright);
  letter-spacing: 1px;
}

.shop-hero-desc {
  font-size: 11px;
  color: #b0f59a;
}

.shop-hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px 12px;
  background: rgba(5, 8, 5, 0.75);
  padding: 8px 10px;
  border: 1px solid var(--retro-green-dim);
}

.shop-stat-badge {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}

.shop-stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-stat-name {
  color: var(--retro-green);
  font-weight: 700;
  font-size: 10px;
}

.shop-stat-val {
  color: #ffffff;
  font-weight: 700;
}

.shop-stat-boost {
  color: var(--retro-green-bright);
  font-size: 10px;
  font-weight: 700;
  margin-left: 2px;
}

.shop-stat-track {
  width: 100%;
  height: 5px;
  background: var(--retro-green-bg);
  border: 1px solid var(--retro-green-dim);
  overflow: hidden;
}

.shop-stat-fill {
  height: 100%;
  background: var(--retro-green-bright);
  transition: width 0.25s ease;
}

@media (max-width: 580px) {
  .shop-hero-card {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    padding: 10px;
  }
  .shop-hero-info {
    text-align: center;
    width: 100%;
  }
  .shop-hero-header {
    justify-content: center;
  }
  .shop-hero-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
}

#shop-cards-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  margin-top: 12px;
}

#heroes-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  margin-top: 12px;
}

.shop-card {
  background: rgba(17, 42, 13, 0.85);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
  padding: 12px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  position: relative;
  box-sizing: border-box;
}

.shop-card-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--retro-green-bright);
}

.shop-card-level {
  font-size: 11px;
  color: var(--retro-green-dim);
}

.shop-card-desc {
  font-size: 11px;
  opacity: 0.85;
  min-height: 28px;
}

.shop-card-cost {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
  padding: 4px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  background: rgba(17, 42, 13, 0.65);
  padding: 8px 12px;
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
}

.setting-slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-value-display {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  color: var(--retro-green-bright);
  min-width: 40px;
  text-align: right;
}

/* Slider con estética Pixel Art Retro */
.retro-slider {
  -webkit-appearance: none;
  appearance: none;
  width: clamp(100px, 25vw, 150px);
  height: 8px;
  background: var(--retro-black);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -2px;
  border-radius: 0;
}

.retro-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 20px;
  background: var(--retro-green);
  border: 2px solid var(--retro-black);
  cursor: var(--retro-cursor-pointer) !important;
  box-shadow: 0 0 6px var(--retro-green-bright);
}

.retro-slider::-moz-range-thumb {
  width: 16px;
  height: 20px;
  background: var(--retro-green);
  border: 2px solid var(--retro-black);
  cursor: var(--retro-cursor-pointer) !important;
  border-radius: 0;
  box-shadow: 0 0 6px var(--retro-green-bright);
}

.retro-title {
  font-size: clamp(16px, 4.5vw, 22px);
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 14px;
  text-shadow: 0 0 10px var(--retro-green);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 36px; /* Deja espacio limpio para el botón de cerrar sin solaparse */
}

.retro-title::before,
.retro-title::after {
  content: "◈";
  font-size: 13px;
  color: var(--retro-green-bright);
  text-shadow: 0 0 6px var(--retro-green);
}

.cards-container {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.upgrade-card {
  background: rgba(17, 42, 13, 0.88);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -4px;
  padding: 14px 12px;
  width: clamp(140px, 42vw, 190px);
  min-height: 120px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
  box-sizing: border-box;
  position: relative;
}

.upgrade-card:hover, .upgrade-card:active {
  background: var(--retro-green);
  color: #050805 !important;
  box-shadow: 0 0 16px var(--retro-green);
  outline-color: #050805;
}

.upgrade-card .card-title {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upgrade-card .card-desc {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.upgrade-card:hover .card-title,
.upgrade-card:active .card-title {
  color: #050805 !important;
  text-shadow: none;
}

.upgrade-card:hover .card-desc,
.upgrade-card:active .card-desc {
  color: #112a0d !important;
  text-shadow: none;
}

/* ===================================================
   MODAL DE COFRE DEL TESORO (TEMA MORADO #b43cff)
   =================================================== */

#modal-chest .retro-box {
  border-color: var(--retro-purple);
  outline-color: var(--retro-purple-dim);
  box-shadow: 0 0 26px rgba(180, 60, 255, 0.45), inset 0 0 16px rgba(34, 8, 54, 0.7);
  scrollbar-color: var(--retro-purple-dim) #050805;
}

#modal-chest .retro-box::-webkit-scrollbar-track {
  border-left-color: var(--retro-purple-dim);
}

#modal-chest .retro-box::-webkit-scrollbar-thumb {
  background: var(--retro-purple-dim);
  border-color: var(--retro-purple);
}

#modal-chest .retro-box::-webkit-scrollbar-thumb:hover {
  background: var(--retro-purple);
  box-shadow: 0 0 8px var(--retro-purple);
}

#modal-chest .retro-title {
  color: var(--retro-purple);
  text-shadow: 0 0 10px var(--retro-purple);
}

#modal-chest .retro-title::before,
#modal-chest .retro-title::after {
  color: var(--retro-purple-bright);
  text-shadow: 0 0 6px var(--retro-purple);
}

#modal-chest #chest-modal-subtitle {
  color: var(--retro-purple-bright) !important;
  text-shadow: 0 0 8px rgba(180, 60, 255, 0.5);
}

#modal-chest .upgrade-card {
  background: rgba(34, 8, 54, 0.88);
  border-color: var(--retro-purple);
  outline-color: var(--retro-purple-dim);
  color: var(--retro-purple);
}

#modal-chest .upgrade-card .card-title {
  color: var(--retro-purple-bright);
  text-shadow: 0 0 8px var(--retro-purple);
}

#modal-chest .upgrade-card .card-desc {
  color: #eedaff;
  text-shadow: 0 0 4px rgba(180, 60, 255, 0.3);
}

#modal-chest .upgrade-card:hover,
#modal-chest .upgrade-card:active {
  background: var(--retro-purple);
  color: #0d0214 !important;
  box-shadow: 0 0 18px var(--retro-purple);
  outline-color: #0d0214;
}

#modal-chest .upgrade-card:hover .card-title,
#modal-chest .upgrade-card:active .card-title {
  color: #0d0214 !important;
  text-shadow: none;
}

#modal-chest .upgrade-card:hover .card-desc,
#modal-chest .upgrade-card:active .card-desc {
  color: #220836 !important;
  text-shadow: none;
}

/* TARJETAS DE HÉROES */
.hero-card {
  background: rgba(17, 42, 13, 0.88);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -4px;
  padding: 14px 12px;
  width: 100%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  touch-action: manipulation;
  box-sizing: border-box;
  position: relative;
}

.hero-card:not(.locked):hover, .hero-card:not(.locked):active {
  background: rgba(28, 70, 22, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(110, 245, 90, 0.45);
}

.hero-card.locked {
  opacity: 0.55;
  border-color: var(--retro-green-dim);
  outline-color: #0a1708;
  cursor: not-allowed;
}

.hero-card.selected {
  outline: 2px solid var(--retro-green-bright);
  background: rgba(45, 110, 35, 0.95);
  box-shadow: 0 0 12px rgba(150, 255, 133, 0.5);
}

.hero-preview-frame {
  width: 60px;
  height: 60px;
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
  background: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 4px;
  box-shadow: inset 0 0 8px rgba(110, 245, 90, 0.3);
}

.hero-preview-img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hero-preview-img.locked-img {
  filter: brightness(0.4) grayscale(1);
}

.hero-stats-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
  background: rgba(5, 8, 5, 0.7);
  padding: 6px;
  border: 1px solid var(--retro-green-dim);
}

.hero-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 11px;
}

.stat-name {
  width: 58px;
  text-align: left;
  font-weight: 700;
  color: var(--retro-green);
}

.stat-bar-track {
  flex: 1;
  height: 6px;
  background: var(--retro-green-bg);
  border: 1px solid var(--retro-green-dim);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--retro-green-bright);
}

.stat-val {
  width: 24px;
  text-align: right;
  font-weight: 700;
}

.hero-status-tag {
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}

.hero-status-tag.locked-tag {
  color: #ff6b6b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.hero-status-tag.locked-tag.can-buy {
  color: #00f5ff;
  text-shadow: 0 0 6px rgba(0, 245, 255, 0.6);
}

.hero-status-tag.locked-tag.cannot-buy {
  color: #ff5599;
}

.hero-status-tag.selected-tag {
  color: var(--retro-green-bright);
}

.hero-status-tag.ready-tag {
  color: var(--retro-green);
}

.card-title {
  font-size: clamp(12px, 3.4vw, 15px);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.card-desc {
  font-size: clamp(10px, 2.7vw, 12px);
  line-height: 1.35;
  color: #b0f59a;
}

.retro-text {
  font-size: clamp(13px, 3.5vw, 16px);
  margin-bottom: 16px;
  line-height: 1.5;
}

.retro-btn {
  background: var(--retro-black);
  border: 2px solid var(--retro-green);
  outline: 1px solid var(--retro-green-dim);
  outline-offset: -3px;
  color: var(--retro-green);
  padding: 8px 20px;
  font-size: clamp(13px, 3.8vw, 16px);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s ease;
  touch-action: manipulation;
  white-space: nowrap;
}

.retro-btn:hover, .retro-btn:active {
  background: var(--retro-green);
  color: var(--retro-black);
  outline-color: var(--retro-black);
}

/* Virtual Joystick */
#joystick-zone {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: auto;
  touch-action: none;
  z-index: 10;
}

#joystick-base {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid var(--retro-green);
  background: rgba(17, 42, 13, 0.4);
  box-shadow: 0 0 12px rgba(110, 245, 90, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  z-index: 15;
}

#joystick-stick {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--retro-green);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px var(--retro-green);
}

/* MEDIA QUERIES EN PANTALLAS ESTRECHAS / MÓVILES VERTICALES */
@media (max-width: 480px) {
  #ui-layer {
    padding: 6px;
  }

  .title-logo-container {
    height: clamp(140px, 30vh, 220px);
    width: 94vw;
  }

  /* Menú de inicio en móvil: Iniciar juego arriba y debajo Héroes y Tienda lado a lado */
  .title-action-row {
    flex-direction: column;
    width: 90vw;
    max-width: 340px;
    gap: 10px;
  }

  .title-action-row .btn-start-game {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    font-size: 16px;
  }

  .title-sub-row {
    display: flex;
    width: 100%;
    gap: 8px;
  }

  .title-sub-row .title-sub-btn {
    flex: 1;
    box-sizing: border-box;
    padding: 10px 8px;
    font-size: 13px;
    text-align: center;
  }

  .retro-box {
    padding: 14px 8px;
    width: 96vw;
  }

  .cards-container {
    gap: 8px;
  }

  /* Mostrar las tarjetas de la tienda y héroes de 2 en 2 en móvil */
  #shop-cards-container,
  #heroes-cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }

  .hero-card {
    width: 100% !important;
    padding: 8px 4px;
    gap: 4px;
  }

  .hero-card .card-title {
    font-size: 11px;
    letter-spacing: 0px;
    line-height: 1.2;
  }

  .hero-card .card-desc {
    font-size: 9px;
    line-height: 1.2;
    min-height: 22px;
  }

  .hero-card .hero-preview-frame {
    width: 44px;
    height: 44px;
    margin-bottom: 2px;
  }

  .hero-card .hero-preview-img {
    width: 36px;
    height: 36px;
  }

  .hero-stats-grid {
    padding: 4px;
    gap: 3px;
    margin: 4px 0;
  }

  .hero-stat-row {
    font-size: 9px;
    gap: 2px;
  }

  .hero-stat-row .stat-name {
    width: 38px;
    font-size: 8px;
  }

  .hero-stat-row .stat-bar-track {
    height: 4px;
  }

  .hero-stat-row .stat-val {
    width: 22px;
    font-size: 8px;
  }

  .hero-status-tag {
    font-size: 9px;
    margin-top: 1px;
  }

  .shop-card {
    width: 100% !important;
    padding: 8px 4px;
    gap: 4px;
  }

  .shop-card-title {
    font-size: 11px;
    letter-spacing: 0px;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .shop-card-level {
    font-size: 9px;
  }

  .shop-card-desc {
    font-size: 9px;
    min-height: 28px;
    line-height: 1.25;
  }

  .shop-card-cost {
    font-size: 11px;
    margin-top: 2px;
  }

  .shop-card .retro-btn {
    padding: 4px 6px;
    font-size: 9px;
    letter-spacing: 0px;
    width: 94%;
  }

  .top-bar {
    gap: 4px;
    height: 32px;
  }

  .hud-item {
    height: 32px;
  }

  .weapon-slot {
    width: 32px;
    height: 32px;
  }

  .hp-hud-panel {
    padding: 0 6px;
    gap: 4px;
  }

  .hp-bar-outer {
    width: 65px;
    height: 9px;
  }

  .hp-label-val {
    font-size: 11px;
    min-width: 44px;
  }

  .hud-stat-badge {
    padding: 0 6px;
    gap: 4px;
    font-size: 11px;
  }

  .hud-timer-badge {
    padding: 0 8px;
    min-width: 60px;
  }

  .hud-timer-val {
    font-size: 14px;
  }

  /* En móviles estrechos mostrar etiquetas compactas */
  .btn-retro {
    padding: 4px 6px;
    font-size: 11px;
    height: 26px;
  }

  .btn-retro .btn-full {
    display: none;
  }

  .btn-retro .btn-short {
    display: inline;
  }
}
