.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
}

.gallery-image {
  width: 280px;
  height: 220px;
  object-fit: cover;
  object-position: top center;
  cursor: pointer;
  transition: transform 0.3s ease;
  box-shadow: 5px 5px 10px rgba(0, 0, 0, .5);
}

.gallery-image.adaptive {
  height: 500px;
}

.gallery-image.epic {
  height: 280px;
}

.gallery-image.unset {
  height: 100%;
}

.gallery-image.round {
  border-radius: 50%;
}

.gallery-image:hover {
  transform: scale(1.05);
  /* Эффект наведения */
}

/* ===== Модальное окно (фон) ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 5px;
  margin: auto;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

/* ===== РАМКА (всегда видна, не скроллится) ===== */
.modal-frame {
  background: #fff;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
}

/* ===== КОНТЕЙНЕР С ПРОКРУТКОЙ ===== */
.modal-scroll {
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ===== КАРТИНКА В РЕАЛЬНОМ РАЗМЕРЕ ===== */
.modal-scroll img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  border-radius: 4px;
}

.modal img:hover {
  transform: none;
}

/* ===== Кнопки навигации ===== */
.modal-nav {
    position: fixed; /* ← меняем с absolute на fixed, чтобы не зависеть от скролла */
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 30px;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-nav:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

/* ===== Кнопка закрытия ===== */
.modal-close {
    position: fixed; /* ← тоже fixed, чтобы всегда была видна */
    top: 20px;
    right: 30px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 1001;
    opacity: 0.8;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* ===== Мобильная версия ===== */
@media (max-width: 768px) {
    .modal-nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .modal-prev {
        left: 10px;
    }
    
    .modal-next {
        right: 10px;
    }
    
    .modal-close {
        top: 10px;
        right: 15px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

@media screen and (max-width: 540px) {
  /* ===== Модальное окно (фон) ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
    padding: 0;
}

/* ===== Рамка (центрирование через absolute) ===== */
 .modal-frame {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }

/* ===== Контейнер с прокруткой ===== */
.modal-scroll {
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* ===== Картинка ===== */
.modal-scroll img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    border-radius: 4px;
}

}