.grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    margin-top: 2rem;
    width: 100%;
}

.card {
    display: flex;
    min-width: 0;
    transition: transform .2s;
}

.card:hover {
    transform: translateY(-5px);
}

.card-inner {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--accent-light);
    border-radius: 4px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.card img.thumbnail {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 2px;
    margin-bottom: .75rem;
}

.card h3 {
    margin: .5rem 0;
    font-size: 1.15rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.card p {
    margin: .25rem 0;
    font-size: .85rem;
}

.card a {
    display: block;
    width: 100%;
    margin-top: 1.25rem;
    background: var(--text);
    color: var(--main-bg);
    padding: .7rem 1rem;
    border-radius: 2px;
    text-decoration: none;
    text-align: center;
    font-size: .85rem;
    font-weight: 700;
}

.card a:hover {
    background: var(--accent-dark);
}

#totals {
    gap: 0;
    margin-top: 0;
    border: 1px solid var(--accent-light);
}

#totals .card-inner {
    background: transparent;
    border: 0;
    border-right: 1px solid var(--accent-light);
    border-radius: 0;
    padding: 1.5rem 2rem;
}

#totals .card-inner:last-child {
    border-right: 0;
}

#totals h3 {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .13em;
    color: var(--text-light);
}

#totals p {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    color: var(--text);
    margin: .25rem 0 0;
    letter-spacing: -.05em;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 2rem;
    border: 1px dashed var(--accent-light);
}

@media(max-width: 600px) {
    #totals {
        grid-template-columns: 1fr;
    }

    #totals .card-inner {
        border-right: 0;
        border-bottom: 1px solid var(--accent-light);
    }

    #totals .card-inner:last-child {
        border-bottom: 0;
    }
}

.card {
    transition: transform .3s;
}

.card:hover {
    transform: translateY(-7px);
}

.card-inner {
    border-radius: 22px;
    padding: 1.15rem;
    background: linear-gradient(145deg, #30132e, var(--card-bg));
    transition: border-color .3s, box-shadow .3s;
}

.card:hover .card-inner {
    border-color: var(--accent);
    box-shadow: 0 18px 40px #0003;
}

.card img.thumbnail {
    border-radius: 13px;
    aspect-ratio: 4 / 3;
}

.card a {
    margin-top: auto;
    border-radius: 999px;
    background: var(--accent);
    padding: .85rem 1rem;
}

.card p:last-of-type {
    margin-bottom: 1.25rem;
}

.card a:hover {
    background: var(--accent-dark);
}

#totals {
    border-radius: 22px;
    overflow: hidden;
    background: #d8a4d80d;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#totals .card-inner {
    padding: 1.75rem;
}

#totals p {
    color: var(--accent-dark);
}

#totals h3 {
    line-height: 1.6;
}

.empty-state {
    border-radius: 18px;
}

@media(max-width:600px) {
    #totals {
        grid-template-columns: 1fr;
    }

    #totals .card-inner {
        padding: 1.25rem 1.5rem;
    }
}

.home-page .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.75rem;
}

.home-page .card {
    text-align: left;
}

.home-page .card-inner {
    padding: 0;
    overflow: hidden;
    border-radius: 20px;
    background: #2b1029;
    border: 1px solid #d8a4d82b;
}

.home-page .card img.thumbnail {
    border-radius: 0;
    aspect-ratio: 16 / 9;
    margin: 0 0 .75rem;
}

.home-page .card h3 {
    font-size: 1.4rem;
    margin: .6rem 1.5rem;
    font-weight: 850;
    letter-spacing: -.03em;
}

.home-page .card p {
    margin: .25rem 1.5rem;
}

.home-page .card p:last-of-type {
    margin-bottom: 1.5rem;
}

.home-page .card a {
    width: calc(100% - 3rem);
    margin: auto 1.5rem 1.5rem;
    border-radius: 10px;
    font-weight: 850;
}

.home-page #totals {
    max-width: 1100px;
    margin: 2.5rem auto 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    border: 0;
    border-radius: 0;
    background: none;
    overflow: visible;
}

.home-page #totals .card-inner {
    background: #f9eff740;
    border: 1px solid #19001818;
    border-radius: 18px;
    padding: 2rem 1.5rem;
    text-align: center;
    align-items: center;
}

.home-page #totals h3 {
    color: #59234f;
}

.home-page #totals p {
    color: #190018;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 950;
    margin: 0;
}

.home-page #groups {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-page #groups img.thumbnail {
    aspect-ratio: 1.5;
    object-fit: contain;
    padding: 1.5rem;
    background: #d8a4d80d;
}

@media(max-width:750px) {
    .home-page #groups {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media(max-width:600px) {

    .home-page .grid,
    .home-page #groups,
    .home-page #totals {
        grid-template-columns: 1fr;
    }

    .home-page .grid {
        gap: 1.25rem;
    }

    .home-page #totals .card-inner {
        padding: 1.5rem;
    }
}

/* Compact game tiles: four across on desktop, two on tablet. */
.home-page :is(#games, #contributed-games) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.home-page :is(#games, #contributed-games) .card-inner {
    border-radius: 16px;
}

.home-page :is(#games, #contributed-games) img.thumbnail {
    margin-bottom: .4rem;
}

.home-page :is(#games, #contributed-games) h3 {
    font-size: 1.1rem;
    margin: .5rem 1rem;
}

.home-page :is(#games, #contributed-games) p {
    font-size: .8rem;
    margin: .2rem 1rem;
}

.home-page :is(#games, #contributed-games) p:last-of-type {
    margin-bottom: 1rem;
}

.home-page :is(#games, #contributed-games) a {
    width: calc(100% - 2rem);
    margin: auto 1rem 1rem;
    padding: .65rem .8rem;
}

@media(max-width:1000px) {
    .home-page :is(#games, #contributed-games) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media(max-width:480px) {
    .home-page :is(#games, #contributed-games) {
        grid-template-columns: 1fr;
    }
}

/* Scale statistics to their card width without splitting numbers. */
.home-page #totals .card-inner {
    container-type: inline-size;
}

.home-page #totals p {
    max-width: 100%;
    white-space: nowrap;
    overflow-wrap: normal;
    font-size: clamp(1rem, 9vw, 2.25rem);
    font-size: clamp(1rem, 13cqi, 4rem);
    font-variant-numeric: tabular-nums;
}

@media(max-width:600px) {
    .home-page :is(#games, #contributed-games) a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .home-page #groups a {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .home-page #groups .card h3 {
        margin: .6rem 1rem;
        font-size: 1.2rem;
    }

    .home-page #groups .card p {
        margin: .25rem 1rem;
    }

    .home-page #groups .card a {
        width: calc(100% - 2rem);
        margin: auto 1rem 1rem;
    }

    .home-page #totals {
        margin-top: 1.5rem;
        gap: .75rem;
    }

    .home-page #totals .card-inner {
        padding: 1.25rem;
    }
}

.page-status {
    margin: 1.5rem 0 .75rem;
    color: var(--text-light);
    font-size: .85rem;
}

.section-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
}

.section-pagination button {
    min-width: 44px;
    min-height: 44px;
    padding: .6rem .85rem;
    border: 1px solid var(--accent-light);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    font-weight: 750;
    cursor: pointer;
}

.section-pagination button[aria-current="page"] {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: var(--main-bg);
}

.section-pagination button:disabled {
    opacity: .4;
    cursor: default;
}

.section-pagination button:hover:not(:disabled) {
    border-color: var(--accent);
}

@media(max-width:600px) {
    .home-page :is(#games, #contributed-games, #groups) {
        grid-template-columns: 1fr;
    }
}