:root {
    color-scheme: dark;

    --background: #111315;
    --surface: #191c1f;
    --border: #30353a;
    --text: #eceeef;
    --muted: #9ba3ab;
    --accent: #a6d783;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select {
    font: inherit;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Header */

header {
    max-width: 1240px;
    margin: auto;
    padding: 22px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--border);
}

.brand {
    color: var(--text);
    font-size: 21px;
    font-weight: 750;
    letter-spacing: -0.7px;
    white-space: nowrap;
}

.brand span {
    color: var(--accent);
}

.brand:hover {
    text-decoration: none;
}

nav {
    display: flex;
    align-items: center;
    gap: 22px;
    font-size: 13px;
}

nav a {
    color: var(--muted);
}

nav a:hover {
    color: var(--text);
}

nav form {
    margin: 0;
}

.account-name {
    color: var(--text);
}

/* Page */

main {
    max-width: 1240px;
    margin: 36px auto;
    padding: 0 28px;
}

h1 {
    margin: 0 0 8px;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -0.8px;
}

h2 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

p {
    margin: 8px 0;
}

.muted,
small,
.stats span {
    color: var(--muted);
}

small {
    font-size: 12px;
}

.page-heading {
    margin-bottom: 24px;
}

.eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
}

/* Cards and account status */

.card {
    margin-bottom: 20px;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stats .card {
    margin: 0;
    min-height: 126px;
}

.stats span {
    font-size: 12px;
}

.stats h2 {
    margin: 8px 0 4px;
    font-size: 23px;
    overflow-wrap: anywhere;
}

#message {
    min-height: 24px;
    margin: 12px 0;
    color: var(--accent);
}

.actions,
.inline,
.member,
.section-head,
.runbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.connect {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.connect > div:first-child {
    flex: 1 1 300px;
}

.connect .muted,
.section-head .muted {
    margin: 0;
    font-size: 13px;
}

.section-head {
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-head > div {
    flex: 1 1 300px;
}

/* Buttons */

button {
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: var(--accent);
    color: #182111;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms, border-color 120ms;
}

button:hover:not(:disabled) {
    background: #b9e49c;
}

button:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.quiet {
    background: #24292e;
    color: var(--text);
    border-color: #3a4148;
}

.quiet:hover:not(:disabled) {
    background: #30373e;
    border-color: #56616b;
}

.danger {
    background: transparent;
    color: #e6a0a0;
    border-color: #634141;
}

.danger:hover:not(:disabled) {
    background: #352526;
    border-color: #a26767;
}

/* Forms */

input,
select {
    min-height: 40px;
    padding: 10px 12px;
    background: #121517;
    color: var(--text);
    border: 1px solid #3a4148;
    border-radius: 5px;
}

input::placeholder {
    color: #7d8790;
}

input[type="checkbox"] {
    min-height: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

label {
    display: block;
    margin: 16px 0;
}

label input {
    display: block;
    width: 100%;
    margin-top: 6px;
}

#search {
    width: 100%;
    margin: 16px 0 20px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.check input {
    width: auto;
    margin: 0;
}

/* Library */

.games {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    max-height: 680px;
    overflow-y: auto;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: #465049 transparent;
}

.games > p {
    grid-column: 1 / -1;
    padding: 24px 0;
}

.game {
    margin: 0;
    overflow: hidden;
    background: #141719;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.game:hover {
    border-color: #66705f;
}

.game:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    background: #1c241a;
}

.game img {
    display: block;
    width: 100%;
    aspect-ratio: 460 / 215;
    object-fit: cover;
    background: #22272b;
}

.game .details {
    padding: 12px;
}

.game input {
    display: inline-block;
    width: auto;
    margin: 0 8px 0 0;
}

.game strong {
    font-size: 13px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.game small {
    display: block;
    margin-top: 6px;
}

.runbar {
    position: sticky;
    bottom: 0;
    margin-top: 20px;
    padding: 16px 0 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.runbar span {
    margin-right: auto;
    color: var(--muted);
    font-size: 13px;
}

/* Steam sign-in */

#qr-box {
    flex: 0 0 100%;
    width: 100%;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

#qr {
    width: 240px;
    max-width: 100%;
    padding: 8px;
    background: white;
    border-radius: 6px;
}

#qr-status {
    color: var(--muted);
}

/* Login and registration */

.auth {
    max-width: 420px;
    margin: 64px auto;
    padding: 28px;
}

.auth h1 {
    font-size: 26px;
}

.auth form {
    margin-top: 24px;
}

.auth form > button {
    width: 100%;
    margin-top: 8px;
}

.auth-link {
    margin-top: 22px;
    font-size: 13px;
}

/* Administration */

.member {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.member:last-child {
    border-bottom: 0;
}

.member strong {
    flex: 1 1 140px;
    overflow-wrap: anywhere;
}

.inline {
    margin-top: 18px;
}

.error,
#message.error {
    color: #efaaaa;
}

.code {
    padding: 14px;
    background: #121517;
    border: 1px dashed #56616b;
    border-radius: 5px;
    font: 16px/1.6 monospace;
    overflow-wrap: anywhere;
    user-select: all;
}

footer {
    max-width: 1240px;
    margin: auto;
    padding: 0 28px 28px;
    color: #87918a;
    font-size: 12px;
}

footer span {
    color: #69736c;
}

.game-image-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 460 / 215;
    padding: 12px;
    background: #141719;
    border-bottom: 1px solid var(--border);
}

.game-image-fallback .brand {
    font-size: clamp(13px, 1.6vw, 20px);
    font-weight: 750;
    letter-spacing: -0.7px;
}

/* Smaller screens */

@media (max-width: 1000px) {
    .games {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    header {
        padding: 18px;
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    nav {
        width: 100%;
        gap: 16px;
        flex-wrap: wrap;
    }

    nav .account-name {
        margin-left: auto;
    }

    main {
        margin-top: 26px;
        padding: 0 18px;
    }

    .card {
        padding: 18px;
    }

    .stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stats .card {
        min-height: 0;
    }

    .stats h2 {
        font-size: 21px;
    }

    .games {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .game .details {
        padding: 10px;
    }

    .runbar {
        gap: 10px;
    }

    .runbar span {
        flex: 1 1 100%;
    }

    .runbar button {
        flex: 1;
    }

    .auth {
        margin: 36px auto;
    }

    footer {
        padding: 0 18px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }
}