:root {
    --bg: #0a0c14;
    --surface: #11131f;
    --surface-hover: #181b2a;
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --text: #e4e4ec;
    --text-dim: #9a9ab0;
    --text-muted: #616178;
    --accent: #3ed884;
    --accent-glow: rgba(62, 216, 132, 0.15);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    scroll-behavior: smooth;
    scroll-padding-top: 56px;
}
body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Noise overlay ── */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ── Stars background ── */
.stars {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(
            1px 1px at 10% 15%,
            rgba(255, 255, 255, 0.4),
            transparent
        ),
        radial-gradient(
            1px 1px at 25% 35%,
            rgba(255, 255, 255, 0.3),
            transparent
        ),
        radial-gradient(
            1.5px 1.5px at 40% 10%,
            rgba(255, 255, 255, 0.5),
            transparent
        ),
        radial-gradient(
            1px 1px at 55% 45%,
            rgba(255, 255, 255, 0.3),
            transparent
        ),
        radial-gradient(
            1px 1px at 70% 20%,
            rgba(255, 255, 255, 0.4),
            transparent
        ),
        radial-gradient(
            1.5px 1.5px at 85% 50%,
            rgba(255, 255, 255, 0.35),
            transparent
        ),
        radial-gradient(
            1px 1px at 15% 60%,
            rgba(255, 255, 255, 0.3),
            transparent
        ),
        radial-gradient(
            1px 1px at 60% 70%,
            rgba(255, 255, 255, 0.25),
            transparent
        ),
        radial-gradient(
            1px 1px at 90% 80%,
            rgba(255, 255, 255, 0.3),
            transparent
        ),
        radial-gradient(
            1.5px 1.5px at 35% 85%,
            rgba(255, 255, 255, 0.35),
            transparent
        ),
        radial-gradient(
            1px 1px at 50% 55%,
            rgba(255, 255, 255, 0.2),
            transparent
        ),
        radial-gradient(
            1px 1px at 80% 35%,
            rgba(255, 255, 255, 0.25),
            transparent
        );
}

/* ── Layout ── */
.page {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Top bar ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: rgba(10, 12, 20, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}
.topbar-brand img {
    height: 32px;
    width: auto;
    filter: drop-shadow(0 0 12px var(--accent-glow));
    transition: filter var(--transition);
}
.topbar-brand:hover img {
    filter: drop-shadow(0 0 20px rgba(62, 216, 132, 0.3));
}
.topbar-brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}
.topbar-links {
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    transition: all var(--transition);
}
.topbar-link:hover {
    color: var(--text);
    background: var(--surface-hover);
}
.topbar-tagline {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 16px;
    background: var(--accent-glow);
    border: 1px solid rgba(62, 216, 132, 0.2);
}

/* ── Section header ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-top: 48px;
}
.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Filter pills ── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.filter-pill {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.filter-pill:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-hover);
}
.filter-pill.active {
    background: var(--accent);
    color: #0a0c14;
    border-color: var(--accent);
    font-weight: 600;
}

/* ── Game grid ── */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 64px;
}

/* ── Game card ── */
.game-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}
.game-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px var(--accent-glow);
}
.game-card:active {
    transform: translateY(-1px);
}

.card-thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: var(--surface-hover);
}
.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.game-card:hover .card-thumb img {
    transform: scale(1.06);
}

.card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--accent);
    color: #0a0c14;
}

.card-body {
    padding: 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card-body h3 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.card-body p {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}
.card-tag {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.card-tag.racing {
    background: rgba(251, 146, 60, 0.12);
    color: #fb923c;
    border-color: rgba(251, 146, 60, 0.2);
}
.card-tag.original-mod {
    background: rgba(96, 165, 250, 0.12);
    color: var(--accent);
    border-color: rgba(96, 165, 250, 0.2);
}
.card-tag.action {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.2);
}
.card-tag.puzzle {
    background: rgba(192, 132, 252, 0.12);
    color: #c084fc;
    border-color: rgba(192, 132, 252, 0.2);
}
.card-tag.strategy {
    background: rgba(74, 222, 128, 0.12);
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.2);
}

/* ── Version tag (dynamic, fetched from version.json) ── */
.card-version {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
    animation: versionIn 0.25s ease-out;
}
.card-version::before {
    content: "v";
    font-size: 0.6rem;
    opacity: 0.7;
    margin-right: 1px;
}
@keyframes versionIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.card-play {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    color: #0a0c14;
    background: var(--accent);
    transition: all var(--transition);
    text-decoration: none;
}
.card-play:hover {
    background: #4fe898;
    box-shadow: 0 0 20px var(--accent-glow);
    transform: scale(1.03);
}
.card-play:active {
    transform: scale(0.97);
}

/* ── Card actions row ── */
.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
.card-credits-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid var(--border);
    color: var(--text-dim);
    background: transparent;
    transition: all var(--transition);
    white-space: nowrap;
}
.card-credits-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border-hover);
}
.card-credits-btn:active {
    transform: scale(0.97);
}

/* ── Credits modal ── */
.credits-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: overlayIn 0.15s ease-out;
}
@keyframes overlayIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.credits-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
.credits-modal h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}
.credits-modal .credit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.credits-modal .credit-row:last-child {
    border-bottom: none;
}
.credits-modal .credit-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.credits-modal .credit-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
.credits-modal .credit-link:hover {
    color: #4fe898;
    text-decoration: underline;
}
.credits-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color var(--transition);
}
.credits-close:hover {
    color: var(--text);
}

/* ── Placeholder card ── */
.game-card.placeholder {
    opacity: 0.5;
    cursor: default;
    border-style: dashed;
}
.game-card.placeholder:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: none;
}
.game-card.placeholder .card-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover);
}
.game-card.placeholder .card-thumb::after {
    content: "?";
    font-size: 4rem;
    font-weight: 800;
    color: var(--text-muted);
    opacity: 0.3;
}
.game-card.placeholder .card-play {
    background: var(--surface-hover);
    color: var(--text-muted);
    pointer-events: none;
    cursor: default;
    box-shadow: none;
}
.game-card.placeholder .card-play:hover {
    transform: none;
    box-shadow: none;
    background: var(--surface-hover);
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 32px 24px 48px;
    color: var(--text-muted);
    font-size: 0.8rem;
    position: relative;
    z-index: 1;
}
.footer a {
    color: var(--accent);
    text-decoration: none;
}
.footer a:hover {
    text-decoration: underline;
}

/* ── Loading skeleton ── */
@keyframes shimmer {
    0% {
        background-position: -400px 0;
    }
    100% {
        background-position: 400px 0;
    }
}
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface) 25%,
        var(--surface-hover) 50%,
        var(--surface) 75%
    );
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
    aspect-ratio: 16/10;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .topbar {
        padding: 0 16px;
        height: 48px;
    }
    .topbar-brand img {
        height: 26px;
    }
    .topbar-brand h1 {
        font-size: 0.95rem;
    }
    .topbar-tagline {
        font-size: 0.65rem;
        padding: 3px 10px;
    }
    .topbar-link {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
    .section-header {
        padding-top: 32px;
    }
    .game-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .filter-bar {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .filter-pill {
        flex-shrink: 0;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
