.gg-container {
  --main-color: #000;
  --secondary-color: #111;
  --txt-color: #fff;
  --img-bg-color: rgba(240, 240, 240, 0.9);
  --backdrop-color: rgba(240, 240, 240, 0.9);
  --gap-length: 2px;
  --row-height: 200px;
  --column-width: 250px; /* уменьшаем базовую ширину для лучшего размещения */
}

/* Десктопные размеры для больших экранов */
@media (min-width: 1200px) {
  .gg-container {
    --column-width: 280px; /* уменьшаем для больших экранов */
    --row-height: 280px;
  }
}

@media (min-width: 969px) and (max-width: 1199px) {
  .gg-container {
    --column-width: 260px; /* уменьшаем средний размер */
    --row-height: 260px;
  }
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
  .gg-container {
    --column-width: calc(33.33% - var(--gap-length)); /* 3 колонки на планшетах */
    --row-height: 180px; /* увеличиваем высоту */
  }
}

@media (max-width: 480px) {
  .gg-container {
    --column-width: calc(50% - var(--gap-length)); /* 2 колонки на телефонах */
    --row-height: 160px; /* увеличиваем высоту */
    --gap-length: 6px; /* увеличиваем отступы */
  }
}

@media (max-width: 320px) {
  .gg-container {
    --column-width: calc(50% - var(--gap-length)); /* минимум 2 колонки даже на очень узких экранах */
    --row-height: 140px; /* увеличиваем высоту */
  }
}

.gg-container *[data-theme="dark"] {
  --main-color: #ddd;
  --secondary-color: #eee;
  --txt-color: #111;
  --img-bg-color: rgba(20, 20, 20, 0.9);
  --backdrop-color: rgba(30, 30, 30, 0.9);
}

.gg-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--column-width), 1fr));
  grid-auto-rows: var(--row-height);
  grid-gap: var(--gap-length);
  margin: 20px 0;
}

.gg-box img {
  object-fit: cover;
  cursor: pointer;
  width: 100%;
  height: 100%;
  background: var(--img-bg-color);
}

.gg-box img:hover {
  opacity: 0.98;
}

#gg-screen {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: var(--backdrop-color);
  z-index: 9999;
  text-align: center;
}

#gg-screen .gg-image {
  height: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

#gg-screen .gg-image img {
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
}

.gg-btn {
  width: 35px;
  height: 35px;
  background: var(--main-color);
  color: var(--txt-color);
  text-align: center;
  line-height: 35px;
  cursor: pointer;
  -moz-transition: all 0.4s ease;
  -o-transition: all 0.4s ease;
  -webkit-transition: all 0.4s ease;
  transition: all 0.4s ease;
  font-size: 20px;
  box-sizing: border-box;
  padding-left: 2px;
  position: fixed;
  bottom: 10px;
}

.gg-btn:hover {
  background: var(--secondary-color);
}

.gg-close {
  top: 10px;
}

.gg-close,
.gg-next {
  right: 10px;
}

.gg-prev {
  right: 50px;
}

.gg-prev,
.gg-next {
  bottom: 10px;
}

@media (min-width: 478px) {
  .gg-box img:nth-child(2n):not(:last-of-type) {
    grid-row-end: span 2;
  }

  [data-layout="horizontal"] img:nth-child(2n):not(:last-of-type) {
    grid-column-end: span 2;
    grid-row-end: span 1;
  }

  [data-layout="square"] img:nth-child(2n):not(:last-of-type) {
    grid-row-end: span 1;
    grid-column-end: span 1;
  }
}

@media (max-width: 768px) {
  .gg-box {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* увеличиваем минимальную ширину */
    grid-auto-rows: var(--row-height); /* используем переменную вместо calc */
    margin: 10px 0;
  }
}

@media (max-width: 450px) {
  .gg-box {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); /* увеличиваем минимальную ширину */
  }
}

/* Стили для пагинации */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 30px 0;
  padding: 20px 0;
}

.pagination-btn {
  background-color: #ea6511;
  color: white;
  padding: 8px 15px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.3s ease;
  font-size: 16px;
}

.pagination-btn:hover {
  background-color: #e7362c;
  color: #333;
}

.pagination-info {
  font-family: 'Bastion', sans-serif;
  font-size: 14px;
  color: #555;
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid #ddd;
}

/* Мобильная адаптация для пагинации */
@media (max-width: 480px) {
  .pagination {
    flex-direction: column;
    gap: 15px;
  }

  .pagination-btn {
    width: 100%;
    max-width: 200px;
    text-align: center;
    padding: 10px 20px;
    font-size: 14px;
  }

  .pagination-info {
    order: -1;
    font-size: 12px;
  }
}

/* Стили для заголовка в полноэкранном режиме */
.gg-title {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #ea6511;
  color: white;
  padding: 8px 15px;
  border-radius: 5px;
  font-family: 'Bastion', sans-serif;
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  max-width: 80%;
  z-index: 10001;
  transition: background-color 0.3s ease;
}

.gg-title:hover {
  background-color: #e7362c;
  color: #333;
}

/* Мобильная адаптация для заголовка */
@media (max-width: 480px) {
  .gg-title {
    top: 60px;
    font-size: 14px;
    padding: 8px 16px;
    max-width: 90%;
  }
}
