/**
 * Takla Arena - Game Styles
 */

/* Screen Transitions */
.game-screen {
    animation: fadeIn 0.3s ease-out;
}

.game-screen.hidden {
    display: none;
}

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

/* Character Animations */
#character {
    transform-origin: center bottom;
}

#character.running {
    animation: running 0.2s ease-in-out infinite alternate;
}

#character.jumping {
    animation: jumping 0.3s ease-out forwards;
}

#character.flipping {
    animation: flipping 0.4s linear infinite;
}

#character.landing-perfect {
    animation: landingPerfect 0.5s ease-out forwards;
}

#character.landing-good {
    animation: landingGood 0.4s ease-out forwards;
}

#character.landing-unstable {
    animation: landingUnstable 0.6s ease-out forwards;
}

#character.falling {
    animation: falling 0.8s ease-in forwards;
}

#character.celebrating {
    animation: celebrating 0.5s ease-in-out infinite alternate;
}

@keyframes running {
    0% { transform: translateY(0) rotate(-2deg); }
    100% { transform: translateY(-3px) rotate(2deg); }
}

@keyframes jumping {
    0% { transform: translateY(0) scaleY(0.8); }
    50% { transform: translateY(-80px) scaleY(1.1); }
    100% { transform: translateY(-120px) scaleY(1); }
}

@keyframes flipping {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes landingPerfect {
    0% { transform: translateY(-20px) scale(0.9); }
    50% { transform: translateY(5px) scale(1.1); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes landingGood {
    0% { transform: translateY(-15px); }
    60% { transform: translateY(3px) rotate(-5deg); }
    100% { transform: translateY(0) rotate(0); }
}

@keyframes landingUnstable {
    0% { transform: translateY(-10px); }
    30% { transform: translateY(5px) rotate(-15deg); }
    60% { transform: translateY(0) rotate(10deg); }
    100% { transform: translateY(0) rotate(0); }
}

@keyframes falling {
    0% { transform: translateY(-10px) rotate(0); }
    50% { transform: translateY(20px) rotate(45deg); }
    100% { transform: translateY(30px) rotate(90deg) scaleY(0.5); }
}

@keyframes celebrating {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-10px) scale(1.05); }
}

/* Arms Animation */
.character-arm-left, .character-arm-right {
    transition: transform 0.1s ease;
}

#character.running .character-arm-left {
    animation: armSwing 0.2s ease-in-out infinite alternate;
}

#character.running .character-arm-right {
    animation: armSwing 0.2s ease-in-out infinite alternate-reverse;
}

#character.celebrating .character-arm-left,
#character.celebrating .character-arm-right {
    transform: rotate(-45deg) translateY(-5px);
}

@keyframes armSwing {
    0% { transform: rotate(-20deg); }
    100% { transform: rotate(20deg); }
}

/* Timing Bar */
#timingMarker {
    transition: left 0.05s linear;
}

/* Power Bar Animation */
#powerFill {
    transition: height 0.05s linear;
}

/* Feedback Popup */
#feedbackPopup {
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.feedback-perfect {
    color: #22c55e;
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

.feedback-good {
    color: #eab308;
    text-shadow: 0 0 20px rgba(234, 179, 8, 0.5);
}

.feedback-ok {
    color: #f97316;
    text-shadow: 0 0 20px rgba(249, 115, 22, 0.5);
}

.feedback-miss {
    color: #ef4444;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* Countdown */
#countdownDisplay p {
    animation: countdownPulse 1s ease-out infinite;
}

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

/* Screen Shake */
.screen-shake {
    animation: screenShake 0.3s ease-out;
}

@keyframes screenShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* Crowd */
.crowd-member {
    width: 8px;
    height: 12px;
    background: linear-gradient(to bottom, #f0d0b0 40%, #6b7280 40%);
    border-radius: 50% 50% 0 0;
    opacity: 0.6;
}

.crowd-member.cheering {
    animation: crowdCheer 0.3s ease-in-out infinite alternate;
}

@keyframes crowdCheer {
    0% { transform: translateY(0) scaleY(1); }
    100% { transform: translateY(-3px) scaleY(1.1); }
}

/* Leaderboard */
.leaderboard-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-item.current-user {
    background: rgba(255, 82, 27, 0.2);
    border: 1px solid rgba(255, 82, 27, 0.4);
}

.leaderboard-item .rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 8px;
    font-size: 14px;
}

.leaderboard-item .rank.gold {
    background: linear-gradient(135deg, #ffd700, #ffb800);
    color: #1a1a1a;
}

.leaderboard-item .rank.silver {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a1a;
}

.leaderboard-item .rank.bronze {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: #fff;
}

.leaderboard-item .rank.normal {
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
}

/* Leaderboard Tabs */
.leaderboard-tab {
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
    transition: all 0.2s ease;
}

.leaderboard-tab:hover {
    background: rgba(255, 255, 255, 0.15);
}

.leaderboard-tab.active {
    background: linear-gradient(135deg, #ff521b, #e63d00);
    color: white;
}

/* Score Popup */
.score-popup {
    position: absolute;
    font-weight: bold;
    font-size: 24px;
    color: #22c55e;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    animation: scoreFloat 1s ease-out forwards;
    pointer-events: none;
}

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

/* Streak Fire */
.streak-fire {
    animation: firePulse 0.5s ease-in-out infinite alternate;
}

@keyframes firePulse {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.3); }
}

/* Confetti */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFall 2s ease-out forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(300px) rotate(720deg); opacity: 0; }
}

/* Loading Spinner */
.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #ff521b;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

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

/* Pulse Glow */
.pulse-glow {
    animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 82, 27, 0.3); }
    50% { box-shadow: 0 0 40px rgba(255, 82, 27, 0.6); }
}

/* Custom Scrollbar */
#leaderboardList::-webkit-scrollbar {
    width: 6px;
}

#leaderboardList::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

#leaderboardList::-webkit-scrollbar-thumb {
    background: rgba(255, 82, 27, 0.5);
    border-radius: 3px;
}

#leaderboardList::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 82, 27, 0.7);
}

/* Desktop Canvas Centering */
#gameArea {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#gameArea > div:first-child {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    #gameCanvas {
        aspect-ratio: 4/5;
        width: 100%;
    }

    #character {
        width: 36px;
        height: 48px;
    }

    #feedbackPopup p {
        font-size: 28px;
    }

    #flipCounter p:first-child {
        font-size: 48px;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
