/* Основные стили */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', sans-serif;
}

body {
  background-color: #f9f9f9d5;
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}


/* Шапка сайта */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background-color: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 999;
}

.header-left,
.header-right {
  flex: 1;
  display: flex;
  align-items: center;
}

.header-center {
  flex: 2;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo {
  font-weight: bold;
  font-size: 1.2rem;
  height: 42px;
}

.logo img {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
  vertical-align: middle;
}

.logo-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.logo-link:hover {
  opacity: 0.9;
}

/* Поиск */
.search-wrapper {
  display: flex;
  align-items: center;
  background-color: #f1f1f1;
  border-radius: 20px;
  padding: 10px 16px;
  width: 100%;
  max-width: 420px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  margin: 0 auto;
}

.search-wrapper:hover,
.search-wrapper:focus-within {
  background-color: #ffffff;
  border-color: #c4c4c4;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.search-icon {
  margin-right: 12px;
  flex-shrink: 0;
  stroke: #767676;
}

.search-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: #111;
}

.search-wrapper input::placeholder {
  color: #767676;
}

.search-wrapper input:focus {
  outline: none;
}

/* Галерея */
main#gallery {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-flow: row;
  direction: ltr;
  gap: 16px;
  padding: 20px;
  padding-top: 80px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0;
  position: relative;
  z-index: 1;
}

/* Карточки */
.card {
  background-color: transparent;
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease;
  position: relative;
  z-index: 2;
  display: block;
  aspect-ratio: 1 / 1;
}

.card:hover {
    transform: scale(1.03);
    z-index: 3;
}

.card.ad-card:hover {
    transform: none !important;
    z-index: 2 !important;
    /* по желанию: */
    cursor: default !important;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 1 / 1;
  pointer-events: none;
}

.card.ad-card {
  background: #f3f3f3;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 120px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
}

.card.ad-card,
.card.ad-card .adsbygoogle,
.card.ad-card iframe,
.card.ad-card > div {
  border-radius: 16px !important;
  overflow: hidden !important;
}

/* Модальное окно */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #fff;
  padding: 20px;
  width: 90%;
  max-width: 700px;
  border-radius: 10px;
  position: relative;
  text-align: center;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1001;
}

.modal-content img {
  max-width: 100%;
  border-radius: 10px;
  margin-bottom: 10px;
}

.modal-content h2 {
  margin-top: 10px;
  font-size: 1.2rem;
}

.modal-content p {
  margin: 10px 0;
  font-size: 0.95rem;
  color: #555;
}

/* Кнопка скачивания */
#downloadBtn {
  display: inline-block;
  padding: 12px 24px;
  background-color: #1976d2;
  color: #fff;
  border: none;
  align-items: center;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.2s ease;
}

#downloadBtn:hover {
  background-color: #0d47a1;
}

/* Кнопка закрытия */
.close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  cursor: pointer;
  color: #888;
}

/* Адаптивность для планшета */
@media (max-width: 1200px) {
  main#gallery {
    grid-template-columns: repeat(4, 1fr); /* 4 карточки в ряд для планшета */
  }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
  header {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: space-between;
    padding: 8px 10px;
    gap: 8px;
  }

  .logo {
    display: flex;
    align-items: center;
  }

  .logo img {
    height: 32px;
    display: block;
  }

  .search-wrapper {
    flex: 1;
    width: 100%;
    max-width: 100%;
    height: 36px;
    padding: 6px 10px;
  }

  .header-right {
    flex: unset;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .terms-button img {
    height: 32px;
    width: auto;
    display: block;
  }

  main#gallery {
    grid-template-columns: repeat(2, 1fr); /* 2 карточки в ряд для мобильных */
    padding: 12px;
    padding-top: 70px;
    min-height: 180px; /* 1 карточка + gap, чтобы всегда была видна */
  }
  .footer {
    margin-top: 8px;
  }
}

/* Кнопка условий использования */
.terms-button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.header-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.terms-button img {
  height: 40px;
  width: auto;
  display: block;
}

@media (max-width: 768px) {
  .terms-button img {
    height: 32px;
  }
}

/* Подвал */
.footer {
  background-color: #f8f8f8;
  padding: 10px 0;
  margin-top: 20px;
  box-shadow: none;
  text-align: center;
  color: #222;
  font-family: 'Segoe UI', sans-serif;
  border-top: 1px solid #d0d0d0;
  width: 100%;
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.footer .social-icons {
  margin-top: 8px !important;
  margin-bottom: 0px;
}

.social-icons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 1px;
}

.social-icons a {
  text-decoration: none;
  display: flex;
  align-items: center;
  width: 30px;
  height: 30px;
  fill: #555;
  transition: fill 0.2s ease;
}

.social-icons img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.social-icons a:hover img {
  transform: scale(1.2);
}

.social-icons a:hover {
  fill: #1976d2;
}

.copyright-text {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: #222;
}

.footer-description {
  font-size: 0.8rem;
  line-height: 1.6;
  margin-bottom: 0;
  color: #222;
  max-width: 600px;
}

.footer-link {
  color: #222;
  text-decoration: none;
  margin: 0 8px;
  transition: color 0.2s;
}
.footer-link:hover {
  color: #1976d2;
}

@media (max-width: 768px) {
  .footer-links {
    flex-direction: column;
    gap: 10px;
  }
}

/* Пагинация */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  position: relative;
  z-index: 2;
}

.pagination-button {
  padding: 8px 16px;
  background-color: #1976d2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  position: relative;
  z-index: 2;
}

.pagination-button:hover:not(:disabled) {
  background-color: #1565c0;
}

.pagination-button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
  opacity: 0.7;
}

@media (max-width: 768px) {
  .footer-links {
    flex-direction: column;
    gap: 10px;
  }
}

/* Added styles for terms content */
.terms-content {
  max-width: 800px; /* Limit width for readability */
  margin: 20px auto; /* Center the content block */
  padding: 0 20px; /* Add some padding */
  text-align: left; /* Align text to the left within the content block */
}

.terms-content h3 {
  margin-top: 15px;
  margin-bottom: 5px;
}

.terms-content p {
  margin-bottom: 10px;
  line-height: 1.6;
}

/* Logo positioning for terms.html */
.terms-logo-container {
  position: absolute;
  top: 0; /* Adjust as needed for desired spacing */
  left: 0; /* Adjust as needed for desired spacing */
  z-index: 10; /* Ensure it's above other content */
}
#pageInput {
  margin: 0 8px;
  padding: 4px;
  font-size: 16px;
}
.page-btn,
.page-input {
  height: 40px;
  line-height: 40px;
  font-size: 16px;
  margin: 4px;
  box-sizing: border-box;
  vertical-align: middle;
  padding-top: 0;
  padding-bottom: 0;
}

.page-btn {
  min-width: 100px;
  height: 40px;
  background-color: #0056b3;
  color: #fff;
  border: none;
  padding: 0 16px;
  font-size: 16px;
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px;
  font-weight: bold;
  transition: background 0.2s;
}

.page-btn:disabled {
  background-color: #e0e0e0;
  color: #222;
  cursor: default;
}

.page-btn:not(:disabled):hover {
  background-color: #003d80;
}

.page-input-wrapper {
  display: flex;
  align-items: center;
  height: 40px;
}

.page-input {
  height: 40px;
  width: 40px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin: 0;
  text-align: center;
  line-height: 40px;
  padding: 0;
  background: #fff;
  color: #222;
}

/* Убрать стрелки у input type=number */
.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.page-input[type=number] {
  -moz-appearance: textfield;
}

.page-input::placeholder {
  color: #000;
  opacity: 0.3; /* Полупрозрачность */
}

.close-cross {
  position: fixed;
  top: -5px;
  right: 8px;
  font-size: 36px;
  color: #888;
  text-decoration: none;
  z-index: 1001;
  transition: color 0.2s;
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
  padding: 0;
}
.close-cross:hover {
  color: #1976d2;
}
@media (max-width: 600px) {
  .close-cross {
    top: 2px;
    right: 0;
    font-size: 32px;
    padding: 0 8px 0 0;
  }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-top: 3px solid #1976d2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Восстановленные стили для рекламы под главной картинкой */
.adsense-container {
  width: 320px;
  height: 100px;
  margin: 20px auto;
  background: #f3f3f3;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.adsbygoogle {
  display: block;
  width: 100% !important;
  height: 100% !important;
  margin: 0 auto;
  background: transparent !important;
}
@media (max-width: 350px) {
  .adsense-container {
    width: 98vw;
    min-width: 0;
    height: 80px;
  }
  .adsbygoogle {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
  }
}
@media (min-width: 1100px) {
  .adsense-container {
    width: 850px;
    height: 110px;
  }
  .adsbygoogle {
    width: 100% !important;
    height: 100% !important;
  }
}

/* Удаляю main-ad-block и связанные с ним стили */
.main-ad-block { display: none !important; }

.ad-row, .adsense-container {
  width: 100%;
  min-width: 320px;
  height: 280px;
  min-height: 250px;
  background: #f3f3f3;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0 auto 16px auto;
  margin-top: 48px;
}
@media (max-width: 768px) {
  .adsense-outer {
    width: 98vw;
    max-width: 100vw;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 20px;
    overflow: hidden;
    background: transparent;
    padding: 0;
    box-sizing: border-box;
}
  .adsense-container {
    width: 100%;
    height: 170px;
    max-width: 100vw;
    border-radius: 20px;
    overflow: hidden;
    background: #f3f3f3;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .adsense-container ins,
  .adsense-container iframe,
  .adsense-container > div {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    height: 100% !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    display: block !important;
  }
}
@media (max-width: 600px) {
  .adsense-outer,
  .adsense-container {
    max-width: 97vw !important;
    width: 97vw !important;
    margin: 0 auto !important;
    padding: 0 !important;
    overflow: hidden !important;
    border-radius: 20px !important;
    box-sizing: border-box !important;
  }
  .adsense-container ins,
  .adsense-container iframe,
  .adsense-container > div {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    margin: 0 auto !important;
    display: block !important;
    box-sizing: border-box !important;
  }
}

.bottom-adsense-outer {
  /* На ПК ничего не меняем */
}
@media (max-width: 600px) {
  .bottom-adsense-outer {
    margin-top: 40px !important;
    margin-bottom: 40px !important;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .related-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .card, .related-grid > div {
    max-height: 60vh;
    height: auto;
    aspect-ratio: 1/1;
    max-width: 60vh;
    width: auto;
  }
  .card img, .related-grid > div img {
    max-height: 60vh;
    height: auto;
    width: 100%;
    object-fit: contain;
  }
}


