.spider {
  --spider-color: #40434F;

  position: absolute;
  width: 75px;
  height: 175px;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: center top;
  top: 190px;
  animation: swing 1s infinite ease-in-out;
  animation-direction: alternate-reverse;
}

@keyframes swing {
  0% {
    transform: translateX(-50%) rotate(25deg);
  }
  
  100% {
    transform: translateX(-50%) rotate(-25deg);
  }
}

.spider::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 100px;
  background: white;
}

.body {
  position: absolute;
  width: 30px;
  height: 40px;
  border-radius: 50% 50% 40% 40%;
  background: var(--spider-color);
  left: 50%;
  top: 100px;
  transform: translateX(-50%);
}

.body::before {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: black;
  border-radius: 50%;
  border: 3px solid white;
  bottom: 6px;
  left: 3px;
}


.body::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: black;
  border-radius: 50%;
  border: 3px solid white;
  bottom: 6px;
  right: 3px;
}

.leg {
  position: absolute;
 
  top: 10px;
  width: 30px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 -3px 0 var(--spider-color);
}

.leg.left {
   left: -25px;
}

.leg.right {
  right: -25px;
}

.leg::before {
  content: '';
  position: absolute;
  top: 10px;
  width: 30px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 -3px 0 var(--spider-color);
}


.leg::after {
  content: '';
  position: absolute;
  top: 20px;
  width: 20px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 -3px 0 var(--spider-color);
}

.leg.left::after {
  left: 8px;
}

.leg.right::after {
  right: 8px;
}