.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* Dynamically fit columns */
  gap: 20px; /* Adds spacing between items */
  width: calc(100% - 40px); /* Avoid horizontal overflow (adjustable) */
  max-width: 1200px; /* Optional maximum width */
  margin: 20px auto; /* Center the gallery */
  box-sizing: border-box; /* Ensures no overflow caused by margins/padding */
}

.gallery-item {
  overflow: hidden; /* Prevents content from spilling out */
  border-radius: 10px; /* Optional styling */
  cursor: pointer;
  transition: transform 0.3s ease;
  padding:20px;
}

.gallery-item img {
  display: block; /* Ensures no inline spacing */
  width: 100%; /* Fills the grid cell */
  height: 100%; /* Matches the height of grid cells */
  object-fit: cover; /* Prevents distortion */
}

.gallery-item:hover {
  transform: scale(1.05); /* Zoom on hover */
}


/* Overlay styling */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.overlay img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 10px;
  animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
  from {
    transform: scale(0.8);
  }
  to {
    transform: scale(1);
  }
}

.ovclose {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 30px;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
}

.ovclose:hover {
  color: #f00;
}

/* Responsive Design */

/* For Tablets */
@media (max-width: 768px) {
  .gallery {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Adjust grid for smaller screens */
    gap: 10px;
  }
  .gallery-item{padding:30px;}

  .overlay img {
    max-width: 80%;
    max-height: 80%;
  }

  .ovclose {
    font-size: 25px;
  }
}

/* For Mobile Phones */
@media (max-width: 480px) {
  .gallery {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Smaller image sizes for mobile */
    gap: 8px;
  }
.gallery-item{padding:40px;}
  .overlay img {
    max-width: 70%;
    max-height: 70%;
  }

  .ovclose {
    font-size: 20px;
    top: 15px;
    right: 20px;
  }
}