/* style.css — Dirección de arte "épico de batalla": piedra, oro y acentos de bando.
   Mantiene los nombres de clase que usa el JS. Pantalla completa, móvil + escritorio. */

:root {
  --oro:   #ffd24a;
  --oro2:  #c79320;
  --azul:  #4aa3ff;
  --rojo:  #ff5a4d;
  --texto: #eaf0fb;
  --texto2:#9aa6bd;
  --panel:  rgba(26,32,46,0.92);
  --panel2: rgba(18,22,33,0.95);
  --piedra: #3a4150;
  --borde:  rgba(255,210,74,0.30);
  --sombra: 0 8px 30px rgba(0,0,0,0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0e16;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#gameCanvas { display: block; width: 100%; height: 100%; background: #0a0e16; }

/* Tipografía de títulos (épica, con serifa). */
.menu-panel h1, .go-panel h1, #banner { font-family: "Georgia", "Times New Roman", serif; }

/* ---- Viñeta de daño ---- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0;
  box-shadow: inset 0 0 150px 50px rgba(255,60,50,0.8);
  transition: opacity 0.18s ease;
}

/* ---- Banner de evento (nivel / objetivo) ---- */
#banner {
  position: fixed; top: 20%; left: 50%;
  transform: translateX(-50%) scale(0.8);
  z-index: 6; pointer-events: none;
  font-size: 32px; font-weight: 800; letter-spacing: 1px;
  color: var(--texto);
  text-shadow: 0 3px 16px rgba(0,0,0,0.9);
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.2,1.4,.4,1);
  text-align: center; white-space: nowrap;
}
#banner.visible { opacity: 1; transform: translateX(-50%) scale(1); }
#banner.jefe { color: var(--oro); font-size: 40px; text-shadow: 0 0 26px rgba(255,170,60,0.9), 0 3px 10px #000; }

/* ===================== HUD ===================== */
#hud { position: fixed; inset: 0; pointer-events: none; color: var(--texto); }
#hud button, #hud .recurso, #hud .recurso-sec { pointer-events: auto; }

/* ---- Barra superior ---- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px calc(10px) ;
  background: linear-gradient(to bottom, rgba(10,14,22,0.92), rgba(10,14,22,0));
}
#oro {
  font-size: 22px; font-weight: 800; color: var(--oro);
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.recurso-sec {
  font-size: 13px; color: var(--texto2); font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,0.28); padding: 3px 9px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}
#poblacion { color: #cdd6ea; }

/* ---- Botón silenciar ---- */
.btn-mute {
  position: absolute; top: 10px; right: 12px; z-index: 7;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--borde); background: var(--panel2);
  color: var(--texto); font-size: 18px; cursor: pointer;
  box-shadow: var(--sombra);
  transition: transform 0.06s ease, background 0.12s ease;
}
.btn-mute:active { transform: scale(0.9); }

/* ---- Tienda inferior ---- */
#shop {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(to top, rgba(10,14,22,0.96), rgba(10,14,22,0));
}
/* Cada grupo es UNA fila; los botones se reparten el ancho sin envolverse ni encimarse. */
.shop-grupo { display: flex; flex-wrap: nowrap; gap: 5px; justify-content: center; }

/* ---- Cartel de ayuda (en la zona del cielo, arriba: NO tapa la batalla) ---- */
#tip {
  position: absolute; top: 56px; bottom: auto; left: 50%; transform: translateX(-50%);
  max-width: min(86vw, 560px); padding: 8px 14px;
  background: var(--panel); border: 1px solid var(--borde); border-radius: 16px;
  font-size: 13px; color: #d6deee; white-space: nowrap; text-align: center; pointer-events: none;
  opacity: 1; transition: opacity 0.4s ease; box-shadow: var(--sombra);
}
#tip.oculto { opacity: 0; }
#tip b { color: var(--oro); }
@media (max-width: 620px) { #tip { white-space: normal; font-size: 12px; top: 52px; padding: 7px 12px; } }

/* ---- Botones de compra (tarjetas de piedra) ---- */
.btn-compra {
  flex: 1 1 0; min-width: 0; max-width: 170px; min-height: 52px;
  padding: 6px 6px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 11px;
  background: linear-gradient(to bottom, #283146, #1a2030);
  color: var(--texto); font-size: 13px; font-weight: 600;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; line-height: 1.15;
  box-shadow: 0 2px 0 rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: transform 0.06s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn-compra .btn-titulo { font-size: 12.5px; font-weight: 700; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.btn-compra .btn-sub    { font-size: 10px; color: var(--texto2); font-weight: 500; white-space: nowrap; }
.btn-compra .btn-costo  { font-size: 12px; color: var(--oro); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.btn-compra:active { transform: translateY(2px) scale(0.97); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }

.btn-compra.asequible { border-color: rgba(255,210,74,0.45); box-shadow: 0 0 12px rgba(255,210,74,0.18), 0 2px 0 rgba(0,0,0,0.4); }
.btn-compra.asequible:hover { filter: brightness(1.1); }
.btn-compra.bloqueado { opacity: 0.42; cursor: not-allowed; }
.btn-compra.bloqueado .btn-costo { color: var(--rojo); }

.btn-compra.u-espadachin { border-left: 4px solid var(--azul); }
.btn-compra.u-arquero    { border-left: 4px solid #e3b341; }
.btn-compra.u-tanque     { border-left: 4px solid #a371f7; }
.btn-compra.u-mago       { border-left: 4px solid #d2a8ff; }
.btn-compra.minero       { border-left: 4px solid #46d06a; }
.btn-compra.mejora       { border-left: 4px solid var(--oro); }

@media (min-width: 900px) { .btn-compra { min-width: 122px; font-size: 14px; } }

/* ---- Botón de habilidad (con barrido radial de recarga) ---- */
.btn-habilidad {
  position: absolute; right: 14px; bottom: 122px;
  width: 78px; height: 78px; border-radius: 50%;
  border: 2px solid var(--oro);
  background: radial-gradient(circle at 50% 35%, #d23b2f, #6e1414);
  color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; overflow: hidden;
  box-shadow: 0 0 18px rgba(255,210,74,0.4);
  transition: transform 0.06s ease, filter 0.12s ease;
  animation: habPulso 1.8s ease-in-out infinite;
}
.btn-habilidad .hab-nombre { font-size: 26px; line-height: 1; }
.btn-habilidad .hab-estado { font-size: 10px; font-weight: 700; }
.btn-habilidad:active { transform: scale(0.92); }
/* Barrido de recarga: superpone un sector oscuro proporcional a --cd. */
.btn-habilidad::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(rgba(0,0,0,0.62) var(--cd, 0deg), rgba(0,0,0,0) 0);
}
.btn-habilidad.recargando { filter: grayscale(0.5) brightness(0.8); border-color: #5a6478; box-shadow: none; animation: none; }
@keyframes habPulso { 0%,100% { box-shadow: 0 0 14px rgba(255,210,74,0.35); } 50% { box-shadow: 0 0 26px rgba(255,210,74,0.7); } }
@media (min-width: 900px) { .btn-habilidad { width: 90px; height: 90px; bottom: 112px; } }

/* ===================== PANELES (game over / menú) ===================== */
#gameover {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(20,12,12,0.78), rgba(6,8,14,0.92));
  backdrop-filter: blur(4px); transition: opacity 0.3s ease;
}
#gameover.oculto { opacity: 0; pointer-events: none; }
.go-panel, .menu-panel {
  background: var(--panel); border: 1px solid var(--borde); border-radius: 18px;
  box-shadow: var(--sombra), inset 0 1px 0 rgba(255,255,255,0.05);
}
.go-panel { padding: 28px 30px; text-align: center; width: min(90vw, 390px); }
.go-panel h1 { font-size: 32px; margin-bottom: 6px; color: var(--rojo); text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.go-sub { color: var(--texto2); margin-bottom: 20px; }
.go-stats { display: flex; flex-direction: column; gap: 9px; margin-bottom: 22px; }
.go-stats > div {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(0,0,0,0.3); border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.05);
}
.go-label { color: var(--texto2); font-size: 14px; }
.go-valor { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--oro); }
.go-gemas { border-color: rgba(210,168,255,0.4) !important; }
.go-gemas .go-valor { color: #d2a8ff; }
.go-acciones { display: flex; flex-direction: column; gap: 10px; }

.btn-reiniciar {
  width: 100%; min-height: 54px; border: none; border-radius: 12px;
  background: linear-gradient(to bottom, #46d06a, #2ea043); color: #06210f;
  font-size: 17px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 14px rgba(46,160,67,0.4);
  transition: filter 0.12s ease, transform 0.06s ease;
}
.btn-reiniciar:hover { filter: brightness(1.08); }
.btn-reiniciar:active { transform: scale(0.97); }
.btn-secundario {
  width: 100%; min-height: 48px; border: 1px solid rgba(210,168,255,0.5); border-radius: 12px;
  background: rgba(40,26,60,0.8); color: #d2a8ff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background 0.12s ease, transform 0.06s ease;
}
.btn-secundario:hover { background: rgba(56,36,80,0.9); }
.btn-secundario:active { transform: scale(0.97); }

/* ===================== MENÚ ===================== */
#menu {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 25%, #1b2336, #0a0e16 75%);
  overflow-y: auto; padding: 20px; transition: opacity 0.35s ease;
}
#menu.oculto { opacity: 0; visibility: hidden; pointer-events: none; }
.menu-panel { width: min(94vw, 470px); text-align: center; padding: 24px 22px; }
.menu-panel h1 { font-size: 30px; margin-bottom: 12px; color: var(--oro); text-shadow: 0 0 22px rgba(255,180,60,0.45), 0 2px 8px #000; }
.menu-panel h2 { font-size: 15px; color: var(--texto2); margin: 18px 0 6px; font-weight: 700; letter-spacing: 0.5px; }
.menu-gemas { font-size: 26px; font-weight: 800; color: #d2a8ff; margin-bottom: 8px; text-shadow: 0 0 16px rgba(210,168,255,0.4); }
.menu-stats { display: flex; justify-content: center; gap: 18px; font-size: 13px; color: var(--texto2); }
.menu-stats b { color: var(--texto); }
.menu-explica { font-size: 12px; color: var(--texto2); margin: 0 0 12px; line-height: 1.4; }
.menu-explica b { color: #d2a8ff; }

.meta-lista { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.meta-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(0,0,0,0.28); border: 1px solid rgba(255,255,255,0.06);
  border-left: 4px solid #8957e5; border-radius: 10px; text-align: left;
}
.meta-info { flex: 1; min-width: 0; }
.meta-nombre { font-size: 14px; font-weight: 700; }
.meta-nombre .meta-nivel { color: #d2a8ff; font-weight: 600; margin-left: 6px; font-size: 12px; }
.meta-desc { font-size: 11px; color: var(--texto2); }
.btn-meta {
  flex: 0 0 auto; min-width: 76px; min-height: 46px; border: 1px solid rgba(210,168,255,0.5);
  border-radius: 10px; background: rgba(40,26,60,0.8); color: #d2a8ff;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background 0.12s ease, transform 0.06s ease, opacity 0.12s ease;
}
.btn-meta:active { transform: scale(0.94); }
.btn-meta.asequible { border-color: #a371f7; background: rgba(56,36,80,0.95); box-shadow: 0 0 12px rgba(163,113,247,0.3); }
.btn-meta.bloqueado { opacity: 0.4; cursor: not-allowed; }
.btn-meta.maximo { opacity: 0.7; cursor: default; border-color: #46d06a; color: #46d06a; }

.menu-bonos {
  margin: 0 0 14px; padding: 10px 12px;
  background: rgba(255,210,74,0.08); border: 1px solid rgba(255,210,74,0.35); border-radius: 10px;
  font-size: 12.5px; color: #e8edf6; line-height: 1.5;
}
.menu-bonos .mb-label { display: block; color: var(--oro); font-weight: 700; font-size: 11px; letter-spacing: 0.5px; margin-bottom: 3px; text-transform: uppercase; }

.btn-jugar {
  width: 100%; min-height: 60px; border: none; border-radius: 14px;
  background: linear-gradient(to bottom, #ffd970, #e0a020); color: #3a2400;
  font-size: 21px; font-weight: 800; letter-spacing: 0.5px; cursor: pointer;
  box-shadow: 0 6px 22px rgba(224,160,32,0.45);
  transition: transform 0.06s ease, filter 0.12s ease;
}
.btn-jugar:hover { filter: brightness(1.08); }
.btn-jugar:active { transform: scale(0.97); }

/* ===================== AJUSTES MÓVIL ===================== */
@media (max-width: 620px) {
  #topbar { gap: 6px; padding: 8px 10px; }
  #oro { font-size: 19px; }
  .recurso-sec { font-size: 11px; padding: 2px 7px; }
  .btn-mute { width: 36px; height: 36px; font-size: 16px; top: 8px; right: 8px; }

  .btn-compra { min-height: 50px; padding: 5px 4px; }
  .btn-compra .btn-titulo { font-size: 11px; }
  .btn-compra .btn-sub { font-size: 9px; }
  .btn-compra .btn-costo { font-size: 11px; }

  /* La habilidad va ENCIMA de la tienda, sin encimarse con los botones. */
  .btn-habilidad { width: 60px; height: 60px; right: 8px; bottom: 132px; }
  .btn-habilidad .hab-nombre { font-size: 20px; }
  .btn-habilidad .hab-estado { font-size: 9px; }
}
