/* ==========================================================================
   GRAND LEGENDS TCG — DUEL FIELD OVERHAUL (v6.8.3)
   - Yu-Gi-Oh! Forbidden Memories (PS1) 3D Stone Arena & Ancient Runes
   - Pokémon GBA Style Battle Animations (Slash, Screen Shake, Floating Retro Text)
   - Yu-Gi-Oh! Duel Links Interactive Targeting Beams, Reticles & Phase Banners
   ========================================================================== */

:root {
  --fm-stone-dark: #0d0f14;
  --fm-stone-border: #2a313d;
  --fm-gold-ancient: #e5b94c;
  --fm-gold-bright: #ffd700;
  --fm-gold-glow: rgba(229, 185, 76, 0.45);
  --fm-rune-cyan: #38bdf8;
  --fm-rune-purple: #c084fc;
  --fm-crimson: #ef4444;
  --duel-links-laser: #00f0ff;
  --duel-links-laser-glow: rgba(0, 240, 255, 0.65);
  --duel-links-target: #ff0055;
  --gba-slash-color: #ffffff;
}

/* ==========================================================================
   1. FORBIDDEN MEMORIES ANCIENT COLISEUM ARENA (2D TACTICAL FIELD)
   ========================================================================== */
.arena-view-container {
  position: relative;
  width: 100%;
}

.battle-arena {
  position: relative;
  border: 3px solid var(--fm-gold-ancient) !important;
  border-radius: 20px !important;
  background: 
    radial-gradient(ellipse at 50% 50%, rgba(30, 42, 60, 0.45) 0%, rgba(13, 17, 26, 0.95) 65%, rgba(6, 8, 12, 0.99) 100%),
    linear-gradient(135deg, #111520 0%, #0a0d14 50%, #130f18 100%) !important;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.9),
    0 0 30px var(--fm-gold-glow),
    inset 0 0 45px rgba(0, 0, 0, 0.85) !important;
  transition: box-shadow 0.3s ease;
  overflow: visible !important;
  padding: 12px !important;
}

/* Modo 2D Clásico Estable */
.battle-arena.mode-2d,
.battle-arena.mode-3d {
  transform: none !important;
}

/* Bordes Rúnicos Místicos Antiguos (Monolito Forbidden Memories) */
.battle-arena::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(229, 185, 76, 0.35);
  border-radius: 15px;
  pointer-events: none;
  z-index: 1;
}

/* Zonas de Campo: Rival vs Jugador */
.arena-half.enemy-half {
  background: radial-gradient(ellipse at 50% 20%, rgba(55, 18, 30, 0.35) 0%, rgba(18, 12, 18, 0.25) 75%, transparent 100%);
  border-radius: 14px 14px 0 0;
  padding: 8px 10px;
  position: relative;
}

.arena-half.player-half {
  background: radial-gradient(ellipse at 50% 80%, rgba(18, 36, 62, 0.35) 0%, rgba(10, 15, 26, 0.25) 75%, transparent 100%);
  border-radius: 0 0 14px 14px;
  padding: 8px 10px;
  position: relative;
}

/* Badges de Lados del Campo */
.field-side-tag.enemy-tag {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.25), rgba(120, 20, 35, 0.35));
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.field-side-tag.player-tag {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.25), rgba(20, 50, 85, 0.35));
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Bandeja del Campo de Invocación */
.field-zone-container {
  background: rgba(8, 11, 18, 0.55);
  border: 1.5px dashed rgba(229, 185, 76, 0.28);
  border-radius: 14px;
  padding: 8px 10px;
  margin: 6px 0;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

.field-zone-container.enemy-zone {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(18, 10, 14, 0.5);
}

/* Pedestales de Invocación Tallados en Piedra */
.arena-unit {
  position: relative;
  background: linear-gradient(180deg, #1f2738 0%, #111624 100%) !important;
  border: 2px solid #5a4625 !important;
  border-radius: 12px !important;
  box-shadow: 
    0 8px 18px rgba(0, 0, 0, 0.75),
    inset 0 1px 3px rgba(255, 215, 0, 0.3),
    inset 0 -3px 8px rgba(0, 0, 0, 0.7) !important;
  color: #f3f4f6 !important;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease !important;
}

.arena-unit:hover {
  transform: translateY(-5px) scale(1.02) !important;
  border-color: var(--fm-gold-bright) !important;
  box-shadow: 
    0 14px 28px rgba(0, 0, 0, 0.85),
    0 0 18px rgba(255, 215, 0, 0.45) !important;
  z-index: 15;
}

.arena-unit.enemy {
  background: linear-gradient(180deg, #2d1a22 0%, #160d13 100%) !important;
  border-color: #702f3b !important;
}

.arena-unit.enemy:hover {
  transform: translateY(-5px) scale(1.02) !important;
  border-color: #f87171 !important;
  box-shadow: 
    0 14px 28px rgba(0, 0, 0, 0.85),
    0 0 18px rgba(248, 113, 113, 0.45) !important;
  z-index: 15;
}

/* Retratos de Líderes como Altares Monolíticos */
.arena-leader {
  background: linear-gradient(180deg, #2c1f14 0%, #140d08 100%) !important;
  border: 2px solid var(--fm-gold-ancient) !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.85), inset 0 0 15px rgba(229, 185, 76, 0.25) !important;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease !important;
}

.arena-leader:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.9), 0 0 22px rgba(255, 215, 0, 0.45) !important;
  border-color: var(--fm-gold-bright) !important;
}

.arena-leader.enemy {
  background: linear-gradient(180deg, #1a2136 0%, #0d1220 100%) !important;
  border-color: #60a5fa !important;
}

.arena-leader.enemy:hover {
  border-color: #93c5fd !important;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.9), 0 0 22px rgba(96, 165, 250, 0.45) !important;
}

/* Bandeja de Mano del Jugador (Frosted Glass Tactile Deck Tray) */
.battle-arena .player-half .hand {
  background: rgba(11, 15, 24, 0.75) !important;
  backdrop-filter: blur(10px) !important;
  border: 1.5px solid rgba(229, 185, 76, 0.35) !important;
  border-radius: 14px !important;
  padding: 10px 8px 14px !important;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

.battle-arena .player-half .hand .card {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.75), 0 0 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.22s ease !important;
}

.battle-arena .player-half .hand .card:hover {
  transform: translateY(-10px) scale(1.04) !important;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.95), 0 0 20px rgba(255, 215, 0, 0.5) !important;
  z-index: 50;
}

/* Zona DON!! Forjada en Metal y Runa */
.battle-arena .donzone {
  background: linear-gradient(180deg, rgba(16, 21, 32, 0.8), rgba(9, 12, 18, 0.9)) !important;
  border: 1.5px solid rgba(229, 185, 76, 0.45) !important;
  border-radius: 12px !important;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7), 0 4px 14px rgba(0, 0, 0, 0.5) !important;
  padding: 10px 12px !important;
}

.battle-arena .doncard {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.battle-arena .doncard:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.7), 0 0 12px rgba(255, 215, 0, 0.6);
}

/* Divisor Central con Sello Milenario */
.arena-divider {
  background: linear-gradient(90deg, rgba(13, 17, 26, 0.95), rgba(45, 28, 65, 0.98), rgba(13, 17, 26, 0.95)) !important;
  border-top: 2px solid var(--fm-gold-ancient) !important;
  border-bottom: 2px solid var(--fm-gold-ancient) !important;
  box-shadow: 0 0 25px rgba(229, 185, 76, 0.35) !important;
  position: relative;
}

.arena-divider::after {
  content: "𓂀";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.25rem;
  color: var(--fm-gold-bright);
  text-shadow: 0 0 14px var(--fm-gold-bright);
  opacity: 0.9;
  pointer-events: none;
}

/* ==========================================================================
   2. ANIMACIONES DE COMBATE ESTILO POKÉMON GBA
   ========================================================================== */

/* Efecto de Sacudida de Pantalla Retro (GBA Screen Shake 2D) */
@keyframes gba-screen-shake {
  0% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-8px, 4px) rotate(-1deg); }
  30% { transform: translate(7px, -5px) rotate(1deg); }
  45% { transform: translate(-6px, -3px) rotate(-0.5deg); }
  60% { transform: translate(5px, 3px) rotate(0.5deg); }
  75% { transform: translate(-3px, 2px) rotate(0deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes gba-screen-shake-heavy {
  0% { transform: translate(0, 0) scale(1); }
  20% { transform: translate(-12px, 6px) scale(1.02); }
  40% { transform: translate(10px, -6px) scale(1.01); }
  60% { transform: translate(-8px, -4px) scale(1.01); }
  80% { transform: translate(5px, 3px) scale(1.005); }
  100% { transform: translate(0, 0) scale(1); }
}

.gba-shake {
  animation: gba-screen-shake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
}

.gba-shake-heavy {
  animation: gba-screen-shake-heavy 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
}

.battle-arena.gba-shake {
  animation: gba-screen-shake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
}

.battle-arena.gba-shake-heavy {
  animation: gba-screen-shake-heavy 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
}

/* Contenedor de Efecto Slash (Corte Relampagueante) */
.slash-effect-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

/* Animación de Corte Diagonal Doble (GBA Dual Slash) */
.gba-slash-blade {
  position: absolute;
  width: 140%;
  height: 8px;
  background: linear-gradient(90deg, transparent 0%, #ffffff 30%, #ffd700 70%, transparent 100%);
  box-shadow: 0 0 15px #ffffff, 0 0 25px #ffd700, 0 0 40px #ff8800;
  border-radius: 50%;
  opacity: 0;
  transform-origin: center;
}

.gba-slash-blade.slash-1 {
  animation: gbaSlashAnim1 0.38s ease-out forwards;
}

.gba-slash-blade.slash-2 {
  animation: gbaSlashAnim2 0.38s 0.08s ease-out forwards;
}

@keyframes gbaSlashAnim1 {
  0% {
    opacity: 0;
    transform: rotate(-45deg) scaleX(0.1) translateY(-30px);
  }
  30% {
    opacity: 1;
    transform: rotate(-45deg) scaleX(1.2) translateY(0px);
  }
  70% {
    opacity: 1;
    transform: rotate(-45deg) scaleX(1.3) translateY(10px);
  }
  100% {
    opacity: 0;
    transform: rotate(-45deg) scaleX(1.5) translateY(25px);
  }
}

@keyframes gbaSlashAnim2 {
  0% {
    opacity: 0;
    transform: rotate(45deg) scaleX(0.1) translateY(-30px);
  }
  30% {
    opacity: 1;
    transform: rotate(45deg) scaleX(1.2) translateY(0px);
  }
  70% {
    opacity: 1;
    transform: rotate(45deg) scaleX(1.3) translateY(10px);
  }
  100% {
    opacity: 0;
    transform: rotate(45deg) scaleX(1.5) translateY(25px);
  }
}

/* Flash de Impacto Retro */
.impact-flash-overlay {
  position: absolute;
  inset: -10px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 215, 0, 0.5) 40%, transparent 70%);
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  animation: impactFlashAnim 0.3s ease-out forwards;
}

@keyframes impactFlashAnim {
  0% { opacity: 0; transform: scale(0.8); }
  25% { opacity: 0.95; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* Números y Estados Flotantes de Combate Retro */
.floating-combat-text {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Outfit', 'Press Start 2P', monospace, sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  animation: floatCombatText 0.9s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  text-shadow: 
    -2px -2px 0 #000, 2px -2px 0 #000, 
    -2px 2px 0 #000, 2px 2px 0 #000,
    0 0 12px currentColor;
}

.floating-combat-text.damage {
  color: #ff3344;
}

.floating-combat-text.critical {
  color: #ffd700;
  font-size: 1.35rem;
}

.floating-combat-text.ko {
  color: #ff0044;
  font-size: 1.4rem;
}

.floating-combat-text.blocked {
  color: #38bdf8;
  font-size: 1.15rem;
}

.floating-combat-text.shield {
  color: #fbbf24;
}

.floating-combat-text.rabbithole {
  color: #a855f7;
  font-size: 1.25rem;
}

@keyframes floatCombatText {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1.2);
  }
  40% {
    transform: translate(-50%, -90%) scale(1.0);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -120%) scale(1.0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -150%) scale(0.8);
  }
}

/* ==========================================================================
   3. INDICADORES INTERACTIVOS ESTILO YU-GI-OH! DUEL LINKS
   ========================================================================== */

/* Overlay SVG de Rayo de Apuntado (Targeting Beam) */
#targetingSvgOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  overflow: visible;
}

/* Línea Láser Holográfica de Apuntado */
.targeting-beam-core {
  stroke: var(--duel-links-laser);
  stroke-width: 4px;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--duel-links-laser)) drop-shadow(0 0 12px var(--duel-links-laser-glow));
  stroke-dasharray: 12, 6;
  animation: beamFlowAnim 0.6s linear infinite;
}

.targeting-beam-pulse {
  stroke: #ffffff;
  stroke-width: 2px;
  stroke-linecap: round;
}

@keyframes beamFlowAnim {
  to {
    stroke-dashoffset: -36;
  }
}

/* Anillo Holográfico de Carta Lista para Atacar (Duel Links Ready Aura) */
.arena-unit.attack-ready {
  box-shadow: 
    0 0 15px rgba(56, 189, 248, 0.4),
    0 0 25px rgba(255, 215, 0, 0.3) !important;
  border-color: #38bdf8 !important;
  animation: duelLinksReadyPulse 1.8s ease-in-out infinite alternate !important;
}

@keyframes duelLinksReadyPulse {
  0% {
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3), 0 0 20px rgba(255, 215, 0, 0.2);
    border-color: #38bdf8;
  }
  100% {
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.6), 0 0 35px rgba(255, 215, 0, 0.5);
    border-color: #fde047;
  }
}

/* Retícula de Apuntado Holográfica Roja (Duel Links Target Reticle) */
.arena-unit.targetable,
.arena-leader.targetable {
  position: relative;
  border-color: #ff0055 !important;
  box-shadow: 
    0 0 20px rgba(255, 0, 85, 0.7),
    inset 0 0 15px rgba(255, 0, 85, 0.4) !important;
  animation: targetReticlePulse 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite !important;
  cursor: crosshair !important;
}

.arena-unit.targetable:hover,
.arena-leader.targetable:hover {
  transform: translateY(-2px) !important;
  border-color: #ff1a6b !important;
  box-shadow: 
    0 0 35px rgba(255, 0, 85, 1),
    inset 0 0 20px rgba(255, 0, 85, 0.6) !important;
}

@keyframes targetReticlePulse {
  0%, 100% {
    box-shadow: 0 0 18px rgba(255, 0, 85, 0.7), inset 0 0 12px rgba(255, 0, 85, 0.4);
  }
  50% {
    box-shadow: 0 0 35px rgba(255, 0, 85, 1), inset 0 0 24px rgba(255, 50, 100, 0.6);
  }
}

/* Soporte de Botones Interactivos en Perspectiva 3D */
.arena-unit button,
.btn-unit-attack,
.btn-unit-evolution,
.btn-unit-ability,
.btn-leader-canto,
.btn-play-card {
  position: relative;
  z-index: 25;
  pointer-events: auto !important;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-unit-attack:hover:not(:disabled),
.btn-unit-evolution:hover:not(:disabled),
.btn-unit-ability:hover:not(:disabled),
.btn-leader-canto:hover:not(:disabled) {
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.8) !important;
}

.btn-unit-attack:disabled,
.btn-unit-evolution:disabled,
.btn-unit-ability:disabled,
.btn-leader-canto:disabled {
  cursor: not-allowed !important;
}

.arena-unit.targetable::before,
.arena-leader.targetable::before {
  content: "⌖";
  position: absolute;
  top: -14px;
  right: -14px;
  font-size: 1.4rem;
  color: #ff0055;
  text-shadow: 0 0 10px #ff0055, 0 0 20px #ff0055;
  animation: reticleSpin 3s linear infinite;
  pointer-events: none;
  z-index: 20;
}

@keyframes reticleSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Escudo Hexagonal Flotante para Bloqueadores (Blocker Hologram) */
.arena-unit[data-blocker="true"]::after {
  content: "🛡️";
  position: absolute;
  top: -8px;
  left: -8px;
  font-size: 1.1rem;
  filter: drop-shadow(0 0 8px #38bdf8);
  animation: blockerFloat 2s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes blockerFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

/* Banner de Transición de Fases (Duel Links Style Cinematic Phase Banner) */
.duel-phase-banner {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  transform: translateY(-50%) scaleY(0);
  background: linear-gradient(90deg, transparent 0%, rgba(26, 16, 45, 0.95) 20%, rgba(15, 23, 42, 0.98) 50%, rgba(26, 16, 45, 0.95) 80%, transparent 100%);
  border-top: 2px solid var(--fm-gold-bright);
  border-bottom: 2px solid var(--fm-gold-bright);
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.4), inset 0 0 25px rgba(0, 240, 255, 0.3);
  padding: 18px 0;
  text-align: center;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
}

.duel-phase-banner.active {
  animation: duelLinksBannerAnim 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.duel-phase-title {
  font-family: var(--font-title, sans-serif);
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffffff;
  text-shadow: 0 0 10px var(--fm-gold-bright), 0 0 20px var(--fm-gold-bright);
  margin: 0;
  text-transform: uppercase;
}

.duel-phase-subtitle {
  font-size: clamp(0.75rem, 2vw, 0.95rem);
  font-weight: 700;
  color: #38bdf8;
  text-shadow: 0 0 8px #38bdf8;
  margin-top: 4px;
}

@keyframes duelLinksBannerAnim {
  0% {
    opacity: 0;
    transform: translateY(-50%) scaleY(0);
  }
  15% {
    opacity: 1;
    transform: translateY(-50%) scaleY(1.1);
  }
  25% {
    transform: translateY(-50%) scaleY(1);
  }
  80% {
    opacity: 1;
    transform: translateY(-50%) scaleY(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-50%) scaleY(0);
  }
}
