* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

/* Generation Menu Styles */
.gen-menu {
    position: fixed;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.75rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
    transition: transform 0.3s ease;
}

.gen-menu.hidden {
    transform: translate(calc(100% + 0.5rem), -50%);
}

.gen-menu-toggle {
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px 0 0 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
    font-size: 14px;
    color: #666;
    padding: 0;
}

.gen-menu-toggle:hover {
    color: #333;
}

.gen-menu.hidden .gen-menu-toggle {
    transform: translateY(-50%) rotate(180deg);
}

.gen-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    background: #3498db;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    padding: 0;
    font-size: 0.9rem;
}

.gen-btn:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.gen-btn.active {
    background: #2c3e50;
}

.gen-btn[data-start="all"] {
    font-size: 0.8rem;
}

body {
    background: #f0f0f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    padding: 2rem;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 1200px) {
    .gallery {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1600px) {
    .gallery {
        grid-template-columns: repeat(6, 1fr);
    }
}

.card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    cursor: default;
}

.card.loaded {
    cursor: pointer;
}

.card.loaded:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0,0,0,0.15);
}

.image-container {
    position: relative;
    width: 100%;
    padding-bottom: 146%; /* 411:600 aspect ratio (600/411 ≈ 1.46) */
    background: #f5f5f5;
    overflow: hidden;
}

.image-container img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed to contain to preserve aspect ratio */
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.card.loaded:hover .image-container img {
    transform: translate(-50%, -50%) scale(1.05);
}

.image-container img.loaded {
    opacity: 1;
}

.image-container .placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.card-info {
    padding: 1rem;
    text-align: center;
}

.number {
    color: #666;
    font-size: 0.9rem;
}

.name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-top: 0.5rem;
    color: #333;
}

.card-date {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
    font-style: italic;
}

h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
}

.navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.nav-button {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.nav-button:hover {
    background-color: #2980b9;
}

.nav-button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.date-picker {
    text-align: center;
    color: #666;
    font-size: 1.1rem;
    min-width: 200px;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.date-picker:focus {
    outline: none;
    border-color: #3498db;
}

.date-picker::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.date-picker::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.error-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

.modal-content {
    position: relative;
    width: min(1200px, 95vw);
    height: min(90vh, 1200px);
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-thumbnail {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: min(293px, 30vh);
    width: auto;
    opacity: 0.5;
    transition: all 0.3s ease;
    object-fit: contain;
    filter: brightness(0.7);
    cursor: pointer;
    z-index: 1;
}

.modal-thumbnail.prev-thumbnail {
    left: 2rem;
}

.modal-thumbnail.next-thumbnail {
    right: 2rem;
    z-index: 0;
}

.modal-thumbnail:hover {
    opacity: 0.8;
    filter: brightness(0.9);
    transform: translateY(-50%) scale(1.1);
}

.modal-image-container {
    position: relative;
    height: min(880px, 90vh);
    width: min(600px, 50vw);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.modal-image-container img {
    max-height: 100%;
    width: 100%;
    max-width: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin: 0 auto;
}

.modal-image-container img.loaded {
    opacity: 1;
}

.modal-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.modal-info {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: white;
    font-size: 1.2rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.75rem;
    border-radius: 8px;
    backdrop-filter: blur(5px);
    width: min(600px, 50vw);
    z-index: 20;
}

.modal-date {
    font-size: 1rem;
    opacity: 0.9;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 1rem;
    pointer-events: none;
    z-index: 10;
}

.modal-nav button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 1rem;
    cursor: pointer;
    border-radius: 50%;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    pointer-events: auto;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal-nav button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Virtual scroll container */
.virtual-scroll-container {
    min-height: 800px; /* Approximate height to prevent layout shifts */
    position: relative;
}

.virtual-scroll-placeholder {
    height: 20px;
    margin: 1rem 0;
    text-align: center;
    color: #666;
}

/* Search styles */
.welcome-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin: 0 auto 2rem;
    max-width: 800px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

.welcome-card h2 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.welcome-card p {
    color: #666;
    line-height: 1.6;
    font-size: 1.1rem;
}

.search-container {
    max-width: 600px;
    margin: 0 auto 2rem;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    border-color: #3498db;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.autocomplete-list.active {
    display: block;
}

.autocomplete-item {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f5f5f5;
}

.no-results {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-size: 1.2rem;
    background: white;
    border-radius: 8px;
    margin: 2rem auto;
    max-width: 600px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
