.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 140px);
    grid-gap: 10px;
    justify-content: center;
    align-items: center;
}

.animated-element {
    position: relative;
    width: 140px;
    height: 140px;
    overflow: hidden;
    border-radius: 15px;
    background-color: transparent; /* Прозрачный фон */
}

.image-element {
    width: 140px;
    height: 140px;
    object-fit: cover;
    opacity: 0;
    animation: fadeInOut 15.8s linear infinite; /* Общая продолжительность анимации */
}

/* Ключевые кадры анимации */
@keyframes fadeInOut {
    0%, 100% {
        opacity: 0;
    }
    2%, 4% {
        opacity: 1;
    }
    6%, 8% {
        opacity: 0;
    }
    10%, 12% {
        opacity: 1;
    }
    14%, 16% {
        opacity: 0;
    }
    18%, 20% {
        opacity: 1;
    }
    22%, 24% {
        opacity: 0;
    }
    26%, 28% {
        opacity: 1;
    }
    30%, 32% {
        opacity: 0;
    }
    34%, 36% {
        opacity: 1;
    }
    38%, 40% {
        opacity: 0;
    }
    42%, 44% {
        opacity: 1;
    }
    46%, 48% {
        opacity: 0;
    }
    50%, 52% {
        opacity: 1;
    }
    54%, 56% {
        opacity: 0;
    }
    58%, 60% {
        opacity: 1;
    }
    62%, 64% {
        opacity: 0;
    }
    66%, 68% {
        opacity: 1;
    }
    70%, 72% {
        opacity: 0;
    }
    74%, 76% {
        opacity: 1;
    }
    78%, 80% {
        opacity: 0;
    }
    82%, 84% {
        opacity: 1;
    }
    86%, 88% {
        opacity: 0;
    }
    90%, 92% {
        opacity: 1;
    }
    94%, 96% {
        opacity: 0;
    }
    98% {
        opacity: 1;
    }
}

/* Задержки для хаотичного порядка */
.animated-element:nth-child(1) .image-element { animation-delay: 0s; }
.animated-element:nth-child(2) .image-element { animation-delay: 0.4s; }
.animated-element:nth-child(3) .image-element { animation-delay: 0.8s; }
.animated-element:nth-child(4) .image-element { animation-delay: 1.2s; }
.animated-element:nth-child(5) .image-element { animation-delay: 1.6s; }
.animated-element:nth-child(6) .image-element { animation-delay: 2s; }
.animated-element:nth-child(7) .image-element { animation-delay: 2.4s; }
.animated-element:nth-child(8) .image-element { animation-delay: 2.8s; }
.animated-element:nth-child(9) .image-element { animation-delay: 3.2s; }