:root {
    color-scheme: dark;
    --bg: #1e1e2e;
    --bg-soft: #181825;
    --surface: rgba(30, 30, 46, 0.9);
    --surface-strong: #313244;
    --border: rgba(137, 180, 250, 0.18);
    --text: #cdd6f4;
    --muted: #a6adc8;
    --accent: #89b4fa;
    --accent-strong: #74c7ec;
    --good: #a6e3a1;
    --warning: #f9e2af;
    --shadow: 0 24px 80px rgba(17, 17, 27, 0.55);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
}

.site-header {
    width: min(1120px, calc(100% - 32px));
    margin: 18px auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(24, 24, 37, 0.7);
    backdrop-filter: blur(12px);
}

.site-brand {
    display: grid;
    gap: 2px;
    color: var(--text);
    text-decoration: none;
}

.site-brand__name {
    font-weight: 800;
    letter-spacing: 0.02em;
}

.site-brand__tagline {
    color: var(--muted);
    font-size: 0.86rem;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.site-nav a {
    color: var(--text);
    text-decoration: none;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background-color 160ms ease, border-color 160ms ease;
}

.site-nav a:hover {
    background: rgba(137, 180, 250, 0.12);
    border-color: rgba(137, 180, 250, 0.18);
}

.site-nav__cta {
    background: var(--accent);
    color: #1e1e2e !important;
    font-weight: 700;
}

.site-nav__cta:hover {
    background: var(--accent-strong);
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: #1e1e2e;
    background: var(--accent);
    font-weight: 600;
    transition: opacity 160ms ease;
}

button:hover {
    opacity: 0.85;
}

button:active {
    opacity: 0.75;
}

.game-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: #1e1e2e;
    background: var(--accent);
    font-weight: 600;
    transition: opacity 160ms ease;
    text-decoration: none;
    border: 0;
}

.game-actions a:hover {
    opacity: 0.85;
}

.game-actions a:active {
    opacity: 0.75;
}

.page-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0 56px;
}

.page-shell--home {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.hero-card,
.library-header,
.stat-card,
.game-card,
.notice-card {
    border: 1px solid var(--border);
    background: var(--surface);
}

.hero-card {
    width: min(760px, 100%);
    border-radius: 8px;
    padding: 32px;
}

.eyebrow {
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 700;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(2.4rem, 5vw, 4.6rem);
    line-height: 0.96;
    margin-bottom: 16px;
}

.hero-copy {
    margin-bottom: 24px;
    max-width: 62ch;
    color: var(--muted);
    font-size: 1.02rem;
    line-height: 1.7;
}

.hero-actions,
.notice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.hero-actions__primary,
.hero-actions__secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.8rem 1rem;
    text-decoration: none;
    font-weight: 700;
    transition: opacity 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.hero-actions__primary {
    background: var(--accent);
    color: #1e1e2e;
}

.hero-actions__secondary {
    color: var(--text);
    border: 1px solid var(--border);
    background: rgba(49, 50, 68, 0.45);
}

.hero-actions__primary:hover,
.hero-actions__secondary:hover {
    opacity: 0.88;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
}

.search-form input {
    width: 100%;
    min-width: 0;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(24, 24, 37, 0.9);
    color: var(--text);
    padding: 1rem 1.1rem;
    outline: none;
}

.search-form input:focus {
    border-color: var(--accent);
}

.form-error,
.game-status,
.game-meta,
.game-notes,
.hint-row,
.notice-card,
.stat-label {
    color: var(--muted);
}

.form-error {
    margin: 14px 0 0;
    color: #f38ba8;
}

.hint-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    font-size: 0.92rem;
}

.hint-row code {
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: rgba(49, 50, 68, 0.9);
    border: 1px solid rgba(137, 180, 250, 0.12);
    color: var(--text);
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
}

.library-header h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    margin-bottom: 6px;
}

.profile-avatar {
    width: 88px;
    height: 88px;
    border-radius: 24px;
    border: 1px solid var(--border);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.toolbar-card {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 14px;
    align-items: end;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 18px;
}

.toolbar-field {
    display: grid;
    gap: 8px;
}

.toolbar-field label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.toolbar-field input,
.toolbar-field select {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(24, 24, 37, 0.9);
    color: var(--text);
    padding: 0.92rem 1rem;
    outline: none;
}

.toolbar-field input:focus,
.toolbar-field select:focus {
    border-color: var(--accent);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.92rem;
    color: var(--text);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.checkbox-label span {
    user-select: none;
}

.toolbar-summary {
    color: var(--muted);
    font-size: 0.92rem;
    padding-bottom: 0.2rem;
    white-space: nowrap;
}

.stat-card {
    border-radius: 8px;
    padding: 16px;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.9rem;
}

.notice-card {
    border-radius: 8px;
    padding: 16px;
}

.notice-card p:last-child {
    margin-bottom: 0;
}

.notice-card--error {
    color: #f38ba8;
}

.game-list {
    display: grid;
    gap: 14px;
}

.game-card {
    border-radius: 8px;
    padding: 16px;
}

.game-card__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 10px;
}

.game-card h2 {
    font-size: 1.28rem;
    margin-bottom: 6px;
}

.game-meta {
    margin-bottom: 0;
    font-size: 0.92rem;
}

.game-owned-by {
    margin: 6px 0 0 0;
    font-size: 0.8rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.owner-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(166, 227, 161, 0.15);
    border: 1px solid rgba(166, 227, 161, 0.3);
    border-radius: 3px;
    font-size: 0.75rem;
    color: #a6e3a1;
    font-weight: 500;
}

.owner-badge--you {
    background: rgba(137, 180, 250, 0.15);
    border-color: rgba(137, 180, 250, 0.3);
    color: #89b4fa;
    font-weight: 600;
}

.game-status {
    margin-bottom: 12px;
}

.game-notes {
    margin-bottom: 16px;
}

.game-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.catalog-card .game-actions a {
    background: rgba(137, 180, 250, 0.12) !important;
    color: var(--text) !important;
    border: 1px solid rgba(137, 180, 250, 0.18);
}

.drm-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e1e2e;
    background: #89b4fa;
    white-space: nowrap;
}

.drm-badge--drm {
    background: #f38ba8;
}

.drm-badge--unknown {
    background: #313244;
    color: #cdd6f4;
}

.drm-badge--free {
    background: #a6e3a1;
}

.drm-badge--steam-appid {
    background: #fab387;
}

.drm-badge--code {
    background: #94e2d5;
}

.drm-badge--tweaks {
    background: #74c7ec;
}

.game-notes a {
    color: var(--accent-strong);
    text-decoration: underline;
}

.drm-badge--dosbox {
    background: #cba6f7;
}

.drm-badge--rom {
    background: #74c7ec;
}

.drm-badge--flash {
    background: #eba0ac;
}

/* Platform-specific button colors */
.button-link--gog {
    background: linear-gradient(135deg, #9d6dd1 0%, #7d5bb8 100%) !important;
}

.button-link--gog:hover {
    opacity: 0.85;
}

.button-link--epic {
    background: #000000 !important;
}

.button-link--epic:hover {
    opacity: 0.85;
}

.button-link--itch {
    background: #f5484d !important;
}

.button-link--itch:hover {
    opacity: 0.85;
}

.button-link--steam {
    background: linear-gradient(135deg, #1b2838 0%, #171a21 100%) !important;
    color: #c7d5e0 !important;
}

.button-link--steam:hover {
    opacity: 0.88;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.library-page-wrapper {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0 56px;
}

.page-shell--library {
    width: auto;
    margin: 0;
    padding: 0;
}

.library-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-card {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 20px;
}

.sidebar-card h2 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    color: var(--text);
}

.sidebar-card h3 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-help {
    margin: 0 0 16px 0;
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
}

.sidebar-section {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    border-radius: 6px;
    font-size: 0.9rem;
}

.sidebar-input::placeholder {
    color: var(--muted);
}

.sidebar-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(137, 180, 250, 0.05);
}

.button-primary,
.button-secondary {
    padding: 10px 16px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.button-primary {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.button-primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    transform: translateY(-1px);
}

.button-secondary:hover {
    background: rgba(137, 180, 250, 0.1);
    border-color: var(--accent);
}

.button-primary:active,
.button-secondary:active {
    transform: translateY(0);
    opacity: 0.8;
}

#friends-select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    border-radius: 6px;
    font-size: 0.9rem;
}

#friends-select option {
    background: var(--bg);
    color: var(--text);
}

.loading-spinner {
    padding: 10px;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

.added-friends-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.friend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(137, 180, 250, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    gap: 12px;
}

.friend-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    flex-shrink: 0;
}

.friend-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.friend-text strong {
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-text .game-count {
    font-size: 0.8rem;
    color: var(--muted);
}

.friend-text.error {
    color: #f38ba8;
}

.friend-text .error-msg {
    font-size: 0.75rem;
    color: #f38ba8;
    white-space: normal;
}

.remove-friend-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-friend-btn:hover {
    background: #f38ba8;
    border-color: #f38ba8;
    color: #000;
}

.empty-state {
    margin: 0;
    padding: 12px 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 720px) {
    .library-page-wrapper {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px 0 32px;
    }

    .library-sidebar {
        order: -1;
    }
    .site-header {
        width: min(1120px, calc(100% - 20px));
        margin-top: 10px;
        padding: 12px;
        align-items: flex-start;
        flex-direction: column;
    }

    .page-shell {
        width: min(1120px, calc(100% - 20px));
        padding: 20px 0 32px;
    }

    .hero-card,
    .library-header {
        padding: 16px;
    }

    .search-form,
    .stats-grid,
    .toolbar-card {
        grid-template-columns: 1fr;
    }

    .library-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .game-card__top {
        flex-direction: column;
    }
}