/* ========================================
   REWARD ANIMATION STYLES
   Floating XP and Bronze animations
   ======================================== */

/* Floating reward icons that fly to status bar */
.floating-reward {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 1.1rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  filter: drop-shadow(0 0 10px currentColor);
}

.floating-reward-xp {
  color: #f7a00f;
}

.floating-reward-bronze {
  color: #f59e0b;
}

.floating-reward-energy {
  color: #22d3ee;
  filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.8));
}

.floating-reward-icon {
  font-size: 1.5rem;
  animation: reward-icon-glow 0.3s ease-out infinite alternate;
}

.floating-reward-value {
  font-family: 'Orbitron', monospace;
}

/* Animation phases */
.floating-reward.phase-rising {
  left: var(--start-x);
  top: var(--start-y);
  transform: translate(-50%, -50%) scale(0);
  animation: reward-rise 0.3s ease-out forwards;
}

.floating-reward.phase-flying {
  animation: reward-fly 0.5s ease-in-out forwards;
}

.floating-reward.phase-done {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
}

@keyframes reward-rise {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -100%) scale(1.3);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -80%) scale(1);
    opacity: 1;
  }
}

@keyframes reward-fly {
  0% {
    left: var(--start-x);
    top: var(--start-y);
    transform: translate(-50%, -80%) scale(1);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    left: var(--end-x);
    top: var(--end-y);
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0.8;
  }
}

@keyframes reward-icon-glow {
  0% {
    filter: brightness(1);
  }
  100% {
    filter: brightness(1.3);
  }
}

/* Hit XP flying animation - spawns from player and flies to XP bar */
@keyframes hit-xp-fly {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -80%) scale(1.2);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -60%) scale(1);
    opacity: 1;
  }
  100% {
    left: var(--target-x);
    top: var(--target-y);
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
}

/* Pulse effect on status bar elements */
.reward-pulse {
  animation: status-pulse 0.3s ease-out;
}

@keyframes status-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.1);
    filter: brightness(1.5);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

/* Special pulse for XP bar */
.top-xp-bar-container.reward-pulse {
  animation: xp-bar-pulse 0.3s ease-out;
}

@keyframes xp-bar-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.6);
  }
  50% {
    box-shadow: 0 0 20px 5px rgba(167, 139, 250, 0.8);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(167, 139, 250, 0);
  }
}

/* Special pulse for bronze */
.bronze-currency.reward-pulse {
  animation: bronze-pulse 0.3s ease-out;
}

@keyframes bronze-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  }
  50% {
    box-shadow: 0 0 20px 5px rgba(245, 158, 11, 0.8);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Level up overlay */
.level-up-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  animation: level-up-fade-in 0.3s ease-out;
}

@keyframes level-up-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.level-up-content {
  text-align: center;
  animation: level-up-bounce 0.6s ease-out;
}

@keyframes level-up-bounce {
  0% {
    transform: scale(0) rotate(-10deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(5deg);
  }
  70% {
    transform: scale(0.9) rotate(-2deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.level-up-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  color: #fbbf24;
  text-shadow: 
    0 0 20px rgba(251, 191, 36, 0.8),
    0 0 40px rgba(251, 191, 36, 0.6),
    0 4px 8px rgba(0, 0, 0, 0.5);
  animation: level-up-glow 0.5s ease-in-out infinite alternate;
}

@keyframes level-up-glow {
  0% {
    filter: brightness(1);
    text-shadow: 
      0 0 20px rgba(251, 191, 36, 0.8),
      0 0 40px rgba(251, 191, 36, 0.6),
      0 4px 8px rgba(0, 0, 0, 0.5);
  }
  100% {
    filter: brightness(1.2);
    text-shadow: 
      0 0 30px rgba(251, 191, 36, 1),
      0 0 60px rgba(251, 191, 36, 0.8),
      0 4px 8px rgba(0, 0, 0, 0.5);
  }
}

.level-up-number {
  font-family: 'Orbitron', sans-serif;
  font-size: 4rem;
  font-weight: 900;
  color: white;
  text-shadow: 
    0 0 15px rgba(167, 139, 250, 0.8),
    0 4px 8px rgba(0, 0, 0, 0.5);
  margin-top: 0.5rem;
}

/* Level up energy bonus text */
.level-up-energy-bonus {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #22d3ee;
  text-shadow: 
    0 0 15px rgba(34, 211, 238, 0.8),
    0 0 30px rgba(34, 211, 238, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.5);
  margin-top: 1rem;
  animation: energy-bonus-pop 0.6s ease-out;
}

@keyframes energy-bonus-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Energy bar pulse glow */
.energy-pulse-glow {
  animation: energy-bar-glow 0.5s ease-out !important;
}

@keyframes energy-bar-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.6);
  }
  50% {
    box-shadow: 0 0 20px 5px rgba(34, 211, 238, 0.8);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0);
  }
}

/* ========================================
   XP BAR FILL ANIMATION
   Smooth progress bar increase
   ======================================== */

.top-xp-fill {
  transition: width 0.5s ease-out;
}

.top-xp-fill.animating {
  transition: width 1s ease-out;
}

/* Glow effect when XP increases - orange color */
.top-xp-bar-wide.xp-increasing .top-xp-fill {
  box-shadow: 0 0 15px rgba(247, 160, 15, 0.8), 0 0 25px rgba(247, 160, 15, 0.5);
  background: linear-gradient(90deg, #f7a00f 0%, #ffb733 100%);
}

/* Live XP counting animation */
.top-xp-text.counting {
  animation: xp-count-pulse 0.15s ease-out;
  color: #f7a00f;
}

@keyframes xp-count-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ========================================
   BRONZE VALUE ANIMATION
   Number counting up effect
   ======================================== */

.bronze-currency.value-changing .currency-value {
  animation: value-bump 0.3s ease-out;
}

@keyframes value-bump {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
    color: #22c55e;
  }
  100% {
    transform: scale(1);
  }
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 1024px) {
  .floating-reward {
    font-size: 0.9rem;
  }
  
  .floating-reward-icon {
    font-size: 1.2rem;
  }
  
  .level-up-text {
    font-size: 2rem;
  }
  
  .level-up-number {
    font-size: 3rem;
  }
}

/* ========================================
   GLOBAL LEVEL-UP POPUP
   Shows on ANY page when player levels up
   ======================================== */

.global-levelup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  background: radial-gradient(ellipse at center, rgba(247, 160, 15, 0.15) 0%, rgba(0, 0, 0, 0.85) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: global-levelup-fadein 0.4s ease-out;
  cursor: pointer;
}

.global-levelup-content {
  text-align: center;
  animation: global-levelup-scalein 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.global-levelup-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: global-levelup-star-spin 1s ease-out;
  filter: drop-shadow(0 0 20px rgba(247, 160, 15, 0.8));
}

.global-levelup-title {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  color: #f7a00f;
  text-shadow:
    0 0 20px rgba(247, 160, 15, 0.8),
    0 0 40px rgba(247, 160, 15, 0.4),
    0 0 80px rgba(247, 160, 15, 0.2),
    0 2px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 6px;
  animation: global-levelup-glow 1.5s ease-in-out infinite alternate;
}

.global-levelup-level {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 1.6rem;
  color: #fff;
  margin-top: 16px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  opacity: 0;
  animation: global-levelup-slideup 0.5s ease-out 0.3s forwards;
}

.global-levelup-energy {
  font-family: 'Orbitron', 'Rajdhani', sans-serif;
  font-size: 1.3rem;
  color: #22d3ee;
  margin-top: 16px;
  text-shadow:
    0 0 12px rgba(34, 211, 238, 0.8),
    0 0 24px rgba(34, 211, 238, 0.4);
  animation: global-levelup-energy-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.global-levelup-tap {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 24px;
  letter-spacing: 1px;
  opacity: 0;
  animation: global-levelup-slideup 0.5s ease-out 1s forwards;
}

/* Flying energy particles */
.global-levelup-energy-particle {
  position: fixed;
  z-index: 100000;
  pointer-events: none;
  font-size: 1.5rem;
  filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.8));
  animation: global-levelup-energy-fly 0.6s ease-in forwards;
  animation-delay: var(--delay, 0ms);
}

/* Animations */
@keyframes global-levelup-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes global-levelup-scalein {
  from {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes global-levelup-star-spin {
  from {
    transform: rotate(-180deg) scale(0.3);
    opacity: 0;
  }
  to {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes global-levelup-glow {
  from {
    text-shadow:
      0 0 20px rgba(247, 160, 15, 0.8),
      0 0 40px rgba(247, 160, 15, 0.4),
      0 2px 4px rgba(0, 0, 0, 0.8);
  }
  to {
    text-shadow:
      0 0 30px rgba(247, 160, 15, 1),
      0 0 60px rgba(247, 160, 15, 0.6),
      0 0 100px rgba(247, 160, 15, 0.3),
      0 2px 4px rgba(0, 0, 0, 0.8);
  }
}

@keyframes global-levelup-slideup {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes global-levelup-energy-pop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.3);
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes global-levelup-energy-fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  30% {
    transform: translate(0, -30px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translate(var(--target-x), var(--target-y)) scale(0.3);
    opacity: 0;
  }
}

/* Mobile adjustments for global level-up */
@media (max-width: 1024px) {
  .global-levelup-title {
    font-size: 2.2rem;
    letter-spacing: 4px;
  }
  
  .global-levelup-level {
    font-size: 1.2rem;
  }
  
  .global-levelup-energy {
    font-size: 1.1rem;
  }
  
  .global-levelup-icon {
    font-size: 3rem;
  }
}
