body.modal-open {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

@supports (-webkit-touch-callout: none) {
  body.modal-open {
    position: fixed;
    width: 100%;
  }
}

.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;
  opacity: 0;
  transition: opacity 0.3s ease;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  perspective: 1000px;
}

.modal-img-container {
  position: relative;
  transform-style: preserve-3d;
  animation: spaceAppear 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  will-change: transform;
}

@keyframes spaceAppear {
  0% {
    transform: scale(0.5) rotateX(45deg) rotateY(15deg) translateY(100px);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotateX(0) rotateY(0) translateY(0);
    opacity: 1;
  }
}

.modal-img {
  max-width: 80vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
}

.image-caption {
  position: absolute;
  bottom: -40px;
  left: 0;
  width: 100%;
  text-align: center;
  color: white;
  font-size: 1.1em;
  padding: 10px;
  background: rgba(0,0,0,0.7);
  border-radius: 0 0 8px 8px;
}

.close {
  position: absolute;
  top: 25px;
  right: 35px;
  color: #fff;
  font-size: 35px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  text-shadow: 0 0 10px #3b82f6;
  z-index: 1001;
}

.close:hover {
  color: #3b82f6;
  transform: rotate(90deg);
}