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

:root {
    --color-bg-primary: #09090b;
    --color-bg-secondary: #18181b;
    --color-accent-secondary: #3f3f46;
    --color-accent-primary: oklch(43.8% 0.218 303.724);
    --color-text-primary: #f4f4f5;
    --color-text-inverse: #09090b;
    --color-text-muted: #a1a1aa;
}

body {
    font-family:
        system-ui,
        -apple-system,
        sans-serif;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    min-height: 100vh;
}
header {
    text-align: left;
    padding: 2rem 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#container {
    max-width: 1300px;
    margin: 0 auto;
    padding-inline: 1em;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
}
.subtitle {
    color: var(--color-text-muted);
    margin-top: 0.25rem;
    font-size: 0.95rem;
}
#search {
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--color-accent-secondary);
    border-radius: 8px;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    font-size: 0.95rem;
    outline: none;
}
#search:focus {
    border-color: var(--color-accent-primary);
}
.stats {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
    text-align: right;
}

.loading {
    text-align: center;
    color: var(--color-text-muted);
    padding: 3rem;
}

.biome-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}
.biome-card {
    min-width: 180px;
    flex: 1 0;
    border: 1px solid var(--color-accent-secondary);
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-bg-secondary);
    cursor: pointer;
    transition:
        border-color 0.15s,
        transform 0.15s;
}
.biome-card:hover {
    border-color: var(--color-accent-primary);
    transform: scale(1.05);
}
.biome-card .thumb {
    width: 100%;
    height: 110px;
    background: #0d1117;
    object-fit: cover;
    overflow: hidden;
}
.biome-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
}
.biome-card .thumb img.loaded {
    opacity: 1;
}
.biome-card .info {
    padding: 0.5rem;
}
.biome-card .info .name {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: capitalize;
}
.biome-card .info .name::before {
    content: attr(data-name);
}
.biome-card .info .count {
    font-size: 0.7rem;
    color: #8b949e;
    margin-top: 0.15rem;
}

.biome-card.active {
    border-color: var(--color-accent-primary);
    background: var(--color-accent-primary);
}

.biome-expanded {
    display: none;
    grid-column: 1 / -1;
    padding: 1.5rem;
    background: var(--color-bg-secondary);
}
.biome-expanded.open {
    display: block;
    position: relative;
    z-index: 1;
}

.biome-expanded.open::before {
    content: "";
    position: absolute;
    width: 100vw;
    height: 100%;
    top: 0;
    left: 50%;
    transform: translateX(-50%);

    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-accent-primary);
    border-bottom: 1px solid var(--color-accent-primary);

    z-index: -1;
}

.biome-expanded .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.biome-expanded .image-grid img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 0.3s,
        transform 0.15s;
}
.biome-expanded .image-grid img.loaded {
    opacity: 1;
}
.biome-expanded .image-grid img:hover {
    transform: scale(1.03);
}

.special-section {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #21262d;
}
.special-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #8b949e;
    font-weight: 600;
}
.special-section .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}
.special-section .image-grid img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 0.3s,
        transform 0.15s;
}
.special-section .image-grid img.loaded {
    opacity: 1;
}
.special-section .image-grid img:hover {
    transform: scale(1.03);
}

#lightbox {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
#lightbox.hidden {
    display: none;
}
#lightbox .lb-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
}
#lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
}
#lightbox .lb-link {
    position: absolute;
    bottom: -2.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: #58a6ff;
    font-size: 0.85rem;
    text-decoration: none;
    background: #161b22;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    border: 1px solid #30363d;
    white-space: nowrap;
}
#lightbox .lb-link:hover {
    border-color: #58a6ff;
}

@media (max-width: 500px) {
    .biome-card {
        width: calc(50% - 0.375rem);
    }
    .biome-card .thumb {
        width: 100%;
        height: 90px;
    }
    .biome-expanded .image-grid img,
    .special-section .image-grid img {
        height: 110px;
    }
}

#lightbox .lb-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.lb-img-container {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;

    width: 90vw;
    max-width: 1000px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.lb-main-img {
    max-width: 95vw;
    max-height: 70vh;
    transition: filter 0.5s ease;
    object-fit: contain;
}

.lb-main-img.blurred {
    filter: blur(20px);
    transform: scale(1.1);
}

/* Controls */
.lb-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

.lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    font-size: 3rem;
    padding: 1rem;
    cursor: pointer;
    z-index: 10;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-prev {
    left: 10px;
}
.lb-next {
    right: 10px;
}

/* Thumbnails Switcher */
.lb-footer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.lb-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    max-width: 80vw;
    padding: 10px;
}

.lb-thumb {
    height: 60px;
    width: 100px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    border: 2px solid transparent;
    transition: 0.2s;
}

.lb-thumb:hover {
    opacity: 0.8;
}
.lb-thumb.active {
    opacity: 1;
    border-color: var(--color-accent-primary);
}
