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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 40px 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    padding: 20px;
}

.photo-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    background: white;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.photo-item.enlarged {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(0);
    width: 90vw;
    height: 90vh;
    max-width: 1600px;
    max-height: 1200px;
    z-index: 1000;
    box-shadow: 0 25px 80px rgba(0,0,0,0.6);
    border-radius: 12px;
}

.photo-item.enlarged .photo-wrapper {
    padding-bottom: 0;
    height: calc(100% - 60px);
}

.photo-item.enlarged .photo-title {
    font-size: 1.2rem;
    padding: 20px;
}

.photo-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.photo-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.4s ease;
}

.photo-item.enlarged .photo-wrapper img {
    object-fit: contain;
}

.photo-title {
    padding: 15px;
    background: white;
    color: #333;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    border-top: 2px solid #f0f0f0;
}

.gallery:has(.photo-item.enlarged)::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999;
}

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    h1 {
        font-size: 1.8rem;
    }
}