/* ============================================================================
   Buddy Game Styles
   ============================================================================ */

/* Modal Container */
.buddy-game-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  animation: fade-in 0.3s forwards;
}

.buddy-game-modal.closing {
  animation: fade-out 0.3s forwards;
}

/* Modal Content */
.buddy-game-content {
  background: white;
  border-radius: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  animation: scale-in 0.3s forwards;
}

.buddy-game-modal.closing .buddy-game-content {
  animation: scale-out 0.3s forwards;
}

/* Header */
.buddy-game-header {
  background: linear-gradient(135deg, #FF6B35 0%, #FFA500 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.buddy-game-title {
  font-size: 24px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-button {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Tabs */
.buddy-game-tabs {
  display: flex;
  border-bottom: 2px solid #E5E7EB;
  background: #F9FAFB;
}

.buddy-game-tab {
  flex: 1;
  padding: 16px;
  text-align: center;
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: #6B7280;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
}

.buddy-game-tab:hover {
  background: #F3F4F6;
  color: #374151;
}

.buddy-game-tab.active {
  color: #FF6B35;
  border-bottom-color: #FF6B35;
  background: white;
}

/* Body */
.buddy-game-body {
  padding: 24px;
  max-height: calc(90vh - 180px);
  overflow-y: auto;
}

/* Buddy Stats Display */
.buddy-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #F9FAFB;
  padding: 16px;
  border-radius: 12px;
  border: 2px solid #E5E7EB;
}

.stat-label {
  font-size: 14px;
  color: #6B7280;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-bar {
  height: 12px;
  background: #E5E7EB;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}

.stat-fill {
  height: 100%;
  transition: width 0.5s ease;
  border-radius: 6px;
}

.stat-fill.energy {
  background: linear-gradient(90deg, #FBBF24 0%, #F59E0B 100%);
}

.stat-fill.mood {
  background: linear-gradient(90deg, #60A5FA 0%, #3B82F6 100%);
}

.stat-fill.hunger {
  background: linear-gradient(90deg, #F87171 0%, #EF4444 100%);
}

.stat-fill.cleanliness {
  background: linear-gradient(90deg, #A78BFA 0%, #8B5CF6 100%);
}

.stat-value {
  font-size: 12px;
  color: #374151;
  font-weight: 600;
  text-align: right;
}

/* Action Buttons */
.action-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.action-button {
  background: white;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-button:hover:not(:disabled) {
  border-color: #FF6B35;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
}

.action-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-icon {
  font-size: 32px;
}

.action-label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.action-cooldown {
  font-size: 11px;
  color: #EF4444;
}

/* Commands List */
.commands-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.command-card {
  background: white;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.command-card:hover {
  border-color: #FF6B35;
  transform: translateX(4px);
}

.command-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.command-name {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
}

.command-mastery {
  font-size: 14px;
  font-weight: 600;
  color: #FF6B35;
}

.command-progress {
  height: 8px;
  background: #E5E7EB;
  border-radius: 4px;
  overflow: hidden;
}

.command-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF6B35 0%, #FFA500 100%);
  transition: width 0.5s ease;
}

/* Animations */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes scale-in {
  from { transform: scale(0.9); }
  to { transform: scale(1); }
}

@keyframes scale-out {
  from { transform: scale(1); }
  to { transform: scale(0.9); }
}

@keyframes confetti-fall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

@keyframes particle-float {
  to {
    transform: translate(
      calc(var(--end-x) - 50vw),
      calc(var(--end-y) - 50vh)
    );
    opacity: 0;
  }
}

@keyframes float-up {
  to {
    transform: translateY(-50px);
    opacity: 0;
  }
}

@keyframes buddy-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes buddy-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Utility Classes */
.pulse { animation: pulse 0.3s ease; }
.shake { animation: shake 0.5s ease; }
.buddy-bounce { animation: buddy-bounce 0.5s ease; }
.buddy-wiggle { animation: buddy-wiggle 0.5s ease; }

/* Level Up Overlay */
.level-up-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fade-in 0.3s;
}

.level-up-overlay.fade-out {
  animation: fade-out 0.5s forwards;
}

.level-up-content {
  text-align: center;
  color: white;
}

.level-up-icon {
  font-size: 80px;
  margin-bottom: 16px;
  animation: buddy-bounce 0.5s infinite;
}

.level-up-text {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 8px;
}

.level-up-number {
  font-size: 64px;
  font-weight: bold;
  color: #FFA500;
}

/* Achievement Unlock */
.achievement-unlock {
  position: fixed;
  top: 20px;
  right: -400px;
  width: 350px;
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  display: flex;
  gap: 16px;
  align-items: center;
  transition: right 0.5s ease;
}

.achievement-unlock.show {
  right: 20px;
}

.achievement-icon {
  font-size: 48px;
}

.achievement-content {
  flex: 1;
}

.achievement-title {
  font-size: 12px;
  color: #6B7280;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.achievement-name {
  font-size: 18px;
  font-weight: bold;
  color: #374151;
  margin-bottom: 4px;
}

.achievement-xp {
  font-size: 14px;
  color: #FF6B35;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 640px) {
  .buddy-game-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .buddy-stats-grid {
    grid-template-columns: 1fr;
  }

  .action-buttons-grid {
    grid-template-columns: 1fr;
  }

  .achievement-unlock {
    width: calc(100% - 40px);
  }
}

/* Loading State */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #E5E7EB;
  border-top-color: #FF6B35;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 40px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #6B7280;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 16px;
}

/* ============================================================================
   Animated Buddy Dog (Homepage)
   ============================================================================ */

/* Dog Container */
.dog-container {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: center bottom;
}

/* Dog Body */
.dog-body {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 60px;
  height: 35px;
  background: linear-gradient(135deg, #FF8C42 0%, #FFA500 100%);
  border-radius: 20px 20px 15px 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Dog Head */
.dog-head {
  position: absolute;
  bottom: 35px;
  left: 60px;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #FF8C42 0%, #FFA500 100%);
  border-radius: 50% 50% 40% 40%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

/* Dog Ears */
.dog-ear {
  position: absolute;
  width: 15px;
  height: 20px;
  background: linear-gradient(135deg, #E67E22 0%, #FF8C42 100%);
  border-radius: 50% 50% 0 0;
}

.dog-ear-left {
  top: -5px;
  left: 5px;
  transform: rotate(-20deg);
}

.dog-ear-right {
  top: -5px;
  right: 5px;
  transform: rotate(20deg);
}

/* Dog Eyes */
.dog-eye {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #2C3E50;
  border-radius: 50%;
  top: 12px;
}

.dog-eye-left {
  left: 10px;
}

.dog-eye-right {
  right: 10px;
}

/* Dog Nose */
.dog-nose {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 6px;
  background: #2C3E50;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
}

/* Dog Tail */
.dog-tail {
  position: absolute;
  bottom: 32px;
  left: 18px;
  width: 6px;
  height: 25px;
  background: linear-gradient(180deg, #FF8C42 0%, #E67E22 100%);
  border-radius: 10px;
  transform-origin: top center;
  animation: tail-wag 0.4s ease-in-out infinite;
}

@keyframes tail-wag {
  0%, 100% {
    transform: rotate(-15deg);
  }
  50% {
    transform: rotate(15deg);
  }
}

/* Dog Legs */
.dog-leg {
  position: absolute;
  width: 8px;
  height: 22px;
  background: linear-gradient(180deg, #FF8C42 0%, #E67E22 100%);
  border-radius: 4px;
  bottom: 0;
}

.dog-leg-front-left {
  left: 32px;
  animation: leg-walk-front 0.6s ease-in-out infinite;
}

.dog-leg-front-right {
  left: 45px;
  animation: leg-walk-front 0.6s ease-in-out infinite 0.3s;
}

.dog-leg-back-left {
  left: 58px;
  animation: leg-walk-back 0.6s ease-in-out infinite 0.3s;
}

.dog-leg-back-right {
  left: 68px;
  animation: leg-walk-back 0.6s ease-in-out infinite;
}

/* Leg walking animation */
@keyframes leg-walk-front {
  0%, 100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-25deg);
  }
}

@keyframes leg-walk-back {
  0%, 100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(25deg);
  }
}

/* Buddy running - horizontal movement */
@keyframes buddy-run {
  0% {
    transform: translateX(-150px);
  }
  50% {
    transform: translateX(150px);
  }
  100% {
    transform: translateX(-150px);
  }
}

.buddy-running {
  animation: buddy-run 8s ease-in-out infinite;
}

/* Mobile: Smaller range */
@media (max-width: 768px) {
  @keyframes buddy-run {
    0% {
      transform: translateX(-80px);
    }
    50% {
      transform: translateX(80px);
    }
    100% {
      transform: translateX(-80px);
    }
  }
}

/* Auto-start running animation */
#buddyCharacter {
  animation: buddy-run 8s ease-in-out infinite;
}

/* Jumping animation (on click) */
@keyframes buddy-jump {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-30px) scale(1.1);
  }
}

.buddy-jumping {
  animation: buddy-jump 0.5s ease-in-out !important;
}

/* Ball rolling in front of dog */
.dog-ball {
  position: absolute;
  bottom: 8px;
  left: 110px;
  width: 20px;
  height: 20px;
  background: radial-gradient(circle at 30% 30%, #FF6B6B, #EE5A6F, #C0392B);
  border-radius: 50%;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    inset -2px -2px 4px rgba(0, 0, 0, 0.2),
    inset 2px 2px 4px rgba(255, 255, 255, 0.3);
  animation: ball-roll 8s linear infinite;
}

/* Ball rolling animation - synced with dog running */
@keyframes ball-roll {
  0% {
    transform: translateX(-260px) rotate(0deg);
  }
  50% {
    transform: translateX(40px) rotate(720deg);
  }
  100% {
    transform: translateX(-260px) rotate(1440deg);
  }
}

/* Mobile: smaller ball movement */
@media (max-width: 768px) {
  @keyframes ball-roll {
    0% {
      transform: translateX(-190px) rotate(0deg);
    }
    50% {
      transform: translateX(0px) rotate(360deg);
    }
    100% {
      transform: translateX(-190px) rotate(720deg);
    }
  }
}

/* Prevent Buddy from causing horizontal scroll */
#buddy {
  max-width: 100vw;
  overflow: visible;
}

/* ============================================================================
   Missing Animations for Buddy Game
   ============================================================================ */

/* Modal animations */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

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

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

/* Confetti animation */
@keyframes confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}
