#gallery {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 900px;
  height: 600px;
  background-color: #fff;
  border-radius: 20px;
  border: 1.5px solid #e0e0e0; /* Soft, thin border */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18),
    0 1.5px 6px rgba(243, 156, 18, 0.08);
  z-index: 1000;
  align-items: center;
  padding: 40px 40px 40px 20px;
}

#gallery-main {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 90%;
}

#gallery-thumbnails {
  display: grid;
  grid-template-columns: 40px;
  justify-content: center;
  gap: 15px;
  left: 0px;
}

#gallery-main {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

#gallery-main img {
  max-width: 450px;
  max-height: 450px;
  border-radius: 20px;
}
#gallery-main video {
  border-radius: 20px;
  transform: scale(0.8);
}

.preview {
  background-size: cover;
  width: 100px;
  height: 100px;
  cursor: pointer;
  border: none;
  border-radius: 10px;
}

.preview:hover {
  transform: scale(1.1);
  border: solid 2px #f39c12;
}

#close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 30px;
  cursor: pointer;
  z-index: 2;
}

#close:hover {
  transform: scale(1.1);
  
}

/* For screens ≤ 900px */
@media (max-width: 900px) {
  #gallery {
    width: 98vw;
    height: 98vh;
    padding: 10px 0 10px 0;
    min-width: unset;
    min-height: unset;
    border-radius: 0;
  }
  #gallery-main {
    padding: 0 24px; /* Add horizontal padding */
  }
  #gallery-main img,
  #gallery-main video {
    max-width: 90vw;
    max-height: 40vh;
  }
  #close {
    margin-top: 0;
    margin-bottom: 10px;
    width: 38px;
    height: 38px;
    font-size: 2rem;
  }
  #gallery-thumbnails {
    margin-top: 0;
    margin-bottom: 12px;
  }
}

@media (max-width: 768px) {
  #gallery {
    width: 100vw;
    height: 100vh;
    padding: 0;
    border-radius: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  #gallery-main {
    position: static;
    left: unset;
    top: unset;
    transform: none;
    padding: 0 12px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  #gallery-main img,
  #gallery-main video {
    max-width: 92vw;
    max-height: 32vh;
  }
  #gallery-thumbnails {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 40px 0 8px 0;
    overflow-x: auto;
  }
  .preview {
    width: 60px;
    height: 60px;
    flex: 0 0 auto;
  }

  #gallery #close {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  #close {
    position: static;
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    background: none;
    border: none;
    color: #2c3e50;
    box-shadow: none;
    z-index: 2;
    margin-bottom: 50px;
  }
}