/* ========================================
   THREE.JS 3D ENHANCEMENTS
   Hearthstone/Elder Scrolls Legends Style
   ======================================== */

#three-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5; /* Raised to layer properly with game elements */
  mix-blend-mode: normal; /* Changed from screen to prevent color artifacts */
  opacity: 1; /* Full visibility for crisp particles */
}

#felt-view {
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center,
    rgba(139, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.6) 100%);
}

/* Enhanced card glow effects for 3D */
.player-card,
.played-card,
.enemy-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, box-shadow;
}

.player-card:hover,
.played-card:hover {
  filter: brightness(1.2) drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
  z-index: 1000;
}

/* Legendary card epic glow */
.legendary {
  animation: legendaryPulse 2s ease-in-out infinite;
  box-shadow:
    0 0 20px rgba(255, 215, 0, 0.8),
    0 0 40px rgba(255, 215, 0, 0.6),
    0 0 60px rgba(255, 215, 0, 0.4),
    inset 0 0 20px rgba(255, 215, 0, 0.3);
}

@keyframes legendaryPulse {
  0%, 100% {
    box-shadow:
      0 0 20px rgba(255, 215, 0, 0.8),
      0 0 40px rgba(255, 215, 0, 0.6),
      0 0 60px rgba(255, 215, 0, 0.4),
      inset 0 0 20px rgba(255, 215, 0, 0.3);
  }
  50% {
    box-shadow:
      0 0 30px rgba(255, 215, 0, 1),
      0 0 60px rgba(255, 215, 0, 0.8),
      0 0 90px rgba(255, 215, 0, 0.6),
      inset 0 0 30px rgba(255, 215, 0, 0.5);
  }
}

/* Epic card purple glow */
.epic {
  animation: epicPulse 2s ease-in-out infinite;
  box-shadow:
    0 0 15px rgba(157, 78, 221, 0.8),
    0 0 30px rgba(157, 78, 221, 0.6),
    inset 0 0 15px rgba(157, 78, 221, 0.3);
}

@keyframes epicPulse {
  0%, 100% {
    box-shadow:
      0 0 15px rgba(157, 78, 221, 0.8),
      0 0 30px rgba(157, 78, 221, 0.6),
      inset 0 0 15px rgba(157, 78, 221, 0.3);
  }
  50% {
    box-shadow:
      0 0 25px rgba(157, 78, 221, 1),
      0 0 50px rgba(157, 78, 221, 0.8),
      inset 0 0 25px rgba(157, 78, 221, 0.5);
  }
}

/* Rare card blue glow */
.rare {
  box-shadow:
    0 0 10px rgba(0, 128, 255, 0.8),
    0 0 20px rgba(0, 128, 255, 0.6),
    inset 0 0 10px rgba(0, 128, 255, 0.3);
}

/* Enhanced battlefield with depth */
#no-mans-land {
  background:
    radial-gradient(circle at 50% 50%, rgba(139, 0, 0, 0.2) 0%, transparent 70%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.3) 100%);
  box-shadow:
    inset 0 10px 30px rgba(0, 0, 0, 0.5),
    inset 0 -10px 30px rgba(0, 0, 0, 0.5);
}

/* Attack readiness glow enhancement */
.ready-to-attack {
  animation:
    readyPulse 1.5s ease-in-out infinite,
    bounce 3s ease 1200ms infinite alternate !important;
  box-shadow:
    0 0 30px rgba(0, 100, 255, 1),
    0 0 60px rgba(0, 100, 255, 0.8),
    0 0 90px rgba(0, 100, 255, 0.6),
    inset 0 0 30px rgba(0, 100, 255, 0.4) !important;
  filter: brightness(1.3) saturate(1.5);
}

@keyframes readyPulse {
  0%, 100% {
    transform: translateY(-15px) scale(1);
  }
  50% {
    transform: translateY(-18px) scale(1.05);
  }
}

/* Card play animation enhancement */
.card-play-animation {
  animation:
    cardPlayZoom 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
    cardPlayRotate 0.8s ease-out,
    cardPlayGlow 0.8s ease-out !important;
  transform-origin: center center;
}

@keyframes cardPlayZoom {
  0% {
    transform: scale(0.8) translateY(0);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.5) translateY(-30px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes cardPlayRotate {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(180deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}

@keyframes cardPlayGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    filter: brightness(1);
  }
  50% {
    box-shadow:
      0 0 40px rgba(255, 215, 0, 1),
      0 0 80px rgba(255, 215, 0, 0.8),
      0 0 120px rgba(255, 215, 0, 0.6);
    filter: brightness(1.5);
  }
}

/* Enhanced damage numbers */
.damage-number {
  animation: floatDamage 1.5s ease-out forwards, damageGlow 0.3s ease-out;
  filter: drop-shadow(0 0 5px currentColor);
  font-weight: 900;
  text-shadow:
    0 0 10px currentColor,
    2px 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes damageGlow {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.5);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Enhanced avatars with 3D depth */
#player-avatar,
#enemy-avatar {
  transition: all 0.3s ease;
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.7));
}

#player-avatar:hover,
#enemy-avatar:hover {
  transform: scale(1.05);
  filter:
    drop-shadow(0 8px 20px rgba(0, 0, 0, 0.9))
    brightness(1.1);
}

/* End turn button epic style */
#end-turn-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

#end-turn-btn:hover {
  transform: scale(1.1) translateY(-2px);
  filter:
    drop-shadow(0 8px 16px rgba(255, 215, 0, 0.6))
    brightness(1.2);
}

#end-turn-btn:active {
  transform: scale(0.95);
}

/* Atmospheric vignette effect */
#felt-view::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
  z-index: 2;
}

/* Card stat enhancement */
.cost-stat,
.atk-stat,
.def-stat {
  text-shadow:
    0 0 5px rgba(0, 0, 0, 0.9),
    0 0 10px rgba(0, 0, 0, 0.7),
    1px 1px 2px rgba(0, 0, 0, 1);
  font-weight: 900;
  transition: all 0.2s ease;
}

.played-card:hover .cost-stat,
.played-card:hover .atk-stat,
.played-card:hover .def-stat,
.player-card:hover .cost-stat,
.player-card:hover .atk-stat,
.player-card:hover .def-stat {
  transform: scale(1.1);
  text-shadow:
    0 0 10px rgba(255, 215, 0, 1),
    0 0 20px rgba(255, 215, 0, 0.8),
    2px 2px 4px rgba(0, 0, 0, 1);
}

/* Performance optimizations */
.player-card,
.played-card,
.enemy-card,
#three-canvas {
  -webkit-backface-visibility: hidden;
  -webkit-perspective: 1000;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

/* Particle container for DOM particles */
.particle {
  pointer-events: none;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* Ensure game elements appear above Three.js canvas */
#enemy-row,
#no-mans-land,
#player-row,
.player-card,
.enemy-card,
.played-card,
#player-avatar,
#enemy-avatar,
#end-turn-btn {
  position: relative;
  z-index: 10;
}
