*, *:before, *:after {
  box-sizing: border-box;
}

body, html {
  height: 100%;
}

#container {
  width: 250px;
  height: 50px;
  position: relative;
  top: calc(50% - 150px);
  left: calc(50% - 125px);
}

.ball {
  width: 50px;
  height: 50px;
  box-shadow: 0 -5px 0 rgba(0, 0, 0, 0.15) inset;
  background-color: #397BF9;
  border-radius: 50%;
  border: 2px solid black;
  position: absolute;
}

.wrap {
  width: 50px;
  height: 50px;
  position: absolute;
}

.wrap:after,
#ball2:after,
#ball3:after,
#ball4:after {
  content: '';
  width: 50px;
  height: 7.5px;
  background: #eee;
  position: absolute;
  bottom: 0;
  top: 70px;
  border-radius: 50%;
}

.wrap:after {
  top: 72px;
  animation: scale 650ms infinite ease-in-out;
}

#wrap1a:after,
#wrap1b:after {
  animation-delay: -325ms;
  left: 2px;
}

#ball2 {
  background-color: #00A656;
  left: 50px;
}

#ball3 {
  background-color: #EEEEEE;
  left: 100px;
}

#ball4 {
  background-color: #F4B400;
  left: 150px;
}

#wrap1a,
#wrap1b {
  transform: translateX(-100px);
  animation: translateX 650ms infinite ease-in;
}

#ball1a,
#ball1b {
  transform: translateY(-100px);
  animation: translateY 650ms infinite ease-in-out;
}

#wrap2a,
#wrap2b {
  transform: translateX(100px);
  left: 200px;
  position: absolute;
  animation: translateX 650ms infinite ease-in;
  animation-delay: -325ms;
}

#ball5a,
#ball5b {
  background-color: #E3746B;
  animation: translateY 650ms infinite ease-in-out;
  animation-delay: -325ms;
}

#ball1b,
#ball5b,
#wrap1b,
#wrap2b {
  animation-direction: reverse;
}

@keyframes translateX {
  25% {
    opacity: 1;
    transform: translateX(0);
  }
  50% {
    opacity: 1;
  }
  51% {
    opacity: 0;
  }
  100% {
    opacity: 0;
    transform: translateX(0);
  }
}
@keyframes translateY {
  0% {
    transform: translateY(-50px);
  }
  25% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(0);
  }
}
@keyframes scale {
  25% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(1.15);
  }
  75% {
    transform: scaleX(1);
  }
}