.pacman {
    position: fixed;
    z-index: 1000;
    display: none;
    width: 60px;
    height: 60px;
    opacity: 0.65;
}

.pacman.active {
    display: block;
    animation: eating 2s linear forwards;
}

.pacman.facing-left {
    transform: scaleX(-1);
}

.pacman.facing-left.active {
    animation: eating-left 2s linear forwards;
}

.pacman-top {
    background-color: #F2D648;
    height: 30px;
    width: 60px;
    border-radius: 30px 30px 0 0;
    animation: spin1 0.25s infinite linear;
}

.pacman-bottom {
    background-color: #F2D648;
    height: 30px;
    width: 60px;
    border-radius: 0 0 30px 30px;
    animation: spin2 0.25s infinite linear;
}

@keyframes spin1 {
    0%, 100% {transform: rotate(0deg);}
    50% {transform: rotate(-35deg);}
}

@keyframes spin2 {
    0%, 100% {transform: rotate(0deg);}
    50% {transform: rotate(35deg);}
}

.fruit {
    width: 30px;
    height: 30px;
    position: fixed;
    z-index: 0;
    display: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.fruit.active {
    display: block;
    animation: fruitPulse 0.8s ease-in-out infinite alternate;
}

@keyframes fruitPulse {
    from {
        transform: scale(1);
        opacity: 0.8;
    }
    to {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes eating {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(var(--travel-distance));
    }
}

@keyframes eating-left {
    0% {
        transform: translateX(0) scaleX(-1);
    }
    100% {
        transform: translateX(var(--travel-distance)) scaleX(-1);
    }
}

.pacman.facing-up {
    transform: rotate(-90deg);
}

.pacman.facing-down {
    transform: rotate(90deg);
}

.pacman.facing-up.active {
    animation: eating-up 2s linear forwards;
}

.pacman.facing-down.active {
    animation: eating-down 2s linear forwards;
}

@keyframes eating-up {
    0% {
        transform: translateY(0) rotate(-90deg);
    }
    100% {
        transform: translateY(var(--travel-distance)) rotate(-90deg);
    }
}

@keyframes eating-down {
    0% {
        transform: translateY(0) rotate(90deg);
    }
    100% {
        transform: translateY(var(--travel-distance)) rotate(90deg);
    }
}
