body {
    background: #F8FAFC;
    color: #333;
    font-family: 'Montserrat', sans-serif;
    font-weight: 300;
    font-size: 15px;
    letter-spacing: .01em;
    line-height: 1.2;
}

a {
    color: #b71c1c;
}

strong {
    font-weight: 700;
}

h2 {
    margin: 0;
    margin-bottom: 5px;
    padding: 0;
    font-size: 9px;
    text-transform: uppercase;
}

details summary {
    cursor: pointer;
}

details summary::-webkit-details-marker {
    display: none;
}

details>summary:first-of-type {
    list-style-type: none;
}

body {
    margin: 0;
    padding: 0;
    position: relative;
}

.search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 0.75em;
    padding: 0.5em 1em;
}

.wrapper {
    padding: 1em;
    position: relative;
}

.material-symbols-rounded {
    font-size: 24px;
}

.material-symbols-rounded.icon-medium {
    font-size: 18px;
}

.material-symbols-rounded.icon-small {
    font-size: 16px;
}

.facets-row {
    display: flex;
    flex-wrap: wrap-reverse;
    align-items: flex-start;
    gap: 1em;
    padding-bottom: 1em;
}

.facets {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative;
    z-index: 10;
    flex-wrap: wrap;
    background-color: #F8FAFC;
    gap: 1em;
    flex: 1 1 600px;
    min-width: min(600px, 100%);
    justify-content: center;
}

.filter-control {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 16px;
    justify-content: center;
    align-items: center;
}

.filter-control .clear-all {
    flex-grow: 0;
    flex-shrink: 0;
}

#current-filters {
    display: contents;
}

.current-filter-chip {
    display: flex;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 24px;
    background: #fff;
    padding: 0 0 0 12px;
    flex-shrink: 0;
}

.current-filter-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    color: #b71c1c;
    border-radius: 24px;
    font-size: 1em;
    line-height: 1;
}

.current-filter-delete:hover {
    background-color: rgba(183, 28, 28, 0.1);
}

.filter-dropdown {
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    background-color: #fff;
    position: relative;
    padding: 0;
    display: flex;
    flex-direction: column;
    flex-grow: 0;
}

.filter-dropdown:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Active filter indicator - red bottom border */
.filter-dropdown.filter-active {
    border-bottom: 3px solid #b71c1c;
}

.filter-dropdown>summary {
    padding: 8.75px 0.75rem;
    list-style: none;
    border: none;
    margin: 0;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 5px;
    min-width: 0;
}

.filter-dropdown>summary .filter-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-dropdown>summary .filter-title::after {
    content: "▼";
    padding-left: 8px;
    font-size: 0.65em;
}

.filter-dropdown[open]>.filter-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    background-color: #f8fafc;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    max-width: calc(100vw - 16px);
    max-height: 50vh;
    overflow-y: auto;
    box-sizing: border-box;
    border-radius: 6px;
    padding: 5px 0;
}

.filter-dropdown-content {
    display: flex;
    flex-direction: column;
}

.filter-search {
    position: sticky;
    top: 0;
    background: #f8fafc;
    padding: 5px 10px 8px;
    z-index: 1;
}

.filter-search-input {
    width: 100%;
    padding: 0.4em 0.6em;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    font-size: 0.9em;
    font-family: inherit;
    box-sizing: border-box;
}

.filter-items {
    display: flex;
    flex-direction: column;
}

.filter-item.search-hidden {
    display: none !important;
}

.clear-all {
    border-radius: 5px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
}

.clear-button {
    background: none;
    color: #b71c1c;
    border: 1px solid #b71c1c;
    border-radius: 24px;
    cursor: pointer;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1em;
    line-height: 1;
    padding: 6px 14px;
}

.clear-button:hover {
    background-color: rgba(183, 28, 28, 0.1);
}

.clear-button:active {
    background-color: rgba(183, 28, 28, 0.15);
}

.logo {
    margin-right: 1em;
}

.search-box {
    max-width: 300px;
    margin-right: 1em;
    flex-grow: 1;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 0.6em;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px !important;
    color: #999;
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 0.5em 2.2em;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    font-family: inherit;
    box-sizing: border-box;
}

.search-clear-btn {
    position: absolute;
    right: 0.3em;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    color: #999;
}

.search-clear-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #555;
}

.search-clear-btn .material-symbols-rounded {
    font-size: 18px !important;
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 1em;
    flex-shrink: 0;
    flex-grow: 1;
    justify-content: flex-end;
}

/* Once List/Grid + Sort no longer fit alongside the search row, drop them to their
   own full-width line and center them there instead of leaving them stuck on the right. */
@media screen and (max-width: 820px) {
    .view-controls {
        flex-basis: 100%;
        justify-content: center;
    }

    .search-box {
        max-width: none;
    }
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 0.3em;
    white-space: nowrap;
}

.sort-by {
    max-width: 150px;
    flex-grow: 1;
    position: relative;
}

.sort-by::after {
    content: "▼";
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65em;
    color: #606c76;
    pointer-events: none;
}

#sort-select {
    padding: 8.5px 1.8rem 8.5px 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    background: #fff;
    color: inherit;
    font-size: 1em;
    font-family: inherit;
    font-weight: inherit;
    box-sizing: border-box;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

#sort-select:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.sort-dir-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8.75px;
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    cursor: pointer;
    box-sizing: border-box;
    overflow: hidden;
}

.sort-dir-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.sort-dir-btn .material-symbols-rounded {
    font-size: 18px;
    line-height: 1;
    color: #606c76;
}


.stats {
    display: inline-block;
    white-space: nowrap;
}

.game-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: 12px auto 0;
    padding: 0;
}

.game-card {
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    position: relative;
    list-style: none;
}

.game-image {
    display: block;
    margin: 0;
    height: 150px;
    width: auto;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 5px;
    box-shadow: none;
    image-rendering: smooth;
    transition: transform 200ms ease-out, box-shadow 200ms ease-out;
    will-change: transform;
}

.game-image:hover {
    transform: scale(1.1);
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.game-title-text,
.game-meta-text,
.game-info-text {
    display: none;
}

/* View toggle (grid is the default, unclassed state) */
.view-toggle {
    display: flex;
    align-items: center;
    gap: 0.25em;
}

.view-toggle button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8.75px 0.7em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35em;
    font-size: 1em;
    font-family: inherit;
    font-weight: inherit;
    color: #606c76;
    box-sizing: border-box;
    min-width: 5.2em;
}

.view-toggle button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.view-toggle img {
    width: 18px;
    height: 18px;
    opacity: 0.6;
}

/* List view overrides */
#hits.list-view .game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr));
    gap: 0.5rem;
}

#hits.list-view .game-card {
    flex-direction: row;
    width: auto;
    min-width: 0;
    border-radius: 6px;
    overflow: hidden;
    background-color: rgba(var(--tint-color, 200, 200, 200), 0.2);
    transition: background-color 0.15s ease-out;
}

#hits.list-view .game-card:hover {
    background-color: rgba(var(--tint-color, 200, 200, 200), 0.25);
}

#hits.list-view .game-summary {
    justify-content: flex-start;
    align-items: stretch;
    width: 100%;
    gap: 1rem;
    min-height: 64px;
}

#hits.list-view .game-image {
    width: 64px;
    height: 64px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: top;
    flex-shrink: 0;
    align-self: center;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

#hits.list-view .game-image:hover {
    transform: none;
}

#hits.list-view .game-info-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.5rem 1rem 0.5rem 0;
}

#hits.list-view .game-title-text {
    display: block;
    font-size: 0.95em;
    font-weight: 600;
}

#hits.list-view .game-meta-text {
    display: flex;
    gap: 14px;
    margin-top: 2px;
}

#hits.list-view .stat-text {
    line-height: 1.25;
}

#hits.list-view .stat-label {
    font-size: 10px;
}

#hits.list-view .stat-value {
    font-size: 12.5px;
}

/* Scrim behind the game-details popup */
.scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    display: none;
}

body:has(details.game-card[open]) .scrim {
    display: block;
}

body:has(details.game-card[open]) {
    overflow: hidden;
}

details:not([open]) > .game-details {
    display: none;
}

.game-details {
    background: #fff;
    box-shadow: 1px 1px 25px rgba(0, 0, 0, 0.4);
    border-radius: 5px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(80%, 900px);
    max-height: calc(100vh - 32px);
    z-index: 100;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.game-details h2 {
    font-size: 1em;
    text-transform: none;
}

.game-details-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.card-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    position: relative;
}

.cover-image {
    height: 60px;
    margin-right: 15px;
    flex-shrink: 0;
}

.cover-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.title-section {
    flex: 1;
    min-width: 0;
}

.game-title {
    margin: 0 0 5px 0;
    font-size: 20px;
    line-height: 1.2;
}

.title-section .tag-chip {
    background: rgba(128, 128, 128, 0.2);
}

.stats-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 15px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #555;
}

.stat-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.stat-label {
    font-size: 0.75em;
    color: #666;
}

.stat-value {
    font-size: 1em;
    color: #333;
}

.icon-themed.icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #999;
    color: #fff;
    font-size: 22px;
    flex-shrink: 0;
}


.description-section {
    padding: 10px 15px;
    line-height: 1.5;
    border-bottom: 1px solid #e0e0e0;
}

.tags-section {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.expansions-section {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.expansion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.expansion-chip {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 0.8em;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
}

.expansion-chip:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
    color: #000;
}

.expansion-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 10px;
}

.expansions-section .expansion-chips a.expansion-tile {
    display: flex;
    align-items: center;
    text-decoration: none;
    min-width: 0;
}

.expansion-thumb {
    display: block;
    margin: 0;
    height: 80px;
    width: auto;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 5px;
    box-shadow: none;
    image-rendering: smooth;
    transition: 200ms ease-out;
}

.expansion-thumb:hover {
    transform: scale(1.1);
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.expansion-tile-name {
    display: none;
}

.expansions-section div a {
    color: #b71c1c;
    text-decoration: none;
}

.expansions-section div a:hover {
    text-decoration: underline;
}

.close-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.0);
    color: #333;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
    transition: background-color 0.2s ease;
}

.close-button:hover {
    background: rgba(0, 0, 0, 0.1);
}

.teaser-text {
    line-height: 1.4;
}

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 1em;
    margin-left: -5px
}

.tag-chip {
    padding: 4px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
}

.tag-chip.mechanics {
    background: #f5f5f5;
    color: #555;
    border-color: #ccc;
}

.tag-chip.categories {
    background: #f8f8f8;
    border-color: #ddd;
}

.bgg-link-header {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.75em;
    color: inherit;
    text-decoration: none;
    opacity: 0.85;
}

.bgg-link-header:hover {
    text-decoration: underline;
    opacity: 1;
}

.bgg-link-header .icon-small {
    font-size: 14px;
}

.loading {
    text-align: center;
    padding: 2em;
    font-size: 1.2em;
    color: #888;
}

.error {
    text-align: center;
    padding: 2em;
    color: #d32f2f;
    background: #ffeaea;
    border: 1px solid #ffcdd2;
    border-radius: 5px;
    margin: 1em;
}

.error pre {
    text-align: left;
    white-space: pre-wrap;
    font-family: inherit;
    margin: 1em 0;
    padding: 1em;
    background: #fff;
    border-radius: 3px;
    border: 1px solid #ffcdd2;
}

.no-results {
    text-align: center;
    padding: 2em;
    color: #888;
    font-style: italic;
}

.filter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4em 0.8em;
    cursor: pointer;
    font-size: 0.9em;
    white-space: nowrap;
}

.filter-item-main {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-shrink: 1;
    min-width: 0;
}

.filter-item-main span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.facet-count {
    color: #888;
    font-size: 0.9em;
    margin-left: 1em;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 5px;
    border-radius: 6px;
}

.filter-item input {
    margin-right: 0.5em;
    vertical-align: middle;
}

.filter-item span {
    vertical-align: middle;
}

.filter-item:hover {
    background: rgba(183, 28, 28, 0.08);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5em;
    margin: 2em 0;
    flex-wrap: wrap;
}

.pagination button {
    padding: 0.5em 0.8em;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 5px;
}

.pagination button:hover {
    background: #f5f5f5;
}

.pagination button.current {
    background: #b71c1c;
    color: white;
    border-color: #b71c1c;
}

.pagination span {
    padding: 0.5em;
    color: #888;
}

.highlight {
    background: yellow;
    color: #333;
}

/* Game details modal goes fullscreen well before the general mobile breakpoint below,
   since its fixed max-width otherwise leaves it cramped on phones and small tablets. */
@media screen and (max-width: 600px) {
    .game-details {
        top: 0;
        left: 0;
        transform: none;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* Mobile: keep last so these override the base rules above */
@media screen and (max-width: 320px) {
    .stats {
        display: none;
    }

    .logo {
        margin-right: 0;
    }

    .search-box {
        flex: 1 1 12em;
        max-width: none;
        margin-right: 0;
    }

    .facets-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75em;
    }

    .view-controls {
        order: -1;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 0.5em;
        flex-grow: 1;
        justify-content: flex-end;
    }

    .sort-by {
        flex: 1 1 auto;
        max-width: none;
    }

    #sort-select {
        width: 100%;
    }

    /* 16px minimum stops iOS Safari from zooming in on focus */
    #search-input,
    #sort-select {
        font-size: 16px;
    }

    .facets {
        min-width: 0;
        flex-basis: auto;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5em;
        justify-content: center;
    }

    .clear-all {
        grid-column: 1 / -1;
    }

    .filter-dropdown>summary {
        padding: 8px 10px;
    }

    .filter-item {
        padding: 0.6em 0.8em;
    }

    .pagination button {
        min-width: 36px;
        min-height: 36px;
    }

    .game-grid {
        flex-direction: column;
        align-items: center;
    }

    .game-card {
        width: 100%;
        max-width: 320px;
    }

    .game-summary {
        width: 100%;
    }

    .game-image {
        width: 100%;
        height: auto;
        max-width: none;
    }

    .game-image:hover {
        transform: scale(1.03);
    }

    .expansion-thumb:hover {
        transform: scale(1.03);
    }

}
