/* ============================================
   LEYENDAS - Argentine Urban Legends Fighting Game
   ============================================ */

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-10px) rotate(-4deg); }
  30% { transform: translateX(10px) rotate(4deg); }
  45% { transform: translateX(-6px) rotate(-2deg); }
  60% { transform: translateX(6px) rotate(2deg); }
  75% { transform: translateX(-3px) rotate(-1deg); }
}

@keyframes lungeRight {
  0% { transform: translateX(0); }
  50% { transform: translateX(60px) scale(1.1); }
  100% { transform: translateX(0); }
}

@keyframes lungeLeft {
  0% { transform: translateX(0); }
  50% { transform: translateX(-60px) scale(1.1); }
  100% { transform: translateX(0); }
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-50px) scale(1.3); }
}

@keyframes barFill {
  from { width: 0%; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.3); }
  50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.6); }
}

@keyframes cardAppear {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.02); }
}

@keyframes victoryBounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-10px) rotate(-3deg); }
  50% { transform: translateY(0) rotate(0); }
  75% { transform: translateY(-5px) rotate(3deg); }
}

@keyframes healGlow {
  0% { box-shadow: 0 0 5px rgba(74, 222, 128, 0.3); }
  50% { box-shadow: 0 0 25px rgba(74, 222, 128, 0.7); }
  100% { box-shadow: 0 0 5px rgba(74, 222, 128, 0.3); }
}

@keyframes defendPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ---- Utility ---- */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

.leyenda-hidden {
  display: none !important;
}

/* ============================================
   CHARACTER SELECTION SCREEN
   ============================================ */
#selectScreen {
  padding: 1rem 0;
}

.select-header {
  text-align: center;
  margin-bottom: 2rem;
}

.select-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.select-subtitle {
  font-size: 1.1rem;
  color: #6b7280;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

.char-card {
  background: white;
  border-radius: 16px;
  padding: 1.2rem;
  border: 2px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: cardAppear 0.4s ease-out backwards;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.char-card:hover {
  border-color: #6366f1;
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

.char-card:active {
  transform: scale(0.97);
}

.char-sprite {
  width: 80px;
  height: 80px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-sprite svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.char-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0.25rem;
  text-align: center;
}

.char-desc {
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
  margin-bottom: 0.75rem;
}

.char-stats {
  width: 100%;
  margin-bottom: 0.75rem;
}

.char-stat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  width: 28px;
  flex-shrink: 0;
}

.stat-bar {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.stat-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.char-special {
  width: 100%;
  text-align: center;
}

.special-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.special-desc {
  font-size: 0.7rem;
  color: #9ca3af;
  line-height: 1.3;
}

/* ============================================
   BATTLE SCREEN
   ============================================ */
#battleScreen {
  padding: 1rem 0;
  max-width: 900px;
  margin: 0 auto;
}

/* ---- Turn Indicator ---- */
.turn-indicator {
  text-align: center;
  padding: 0.6rem 1.5rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  display: inline-block;
  animation: fadeIn 0.3s ease;
}

.player-turn {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
}

.cpu-turn {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
}

/* ---- Health Bars (Top) ---- */
.hp-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 0 1rem;
}

.hp-block {
  flex: 1;
  max-width: 320px;
}

.hp-block.cpu {
  text-align: right;
}

.hp-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hp-block.cpu .hp-label {
  justify-content: flex-end;
}

.hp-bar-bg {
  width: 100%;
  height: 22px;
  background: #e5e7eb;
  border-radius: 11px;
  overflow: hidden;
  position: relative;
  border: 2px solid #d1d5db;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 9px;
  transition: width 0.5s ease, background 0.3s ease;
  position: relative;
}

.hp-fill.hp-mid {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.hp-fill.hp-low {
  background: linear-gradient(90deg, #ef4444, #f87171);
  animation: pulse 1s ease-in-out infinite;
}

.hp-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7280;
  margin-top: 0.2rem;
}

/* ---- Fighter Arena ---- */
.battle-arena {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
  border-radius: 20px;
  border: 2px solid #e5e7eb;
  min-height: 220px;
  position: relative;
}

.fighter-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.fighter-side.player {
  align-items: flex-start;
}

.fighter-side.cpu {
  align-items: flex-end;
}

.fighter-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0.75rem;
  padding: 0.3rem 0.8rem;
  background: white;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.fighter-sprite {
  padding: 0.5rem;
  border-radius: 20px;
  background: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
  position: relative;
  width: 120px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.fighter-sprite svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.15));
}

/* CPU sprites are mirrored to face player */
.fighter-side.cpu .fighter-sprite svg {
  transform: scaleX(-1);
}

/* Idle breathing animation */
.fighter-sprite[data-state="idle"] svg .sprite-body {
  animation: breathe 2s ease-in-out infinite;
}

.fighter-sprite.shake {
  animation: shake 0.5s ease-in-out;
}

.fighter-sprite.attack-lunge {
  animation: lungeRight 0.4s ease-in-out;
}

.fighter-side.cpu .fighter-sprite.attack-lunge {
  animation: lungeLeft 0.4s ease-in-out;
}

/* Victory animation */
.fighter-sprite[data-state="victory"] svg .sprite-body {
  animation: victoryBounce 0.8s ease-in-out infinite;
}

/* Defeat animation */
.fighter-sprite[data-state="defeat"] svg .sprite-body {
  animation: none;
  opacity: 0.6;
}

/* Heal glow */
.fighter-sprite[data-state="heal"] {
  animation: healGlow 0.8s ease-in-out;
}

/* Defend shield pulse */
.fighter-sprite[data-state="defend"] svg {
  animation: defendPulse 0.6s ease-in-out;
}

/* Damage numbers */
.damage-float {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  font-weight: 900;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}

.damage-float.damage {
  color: #ef4444;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.damage-float.heal {
  color: #22c55e;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.damage-float.show {
  animation: floatUp 1s ease-out forwards;
}

/* VS badge */
.vs-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 900;
  color: #6b7280;
  background: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border: 3px solid #e5e7eb;
}

/* ---- Action Buttons ---- */
.action-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0 1rem;
}

.action-btn {
  padding: 1rem 0.5rem;
  border-radius: 14px;
  border: none;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  color: white;
  position: relative;
  overflow: hidden;
}

.action-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.15s;
}

.action-btn:hover::before {
  opacity: 1;
}

.action-btn:active {
  transform: scale(0.95);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.action-btn .btn-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.action-btn .btn-label {
  font-size: 0.8rem;
}

.btn-attack {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-special {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-defend {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-heal {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ---- Status Info ---- */
.status-bar {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.status-text {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  background: #f3f4f6;
}

.status-text.ready {
  color: #059669;
  background: #d1fae5;
}

.status-text.cooldown {
  color: #dc2626;
  background: #fee2e2;
}

/* ---- Battle Log ---- */
.battle-log-container {
  margin: 0 1rem;
  background: #f9fafb;
  border-radius: 14px;
  padding: 0.75rem 1rem;
  border: 1px solid #e5e7eb;
  max-height: 150px;
  overflow-y: auto;
}

.battle-log-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

#battleLog {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.log-entry {
  font-size: 0.85rem;
  color: #4b5563;
  padding: 0.25rem 0;
  border-bottom: 1px solid #e5e7eb;
  animation: fadeIn 0.2s ease;
}

.log-entry:last-child {
  border-bottom: none;
}

/* ============================================
   RESULT SCREEN
   ============================================ */
#resultScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 2rem;
}

.result-card {
  background: white;
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  border: 2px solid #e5e7eb;
  max-width: 380px;
  width: 100%;
  animation: fadeInScale 0.5s ease-out;
}

.result-emoji {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 1rem;
  display: block;
}

.result-title {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.result-title.win {
  color: #059669;
}

.result-title.lose {
  color: #dc2626;
}

.result-text {
  font-size: 1rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-btn {
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.result-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.result-btn.primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
}

.result-btn.secondary {
  background: #f3f4f6;
  color: #374151;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
  .select-title {
    font-size: 1.8rem;
  }

  .character-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 0 0.75rem;
  }

  .char-card {
    padding: 0.9rem;
  }

  .char-emoji {
    font-size: 2.5rem;
  }

  .char-name {
    font-size: 0.95rem;
  }

  .battle-arena {
    min-height: 160px;
    padding: 1rem;
  }

  .fighter-sprite {
    font-size: 3rem;
    width: 80px;
    height: 80px;
  }

  .vs-badge {
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }

  .action-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .action-btn {
    padding: 0.75rem 0.4rem;
  }

  .action-btn .btn-icon {
    font-size: 1.2rem;
  }

  .action-btn .btn-label {
    font-size: 0.75rem;
  }

  .hp-section {
    gap: 0.75rem;
    padding: 0 0.75rem;
  }

  .hp-bar-bg {
    height: 18px;
  }

  .fighter-name {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
  }

  .damage-float {
    font-size: 1.2rem;
  }
}
