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

html, body {
    overflow-x: hidden;
}

body.popup-open {
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
    color: #ffffff;
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
    will-change: opacity;
}

.star.small {
    width: 1px;
    height: 1px;
    animation-duration: 2s;
}

.star.medium {
    width: 2px;
    height: 2px;
    animation-duration: 3s;
}

.star.large {
    width: 3px;
    height: 3px;
    animation-duration: 4s;
}

.shooting-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    animation: shoot 3s linear infinite;
    will-change: transform, opacity;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes shoot {
    0% {
        transform: translateX(-100px) translateY(-100px);
        opacity: 1;
    }
    100% {
        transform: translateX(100vw) translateY(100vh);
        opacity: 0;
    }
}

.ascii-title {
    font-family: 'Courier New', monospace;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    white-space: pre;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    margin: 0;
    padding: 3rem 1rem 1.5rem 1rem;
    position: relative;
    z-index: 10;
}

.gallery-container {
    position: relative;
    z-index: 10;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 2rem 0;
}

.sketch-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease-out,
                border-color 0.2s ease-out,
                background-color 0.2s ease-out;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
    will-change: transform;
}

.sketch-item:hover {
    transform: scale(1.02);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.sketch-header {
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sketch-title {
    font-size: 1.3rem;
    font-weight: 600;
    text-transform: capitalize;
    color: #ffffff;
    margin: 0;
    letter-spacing: 0.5px;
}

.sketch-iframe-container {
    position: relative;
    width: 100%;
    height: 200px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-radius: 16px;
}


.sketch-iframe-container.has-iframe {
    cursor: default;
}

.sketch-iframe-container.has-iframe:hover {
    background: #000;
}

.sketch-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
    border-radius: 8px;
    position: absolute;
    top: 0;
    left: 0;
}

/* Placeholder styles */
.sketch-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    background-color: #000;
    border-radius: 12px;
    position: relative;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

.hover-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    max-width: 85%;
    line-height: 1.3;
    word-wrap: break-word;
    hyphens: auto;
}

.sketch-placeholder:hover .hover-title {
    opacity: 1;
}

/* Popup styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    overflow: hidden;
}

.popup-content {
    position: relative;
    overflow: hidden;
    /* Width and height will be set dynamically by JavaScript */
}

/* Disable hover effects for popup sketches */
.popup-content.sketch-item:hover {
    transform: none !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    background: rgba(255, 255, 255, 0.1) !important;
}


.popup-iframe-container {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-iframe {
    border: none;
    border-radius: 16px;
    display: block;
    overflow: hidden;
    flex-shrink: 0;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .star, .shooting-star {
        animation: none;
    }
    
    .sketch-item {
        transition: none;
    }
    
    .sketch-item:hover {
        transform: none;
    }
    
    .hover-title {
        transition: none;
    }
}

/* Performance optimization for low-end devices */
@media (max-width: 768px) {
    .sketch-item {
        backdrop-filter: none;
        transition-duration: 0.1s;
    }
}

/* Loading states */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #444;
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Loading state positioning for popup */
.popup-iframe-container .loading-spinner,
.popup-iframe-container .loading-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Error states */
.error-icon {
    font-size: 2rem;
    color: #ff6b6b;
    margin-bottom: 0.5rem;
}

.error-text {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.click-to-retry {
    color: #ffffff;
    font-size: 0.8rem;
    opacity: 0.8;
    cursor: pointer;
    text-decoration: underline;
}



@media (max-width: 1200px) {
    .ascii-title {
        font-size: 10px;
    }
}

@media (max-width: 900px) {
    .ascii-title {
        font-size: 8px;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .ascii-title {
        font-size: 7px;
    }
    
    .gallery-container {
        padding: 0 1rem;
    }
    
    .sketch-iframe-container {
        height: 280px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1.5rem 1rem;
    }
    
    .ascii-title {
        font-size: 5px;
    }
    
    .sketch-iframe-container {
        height: 220px;
    }
}