body {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    width: 100%;
    height: 600px;
    font-family: monospace;
}

.container {
    position: relative;
    perspective: 800px;
    width: 200px;
    height: 200px;
}

.cube-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform: translateZ(-100px);
    animation: spin 8s infinite ease-in-out;
}

.cube {
    width: 200px;
    height: 200px;
    position: absolute;
    opacity: 0.7;
}

.top {
    background-color: red;
    transform: rotateX(90deg) translateZ(100px);
}

.bottom {
    background-color: aqua;
    transform: rotateX(-90deg) translateZ(100px);
}

.left {
    background-color: blueviolet;
    transform: rotateY(-90deg) translateZ(100px);
}

.right {
    background-color: blue;
    transform: rotateY(90deg) translateZ(100px);
}

.front {
    background-color: beige;
    transform: translateZ(100px)
}

.back {
    background-color: yellow;
    transform: rotateX(180deg) translateZ(100px);
}

@keyframes spin{
    0% {
        transform: translateZ(-100px) rotateX(0) rotateY(0);
    }
    100% {
        transform: translateZ(-100px) rotateX(360deg) rotateY(360deg);
    }
}