html,
body {
  height: 100%;
  margin: 0;
}

body {
  background-color: #181818;
  color: #fff;
  text-align: center;
  width: 100%;
  display: flex;
  align-items: center;
  flex-direction: column;
  overflow: auto;
}

body.overlay-open {
  position: fixed;
  width: 100%;
}

input[type="file"] {
  display: none;
}

.custom-file-input {
  margin: 10px;
  padding: 10px 20px;
  font-size: 16px;
  font-family: Arial, Helvetica, sans-serif;
  cursor: pointer;
  background-color: #f3c669;
  color: #fff;
  border: none;
  border-radius: 10px;
  display: inline-block;
}

#clearAll {
  background-color: #fc357b;
}

/* Common button styles */
button {
  margin: 10px 0 10px 10px;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background-color: #393939;
  color: #fff;
  border: none;
  border-radius: 10px;
}

button.selectedGridOption {
  outline: #f3c669 2px solid;
}

button span {
  opacity: 0.8;
}

/* Shared menu button styles */
.menu-button {
  margin: 5px 0;
  background-color: #393939;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: auto;
  margin-right: auto;
}

/* Shared page info styles */
.page-info {
  margin: 20px 0;
  font-size: 12px;
  color: #f3c669;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 5px;
}

.page-info input {
  background-color: transparent;
  border: 1px solid #f3c669;
  border-radius: 5px;
  padding: 5px;
  text-align: center;
  width: 30px;
  color: #f3c669;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
}

.page-info input:focus {
  outline: 2px solid #f3c669;
  background-color: rgba(243, 198, 105, 0.1);
  cursor: text;
}

.page-info .page-separator {
  width: 100%;
  border-top: 1px solid rgba(243, 198, 105, 0.3);
  margin: 3px 0;
}

.page-info span {
  color: #f3c669;
  opacity: 0.8;
}

/* Shared side menu base styles */
.side-menu-base {
  position: fixed;
  left: -100px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  background-color: rgba(25, 25, 25, 0.95);
  border-radius: 40px;
  padding: 20px 10px;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  text-align: center;
  border: 1px solid rgba(243, 198, 105, 0.4);
  box-shadow:
    0 0 0 1px rgba(243, 198, 105, 0.2),
    0 8px 20px rgba(0, 0, 0, 0.6);
}

.side-menu-base.visible {
  left: 20px;
}

#buttonContainer {
  min-width: 90%;
  margin: 35px 0 15px;
}

@media (min-width: 600px) {
  #buttonContainer {
    display: flex;
    justify-content: space-between;
  }
}

.image-container {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  max-width: 90%;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}

.image-container.no-gap {
  gap: 0;
}

.image-container img {
  width: 100%;
  height: auto;
  object-fit: cover;
  cursor: pointer;
}

@media (min-width: 600px) {
  .image-container.twenty-four-per-row {
    grid-template-columns: repeat(24, 1fr);
  }
  .image-container.twelve-per-row {
    grid-template-columns: repeat(12, 1fr);
  }
  .image-container.six-per-row {
    grid-template-columns: repeat(6, 1fr);
  }
  .image-container.three-per-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .image-container.two-per-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .image-container.one-per-row {
    grid-template-columns: repeat(1, 1fr);
  }
}

/* Force full-width container ONLY in one-per-row */
.image-container.one-per-row {
  width: 100%;
  justify-items: stretch;
}

/* Default: fill width */
.image-container.one-per-row img {
  width: 100%;
  height: auto;
}

/* Toggle OFF: keep intrinsic size */
.image-container.one-per-row.actual-width img {
  width: auto;
  max-width: 100%;
  justify-self: center;
}

#overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.8);
  overflow-y: auto;
  overflow-x: hidden;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#overlay.width-limited-mode {
  justify-content: center;
  align-items: center;
}

#overlay.width-limited-mode img.width-limited.tall {
  align-self: flex-start;
}

#overlay.height-limited-mode {
  justify-content: center;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
}

#overlayImage {
  width: 100%;
  height: auto;
  max-height: 100vh;
  display: block;
  margin: auto;
  object-fit: contain;
}

#overlayImage.width-limited {
  max-width: 80vw;
  max-height: none;
  height: auto;
}

#overlayImage.height-limited {
  max-height: 80vh;
  max-width: none;
  width: auto;
}

#overlayImage.zoomed {
  cursor: zoom-out;
}

#zoomLens {
  position: absolute;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: crosshair;
  display: none;
  pointer-events: none;
}

/* Apply shared styles to both side menus */
#sideMenu,
#mainSideMenu {
  z-index: 1001;
}

#mainSideMenu {
  z-index: 999;
}

#scrollToTopBtn {
  position: fixed;
  bottom: 40px;
  right: 40px;
  display: none;
  background-color: #f3c669;
  border: none;
  border-radius: 50%;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: opacity 0.3s;
  font-size: 24px;
  font-weight: bold;
}

#scrollToTopBtn:hover {
  background-color: #e0b94d;
}
