:root {
    --bg: #111315;
    --surface: #1a1d20;
    --surface-2: #23272b;
    --border: #2e3338;
    --text: #e8e6e3;
    --muted: #9aa0a6;
    --accent: #107c10;
    --accent-bright: #3dbb3d;
    --link: #7aa7ff;
    --danger: #f2706b;
    --radius: 12px;
    --font: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;

    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 32px 16px 48px;
    font-family: var(--font);
    background-color: var(--bg);
    background-image: radial-gradient(ellipse 80% 300px at 50% -80px, rgba(16, 124, 16, 0.18), transparent);
    background-repeat: no-repeat;
    color: var(--text);
    line-height: 1.45;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.site-header,
main,
.site-footer {
    max-width: 1080px;
    margin: 0 auto;
}

/* Header */

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    flex: none;
}

h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.tagline {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: var(--surface);
}

.nav a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s, background-color 0.15s;
}

.nav a:hover {
    background-color: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.nav a:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 1px;
}

.nav a[aria-current="page"] {
    background-color: var(--accent);
    color: #fff;
}

/* Mark links that leave the site. */
.nav a[target="_blank"]::after {
    content: '↗';
    font-size: 11px;
    opacity: 0.6;
}

/* Status bar */

.status-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 48px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.refresh {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 8px;
    width: 100%;
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-bright);
    box-shadow: 0 0 0 0 rgba(61, 187, 61, 0.6);
    animation: pulse 2s infinite;
}

.refresh.error .live-dot {
    background: var(--danger);
    animation: none;
}

.refresh-track {
    flex-basis: 100%;
    height: 3px;
    border-radius: 3px;
    background: var(--surface-2);
    overflow: hidden;
}

.refresh-bar {
    height: 100%;
    width: 100%;
    background: var(--accent-bright);
    transform-origin: left;
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 8px rgba(61, 187, 61, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(61, 187, 61, 0);
    }
}

/* Footer */

.site-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.server-details {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 32px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.server-details div {
    display: flex;
    gap: 8px;
}

.server-details dd {
    margin: 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* Sessions */

.sessions {
    display: grid;
    gap: 12px;
}

.session-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s;
}

.session-card:hover {
    border-color: #3a4046;
}

.game {
    display: flex;
    gap: 16px;
    min-width: 0;
}

.game-icon {
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    background: var(--surface-2);
    object-fit: cover;
}

.game-icon.placeholder {
    padding: 14px;
    object-fit: contain;
    opacity: 0.6;
}

.game-info {
    min-width: 0;
}

.game-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
}

.game-title a {
    color: var(--text);
}

.host {
    font-weight: 600;
}

.presence {
    color: var(--muted);
    font-size: 14px;
    white-space: pre-line;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chip {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
}

.chip b {
    color: var(--text);
    font-family: var(--mono);
    font-weight: 400;
}

.copy-xuid-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 5px 12px 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s, transform 0.1s;
}

.copy-xuid-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.copy-xuid-btn .icon-check,
.copy-xuid-btn.copied .icon-copy {
    display: none;
}

.copy-xuid-btn.copied .icon-check {
    display: block;
}

.copy-xuid-btn:hover {
    border-color: var(--muted);
}

.copy-xuid-btn:active {
    transform: scale(0.97);
}

.copy-xuid-btn:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 2px;
}

.copy-xuid-btn.copied {
    border-color: var(--accent-bright);
    color: var(--accent-bright);
}

.copy-xuid-btn.failed {
    border-color: var(--danger);
    color: var(--danger);
}

/* Copying an XUID is only useful on desktop, where Xenia runs. */
@media only screen and (max-width: 1024px) {
    .copy-xuid-btn {
        display: none;
    }
}

.players-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.slots {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.slot-track {
    height: 4px;
    margin-bottom: 12px;
    border-radius: 4px;
    background: var(--surface-2);
    overflow: hidden;
}

.slot-bar {
    height: 100%;
    background: var(--accent-bright);
}

.player-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 14px;
}

.player img {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--border);
}

.player span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player.is-host {
    box-shadow: inset 0 0 0 1px var(--accent);
    font-weight: 600;
}


/* Empty / error states */

.empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.empty img {
    opacity: 0.5;
}

.empty h2 {
    margin: 12px 0 4px;
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
}

.empty p {
    margin: 0;
}

/* Skeleton loader */

.session-card.skeleton {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sk {
    background: linear-gradient(90deg, var(--surface-2) 0, #2c3135 80px, var(--surface-2) 160px);
    background-size: 600px 100%;
    animation: shine 1.6s infinite linear;
}

.sk-icon {
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 10px;
}

.sk-lines {
    flex: 1;
}

.sk-line {
    height: 14px;
    max-width: 260px;
    margin: 8px 0;
    border-radius: 7px;
}

.sk-line.short {
    max-width: 160px;
}

@keyframes shine {
    from {
        background-position: -160px 0;
    }
    to {
        background-position: 440px 0;
    }
}

/* Compatibility list */

/* Total on the left, then one tile per column. */
.stats.compat-stats {
    display: grid;
    grid-template-columns: auto repeat(4, minmax(0, 1fr));
    align-items: stretch;
    gap: 10px;
    width: 100%;
}

.stats.session-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.session-stats .stat,
.compat-stats .stat {
    justify-content: center;
    padding: 12px 8px;
    border-radius: 8px;
    background: var(--surface-2);
    text-align: center;
}

.compat-stats .stat:first-child {
    padding: 4px 24px 4px 8px;
    margin-right: 6px;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: none;
}

.compat-stats .stat:first-child .stat-value {
    color: var(--accent-bright);
    font-size: 30px;
}

.compat-intro {
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 14px;
}

.compat-intro p {
    margin: 0 0 8px;
}

.compat-intro b {
    color: var(--text);
}

.compat-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.search {
    flex: 1 1 100%;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.search:focus {
    outline: none;
    border-color: var(--accent-bright);
}

.filters {
    display: flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.filter {
    flex: 1 1 auto;
    padding: 6px 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}

.filter:hover {
    background: var(--surface-2);
    color: var(--text);
}

.filter:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 1px;
}

.filter.is-active {
    background: var(--accent);
    color: #fff;
}

.filter .label-short {
    display: none;
}

.result-count {
    margin-left: auto;
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.compat-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.compat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.compat-table thead th {
    position: sticky;
    top: 0;
    padding: 10px 12px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}

.compat-table td,
.compat-table tbody th {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    vertical-align: top;
    text-align: left;
}

.compat-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.compat-table .status-col {
    width: 96px;
    text-align: center;
}

.game-cell {
    width: 30%;
    font-weight: 600;
}

.game-cell-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.compat-icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--surface-2);
    object-fit: cover;
}

.compat-icon.placeholder {
    padding: 8px;
    object-fit: contain;
    opacity: 0.6;
}

.game-name {
    display: block;
    margin-bottom: 4px;
}

.game-cell .chip {
    font-weight: 400;
}

.notes-cell {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.note + .note {
    margin-top: 8px;
}

.notes-cell code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
}

.compat-loading {
    padding: 32px 12px !important;
    color: var(--muted);
    text-align: center !important;
}

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.status.working {
    background: rgba(61, 187, 61, 0.16);
    color: var(--accent-bright);
}

.status.partial {
    background: rgba(232, 179, 57, 0.16);
    color: var(--warning);
}

.status.broken {
    background: rgba(242, 112, 107, 0.16);
    color: var(--danger);
}

.legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-top: 24px;
    color: var(--muted);
    font-size: 14px;
}

.legend h2 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.legend ul {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend dl,
.legend p {
    margin: 0;
}

.legend dt {
    color: var(--text);
}

.legend dd {
    margin: 0 0 8px;
}

@media only screen and (max-width: 720px) {
    /* Total across the top, then the four columns as a 2x2 grid. */
    .stats.compat-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .compat-stats .stat {
        padding: 10px 8px;
    }

    .compat-stats .stat:first-child {
        grid-column: 1 / -1;
        padding: 0 0 4px;
        margin-right: 0;
        border-right: none;
    }

    .compat-table thead {
        display: none;
    }

    .compat-table,
    .compat-table tbody,
    .compat-table tr {
        display: block;
    }

    .compat-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px;
        border-top: 1px solid var(--border);
    }

    .compat-table tbody tr:first-child {
        border-top: none;
    }

    .compat-table td,
    .compat-table tbody th {
        padding: 0;
        border: none;
    }

    .compat-table .game-cell,
    .compat-table .notes-cell,
    .compat-loading {
        flex-basis: 100%;
        width: auto;
    }

    .compat-table .status-col {
        display: flex;
        align-items: center;
        gap: 6px;
        width: auto;
        padding: 3px 10px 3px 4px;
        border-radius: 999px;
        background: var(--surface-2);
        font-size: 12px;
    }

    .compat-table .status-col:empty {
        display: none;
    }

    .compat-table .status-col::after {
        color: var(--text);
    }

    .compat-table .status-col:nth-of-type(1)::after {
        content: 'Public';
    }

    .compat-table .status-col:nth-of-type(2)::after {
        content: 'Tested Locally';
    }

    .compat-table .status-col:nth-of-type(3)::after {
        content: 'Only Local';
    }

    .compat-table .status-col:nth-of-type(4)::after {
        content: 'Systemlink';
    }

    .notes-cell:empty {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sk,
    .live-dot {
        animation: none;
    }
}

@media only screen and (max-width: 720px) {
    body {
        padding-top: 20px;
    }

    .session-card {
        grid-template-columns: 1fr;
    }

    .stats {
        gap: 32px;
    }

    /* Stack each label over its value in three even columns. */
    .server-details {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        text-align: center;
    }

    .server-details div {
        flex-direction: column;
        gap: 2px;
    }

    /* Stretch the filter bar across the screen with shorter labels. */
    .filters {
        flex: 1 1 100%;
    }

    .filter {
        padding: 6px 4px;
        font-size: 12px;
    }

    .filter .label-long {
        display: none;
    }

    .filter .label-short {
        display: inline;
    }

    /* Keep the nav on one row, stretched across the screen. */
    .nav {
        flex-wrap: nowrap;
        width: 100%;
    }

    .nav a {
        flex: 1 1 auto;
        justify-content: center;
        padding: 6px 6px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Reserve two lines so the nav sits at the same height on every page. */
    .tagline {
        min-height: calc(2 * 1.45em);
    }
}

@media only screen and (max-width: 360px) {
    /* Keep page titles on one line. */
    h1 {
        font-size: 20px;
    }

    /* Drop the external link arrows so the nav still fits on one row. */
    .nav a[target="_blank"]::after {
        content: none;
    }
}
