.loader {
  --primary-color: #fff;
  --ball-size: 15px;
  --margin: 2px;
  --size: 25px;
}

.loader-bg {
  background: #2d2f33;
  height: 100%;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
}

.loader {
  margin: auto;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  height: 50px;
  width: 0;
}

@keyframes rotate_pacman_half_up {
  0% {
    transform: rotate(270deg);
  }
  50% {
    transform: rotate(360deg);
  }
  100% {
    transform: rotate(270deg);
  }
}

@keyframes rotate_pacman_half_down {
  0% {
    transform: rotate(90deg);
  }
  50% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(90deg);
  }
}

@keyframes pacman-balls {
  75% {
    opacity: 0.7;
  }
  100% {
    --length-percentage1: calc(-4 * var(--size));
    --length-percentage2: calc(-1 * var(--size) / 4);
    transform: translate(var(--length-percentage1), var(--length-percentage2));
  }
}

.pacman {
  position: relative;
}

.pacman > div:nth-child(2) {
  animation: pacman-balls 1s -0.99s infinite linear;
}

.pacman > div:nth-child(3) {
  animation: pacman-balls 1s -0.66s infinite linear;
}

.pacman > div:nth-child(4) {
  animation: pacman-balls 1s -0.33s infinite linear;
}

.pacman > div:nth-child(5) {
  animation: pacman-balls 1s 0s infinite linear;
}

.pacman > div:first-of-type {
  width: 0px;
  height: 0px;
  border-right: var(--size) solid transparent;
  border-top: var(--size) solid var(--primary-color);
  border-left: var(--size) solid var(--primary-color);
  border-bottom: var(--size) solid var(--primary-color);
  border-radius: var(--size);
  animation: rotate_pacman_half_up 0.5s 0s infinite;
  position: relative;
  left: -30px;
}

.pacman > div:nth-child(2) {
  width: 0px;
  height: 0px;
  border-right: var(--size) solid transparent;
  border-top: var(--size) solid var(--primary-color);
  border-left: var(--size) solid var(--primary-color);
  border-bottom: var(--size) solid var(--primary-color);
  border-radius: var(--size);
  animation: rotate_pacman_half_down 0.5s 0s infinite;
  margin-top: calc(-2 * var(--size));
  position: relative;
  left: -30px;
}

.pacman > div:nth-child(3), .pacman > div:nth-child(4), .pacman > div:nth-child(5), .pacman > div:nth-child(6) {
  background-color: var(--primary-color);
  border-radius: 100%;
  margin: var(--margin);
  width: 10px;
  height: 10px;
  position: absolute;
  --length-percentage2: calc(-1 * var(--size) / 4);
  transform: translate(0, var(--length-percentage2));
  top: 25px;
  left: 70px;
}
