/* ================== DESIGN TOKENS ==================
   One source of truth for colour, type and spacing. Every value below was
   picked against the page background for a WCAG AA contrast ratio; the old
   palette leaned on #555/#777 greys that measured 2.1:1 and 3.4:1, which is
   why so much of the archive was hard to read. Ratios are noted per token.
   ==================================================== */
:root {
    /* Surfaces: one deliberate elevation ramp, replacing a dozen ad-hoc
       near-blacks (#050505, #0d0d0d, #111, #141414, #1c1c1c, #1f1f1f …). */
    --bg:           #0b0b0c;
    --surface-1:    #131315;  /* cards, panels                 */
    --surface-2:    #1a1a1d;  /* raised: chips, table headers   */
    --surface-3:    #232327;  /* inputs, hover fills            */
    --border:       #2c2c32;
    --border-strong:#3c3c44;

    /* Text, measured on --bg */
    --text:           #f2f2f3;  /* 17.9:1 */
    --text-secondary: #c4c4c9;  /* 11.2:1 */
    --text-muted:     #a3a3ab;  /*  7.5:1 */
    --text-faint:     #8d8d96;  /*  5.6:1 — the floor; nothing dimmer */

    /* Accent. #ff0000 on black is 5.2:1 but vibrates badly at text sizes;
       #ff4d4d is both calmer and higher contrast. --accent-strong is the
       only red used behind white text (5.2:1). */
    --accent:        #ff4d4d;  /* 6.4:1 on --bg */
    --accent-strong: #d12b2b;
    --accent-soft:   rgba(255, 77, 77, 0.13);
    --accent-border: rgba(255, 77, 77, 0.38);

    /* Focus ring: deliberately not red, so it can never be confused with a
       hover state and stays visible on top of red surfaces. */
    --focus: #6ea8ff;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Type scale. Nothing below 13px: the old sheet had 30 rules at 10-12px. */
    --fs-xs:   0.8125rem; /* 13px */
    --fs-sm:   0.875rem;  /* 14px */
    --fs-base: 1rem;      /* 16px */
    --fs-md:   1.0625rem; /* 17px - long-form body */
    --fs-lg:   1.25rem;
    --fs-xl:   1.5rem;
    --fs-2xl:  2rem;
    --fs-3xl:  2.75rem;

    /* 4px spacing scale */
    --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
    --sp-5: 20px;  --sp-6: 24px;  --sp-8: 32px;  --sp-10: 40px;
    --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

    --r-sm: 6px;  --r-md: 10px;  --r-lg: 14px;  --r-pill: 999px;


    --measure: 68ch;      /* readable line length for prose */
    --content: 1120px;    /* standard page width            */
    --reading: 860px;     /* long-form article column       */
}

/* ================== RESET ================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    /* The off-canvas mobile drawer sits at translateX(100%), which extends the
       scrollable area by its own width. `clip` contains it without making the
       root a scroll container, which `hidden` would -- and that breaks the
       sticky nav. */
    overflow-x: clip;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================== BODY ================== */
body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; }

/* Prose links. Anything without a component class -- the About page copy, the
   essay bodies, injected cross-links -- was falling back to the UA's #0000EE,
   which measures 2.1:1 on this background. Component classes set their own
   colour and outrank this on specificity, so they are unaffected. */
a {
    color: var(--accent);
    text-underline-offset: 0.18em;
    text-decoration-thickness: from-font;
}
a:hover { color: var(--text); }

::selection {
    background: var(--accent-strong);
    color: var(--text);
}

/* Keyboard users had no visible focus anywhere on the site. */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* Names a region for screen readers without changing the visual design.
   Used where a card grid would otherwise follow the page h1 with no h2. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--sp-4);
    top: calc(-1 * var(--sp-16));
    z-index: 2000;
    background: var(--accent-strong);
    color: var(--text);
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--r-sm);
    text-decoration: none;
    font-weight: 600;
    transition: top 0.15s ease;
}
.skip-link:focus {
    top: var(--sp-4);
}

/* The background wordmark used to be a 90vw disc at 0.18 opacity sitting
   behind every page, so text landed on black in some places and dark red in
   others. It is now a small, near-invisible corner mark. */
.bg-logo {
    position: fixed;
    right: -60px;
    bottom: -60px;
    top: auto;
    left: auto;
    transform: none;
    width: 340px;
    height: 340px;
    opacity: 0.045;
    z-index: 0;
    pointer-events: none;
}

.bg-logo text { fill: var(--accent); }
.bg-logo circle { stroke: var(--accent); }

/* ================== NAVBAR ==================
   Scoped away from <nav class="crumbs">: the breadcrumb trail is also a
   <nav>, so the bare element selector was giving it space-between and
   spreading Home / Games / Pac-Man across the full page width. */
nav:not(.crumbs) {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-6);
    padding: var(--sp-3) var(--sp-8);
    position: sticky;
    top: 0;
    z-index: 1001;
    background: rgba(11, 11, 12, 0.88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

nav:not(.crumbs) img { width: 42px; display: block; }

.nav-logo {
    display: flex;
    align-items: center;
    border-radius: var(--r-sm);
    flex-shrink: 0;
}

/* ================== NAV LINKS ================== */
.nav-links {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--fs-sm);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    white-space: nowrap;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-links a:hover {
    color: var(--text);
    background: var(--surface-2);
}

.nav-links a.active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

/* ================== HAMBURGER MENU ================== */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 44px;
    height: 44px;
    padding: 11px 7px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background: var(--accent);
    border-radius: 2px;
}

/* ================== BUTTON ================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 44px;
    padding: var(--sp-3) var(--sp-6);
    background: var(--accent-strong);
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

/* The old hover scaled the button 5% and flared a 25px red glow, which made
   toolbars twitch as the pointer crossed them. */
.btn:hover {
    background: var(--accent);
    color: #14090a;
}

.btn:active { transform: translateY(1px); }

/* ================== ANIMATIONS ================== */
@keyframes fadeIn {
    from {opacity: 0;}
    to {opacity: 1;}
}

/* ================== MOBILE RESPONSIVE ================== */
@media (max-width: 900px) {
    nav:not(.crumbs) {
        padding: var(--sp-3) var(--sp-4);
    }

    /* Show hamburger menu */
    .menu-toggle {
        display: flex;
    }

    /* Mobile nav */
    .nav-links {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        height: 100dvh;
        width: min(84%, 340px);
        background: var(--surface-1);
        border-left: 1px solid var(--border);
        padding: var(--sp-20) var(--sp-4) var(--sp-8);
        gap: var(--sp-1);
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.25s ease-in-out;
        z-index: 1000;
    }

    .nav-links.active {
        transform: translateX(0);
    }

    .nav-links a {
        font-size: var(--fs-base);
        padding: var(--sp-3) var(--sp-4);
    }
}

/* ================== ENCYCLOPEDIA SECTION (index.html) ================== */
.enc-section {
    max-width: var(--content);
    margin: 0 auto var(--sp-16);
    padding: 0 var(--sp-5);
    position: relative;
    z-index: 1;
}
.enc-header {
    margin-bottom: var(--sp-6);
}
.enc-header h2 {
    font-size: var(--fs-xl);
    color: var(--text);
    font-weight: 700;
    margin-bottom: var(--sp-2);
    letter-spacing: -0.01em;
}
.enc-header p {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.6;
    max-width: var(--measure);
}
.enc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.enc-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-5);
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.enc-card:hover {
    border-color: var(--accent-border);
    background: var(--surface-2);
}
.enc-card-name {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--sp-1);
}
.enc-card-era {
    font-size: var(--fs-xs);
    color: var(--accent);
    font-weight: 600;
    margin-bottom: var(--sp-3);
}
.enc-card-desc {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}
.enc-browse-btn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--fs-sm);
    font-weight: 500;
    border: 1px solid var(--border);
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--r-sm);
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.enc-browse-btn:hover {
    border-color: var(--accent-border);
    background: var(--surface-2);
    color: var(--text);
}

/* ================== EXTRA SMALL DEVICES ================== */
@media (max-width: 480px) {
    nav:not(.crumbs) img { width: 36px; }
    .enc-section { padding: 0 var(--sp-4); }
}

/* ================== DEVELOPER PAGES ================== */
.dev-figures-row {
    margin-top: var(--sp-4);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}
.dev-figure {
    display: inline-block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--sp-1) var(--sp-3);
    margin: var(--sp-1) var(--sp-1) 0 0;
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}
.dev-notable {
    margin-top: var(--sp-4);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}
.dev-notable ul {
    margin-top: var(--sp-2);
    padding-left: var(--sp-5);
}
.dev-notable li { margin-bottom: var(--sp-1); }

.trivia-table {
    margin-top: var(--sp-4);
    border-collapse: collapse;
    width: 100%;
    max-width: 520px;
    font-size: var(--fs-sm);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.trivia-table th,
.trivia-table td {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
    text-align: left;
    color: var(--text-secondary);
}
.trivia-table tr:last-child th,
.trivia-table tr:last-child td { border-bottom: none; }
.trivia-table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600;
    width: 40%;
}
.trivia-table td {
    background: var(--surface-1);
}

/* ================== GAMES HERO ================== */
.games-hero {
    text-align: center;
    padding: 80px 20px 30px;
    animation: fadeIn 1.2s ease;
    position: relative;
    z-index: 1;
}

.games-hero h1 {
    font-size: 52px;
    color: var(--accent);
    margin-bottom: 12px;
}

.games-hero p {
    font-size: 18px;
    opacity: 0.75;
}

/* ================== CONTROLS ================== */
.games-controls {
    max-width: var(--content);
    margin: 0 auto 12px;
    padding: 0 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 420px;
}

.search-wrapper input {
    width: 100%;
    padding: 12px 40px 12px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
    transition: border-color 0.25s;
}

.search-wrapper input:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

.search-wrapper input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-border);
}

.search-wrapper input::placeholder {
    color: var(--text-faint);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 16px;
    pointer-events: none;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.filter-btn.active {
    background: var(--accent-strong);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 12px var(--accent-border);
}

/* ================== GAME COUNT ================== */
.games-count {
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
    margin-bottom: 30px;
    position: relative;
    z-index: 1;
}

/* ================== GAMES GRID ================== */
.games-grid {
    max-width: var(--content);
    margin: 0 auto 80px;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
    position: relative;
    z-index: 1;
}

.loading-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-faint);
    padding: 60px 0;
    font-size: 18px;
}

/* ================== GAME CARD ================== */
.game-card {
    background: var(--surface-1);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
}

.game-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-soft);
}

.game-card-img-wrap {
    position: relative;
    width: 100%;
    height: 180px;
    background: var(--surface-1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    transition: transform 0.3s;
}

.game-card:hover .game-card-img-wrap img {
    transform: scale(1.05);
}

.game-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    font-weight: bold;
    color: var(--text-faint);
    background: var(--surface-1);
}

.game-card-decade {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--accent-strong);
    color: var(--text);
    font-size: 13px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.game-card-playable {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.75);
    color: var(--accent);
    font-size: 13px;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    border: 1px solid var(--accent-border);
}

.game-card-body {
    padding: 14px 16px 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.game-card-title {
    font-size: 17px;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.game-card-meta {
    font-size: 13px;
    color: var(--accent);
    display: flex;
    gap: 6px;
    align-items: center;
}

.dot {
    opacity: 0.5;
}

.game-card-platform {
    font-size: 14px;
    color: var(--text-faint);
    margin: 0;
}

.game-card-desc {
    font-size: 13px;
    color: var(--text-faint);
    margin: 6px 0 0;
    line-height: 1.5;
}

/* ================== NO RESULTS ================== */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
    position: relative;
    z-index: 1;
}

.no-results p {
    font-size: 18px;
    margin-bottom: 20px;
}



/* ================== GAME DETAIL PAGE ================== */
.game-detail-wrapper {
    max-width: var(--content);
    margin: 0 auto 80px;
    padding: 30px 20px 0;
    position: relative;
    z-index: 1;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-3);
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent);
}

.game-detail-card {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.game-detail-image-col {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-detail-img {
    width: 100%;
    aspect-ratio: 4 / 3; /* reserve space before load to avoid layout shift */
    object-fit: contain;
    background: var(--surface-1);
    border-radius: 10px;
    border: 1px solid var(--surface-3);
    box-shadow: 0 0 30px var(--accent-soft);
}

.game-meta {
    background: var(--surface-1);
    border: 1px solid var(--surface-2);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meta-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    border-bottom: 1px solid var(--surface-2);
    padding-bottom: 8px;
}

.meta-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.meta-label {
    color: var(--text-faint);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.meta-value {
    color: var(--text-secondary);
    text-align: right;
}

.game-detail-info-col {
    flex: 1;
    min-width: 0;
}

.game-decade-badge {
    display: inline-block;
    background: var(--accent-strong);
    color: var(--text);
    font-size: 14px;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 10px var(--accent-border);
}

.game-detail-title {
    font-size: 44px;
    color: var(--text);
    margin: 0 0 6px;
    line-height: 1.1;
}

.game-detail-year {
    color: var(--accent);
    font-size: 15px;
    margin: 0 0 30px;
}

.game-detail-desc {
    margin-bottom: 28px;
}

.game-detail-desc h2 {
    font-size: 18px;
    color: var(--accent);
    margin-bottom: 10px;
    border-bottom: 1px solid var(--surface-2);
    padding-bottom: 8px;
}

.game-detail-desc p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.75;
}

.game-trivia {
    background: var(--bg);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    padding: 20px 22px 22px;
}

.game-trivia h2 {
    font-size: 14px !important;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent) !important;
    border-bottom: 1px solid var(--surface-2) !important;
    padding-bottom: 12px !important;
    margin-bottom: 16px !important;
}

.trivia-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    counter-reset: trivia;
}

.trivia-list li {
    counter-increment: trivia;
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 13px;
    align-items: start;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    padding: 12px 14px 12px 12px;
    background: var(--surface-1);
    border: 1px solid var(--surface-2);
    border-radius: 6px;
    transition: border-color 0.18s, background 0.18s;
}

.trivia-list li:hover {
    border-color: var(--accent-border);
    background: var(--surface-1);
}

/* Game titles in these lists are linked to their archive page where one
   exists. Without this they fall back to the UA's blue-and-underlined default,
   which reads as broken against the dark theme. */
.trivia-list a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent-border);
    transition: color 0.18s, border-color 0.18s;
}

.trivia-list a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent-strong);
}

.trivia-list li::before {
    content: counter(trivia);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--accent-strong);
    color: var(--text);
    font-size: 13px;
    font-weight: bold;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
    box-shadow: 0 0 6px var(--accent-border);
}

/* ================== MOBILE ================== */
@media (max-width: 768px) {
    .games-hero h1 { font-size: 32px; }
    .games-controls { flex-direction: column; }
    .search-wrapper { max-width: 100%; }
    .games-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
    .game-card-img-wrap { height: 130px; }

    .game-detail-card {
        flex-direction: column;
        gap: 24px;
    }

    .game-detail-image-col {
        flex: none;
        width: 100%;
        flex-direction: row;
        align-items: flex-start;
        gap: 16px;
    }

    .game-detail-img {
        width: 140px;
        flex-shrink: 0;
    }

    .game-meta {
        flex: 1;
    }

    .game-detail-title { font-size: 28px; }
}

@media (max-width: 480px) {
    .games-grid { grid-template-columns: 1fr 1fr; }
    .game-detail-image-col { flex-direction: column; }
    .game-detail-img { width: 100%; }
}

/* ================== NAV EXTRAS ================== */
.nav-random {
    color: var(--text-muted);
    font-size: 14px;
    letter-spacing: 0.3px;
}
.nav-random:hover { color: var(--accent) !important; }

/* ================== PLAY / DOWNLOAD ACTIONS ================== */
.game-play-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
    margin-bottom: 4px;
}
.btn-play, .btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-play {
    background: var(--accent-strong);
    color: var(--text);
    border: 1px solid var(--accent);
}
.btn-play:hover {
    background: var(--accent-strong);
    box-shadow: 0 0 16px var(--accent-border);
}
.btn-download {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}
.btn-download:hover {
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 10px var(--accent-soft);
}

/* ================== SHARE BUTTON ================== */
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 9px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
    margin-top: 16px;
}
.share-btn:hover {
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 10px var(--accent-soft);
}

/* ================== RELATED GAMES ================== */
.related-section {
    max-width: var(--content);
    margin: 48px auto 80px;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}
.related-section h2 {
    font-size: 22px;
    color: var(--accent);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--surface-2);
    padding-bottom: 10px;
}
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
}

/* ================== RELATED ENTRIES (cross-links) ================== */
.related-entries {
    max-width: var(--content);
    margin: 40px auto 0;
    padding: 28px 0 0;
    border-top: 1px solid var(--surface-2);
}
/* When the SEO middleware injects this block it lands as a direct child of
   body rather than inside a page wrapper, so it has no inherited side padding
   to sit in and would run to the viewport edge on narrow screens. */
body > .related-entries {
    padding-left: 1rem;
    padding-right: 1rem;
    margin-bottom: 40px;
}
.related-entries h2 {
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 18px;
}
.related-entries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.related-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background: var(--surface-1);
    border: 1px solid var(--surface-2);
    border-radius: 8px;
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}
.related-link:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.related-link .related-cat {
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
}
.related-link .related-title {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.35;
}

/* ================== ENTRY SOURCES ================== */
.entry-sources {
    max-width: var(--content);
    margin: 40px auto 0;
    padding: 28px 0 0;
    border-top: 1px solid var(--surface-2);
}
.entry-sources h2 {
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 14px;
}
.entry-sources-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.entry-sources-list li {
    padding: 7px 0 7px 18px;
    position: relative;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    border-bottom: 1px solid var(--surface-1);
}
.entry-sources-list li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}
.entry-sources-list a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}
.entry-sources-list a:hover {
    color: var(--text);
    border-bottom-color: var(--accent);
}
.entry-sources-list .source-pub {
    color: var(--text-faint);
}

/* ================== GAME OF THE DAY (index.html) ================== */
.gotd-section {
    max-width: var(--content);
    margin: 0 auto 60px;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}
.gotd-section h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-faint);
    margin-bottom: 16px;
}
.gotd-card {
    display: flex;
    gap: 28px;
    background: var(--surface-1);
    border: 1px solid var(--accent-strong);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 0 30px var(--accent-soft);
    transition: box-shadow 0.3s, border-color 0.3s;
}
.gotd-card:hover {
    box-shadow: 0 0 40px var(--accent-border);
    border-color: var(--accent);
}
.gotd-img {
    width: 160px;
    min-height: 160px;
    object-fit: cover;
    object-position: top;
    flex-shrink: 0;
}
.gotd-body {
    padding: 22px 22px 22px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}
.gotd-badge {
    display: inline-block;
    background: var(--accent-strong);
    color: var(--text);
    font-size: 13px;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    width: fit-content;
}
.gotd-title {
    font-size: 26px;
    font-weight: bold;
    color: var(--text);
    line-height: 1.15;
    margin: 0;
}
.gotd-meta {
    font-size: 13px;
    color: var(--accent);
}
.gotd-desc {
    font-size: 14px;
    color: var(--text-faint);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
@media (max-width: 600px) {
    .gotd-card { flex-direction: column; }
    .gotd-img { width: 100%; min-height: 140px; }
    .gotd-body { padding: 16px; }
}

/* ================== PLATFORM LIST PAGE ================== */
.platforms-hero {
    text-align: center;
    padding: 80px 20px 40px;
    position: relative;
    z-index: 1;
}
.platforms-hero h1 {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 12px;
}
.platforms-hero p { font-size: 17px; opacity: 0.7; }
.platforms-grid {
    max-width: var(--content);
    margin: 0 auto 80px;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    position: relative;
    z-index: 1;
}
.platform-card {
    background: var(--surface-1);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    padding: 24px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.platform-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-soft);
    transform: translateY(-3px);
}
.platform-card-name {
    font-size: 20px;
    font-weight: bold;
    color: var(--text);
}
.platform-card-era {
    font-size: 14px;
    color: var(--accent);
    font-weight: bold;
    letter-spacing: 0.5px;
}
.platform-card-count {
    font-size: 13px;
    color: var(--text-faint);
}
.platform-card-desc {
    font-size: 13px;
    color: var(--text-faint);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ================== PLATFORM DETAIL PAGE ================== */
.platform-detail-wrapper {
    max-width: var(--content);
    margin: 0 auto;
    padding: 30px 20px 0;
    position: relative;
    z-index: 1;
}
.platform-detail-header {
    margin-bottom: 40px;
}
.platform-detail-header h1 {
    font-size: 42px;
    color: var(--text);
    margin: 0 0 6px;
}
.platform-detail-era {
    color: var(--accent);
    font-size: 14px;
    margin: 0 0 24px;
    font-weight: bold;
    letter-spacing: 0.5px;
}
.platform-detail-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: 16px;
    max-width: 780px;
}
/* ================== GENRE ENCYCLOPEDIA — LIST PAGE ================== */
.genres-hero {
    text-align: center;
    padding: 80px 20px 40px;
    position: relative;
    z-index: 1;
}
.genres-hero h1 {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 12px;
}
.genres-hero p { font-size: 17px; opacity: 0.7; max-width: 600px; margin: 0 auto; }

.genres-grid {
    max-width: var(--content);
    margin: 0 auto 80px;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    position: relative;
    z-index: 1;
}

.genre-card {
    background: var(--surface-1);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.genre-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-soft);
}
.genre-card-img-wrap {
    width: 100%;
    height: 160px;
    background: var(--surface-1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.genre-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s;
    filter: grayscale(20%);
}
.genre-card:hover .genre-card-img-wrap img { transform: scale(1.06); filter: grayscale(0%); }
.genre-card-body { padding: 18px 20px 22px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.genre-card-era { font-size: 13px; color: var(--accent); font-weight: bold; letter-spacing: 0.5px; text-transform: uppercase; }
.genre-card-name { font-size: 20px; font-weight: bold; color: var(--text); line-height: 1.2; }
.genre-card-count { font-size: 14px; color: var(--text-faint); }
.genre-card-desc { font-size: 13px; color: var(--text-faint); line-height: 1.55; margin-top: 4px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ================== GENRE ENCYCLOPEDIA — DETAIL (WIKI) PAGE ================== */
.genre-wiki-wrapper {
    max-width: 1040px;
    margin: 0 auto 80px;
    padding: 30px 20px 0;
    position: relative;
    z-index: 1;
}

.genre-article { position: relative; }

.genre-article-title {
    font-size: 42px;
    color: var(--text);
    margin: 0 0 6px;
    line-height: 1.1;
}
.genre-article-subtitle {
    font-size: 16px;
    color: var(--text-faint);
    font-style: italic;
    margin: 0 0 24px;
    line-height: 1.5;
}

/* Infobox — floats right like Wikipedia */
.genre-infobox {
    float: right;
    margin: 0 0 24px 32px;
    width: 260px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    font-size: 13px;
    flex-shrink: 0;
}
.genre-infobox-title {
    background: var(--accent-strong);
    color: var(--text);
    text-align: center;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
}
.genre-infobox-image img {
    width: 100%;
    display: block;
    max-height: 200px;
    object-fit: cover;
    object-position: center;
    border-bottom: 1px solid var(--surface-3);
}
.genre-infobox-caption {
    font-size: 13px;
    color: var(--text-faint);
    padding: 8px 10px;
    line-height: 1.45;
    border-bottom: 1px solid var(--surface-3);
    text-align: center;
}
.genre-infobox-license { font-size: 13px; color: var(--text-faint); display: block; margin-top: 3px; }
.genre-infobox-table { width: 100%; border-collapse: collapse; }
.genre-infobox-table tr { border-top: 1px solid var(--surface-2); }
.genre-infobox-table tr:first-child { border-top: none; }
.gi-label {
    color: var(--text-faint);
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 7px 10px;
    vertical-align: top;
    white-space: nowrap;
    width: 40%;
}
.gi-value {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 7px 10px;
    vertical-align: top;
}

/* Table of contents */
.genre-toc {
    display: inline-block;
    background: var(--surface-1);
    border: 1px solid var(--surface-3);
    border-radius: 6px;
    padding: 14px 20px 14px 16px;
    margin-bottom: 28px;
    min-width: 210px;
    max-width: 320px;
    clear: left;
}
.genre-toc-title {
    font-size: 13px;
    font-weight: bold;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.genre-toc ol {
    margin: 0;
    padding-left: 18px;
    list-style: decimal;
}
.genre-toc li { font-size: 13px; line-height: 1.9; color: var(--text-faint); }
.genre-toc a { color: var(--text-muted); text-decoration: none; transition: color 0.15s; }
.genre-toc a:hover { color: var(--accent); }

/* Intro paragraph */
.genre-article-intro {
    margin-bottom: 32px;
}
.genre-article-intro p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.75;
    border-left: 3px solid var(--accent-strong);
    padding-left: 16px;
}

/* Article sections */
.genre-section { margin-bottom: 36px; }
.genre-section h2 {
    font-size: 22px;
    color: var(--text);
    border-bottom: 1px solid var(--surface-3);
    padding-bottom: 8px;
    margin-bottom: 16px;
}
.genre-section p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 0 0 14px;
}
.genre-section p:last-child { margin-bottom: 0; }
.genre-section strong { color: var(--text); }
.genre-section em { color: var(--text-secondary); font-style: italic; }

/* Games section */
.genre-games-section { clear: both; margin-top: 48px; }
.genre-games-heading {
    font-size: 24px;
    color: var(--accent);
    border-bottom: 1px solid var(--surface-2);
    padding-bottom: 10px;
    margin-bottom: 24px;
}
.genre-games-section .games-grid { max-width: 100%; margin-bottom: 0; padding: 0; }

/* Responsive: collapse infobox on mobile */
@media (max-width: 700px) {
    .genre-infobox {
        float: none;
        width: 100%;
        margin: 0 0 24px 0;
    }
    .genre-article-title { font-size: 28px; }
    .genres-hero h1 { font-size: 32px; }
    .genres-grid { grid-template-columns: 1fr; }
}

/* ================== PLATFORM GAMES HEADING ================== */
.platform-games-heading {
    font-size: 22px;
    color: var(--accent);
    margin: 40px 0 20px;
    border-bottom: 1px solid var(--surface-2);
    padding-bottom: 10px;
}

/* ================== ESSAYS — LIST PAGE ================== */
.essays-hero {
    text-align: center;
    padding: 80px 20px 40px;
    position: relative;
    z-index: 1;
}
.essays-hero h1 {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 12px;
}
.essays-hero p { font-size: 17px; opacity: 0.7; max-width: 600px; margin: 0 auto; }

.essays-wrapper {
    max-width: var(--content);
    margin: 0 auto 80px;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

.essays-category-section { margin-bottom: 52px; }

.essays-category-heading {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-faint);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--surface-2);
}

.essays-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.essay-card {
    background: var(--bg);
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    padding: 22px 24px 20px;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.essay-card:hover {
    border-color: var(--accent-strong);
    transform: translateY(-3px);
    box-shadow: 0 0 20px var(--accent-soft);
}
.essay-card-category {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    font-weight: bold;
}
.essay-card-title {
    font-size: 18px;
    color: var(--text);
    line-height: 1.25;
    margin: 0;
}
.essay-card-subtitle {
    font-size: 13px;
    color: var(--text-faint);
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.essay-card-meta {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.essay-card-read {
    font-size: 13px;
    color: var(--text-faint);
    font-weight: bold;
    letter-spacing: 0.3px;
}

/* ================== ESSAYS — DETAIL PAGE ================== */
.essay-wrapper {
    max-width: var(--reading);
    margin: 0 auto 80px;
    padding: 30px 20px 0;
    position: relative;
    z-index: 1;
}

.essay-header {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--surface-2);
}
.essay-header-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.essay-header-category {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    font-weight: bold;
}
.essay-header-read {
    font-size: 13px;
    color: var(--text-faint);
    font-weight: bold;
}
.essay-title {
    font-size: 40px;
    color: var(--text);
    line-height: 1.1;
    margin: 0 0 12px;
}
.essay-subtitle {
    font-size: 17px;
    color: var(--text-faint);
    line-height: 1.55;
    margin: 0;
    font-style: italic;
}

.essay-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 48px;
    align-items: start;
}

.essay-toc {
    position: sticky;
    top: 24px;
}
.essay-toc-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-faint);
    font-weight: bold;
    margin-bottom: 12px;
}
.essay-toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    counter-reset: toc;
}
.essay-toc li { counter-increment: toc; }
.essay-toc a {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 14px;
    color: var(--text-faint);
    text-decoration: none;
    line-height: 1.5;
    padding: 4px 0;
    transition: color 0.15s;
}
.essay-toc a::before {
    content: counter(toc);
    font-size: 13px;
    color: var(--text-faint);
    flex-shrink: 0;
    width: 14px;
}
.essay-toc a:hover { color: var(--accent); }

.essay-body { min-width: 0; }

.essay-section { margin-bottom: 44px; }
.essay-section h2 {
    font-size: 20px;
    color: var(--text);
    border-bottom: 1px solid var(--surface-2);
    padding-bottom: 8px;
    margin-bottom: 18px;
    font-weight: bold;
}
.essay-section p {
    font-size: var(--fs-md);
    color: var(--text-secondary);
    line-height: 1.85;
    margin: 0 0 16px;
}
.essay-section p:last-child { margin-bottom: 0; }
.essay-section strong { color: var(--text); }
.essay-section em { color: var(--text-secondary); font-style: italic; }

@media (max-width: 768px) {
    .essays-hero h1 { font-size: 32px; }
    .essays-grid { grid-template-columns: 1fr; }
    .essay-layout { grid-template-columns: 1fr; }
    .essay-toc { display: none; }
    .essay-title { font-size: 28px; }
    .essay-subtitle { font-size: 15px; }
}

/* ================== GROUPED NAV (mega menu) ================== */
.nav-logo { display: flex; align-items: center; }
button.menu-toggle {
    background: none;
    border: none;
    padding: 0;
}
.nav-drop { position: static; }
.nav-drop summary {
    list-style: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: var(--fs-sm);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    white-space: nowrap;
    user-select: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.nav-drop summary::-webkit-details-marker { display: none; }
.nav-drop summary:hover { color: var(--text); background: var(--surface-2); }
.nav-drop[open] summary,
.nav-drop summary.active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}
.nav-mega {
    position: absolute;
    left: auto;
    right: var(--sp-5);
    width: min(1080px, calc(100vw - var(--sp-10)));
    top: calc(100% + 2px);
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-6);
    display: grid;
    /* 150px tracks needed 1020px but the overflow scrollbar leaves 1015px, so
       the sixth group wrapped to a second row. 140px leaves headroom. */
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--sp-5) var(--sp-6);
    scrollbar-gutter: stable;
    max-height: 72vh;
    overflow-y: auto;
    z-index: 1002;
    box-shadow: 0 12px 40px rgba(0,0,0,0.8);
}
.nav-mega-group { display: flex; flex-direction: column; gap: 7px; }
.nav-mega-title {
    color: var(--accent);
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 3px;
}
.nav-mega a {
    color: var(--text-muted);
    font-weight: normal;
    font-size: 13px;
}
.nav-mega a:hover { color: var(--text); }
.nav-mega a.active { color: var(--accent); }
.nav-mega-all {
    grid-column: 1 / -1;
    border-top: 1px solid var(--surface-3);
    padding-top: 12px;
    font-weight: bold !important;
    color: var(--text-secondary) !important;
}
.nav-search { display: flex; align-items: center; }
.nav-search input {
    background: var(--surface-1);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 5px;
    padding: 6px 12px;
    font-size: 13px;
    width: 130px;
    transition: width 0.2s, border-color 0.2s;
}
.nav-search input:focus {
    border-color: var(--accent);
    width: 180px;
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

@media (max-width: 768px) {
    .nav-links { overflow-y: auto; padding-bottom: 40px; }
    .nav-mega {
        position: static;
        display: flex;
        flex-direction: column;
        gap: 16px;
        max-height: none;
        overflow: visible;
        border: none;
        box-shadow: none;
        background: transparent;
        padding: 10px 0 0;
    }
    .nav-search { justify-content: center; padding: 0 20px; }
    .nav-search input, .nav-search input:focus { width: 100%; }
}

/* ================== SITE FOOTER ================== */
.site-footer {
    margin-top: 90px;
    border-top: 1px solid var(--surface-2);
    background: var(--bg);
    position: relative;
    z-index: 1;
    padding: 50px 30px 30px;
}
.footer-grid {
    max-width: var(--content);
    margin: 0 auto;
    padding: 0 var(--sp-5);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 28px 24px;
}
.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-col-title {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 4px;
}
.footer-col a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--fs-xs);
    padding: var(--sp-1) 0;
}
.footer-col a:hover { color: var(--text); }

/* The footer carries ~100 links in stacked columns. At 13px with no padding
   each one was a 21px-tall tap target, well under the 44px guideline; on
   touch widths they get real vertical room instead. */
@media (max-width: 768px) {
    .footer-col { gap: var(--sp-1); }
    .footer-col a {
        padding: var(--sp-2) 0;
        font-size: var(--fs-sm);
    }
    .footer-bottom { line-height: 2.2; }
}
.footer-bottom {
    max-width: var(--content);
    margin: 36px auto 0;
    padding: 20px var(--sp-5) 0;
    border-top: 1px solid var(--surface-2);
    color: var(--text-faint);
    font-size: 13px;
    text-align: center;
}
.footer-bottom a { color: var(--text-faint); text-decoration: none; }
.footer-bottom a:hover { color: var(--text); }

/* ================== BROWSE PAGE ================== */
.browse-wrapper {
    max-width: var(--content);
    margin: 0 auto;
    padding: 0 20px 60px;
    position: relative;
    z-index: 1;
}
.browse-group { margin-bottom: 40px; }
.browse-group h2 {
    color: var(--accent);
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
}
.browse-links { display: flex; flex-wrap: wrap; gap: 10px; }
.browse-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    background: var(--surface-1);
    border: 1px solid var(--surface-3);
    border-radius: 6px;
    padding: 8px 14px;
    transition: border-color 0.2s, color 0.2s;
}
.browse-links a:hover { border-color: var(--accent); color: var(--text); }

/* ================== BREADCRUMBS ================== */
.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-faint);
    margin-bottom: var(--sp-5);
    position: relative;
    z-index: 1;
}
/* The SEO middleware falls back to injecting crumbs straight after the site
   nav on templates with no back-link to anchor to, which leaves them outside
   any page wrapper and so without the wrapper's width limit or side padding. */
body > .crumbs {
    max-width: var(--content);
    margin: var(--sp-5) auto 0;
    padding: 0 var(--sp-5);
}
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs span[aria-current] { color: var(--text-secondary); }

/* ================== HOMEPAGE (archive-first) ================== */
.home-hero {
    text-align: center;
    padding: 90px 20px 50px;
    position: relative;
    z-index: 1;
    animation: fadeIn 1.5s ease;
}
.home-hero h1 {
    font-size: 54px;
    color: var(--accent);
    margin-bottom: 12px;
}
.home-hero .home-tagline {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}
.home-search {
    display: flex;
    justify-content: center;
    gap: 10px;
    max-width: 560px;
    margin: 0 auto 26px;
}
.home-search input {
    flex: 1;
    background: var(--surface-1);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 13px 18px;
    font-size: 16px;
}
.home-search input:focus { border-color: var(--accent); }
.home-search input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.home-search button {
    background: var(--accent-strong);
    color: var(--text);
    border: none;
    border-radius: 6px;
    padding: 13px 24px;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
}
.home-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--text-faint);
    font-size: 14px;
}
.home-stats a { color: var(--text-muted); text-decoration: none; border-bottom: 1px dotted var(--border-strong); padding: var(--sp-2) var(--sp-1); }
.home-stats a:hover { color: var(--text); }
@media (max-width: 768px) {
    .home-hero h1 { font-size: 36px; }
    .home-hero .home-tagline { font-size: 16px; }
    .home-search { flex-direction: column; }
}

/* Linked metadata values on detail pages */
.meta-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--text-faint);
}
.meta-link:hover { color: var(--text); border-bottom-color: var(--accent); }

/* ================== RETRO NEWS SECTION ================== */
.news-section {
    max-width: var(--content);
    margin: 0 auto 70px;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}
.news-header {
    margin-bottom: 24px;
}
.news-header h2 {
    font-size: 22px;
    color: var(--text-secondary);
    font-weight: bold;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.news-header p {
    font-size: 13px;
    color: var(--text-faint);
}
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.news-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--surface-2);
    border-radius: 8px;
    padding: 18px 20px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.news-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 0 14px var(--accent-soft);
}
.news-card-source {
    font-size: 13px;
    color: var(--accent);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.news-card-title {
    font-size: 15px;
    font-weight: bold;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}
.news-card-desc {
    font-size: 14px;
    color: var(--text-faint);
    line-height: 1.6;
    margin: 0;
    flex: 1;
}
.news-loading, .news-empty {
    color: var(--text-faint);
    font-size: 14px;
    grid-column: 1 / -1;
}
@media (max-width: 768px) {
    .news-grid { grid-template-columns: 1fr; }
}

/* ================== AUTOCOMPLETE ================== */
.nav-ac {
    position: absolute;
    top: calc(100% + 4px);
    left: auto;
    right: 0;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    list-style: none;
    padding: var(--sp-1) 0;
    margin: 0;
    z-index: 2000;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.7);
    width: max(300px, 100%);
    max-width: calc(100vw - var(--sp-8));
}
.nav-ac li a {
    display: flex;
    flex-direction: column;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--text);
    gap: 2px;
    border-bottom: 1px solid var(--surface-2);
    transition: background 0.12s;
}
.nav-ac li:last-child a { border-bottom: none; }
.nav-ac li a:hover { background: var(--surface-2); }
.ac-title { font-size: var(--fs-sm); font-weight: 600; }
.ac-sub { font-size: var(--fs-xs); color: var(--text-muted); }

/* ================== 404 PAGE ================== */
.notfound-wrapper {
    max-width: 480px;
    margin: 4rem auto;
    padding: 0 1.5rem;
    text-align: center;
    position: relative;
    z-index: 1;
}
.notfound-code {
    font-size: 7rem;
    font-weight: 900;
    color: var(--accent);
    line-height: 1;
}
.notfound-title {
    font-size: 1.4rem;
    margin: 0.5rem 0 0.6rem;
    color: var(--text-secondary);
}
.notfound-sub {
    color: var(--text-faint);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}
.notfound-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2.5rem;
}
.notfound-random {
    background: var(--surface-2);
    box-shadow: none;
}
.notfound-suggest-label {
    color: var(--text-muted);
    font-size: var(--fs-xs);
    margin-bottom: 0.8rem;
}
.notfound-card {
    max-width: 240px;
    display: inline-block;
    text-align: left;
}

/* Disambiguating suffix appended to headings whose subject name is shared by
   another page in the archive ("Sonic the Hedgehog" is a game, a franchise, a
   box art entry and a speedrun). Muted and lighter so the entity name still
   reads as the heading. */
.h1-qualifier {
    color: var(--text-faint);
    font-weight: 400;
    white-space: nowrap;
}

/* ================== SAVE / BOOKMARK BUTTON ==================
   Previously inline-styled in bookmarkBtn() with hardcoded #444/#fff and no
   bottom margin, so it collided with the "Overview" heading beneath it. */
.bm-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 40px;
    margin: var(--sp-4) 0 var(--sp-8);
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.bm-btn:hover {
    border-color: var(--accent-border);
    background: var(--surface-3);
    color: var(--text);
}
.bm-btn.is-saved {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-soft);
}
