* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f0f0f0;
  padding: 20px;
}

.container {
  width: 100%;
  margin: 0 auto;
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  color: #333;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px;
}

@media (max-width: 768px) {
  .image-list {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  .image-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.image-item {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s;
  height: 100%;
}

.image-item:hover {
  transform: scale(1.02);
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  overflow: hidden;
  justify-content: center;
  align-items: center;
}

.modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: move;
  user-select: none;
  display: block;
  margin: auto;
}

.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
  z-index: 1001;
}

.close:hover, .close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px;
  margin-top: -50px;
  color: white;
  font-weight: bold;
  font-size: 20px;
  transition: 0.6s ease;
  border-radius: 3px;
  user-select: none;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 1001;
}

.prev {
  left: 10px;
}

.next {
  right: 10px;
}

.prev:hover, .next:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.drag-image {
  position: relative;
  touch-action: none;
  transform-origin: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.image-index {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-index.visible {
  opacity: 1;
}

.image-container {
  display: flex;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: none;
  width: 100%;
  height: 100%;
  will-change: transform;
  transform: translateZ(0);
}

.image-container img {
  min-width: 100%;
  min-height: 100%;
  object-fit: contain;
  user-select: none;
  will-change: transform;
  transform: translateZ(0);
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  .modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    overflow: hidden;
    justify-content: center;
    align-items: center;
  }
  
  .modal-content {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: default;
    user-select: none;
    display: block;
    margin: auto;
  }
  
  .close {
    display: none;
  }
  
  .prev, .next {
    display: none;
  }
  
  .drag-image {
    touch-action: pan-x, pan-y, pinch-zoom;
  }
}