@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

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

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

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

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

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

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

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

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

@keyframes starPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

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

@keyframes celebrate {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(-5deg);
    }
    50% {
        transform: scale(1.2) rotate(0deg);
    }
    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

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

@keyframes correctPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
}

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

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

@keyframes loadingPulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

@keyframes characterWalk {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-5px);
    }
    75% {
        transform: translateY(-5px);
    }
}

@keyframes characterClimb {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-8px) rotate(-2deg);
    }
    50% {
        transform: translateY(-15px) rotate(0deg);
    }
    75% {
        transform: translateY(-8px) rotate(2deg);
    }
}

@keyframes characterDescend {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(8px) rotate(2deg);
    }
    50% {
        transform: translateY(15px) rotate(0deg);
    }
    75% {
        transform: translateY(8px) rotate(-2deg);
    }
}

@keyframes characterWave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(15deg);
    }
    75% {
        transform: rotate(-15deg);
    }
}

@keyframes characterJump {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes characterDance {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(-5px) rotate(-5deg);
    }
    50% {
        transform: translateX(0) rotate(0deg);
    }
    75% {
        transform: translateX(5px) rotate(5deg);
    }
}

@keyframes characterCelebrate {
    0%, 100% {
        transform: scale(1) rotate(0deg) translateY(0);
    }
    25% {
        transform: scale(1.1) rotate(-10deg) translateY(-10px);
    }
    50% {
        transform: scale(1.2) rotate(0deg) translateY(-20px);
    }
    75% {
        transform: scale(1.1) rotate(10deg) translateY(-10px);
    }
}

@keyframes characterSad {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(5px) rotate(-5deg);
    }
}

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

@keyframes stairsStepUp {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-30px);
    }
}

@keyframes stairsStepDown {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(30px);
    }
}

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

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

@keyframes dangerAlert {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
    }
}

@keyframes rainbow {
    0% {
        filter: hue-rotate(0deg);
    }
    100% {
        filter: hue-rotate(360deg);
    }
}

@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

@keyframes progressFill {
    from {
        width: 0%;
    }
    to {
        width: var(--target-width);
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.screen-transition {
    animation-duration: 0.5s;
    animation-timing-function: ease-in-out;
    animation-fill-mode: both;
}

.screen-transition.fade-in {
    animation-name: fadeIn;
}

.screen-transition.fade-out {
    animation-name: fadeOut;
}

.screen-transition.slide-in-up {
    animation-name: slideInUp;
}

.screen-transition.slide-in-down {
    animation-name: slideInDown;
}

.screen-transition.slide-in-left {
    animation-name: slideInLeft;
}

.screen-transition.slide-in-right {
    animation-name: slideInRight;
}

.screen-transition.scale-in {
    animation-name: scaleIn;
}

.character-animation {
    animation-duration: 1s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

.character-animation.walk {
    animation-name: characterWalk;
    animation-duration: 0.8s;
}

.character-animation.climb {
    animation-name: characterClimb;
    animation-duration: 1.2s;
}

.character-animation.descend {
    animation-name: characterDescend;
    animation-duration: 1.2s;
}

.character-animation.wave {
    animation-name: characterWave;
    animation-duration: 0.6s;
}

.character-animation.jump {
    animation-name: characterJump;
    animation-duration: 0.8s;
}

.character-animation.dance {
    animation-name: characterDance;
    animation-duration: 0.6s;
}

.character-animation.celebrate {
    animation-name: characterCelebrate;
    animation-duration: 1s;
}

.character-animation.sad {
    animation-name: characterSad;
    animation-duration: 1.5s;
}

.character-animation.thinking {
    animation-name: characterThinking;
    animation-duration: 1s;
}

.feedback-animation {
    animation-duration: 0.6s;
    animation-timing-function: ease-in-out;
    animation-fill-mode: both;
}

.feedback-animation.correct {
    animation-name: correctPulse;
}

.feedback-animation.incorrect {
    animation-name: incorrectShake;
}

.feedback-animation.celebrate {
    animation-name: celebrate;
    animation-duration: 1s;
}

.feedback-animation.warning {
    animation-name: warningPulse;
    animation-iteration-count: 3;
}

.loading-animation {
    animation-duration: 1s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.loading-animation.spinner {
    animation-name: loadingSpinner;
}

.loading-animation.pulse {
    animation-name: loadingPulse;
}

.scene-visual-intro {
    animation: slideInUp 0.6s ease-out;
}

.scene-visual-question {
    animation: slideInUp 0.6s ease-out;
    animation-delay: 0.2s;
    animation-fill-mode: both;
}

.scene-visual-question:nth-child(2) {
    animation-delay: 0.3s;
}

.scene-visual-question:nth-child(3) {
    animation-delay: 0.4s;
}

.stairs-scene-container,
.stairs-direction-scene,
.playing-scene-container,
.crowd-scene-container {
    animation: fadeIn 0.8s ease-out;
}

.stairs-behavior,
.playing-behavior,
.crowd-behavior {
    animation: slideInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.stairs-behavior:nth-child(2),
.playing-behavior:nth-child(2),
.crowd-behavior:nth-child(2) {
    animation-delay: 0.2s;
}

.character-on-stairs,
.stairs-character,
.playing-character,
.crowd-character {
    transition: all 0.3s ease;
}

.character-on-stairs:hover,
.stairs-character:hover,
.playing-character:hover,
.crowd-character:hover {
    transform: scale(1.1);
    cursor: pointer;
}

.visual-choice,
.direction-choice-btn,
.playing-choice,
.crowd-choice {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.visual-choice:nth-child(1),
.direction-choice-btn:nth-child(1),
.playing-choice:nth-child(1),
.crowd-choice:nth-child(1) {
    animation-delay: 0.1s;
}

.visual-choice:nth-child(2),
.direction-choice-btn:nth-child(2),
.playing-choice:nth-child(2),
.crowd-choice:nth-child(2) {
    animation-delay: 0.2s;
}

.visual-choice:nth-child(3),
.direction-choice-btn:nth-child(3),
.playing-choice:nth-child(3),
.crowd-choice:nth-child(3) {
    animation-delay: 0.3s;
}

.visual-choice:hover,
.direction-choice-btn:hover,
.playing-choice:hover,
.crowd-choice:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.visual-choice.correct,
.direction-choice-btn.correct,
.playing-choice.correct,
.crowd-choice.correct {
    animation: correctPulse 0.6s ease;
}

.visual-choice.incorrect,
.direction-choice-btn.incorrect,
.playing-choice.incorrect,
.crowd-choice.incorrect {
    animation: incorrectShake 0.6s ease;
}

.scene-card {
    animation: slideInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.scene-card:nth-child(1) {
    animation-delay: 0.1s;
}

.scene-card:nth-child(2) {
    animation-delay: 0.2s;
}

.scene-card:nth-child(3) {
    animation-delay: 0.3s;
}

.scene-card:nth-child(4) {
    animation-delay: 0.4s;
}

.scene-card:hover:not(.locked) {
    animation: bounce 0.5s ease;
}

.scene-card.completed {
    animation: pulse 2s ease-in-out infinite;
}

.scene-card.completed:hover {
    animation: none;
}

.safety-badge-play,
.danger-badge-play,
.crowd-badge {
    animation: scaleIn 0.5s ease;
}

.safety-badge-play {
    animation: glow 2s ease-in-out infinite;
}

.danger-badge-play,
.crowd-badge.danger {
    animation: dangerAlert 1s ease-in-out infinite;
}

.protect-arms-animation {
    animation: protectPose 1.5s ease-in-out infinite;
}

.danger-sign,
.warning-icon {
    animation: dangerAlert 1s ease-in-out infinite;
}

.action-lines {
    animation: shake 0.5s ease-in-out infinite;
}

.hand-holding {
    animation: characterWave 1s ease-in-out infinite;
}

.wrong-behavior-indicator {
    animation: warningPulse 1s ease-in-out infinite;
}

.safety-tip,
.crowd-tip {
    animation: slideInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.safety-tip:nth-child(1),
.crowd-tip:nth-child(1) {
    animation-delay: 0.1s;
}

.safety-tip:nth-child(2),
.crowd-tip:nth-child(2) {
    animation-delay: 0.2s;
}

.safety-tip:nth-child(3),
.crowd-tip:nth-child(3) {
    animation-delay: 0.3s;
}

.safety-tip:nth-child(4),
.crowd-tip:nth-child(4) {
    animation-delay: 0.4s;
}

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

@media (max-width: 768px) {
    .character-animation {
        animation-duration: 0.8s;
    }
    
    .feedback-animation {
        animation-duration: 0.4s;
    }
    
    .scene-visual-question {
        animation-duration: 0.4s;
    }
}

@keyframes restartPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 15px rgba(78, 205, 196, 0);
    }
}

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

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

@keyframes restartGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(78, 205, 196, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(78, 205, 196, 0.8), 0 0 30px rgba(78, 205, 196, 0.6);
    }
}

@keyframes restartConfirmPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 15px rgba(255, 107, 107, 0);
    }
}

@keyframes restartSuccess {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.restart-btn-animation {
    animation-duration: 2s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

.restart-btn-animation.pulse {
    animation-name: restartPulse;
}

.restart-btn-animation.glow {
    animation-name: restartGlow;
}

.restart-icon-animation {
    animation-duration: 1s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

.restart-icon-animation.rotate {
    animation-name: restartRotate;
}

.restart-icon-animation.shake {
    animation-name: restartShake;
}

.restart-confirm-animation {
    animation-duration: 1.5s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

.restart-confirm-animation.pulse {
    animation-name: restartConfirmPulse;
}

.restart-success-animation {
    animation-name: restartSuccess;
    animation-duration: 0.5s;
    animation-timing-function: ease-in-out;
    animation-fill-mode: both;
}

.modal-content.restart-modal {
    animation: slideInDown 0.4s ease-out;
}

.restart-content {
    animation: fadeIn 0.6s ease-out;
}

.restart-content > * {
    animation: slideInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.restart-content > *:nth-child(1) {
    animation-delay: 0.1s;
}

.restart-content > *:nth-child(2) {
    animation-delay: 0.2s;
}

.restart-content > *:nth-child(3) {
    animation-delay: 0.3s;
}

.restart-content > *:nth-child(4) {
    animation-delay: 0.4s;
}

.restart-content > *:nth-child(5) {
    animation-delay: 0.5s;
}

.restart-actions {
    animation: slideInUp 0.5s ease-out;
    animation-delay: 0.6s;
    animation-fill-mode: both;
}
