/* ============================================
   ACDb - Assassin's Creed Collector's Database
   Dark theme inspired by the Animus interface
   ============================================ */

/* ---- Design tokens ----
   Component rules use only these. Gold is for interaction, selection and
   progress; green / purple / blue mark the state of one item (owned / read
   / wishlist); red is for danger only (and the NEW sticker). */
:root {
    /* Surfaces */
    --surface-page: #0a0a0f;
    --surface-bar: #12121a;          /* header, toolbar, menus, footer */
    --surface-card: #161622;
    --surface-card-hover: #1c1c2e;
    --surface-overlay: #13131f;      /* dialogs */
    --line: #2a2a3a;
    --line-strong: #3a3a4a;
    --line-control: #5a5a70;         /* switch track edge */

    /* Text (on cards: --text-2 7.2:1, --text-3 5.3:1) */
    --text: #e8e6e3;
    --text-2: #a3a3ad;
    --text-3: #8b8b98;

    /* Accent */
    --gold: #c9a84c;
    --gold-strong: #d4b85a;
    --gold-deep: #8a6d2b;
    --gold-tint: rgba(201, 168, 76, 0.08);
    --gold-tint-2: rgba(201, 168, 76, 0.16);
    --gold-glow: rgba(201, 168, 76, 0.35);
    --surface-set: #191714;          /* a filter with a value: --gold-tint on --surface-page, opaque so native <option> lists stay dark */

    /* Status. -solid takes white text (4.5:1+), -text reads on cards */
    --owned: #27ae60;
    --owned-text: #2ecc71;
    --owned-solid: #1d7a43;
    --owned-tint: rgba(39, 174, 96, 0.08);
    --owned-edge: rgba(39, 174, 96, 0.45);
    --read: #9b59b6;
    --read-text: #bb8fce;
    --read-solid: #7d3c98;
    --read-edge: rgba(155, 89, 182, 0.55);
    --wish: #3498db;
    --wish-text: #5dade2;
    --wish-solid: #2471a3;
    --wish-edge: rgba(52, 152, 219, 0.4);
    --danger: #e74c3c;
    --danger-text: #ef6b5e;
    --danger-solid: #c0392b;

    /* Item condition scale */
    --cond-mint: #1abc9c;
    --cond-near-mint: #2ecc71;
    --cond-excellent: #27ae60;
    --cond-good: #f39c12;
    --cond-fair: #e67e22;
    --cond-poor: #e74c3c;

    /* Type */
    --font-display: 'Cinzel', Georgia, serif;
    --font-body: 'Raleway', 'Segoe UI', system-ui, sans-serif;
    --font-data: 'JetBrains Mono', ui-monospace, Consolas, monospace;   /* counts and fractions */
    --fs-label: 0.6875rem;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-md: 0.875rem;
    --fs-base: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.375rem;
    --fs-2xl: 1.75rem;
    --tracking-label: 0.12em;        /* uppercase labels and section headings */

    /* Space and shape */
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;
    --s7: 48px;
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-pill: 999px;
    --h-sm: 32px;
    --h-md: 38px;

    /* Depth */
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.55);
    --shadow-modal: 0 24px 80px rgba(0, 0, 0, 0.7);
    --glow-card: 0 8px 32px rgba(201, 168, 76, 0.12);
    /* Eagle Vision only: the light around an owned or a wishlist card */
    --glow-owned: 0 0 0 1px var(--owned), 0 0 28px rgba(39, 174, 96, 0.4);
    --glow-wish: 0 0 0 1px var(--wish), 0 0 28px rgba(52, 152, 219, 0.4);

    /* Motion (named properties, never "all") */
    --t-fast: 120ms;
    --t: 200ms;
    --t-slow: 320ms;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --transition: color var(--t-fast), background-color var(--t-fast), border-color var(--t-fast),
        box-shadow var(--t), opacity var(--t), transform var(--t) var(--ease);

    /* Keyboard focus */
    --focus: 2px solid var(--gold);

    /* Paper: only inside the print block at the end of this file */
    --print-paper: #fff;             /* the page */
    --print-ink: #000;               /* text and the header rule */
    --print-line: #999;              /* the rule under each row */
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--surface-page);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    /* Raleway defaults to old-style figures ("AC1" looked like a subscript) */
    font-variant-numeric: lining-nums;
}

/* Form controls don't inherit font settings by default */
button,
input,
select,
textarea {
    font-variant-numeric: inherit;
}

/* One focus ring for every control; fields add a gold border */
:focus-visible {
    outline: var(--focus);
    outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline-offset: 0;
    border-color: var(--gold);
}

/* Visually hidden, still read by screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion: no pulsing, sliding, lifting, falling or smooth scrolling */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0s !important;
        transition-duration: 0.01ms !important;
    }

    /* !important like the rules above: the hover lifts come later in the file */
    .item-card:hover,
    .items-grid.list-view .item-card:hover,
    .item-card:hover .card-image img,
    .game-tile:hover,
    .character-card:hover {
        transform: none !important;
    }

    .confetti-container {
        display: none;
    }
}

/* The hidden attribute always wins over a component's display */
[hidden] {
    display: none !important;
}

/* ============================================
   Components: buttons and links
   Ladder: primary (gold fill) > secondary (gold tint) > quiet (outline)
   > link. Danger for destructive actions; publish (green) for putting the
   collection out there. Sizes: default 38px, .btn-sm 32px.
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s2);
    height: var(--h-md);
    padding: 0 var(--s4);
    background: none;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    color: var(--text-2);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    height: var(--h-sm);
    padding: 0 var(--s3);
    gap: 6px;
    font-size: var(--fs-sm);
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--surface-page);
}

.btn-primary:hover:not(:disabled) {
    background: var(--gold-strong);
    border-color: var(--gold-strong);
}

.btn-secondary {
    background: var(--gold-tint);
    border-color: var(--gold-deep);
    color: var(--gold);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gold-tint-2);
    border-color: var(--gold);
    color: var(--gold-strong);
}

.btn-quiet {
    border-color: var(--line-strong);
    color: var(--text-2);
    font-weight: 500;
}

.btn-quiet:hover:not(:disabled) {
    border-color: var(--text-3);
    color: var(--text);
}

.btn-danger {
    border-color: var(--danger-solid);
    color: var(--danger-text);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-solid);
    color: #fff;
}

.btn-publish {
    background: var(--owned-tint);
    border-color: var(--owned-edge);
    color: var(--owned-text);
}

.btn-publish:hover:not(:disabled) {
    background: rgba(39, 174, 96, 0.16);
    border-color: var(--owned);
}

.btn-publish-fill {
    background: var(--owned-solid);
    border-color: var(--owned-solid);
    color: #fff;
}

.btn-publish-fill:hover:not(:disabled) {
    background: var(--owned);
    border-color: var(--owned);
}

/* Text-only actions */
.link {
    padding: 0;
    background: none;
    border: 0;
    color: var(--gold);
    font-family: var(--font-body);
    font-size: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link-quiet {
    color: var(--text-2);
    font-weight: 500;
}

.link-quiet:hover {
    color: var(--gold);
}

/* Round icon-only buttons (close, share, arrows); always with aria-label */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--surface-bar);
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--text-2);
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

.icon-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.icon-btn-sm {
    width: 28px;
    height: 28px;
}

.icon-btn-sm svg {
    width: 16px;
    height: 16px;
}

.icon-btn-bare {
    background: none;
    border-color: transparent;
}

.icon-btn-bare:hover {
    border-color: transparent;
}

/* ============================================
   Components: pick-one controls
   Tabs move to another view; a segmented control switches how one view
   is shown; chips narrow a list.
   ============================================ */

/* Tabs (in-page; the header nav is the primary size, .main-nav-link) */
.tabs {
    display: flex;
    gap: var(--s5);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    position: relative;
    flex-shrink: 0;
    padding: 10px 0 12px;
    color: var(--text-2);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text);
}

.tab:focus-visible {
    outline-offset: -2px;
}

.tab.active {
    color: var(--gold);
}

.tab.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    border-radius: 1px;
    background: var(--gold);
}

/* Segmented control */
.seg {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-page);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.seg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 30px;
    height: 30px;
    padding: 0 var(--s3);
    background: none;
    border: 0;
    border-radius: 5px;
    color: var(--text-2);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.seg-btn svg {
    width: 16px;
    height: 16px;
}

.seg-btn:hover {
    color: var(--text);
}

.seg-btn.active {
    background: var(--gold-tint-2);
    color: var(--gold);
}

/* Filter chips */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    height: 30px;
    padding: 0 var(--s3);
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    color: var(--text-2);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.chip-count {
    font-family: var(--font-data);
    font-size: var(--fs-label);
    color: var(--text-3);
}

.chip:hover {
    border-color: var(--gold-deep);
    color: var(--text);
}

.chip.active {
    background: var(--gold-tint-2);
    border-color: var(--gold);
    color: var(--gold);
}

.chip.active .chip-count {
    color: var(--gold);
}

/* Chip row: chips wrap on wide screens; on phones they become one row that
   scrolls sideways inside itself (never the page), like the game timeline */
.chip-row {
    position: relative;   /* chips' offsetLeft is measured from the row */
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
}

/* Thin bar in the site's scrollbar style (a standard scrollbar-width
   would switch Chrome back to its default light scrollbar) */
.chip-row::-webkit-scrollbar {
    height: 6px;
}

@media (max-width: 768px) {
    .chip-row {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.35rem;
    }
}

/* Search box: a field with a search icon and a clear button. It gets
   .is-set while it has text, like any filter with a value */
.search-box {
    position: relative;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-3);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 2.5rem 0.6rem 2.5rem;
    background: var(--surface-page);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    transition: var(--transition);
    appearance: none;
}

/* type="search" draws its own clear button; the box has one already */
.search-box input::-webkit-search-cancel-button {
    display: none;
}

/* Kept before :focus so focus still wins */
.search-box input.is-set {
    border-color: var(--gold-deep);
    background-color: var(--surface-set);
}

.search-box input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-tint);
}

.search-box input::placeholder {
    color: var(--text-3);
}

/* A placeholder longer than its box ends in "…" instead of being cut */
.search-box input:placeholder-shown {
    text-overflow: ellipsis;
}

.search-box .clear-search {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
}

.search-box .clear-search.visible {
    display: inline-flex;
}

/* ============================================
   Components: status and progress
   ============================================ */

/* Badges: the state of one item, never interactive */
.badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--r-sm);
    font-family: var(--font-body);
    font-size: var(--fs-label);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-owned { background: var(--owned-solid); color: #fff; }
.badge-wishlist { background: var(--wish-solid); color: #fff; }
.badge-read { background: var(--read-solid); color: #fff; }

.badge-accent {
    background: var(--gold-tint-2);
    color: var(--gold);
}

.badge-plain {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-2);
    font-size: var(--fs-xs);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.condition-mint { background: rgba(26, 188, 156, 0.15); color: var(--cond-mint); }
.condition-near-mint { background: rgba(46, 204, 113, 0.15); color: var(--cond-near-mint); }
.condition-excellent { background: rgba(39, 174, 96, 0.15); color: var(--owned-text); }
.condition-good { background: rgba(243, 156, 18, 0.15); color: var(--cond-good); }
.condition-fair { background: rgba(230, 126, 34, 0.15); color: var(--cond-fair); }
.condition-poor { background: rgba(231, 76, 60, 0.15); color: var(--danger-text); }

/* Progress: gold measures progress; a status colour marks "complete" */
.progress {
    display: block;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--line);
    overflow: hidden;
}

.progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--gold);
    transition: width 0.4s ease;
}

.progress-thin {
    height: 4px;
}

.progress-count {
    font-family: var(--font-data);
    font-size: var(--fs-sm);
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
    white-space: nowrap;
}

.done-read { color: var(--read-text); }
.done-owned { color: var(--owned-text); }

/* Section heading: Cinzel overline with an optional count on the right */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s4);
    margin: 0;
    padding-bottom: var(--s2);
    border-bottom: 1px solid var(--line);
    color: var(--gold);
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

.section-head-count {
    font-family: var(--font-data);
    font-size: var(--fs-xs);
    font-weight: 500;
    letter-spacing: 0;
    color: var(--text-3);
}

/* Small uppercase label (meta labels, form labels, table headers) */
.label {
    font-family: var(--font-body);
    font-size: var(--fs-label);
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--text-3);
}

/* ============================================
   Components: page header and breadcrumb
   ============================================ */
.page-head {
    display: grid;
    gap: var(--s3);
    margin-bottom: var(--s5);
}

.page-head-tight {
    margin-bottom: var(--s4);
}

.page-title {
    margin: 0;
    color: var(--gold);
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: 700;
    line-height: 1.15;
    text-wrap: balance;
}

.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);
    color: var(--text-3);
}

.crumbs a {
    color: var(--text-2);
    text-decoration: none;
}

.crumbs a:hover {
    color: var(--gold);
}

.crumbs li + li::before {
    content: '\203A';
    margin-right: 6px;
    color: var(--text-3);
}

.crumbs [aria-current] {
    color: var(--text);
}

/* ---- Ambient Background ---- */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(201, 168, 76, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(201, 168, 76, 0.02) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(192, 57, 43, 0.02) 0%, transparent 50%),
        var(--surface-page);
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--surface-bar);
}
::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: var(--r-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gold-deep);
}

/* ---- Header ---- */
.main-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, rgba(10, 10, 15, 0.98) 0%, rgba(10, 10, 15, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 2rem;
}

/* As wide as the content under it: the page containers are 1600px with
   their 2rem padding inside, and this bar's padding is outside its inner
   box (the toolbar and the sign-in banner do the same) */
.header-inner {
    max-width: calc(1600px - 4rem);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.ac-symbol {
    width: 48px;
    height: 48px;
    color: var(--gold);
    filter: drop-shadow(0 0 10px rgba(201, 168, 76, 0.3));
    animation: symbolPulse 4s ease-in-out infinite;
}

@keyframes symbolPulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(201, 168, 76, 0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(201, 168, 76, 0.5)); }
}

.ac-logo-svg {
    width: 100%;
    height: 100%;
}

.logo-text h1 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 4px;
    text-transform: uppercase;
    line-height: 1;
}

.logo-subtitle {
    font-size: 0.65rem;
    color: var(--text-2);
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 500;
}

/* The widest this gets is "Publish collection" beside the account button
   (anyone who hasn't published yet). The breakpoints below are set so the
   row fits with both showing; wrapping is only the last resort. */
.header-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.collection-actions {
    display: flex;
    gap: 0.4rem;
    padding-left: 1rem;
    border-left: 1px solid var(--line);
}

/* ---- Main navigation (Collection / Reading Order / Games / Characters / Leaderboard) ---- */
.main-nav {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    margin: 0 auto 0 1rem;
}

.main-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.5rem 0.65rem;
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    color: var(--text-2);
    border-radius: var(--r-md);
    transition: var(--transition);
}

.main-nav-link:hover {
    color: var(--text);
    background: var(--gold-tint);
}

.main-nav-link.active {
    color: var(--gold);
}

.main-nav-link.active::after {
    content: '';
    position: absolute;
    left: 0.65rem;
    right: 0.65rem;
    bottom: 0;
    height: 2px;
    border-radius: 1px;
    background: var(--gold);
}

/* ---- Progress meter (owned / total) ---- */
.progress-meter {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 170px;
    padding: 0.35rem 0.6rem;
    background: transparent;
    border: none;
    border-radius: var(--r-md);
    color: var(--text-2);
    font-family: var(--font-body);
    cursor: pointer;
    transition: var(--transition);
}

.progress-meter:hover {
    background: var(--gold-tint);
}

.progress-meter-text {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    white-space: nowrap;
}

.progress-meter-count {
    font-family: var(--font-data);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--gold);
}

.progress-meter-label {
    font-size: var(--fs-label);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.progress-meter-pct {
    margin-left: auto;
    font-family: var(--font-data);
    font-size: var(--fs-md);
    color: var(--text);
}

.progress-meter-bar {
    display: block;
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--line);
    overflow: hidden;
}

.progress-meter-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--gold);
    transition: width 0.6s ease;
}

.stat-number {
    display: block;
    font-family: var(--font-data);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--gold);
    line-height: 1.2;
    min-height: 1.8rem;
}

.stat-label {
    font-size: var(--fs-label);
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ---- Toolbar ---- */
.toolbar {
    background: rgba(18, 18, 26, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 2rem;
    position: sticky;
    top: var(--header-height, 76px);   /* set on this element by init() in js/app.js */
    z-index: 99;
}

.toolbar-inner {
    max-width: calc(1600px - 4rem);   /* lines up with the content: see .header-inner */
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* The collection's search: a .search-box (Components) that fills the row */
.search-container {
    flex: 1;
    min-width: 250px;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    min-height: 38px;
}

.filter-select {
    padding: 0.6rem 2rem 0.6rem 0.75rem;
    background: var(--surface-page);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.filter-select.is-set {
    border-color: var(--gold-deep);
    background-color: var(--surface-set);
}

.filter-select:focus {
    border-color: var(--gold);
}

/* ---- Multi-Select Dropdown ---- */
/* 140px keeps five dropdowns, status, sort and the layout toggle on one
   row with the search down to 1521px */
.multi-select {
    position: relative;
    min-width: 140px;
    max-width: 250px;
}

/* Long selected values (e.g. a series title) are ellipsised so one dropdown
   can't balloon across the toolbar; the full value is in the title tooltip. */
.multi-select-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cascading dropdowns with nothing to offer (e.g. Series when no comics
   are upstream) are removed from the toolbar entirely. */
.multi-select[hidden] {
    display: none;
}

.multi-select-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--surface-page);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    white-space: nowrap;
    min-height: 38px;
}

.multi-select.has-selection > .multi-select-toggle {
    border-color: var(--gold-deep);
    background-color: var(--surface-set);
}

.multi-select-toggle:focus {
    border-color: var(--gold);
}

.multi-select.open .multi-select-toggle {
    border-color: var(--gold);
}

.multi-select-clear {
    display: none;
    width: 18px;
    height: 18px;
    line-height: 16px;
    text-align: center;
    font-size: var(--fs-md);
    color: var(--text-3);
    border-radius: 50%;
    flex-shrink: 0;
    transition: var(--transition);
}

.multi-select.has-selection .multi-select-clear {
    display: block;
}

.multi-select-clear:hover {
    color: var(--danger-solid);
    background: rgba(192, 57, 43, 0.15);
}

.multi-select-chevron {
    width: 12px;
    height: 12px;
    color: var(--text-3);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.multi-select.open .multi-select-chevron {
    transform: rotate(180deg);
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    padding: var(--s1) 0;
    background: var(--surface-bar);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    z-index: 200;
}

.multi-select-options {
    max-height: 260px;
    overflow-y: auto;
}

.multi-select.open .multi-select-dropdown {
    display: block;
}

.multi-select-search {
    display: block;
    width: calc(100% - 1rem);
    margin: 0.4rem 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--surface-bar);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    transition: border-color 0.2s ease;
    border-bottom: 1px solid var(--line);
}

.multi-select-search:focus {
    border-color: var(--gold);
}

.multi-select-search::placeholder {
    color: var(--text-3);
}

.multi-select-separator {
    height: 1px;
    background: var(--line);
    margin: 0.25rem 0.75rem;
}

.multi-select-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: var(--fs-md);
    color: var(--text);
    white-space: nowrap;
}

.multi-select-option:hover {
    background: var(--surface-card-hover);
}

/* Hidden but focusable, so the options work from the keyboard (Tab, Space) */
.multi-select-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
}

.multi-select-option:has(input:focus-visible) {
    outline: var(--focus);
    outline-offset: -2px;
    background: var(--surface-card-hover);
}

.multi-select-check {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--r-sm);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.multi-select-option input:checked + .multi-select-check {
    background: var(--gold);
    border-color: var(--gold);
}

.multi-select-option input:checked + .multi-select-check::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid var(--surface-page);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-1px);
}

.view-controls {
    flex-shrink: 0;
}

/* Phones only (see the 768px query): the filters fold behind this */
.filters-toggle {
    display: none;
}

.filters-count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--r-pill);
    background: var(--gold);
    color: var(--surface-page);
    font-family: var(--font-data);
    font-size: var(--fs-label);
    line-height: 20px;
    text-align: center;
}

/* ---- Game Timeline ---- */
/* Buttons wrap on wide screens; on phones they become one sideways-scrolling
   row, like the Reading Order game filter (see the media query) */
.game-timeline {
    background: rgba(18, 18, 26, 0.6);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    min-height: 44px;
}

/* Thin bar in the site's scrollbar style (a standard scrollbar-width
   would switch Chrome back to its default light scrollbar) */
.game-timeline::-webkit-scrollbar {
    height: 6px;
}

.timeline-inner {
    display: flex;
    flex-wrap: wrap;
    padding: var(--s2) 2rem;
    gap: var(--s2);
    max-width: 1600px;
    margin: 0 auto;
}

.timeline-btn {
    flex-shrink: 0;
}

/* ---- Stats Dashboard ---- */
.stats-dashboard {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
}

.stats-toggle {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) 0;
    background: none;
    border: none;
    color: var(--gold);
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
}

.stats-toggle:hover {
    color: var(--gold-strong);
}

.stats-chevron {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.stats-dashboard.open .stats-chevron {
    transform: rotate(180deg);
}

.stats-panel {
    display: none;
    padding: 1rem 0 0.5rem;
}

.stats-dashboard.open .stats-panel {
    display: block;
}

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto 1fr;
    gap: 1.5rem;
}

/* Spending, Spent by category, Collected by year: a second row of three.
   Before the media queries, so they still make it two columns, then one. */
.stats-grid-spending {
    grid-template-columns: repeat(3, 1fr);
    margin-top: var(--s5);
}

/* A long item name cuts off instead of widening its column */
.stats-grid-spending > .stats-section {
    min-width: 0;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stats-section h4 {
    margin-bottom: var(--s3);
}

.stats-bars {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.8rem;
}

.stats-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--fs-xs);
}

.stats-bar-row.clickable {
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    margin: 0 -0.35rem;
    border-radius: var(--r-sm);
    transition: background 0.15s ease;
}

/* A clickable row that is a real button (the spending rows): it looks
   like the other rows, and the global focus ring applies */
button.stats-bar-row {
    background: none;
    border: 0;
    color: inherit;
    font-family: inherit;
    font-weight: inherit;
    line-height: inherit;
    text-align: left;
}

.stats-bar-row.clickable:hover {
    background: rgba(255, 255, 255, 0.06);
}

.stats-bar-row.clickable:hover .stats-bar-label {
    color: var(--text);
}

.stats-bar-label {
    width: 140px;
    flex-shrink: 0;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-bar-track {
    flex: 1;
}

/* The currency pick above the Spending figures */
.stats-currency {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s2);
    margin-bottom: var(--s3);
}

/* Figures without a bar (Spending) line up at the right edge */
.stats-figures .stats-bar-value {
    margin-left: auto;
}

/* The item name in "Most expensive"; a long one cuts off */
.stats-bar-item {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-summary .stats-bar-label,
.stats-summary .stats-bar-value {
    color: var(--gold);
}

.stats-empty {
    font-size: var(--fs-sm);
    color: var(--text-3);
}

.stats-bar-value {
    min-width: 70px;
    text-align: right;
    color: var(--text-3);
    font-family: var(--font-data);
    font-size: var(--fs-xs);
    white-space: nowrap;
}

.stats-bar-pct {
    margin-left: 0.25rem;
    color: var(--gold);
}

.stats-bar-pct.done-owned {
    color: var(--owned-text);
}

.stats-bar-pct.done-read {
    color: var(--read-text);
}

/* ---- Toast Notification ---- */
#acdb-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: var(--s3);
    max-width: min(520px, calc(100vw - 2rem));
    padding: var(--s3) var(--s5) var(--s3) var(--s4);
    background: var(--surface-bar);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
    transition: opacity var(--t-slow) ease, transform var(--t-slow) var(--ease);
}

#acdb-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#acdb-toast svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

#acdb-toast.toast-success svg {
    color: var(--owned-text);
}

#acdb-toast.toast-error {
    border-color: var(--danger-solid);
}

#acdb-toast.toast-error svg {
    color: var(--danger-text);
}

/* ---- Celebration Toast ---- */
#acdb-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 10000;
    max-width: calc(100vw - 2rem);
    padding: var(--s5) var(--s6);
    background: var(--surface-card);
    border: 1px solid var(--owned);
    border-radius: var(--r-lg);
    box-shadow: 0 0 40px rgba(39, 174, 96, 0.3), var(--shadow-modal);
    color: var(--owned-text);
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.9);
    transition: opacity var(--t-slow) ease, transform var(--t-slow) var(--ease);
}

#acdb-celebration.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ---- Confetti ---- */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    border-radius: 2px;
    opacity: 0;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* ---- Lightbox ---- */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.lightbox-close svg {
    width: 28px;
    height: 28px;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.lightbox-nav:hover {
    opacity: 1;
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-nav svg {
    width: 28px;
    height: 28px;
}

.lightbox-image-container {
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image-container img {
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: default;
    animation: lightboxFadeIn 0.2s ease;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.lightbox-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-data);
    font-size: 0.8rem;
}

/* ---- Search: how the text was read ---- */
/* "UNDERSTOOD AS  Statue · before 2012 · “ezio”" above the count, when the
   search text was read as more than plain words (js/search.js), then a
   .link button for the items that only mention those words. It wraps. */
.search-read {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--s1) var(--s3);
    margin: 0 0 var(--s2);
    font-size: var(--fs-sm);
    color: var(--text-2);
}

.search-read-parts {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* A long button wraps like the text beside it */
.search-read .link {
    text-align: left;
}

/* "Found in your browser using code, not AI.", with a .link to the privacy page */
.search-read-note {
    font-size: var(--fs-xs);
    color: var(--text-3);
}

/* An Easter egg: the Creed's next line, above the results when the search
   is a line of it */
.search-reply {
    display: flex;
    align-items: center;
    gap: var(--s2);
    margin: 0 0 var(--s3);
    color: var(--gold);
    font-family: var(--font-display);
    font-size: var(--fs-base);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.02em;
    animation: search-reply-in var(--t-slow) var(--ease);
}

.search-reply-mark {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* It fades in each time it appears (it goes from hidden to shown) */
@keyframes search-reply-in {
    from { opacity: 0; }
}

/* Another: the line that names Eagle Vision while it is on, with its way
   out. The same gold line, floating in the window's bottom left corner on
   the toast's surface (Back to Top has the right corner): in the page it
   pushed the grid down a row as Eagle Vision started, and scrolled out of
   reach. The button is an ordinary quiet link. */
.eagle-line {
    position: fixed;
    bottom: 2rem;   /* level with Back to Top */
    left: 2rem;
    z-index: 100;   /* over the start's veil, under dialogs */
    min-height: var(--h-md);
    margin: 0;
    padding: 0 var(--s4);
    background: var(--surface-bar);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
}

.eagle-line .link {
    margin-left: var(--s2);
    font-size: var(--fs-sm);
    letter-spacing: 0;
}

/* Phones: the line is as wide as the gap the toast needs, so a toast shows
   above it while it is there */
@media (max-width: 768px) {
    .eagle-line {
        left: 1rem;
    }

    body:has(.eagle-line:not([hidden])) #acdb-toast {
        bottom: calc(2rem + var(--h-md) + var(--s3));
    }
}

/* ---- Results Count ---- */
/* The count on the left and the top collectors on the right. At 1180px and
   below the collectors get a line of their own under the count (see the
   media query): by a fixed rule, not by wrapping, so the grid doesn't move
   when the names arrive. */
.results-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s1) var(--s5);
    margin-bottom: var(--s3);
}

.results-count {
    flex-shrink: 0;
    font-size: var(--fs-md);
    color: var(--text-2);
    font-family: var(--font-data);
    min-height: 1.2em;
    letter-spacing: 0.5px;
}

/* ---- Top collectors ---- */
/* The leaderboard's top three (loadTopCollectors in sharing.js). One row that
   never wraps: where it is wider than its room (phones), it scrolls sideways
   inside itself like a chip row, with no scrollbar. The padding leaves room
   for its links' focus rings, which the scrolling would cut off, and the
   negative margin takes that room back. It is empty until the leaderboard
   has loaded and keeps a line's height meanwhile. It is position: relative
   so the hidden "items owned" words (.sr-only, absolutely placed) scroll
   and clip with the row: otherwise they sit outside it, widen the page and
   let a phone zoom the whole site out. */
.top-collectors {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--s4);
    min-width: 0;
    min-height: calc(1.6em + 2 * var(--s1));
    margin: calc(-1 * var(--s1));
    padding: var(--s1);
    overflow-x: auto;
    scrollbar-width: none;
    font-size: var(--fs-sm);
}

@media (max-width: 1180px) {
    .results-row {
        flex-direction: column;
        align-items: stretch;
    }
}

.top-collectors::-webkit-scrollbar {
    display: none;
}

.top-collectors > * {
    flex-shrink: 0;
}

.top-collectors-list {
    display: flex;
    align-items: center;
    gap: var(--s4);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Medal, name and count are one link to the profile */
.top-collector {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.top-collector-name {
    max-width: 22ch;
    overflow: hidden;
    color: var(--gold);
    font-weight: 600;
    text-overflow: ellipsis;
}

.top-collector:hover .top-collector-name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.top-collector-count {
    color: var(--text-2);
    font-family: var(--font-data);
    font-size: var(--fs-xs);
}

.top-collectors .link {
    white-space: nowrap;
}

/* ---- Main Content ---- */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
    min-height: 60vh;
}

/* ---- Items Grid ---- */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.items-grid.list-view {
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

/* ---- Item Card (Grid View) ---- */
.item-card {
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: visible;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    text-decoration: none;
    color: inherit;
    display: block;
}

.item-card:hover {
    transform: translateY(-3px);
    border-color: var(--gold-deep);
    box-shadow: var(--glow-card);
    background: var(--surface-card-hover);
}

.item-card.owned {
    border-color: var(--owned-edge);
}

.item-card.owned:hover {
    border-color: var(--owned);
    box-shadow: 0 8px 40px rgba(39, 174, 96, 0.15);
}

.item-card.wishlist {
    border-color: var(--wish-edge);
}

.card-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--surface-bar) 0%, var(--surface-page) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

/* "NEW" sticker for the most-recently-added items — sits rotated
   at the top-right, deliberately poking outside the card edge. */
.badge-new {
    position: absolute;
    top: -9px;
    right: -10px;
    z-index: 3;
    padding: 4px 12px;
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-radius: 3px;
    transform: rotate(14deg);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(0, 0, 0, 0.25),
                inset 0 -2px 0 rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.card-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        rgba(201, 168, 76, 0.03) 0%,
        transparent 50%,
        rgba(201, 168, 76, 0.02) 100%);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.item-card:hover .card-image img {
    transform: scale(1.05);
}

.card-image .placeholder-icon {
    width: 60px;
    height: 60px;
    color: var(--line-strong);
    opacity: 0.5;
    transition: var(--transition);
}

.item-card:hover .card-image .placeholder-icon {
    opacity: 0.7;
    color: var(--gold-deep);
}

.card-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.card-body {
    padding: 1rem;
}

/* Game line with the item's permanent id pill at its right end */
.card-game-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s2);
    margin-bottom: 0.35rem;
}

.card-game {
    font-size: var(--fs-label);
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    min-width: 0;
}

/* The permanent item id pill (#14): card game line and item modal Game line */
.item-id {
    flex-shrink: 0;
    font-family: var(--font-data);
}

.card-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-description {
    font-size: var(--fs-sm);
    color: var(--text-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-year {
    font-family: var(--font-data);
    font-size: var(--fs-xs);
    color: var(--text-3);
}


/* ---- List View Cards ---- */
.items-grid.list-view .item-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    border-radius: var(--r-md);
}

.items-grid.list-view .item-card:hover {
    transform: translateX(3px);
}

.items-grid.list-view .card-image {
    display: contents;
}

.items-grid.list-view .card-image::before {
    display: none;
}

.items-grid.list-view .card-image img {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    margin: var(--s2) 0 var(--s2) var(--s3);
    border-radius: var(--r-sm);
}

.items-grid.list-view .card-image .placeholder-icon {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    margin: var(--s2) 0 var(--s2) var(--s3);
    padding: var(--s4);
    background: var(--surface-bar);
    border-radius: var(--r-sm);
}

.items-grid.list-view .card-body {
    order: 2;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--s4);
    padding: var(--s2) var(--s4);
}

.items-grid.list-view .card-title {
    flex: 1;
    margin-bottom: 0;
    -webkit-line-clamp: 1;
}

.items-grid.list-view .card-description {
    display: none;
}

.items-grid.list-view .card-footer {
    gap: var(--s2);
    flex-shrink: 0;
}

.items-grid.list-view .card-badges:empty {
    display: none;
}

.items-grid.list-view .card-badges {
    position: static;
    order: 3;
    flex-shrink: 0;
    margin-right: var(--s4);
}

.items-grid.list-view .badge-new {
    top: -6px;
    right: -6px;
}

/* Above the phone layout (768px), the row's parts form one flex line so
   every row ends with the year and the id at the same x:
   thumb · game · title · type · condition · status badges · year · #id */
@media (min-width: 769px) {
    .items-grid.list-view .item-card {
        gap: var(--s2);
        padding-right: var(--s4);
    }

    .items-grid.list-view .card-body,
    .items-grid.list-view .card-game-row,
    .items-grid.list-view .card-footer {
        display: contents;
    }

    .items-grid.list-view .card-game {
        order: 1;
        flex: 0 0 180px;
        margin-left: var(--s2);
    }

    .items-grid.list-view .card-title {
        order: 2;
        min-width: 0;
        margin-inline: var(--s2);
    }

    .items-grid.list-view .card-type { order: 3; }
    .items-grid.list-view .card-condition { order: 4; }

    .items-grid.list-view .card-badges {
        order: 5;
        margin-right: 0;
    }

    .items-grid.list-view .card-year {
        order: 6;
        margin-left: var(--s1);
    }

    /* Fixed width (room for "#999") so the years above line up */
    .items-grid.list-view .item-id {
        order: 7;
        min-width: 6ch;
        justify-content: center;
        margin-left: var(--s1);
    }
}

/* ---- Eagle Vision (an Easter egg) ----
   V, or "eagle vision" typed in the search, puts .eagle-vision on the
   collection's grid (js/app.js): the owned cards light up green and the
   wishlist cards blue, in grid and list view, and every other card
   recedes. A receding card keeps the three text colours on a darker
   surface, and nothing is filtered or faded on the card itself, so its
   text passes 4.5:1 and its focus ring is the usual gold. */
.items-grid.eagle-vision .item-card.owned {
    border-color: var(--owned);
    box-shadow: var(--glow-owned);
}

.items-grid.eagle-vision .item-card.wishlist {
    border-color: var(--wish);
    box-shadow: var(--glow-wish);
}

.items-grid.eagle-vision .item-card:not(.owned):not(.wishlist) {
    background: var(--surface-page);
}

.items-grid.eagle-vision .item-card:not(.owned):not(.wishlist) .card-image img {
    filter: grayscale(1) brightness(0.4);
}

.items-grid.eagle-vision .item-card:not(.owned):not(.wishlist) .badge-new {
    filter: grayscale(1) brightness(0.6);
}

.items-grid.eagle-vision .item-card:not(.owned):not(.wishlist) .card-title {
    color: var(--text-2);
}

.items-grid.eagle-vision .item-card:not(.owned):not(.wishlist) .card-game,
.items-grid.eagle-vision .item-card:not(.owned):not(.wishlist) .card-description {
    color: var(--text-3);
}

/* The start, about a second: the page under the header goes dark and
   clears (the veil), two pale rings open from the middle of the window one
   after the other, and the lit cards on screen flare before they settle
   (.eagle-flare). app.js adds the veil, the rings and the flare, removes
   them when they are done, and leaves them all out under reduced motion. */
.eagle-pulse {
    position: fixed;
    inset: 0;
    z-index: 90;   /* over the page, under the header and the toolbar */
    overflow: hidden;
    pointer-events: none;
}

.eagle-pulse::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--surface-page);
    opacity: 0;
    animation: eagle-veil calc(var(--t-slow) * 3) ease-out;
}

.eagle-pulse span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vmax;
    height: 100vmax;
    margin: -50vmax 0 0 -50vmax;
    border-radius: 50%;
    box-shadow: 0 0 var(--s7) var(--text), inset 0 0 var(--s7) var(--text);
    opacity: 0;
    animation: eagle-pulse calc(var(--t-slow) * 2) var(--ease);
}

.eagle-pulse span + span {
    animation-delay: calc(var(--t-slow) / 2);
}

@keyframes eagle-veil {
    from { opacity: 0.8; }
    to { opacity: 0; }
}

@keyframes eagle-pulse {
    from { opacity: 0.45; transform: scale(0.1); }
    to { opacity: 0; transform: scale(1.5); }
}

/* The flare is a second, stronger light on top of the card's own, fading
   out: only its opacity moves, and the card's entrance animation is left
   alone. */
.items-grid.eagle-vision .item-card.owned { --eagle-light: var(--owned); }
.items-grid.eagle-vision .item-card.wishlist { --eagle-light: var(--wish); }

.items-grid.eagle-vision .item-card.eagle-flare::after {
    content: '';
    position: absolute;
    inset: -1px;   /* over the card's border */
    border-radius: inherit;
    box-shadow: 0 0 0 var(--s1) var(--eagle-light), 0 0 var(--s7) var(--s2) var(--eagle-light);
    opacity: 0;
    pointer-events: none;
    animation: eagle-flare calc(var(--t-slow) * 4) var(--ease);
}

@keyframes eagle-flare {
    from { opacity: 0; }
    25% { opacity: 1; }
    to { opacity: 0; }
}

/* ---- Empty state ----
   What every searched or filtered list shows when nothing matches (the
   collection, Games, Characters): the emblem, the Creed line and "Clear
   search and filters". One component; don't write a view its own. */
.no-results {
    display: grid;
    justify-items: center;
    gap: var(--s5);
    padding: 4rem var(--s4);
    text-align: center;
}

.no-results-icon {
    width: 80px;
    height: 80px;
    color: var(--line-strong);
}

.no-results p {
    color: #666;   /* the original grey, kept at the owner's request (3.4:1) */
    font-size: 1.1rem;   /* the original size */
    font-style: italic;
}

.no-results .btn {
    margin-top: var(--s2);
}

/* Not the italic grey line above: an ordinary sentence with links */
.no-results .no-results-suggest {
    color: var(--text-2);
    font-size: var(--fs-md);
    font-style: normal;
}

.no-results-suggest .link {
    white-space: nowrap;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal {
    background: var(--surface-overlay);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    max-width: 980px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-modal);
    transform: scale(0.97);
    transition: transform var(--t-slow) var(--ease), max-width 0.35s ease;
    position: relative;
}

.modal.landscape {
    max-width: 1300px;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

/* Zero-height bar that sticks to the top of the scrolling item modal */
.modal-actions {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 0;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

.modal-content {
    display: grid;
    grid-template-columns: 1fr 500px;
}

.modal-image-section {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--surface-bar) 0%, var(--surface-page) 100%);
    border-radius: var(--r-xl) 0 0 var(--r-xl);
    min-height: 450px;
}

/* ---- Gallery ---- */
/* A window taller than the screen scrolls (books with reading orders): the
   gallery is then as tall as the part on screen and stays there, so the
   photo is centred in what the visitor sees, not in the whole scrolling
   height. 90vh is .modal's max-height; 3rem is the section's padding. */
.modal-gallery {
    position: sticky;
    top: 1.5rem;
    align-self: flex-start;
    width: 100%;
    height: 100%;
    max-height: calc(90vh - 3rem);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-image-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.gallery-image-wrapper img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--r-md);
    animation: gallerySlideLeft 0.25s ease;
}

.gallery-image-wrapper img.slide-right {
    animation: gallerySlideRight 0.25s ease;
}

@keyframes gallerySlideLeft {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes gallerySlideRight {
    from { opacity: 0; transform: translateX(-40px); }
    to   { opacity: 1; transform: translateX(0); }
}

.gallery-image-wrapper .placeholder-icon {
    width: 120px;
    height: 120px;
    color: var(--line-strong);
    opacity: 0.4;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 5;
    padding: 0;
}

.gallery-nav svg {
    width: 20px;
    height: 20px;
}

.gallery-nav:hover {
    background: var(--gold-deep);
    border-color: var(--gold);
    color: var(--gold);
}

.gallery-prev { left: 10px; }
.gallery-next { right: 10px; }

.gallery-nav.visible {
    display: flex;
}

.gallery-counter {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.65);
    color: var(--text-2);
    font-family: var(--font-data);
    font-size: var(--fs-label);
    padding: 3px 8px;
    border-radius: var(--r-pill);
    display: none;
    z-index: 5;
}

.gallery-counter.visible {
    display: block;
}

.gallery-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 6px;
    z-index: 5;
}

.gallery-dots.visible {
    display: flex;
}

.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: var(--transition);
}

.gallery-dot:hover {
    background: rgba(255, 255, 255, 0.5);
}

.gallery-dot.active {
    background: var(--gold);
    box-shadow: 0 0 6px rgba(201, 168, 76, 0.5);
}

.modal-details {
    padding: 2rem;
    overflow-y: auto;
}

.modal-badges-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.modal-badge {
    font-size: var(--fs-xs);
}

.modal-badge.filter-link,
.modal-game.filter-link,
.modal-series.filter-link {
    cursor: pointer;
}

.badge-accent.filter-link:hover {
    background: rgba(201, 168, 76, 0.28);
}

.badge-plain.filter-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}

.modal-game.filter-link:hover,
.modal-game[href]:hover,
.modal-series.filter-link:hover,
.modal-series[href]:hover {
    text-decoration: underline;
}

/* Share/copy-link button — circular sibling of .modal-close, sits to its left */
.modal-copy-link {
    position: absolute;
    top: 1rem;
    right: calc(1rem + 36px + 0.5rem);
    z-index: 10;
}

.modal-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

/* Game / Series / Reading order: a label column as wide as the longest
   label, so every value starts at the same x. The series row and reading
   order lines are display: contents wrappers, so their label and value
   cells land straight in this grid. */
.modal-meta {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 1rem;
    row-gap: 0.4rem;
    align-items: baseline;
    margin-bottom: 1rem;
    font-size: var(--fs-md);
}

.modal-meta-label {
    font-size: var(--fs-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-3);
}

.modal-meta-value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
    min-width: 0;
}

.modal-game {
    color: var(--gold);
    font-weight: 600;
    text-decoration: none;
}

.modal-year {
    font-family: var(--font-data);
    color: var(--text-3);
}

/* Series row — only present for items that belong to a comic/manga series */
.modal-series-row {
    display: contents;
}

.modal-series-row[hidden] {
    display: none;
}

.modal-series {
    color: var(--gold);
    font-weight: 600;
    text-decoration: none;
}

.modal-series-count {
    font-family: var(--font-data);
    font-size: var(--fs-sm);
    color: var(--text-3);
}

/* Reading order line(s), under the series row (js/reading.js) */
.modal-reading-order,
.modal-reading-line {
    display: contents;
}

.modal-reading-order[hidden] {
    display: none;
}

/* "Next: …" / "Last book" gets its own line under the order name */
.modal-reading-next,
.modal-reading-last {
    flex-basis: 100%;
}

.modal-reading-name {
    color: var(--gold);
    font-weight: 600;
    text-decoration: none;
}

.modal-reading-next {
    color: var(--text-2);
    text-decoration: none;
}

.modal-reading-name:hover,
.modal-reading-next:hover {
    text-decoration: underline;
}

.modal-reading-next::after {
    content: ' \2192';
}

/* Hint under a collected edition's Read switch */
.modal-reading-collects {
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--text-3);
}

.modal-reading-last {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.modal-description {
    font-size: var(--fs-md);
    color: var(--text-2);
    line-height: 1.7;
    margin-bottom: 1rem;
}

.modal-contents-section {
    margin-bottom: 1rem;
}

.modal-contents-section .section-head {
    margin-bottom: var(--s2);
}

.modal-contents-section p {
    font-size: var(--fs-md);
    color: var(--text-2);
    line-height: 1.6;
}

/* "Read on Internet Archive" — only shown for items with a `read` URL
   (comics, graphic novels, manga that have a free scan on archive.org). */
.modal-read-link {
    margin-bottom: 1rem;
}

.modal-read-link .modal-read-external {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.modal-divider {
    height: 0;
    margin: var(--s5) 0 0;
}

.collection-heading {
    margin-bottom: var(--s4);
}

.collection-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.control-row label {
    font-size: var(--fs-md);
    color: var(--text-2);
    font-weight: 500;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

/* The checkbox covers the whole switch: clickable, and its focus shows */
.toggle-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: var(--focus);
    outline-offset: 2px;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--line);
    border: 1px solid var(--line-control);
    border-radius: var(--r-pill);
    transition: var(--transition);
    pointer-events: none;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 50%;
    margin-top: -8px;
    background: var(--text-2);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--gold);
    border-color: var(--gold);
}

.toggle-owned input:checked + .toggle-slider {
    background: var(--owned);
    border-color: var(--owned);
}

.toggle-wish input:checked + .toggle-slider {
    background: var(--wish);
    border-color: var(--wish);
}

.toggle-read input:checked + .toggle-slider {
    background: var(--read);
    border-color: var(--read);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: var(--surface-page);
}

/* Check: a round tick for ticking rows in a list (a game page's DLCs). The
   real checkbox covers it, like the switch's; colour variants by meaning */
.list-check {
    position: relative;
    display: block;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.list-check input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.list-check-mark {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border: 2px solid var(--line-strong);
    border-radius: 50%;
    color: transparent;
    transition: var(--transition);
    pointer-events: none;
}

.list-check-mark svg {
    width: 16px;
    height: 16px;
}

.list-check input:hover + .list-check-mark {
    border-color: var(--gold-deep);
}

.list-check input:focus-visible + .list-check-mark {
    outline: var(--focus);
    outline-offset: 2px;
}

.list-check input:checked + .list-check-mark {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--surface-page);
}

.list-check-read input:checked + .list-check-mark {
    background: var(--read);
    border-color: var(--read);
}

.modal-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--surface-bar);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: var(--transition);
}

.modal-select:focus {
    border-color: var(--gold);
}

/* Copies Control */
.copies-control {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
}

.copies-btn {
    width: 32px;
    height: 32px;
    background: var(--surface-bar);
    border: none;
    color: var(--text);
    font-size: var(--fs-base);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.copies-btn:hover {
    background: var(--gold-deep);
    color: var(--gold);
}

#modalCopies {
    width: 50px;
    text-align: center;
    background: var(--surface-page);
    border: none;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    color: var(--text);
    font-family: var(--font-data);
    font-size: var(--fs-md);
    padding: 0.35rem 0;
    -moz-appearance: textfield;
}

#modalCopies::-webkit-inner-spin-button,
#modalCopies::-webkit-outer-spin-button {
    -webkit-appearance: none;
}


#modalNotes {
    width: 100%;
    padding: 0.6rem;
    background: var(--surface-bar);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    resize: vertical;
    transition: var(--transition);
}

#modalNotes:focus {
    border-color: var(--gold);
}

#modalNotes::placeholder {
    color: var(--text-3);
}

.modal-price-input,
.modal-date-input {
    padding: 0.5rem 0.75rem;
    background: var(--surface-bar);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--font-data);
    font-size: var(--fs-md);
    transition: var(--transition);
    width: 140px;
}

.modal-price-input:focus,
.modal-date-input:focus {
    border-color: var(--gold);
}

.modal-date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

/* ---- Footer ---- */
.main-footer {
    background: var(--surface-bar);
    border-top: 1px solid var(--line);
    padding: 2rem;
    text-align: center;
}

.footer-inner {
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    z-index: 0;
    display: grid;
    justify-items: center;
    gap: var(--s4);
}

/* Faint Assassin's Creed emblem watermark behind the footer text.
   Same path as the favicon/header logo (var(--gold) #c9a84c). */
.footer-inner::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(180px, 22vw, 300px);
    aspect-ratio: 1 / 1;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 5 L30 55 L5 95 L25 95 L50 55 L75 95 L95 95 L70 55 Z' fill='%23c9a84c'/%3E%3C/svg%3E") center / contain no-repeat;
    opacity: 0.05;
    z-index: -1;
    pointer-events: none;
}

.footer-brand {
    color: var(--text-2);
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s2) var(--s5);
    font-size: var(--fs-md);
}

.footer-legal {
    max-width: 90ch;
    color: var(--text-3);
    font-size: var(--fs-xs);
    line-height: 1.7;
}

.footer-legal a {
    color: var(--gold);
}

.footer-meta {
    color: var(--text-3);
    font-family: var(--font-data);
    font-size: var(--fs-label);
}

/* ---- Share Button ---- */
/* ---- Share Modal ---- */
.share-modal {
    max-width: 480px;
}

.share-modal-content {
    padding: 2rem;
}

.share-preview {
    display: flex;
    gap: var(--s6);
    justify-content: center;
    padding: var(--s4);
    margin: var(--s4) 0;
    background: var(--surface-page);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.share-preview-stat {
    text-align: center;
}

.share-preview-stat .stat-number {
    font-size: var(--fs-xl);
}

.share-success {
    text-align: center;
    padding: 1rem 0;
}

.share-success p {
    margin-bottom: var(--s4);
    color: var(--owned-text);
    font-family: var(--font-display);
    font-size: var(--fs-lg);
}

.share-done {
    margin-top: 1rem;
}

.share-url-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.share-url-box input {
    flex: 1;
    min-width: 0;
    height: var(--h-md);
    padding: 0 var(--s3);
    background: var(--surface-page);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--gold);
    font-family: var(--font-data);
    font-size: var(--fs-sm);
}


#shareNameStatus {
    min-height: 1.2em;
}

.share-manage-name {
    text-align: center;
    font-size: var(--fs-base);
    color: var(--text-2);
    margin-bottom: 0.5rem;
}

.share-manage-name strong {
    color: var(--gold);
}

/* ---- Profile View ---- */
#profileView,
#leaderboardView {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
}

/* One centred column at the reading width of the legal pages */
#leaderboardView {
    max-width: calc(760px + 4rem);
}

/* ---- Reading Order View ---- */
/* Same width as the main grid (.main-content) */
#readingView {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
}

.reading-tabs {
    margin-bottom: var(--s5);
}

/* Game filter: a .chip-row (Components) */
.reading-games {
    margin-bottom: var(--s4);
}

.reading-game {
    flex-shrink: 0;
}

.reading-name {
    margin-bottom: var(--s2);
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
}

.reading-description {
    max-width: 75ch;
    color: var(--text-2);
    font-size: var(--fs-md);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.reading-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.reading-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 200px;
    flex: 0 1 280px;
}

.reading-progress .progress {
    flex: 1;
}

.reading-progress-text {
    font-size: var(--fs-sm);
}

/* Two columns where there's room, read left to right like the main grid */
.reading-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(520px, 100%), 1fr));
    gap: 0.5rem 1rem;
    container-type: inline-size;   /* game rows indent only in one column */
}

.reading-entry {
    display: grid;
    grid-template-columns: 2.5rem 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s4);
    padding: var(--s3) var(--s4);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    transition: var(--transition);
}

/* Read, or for a game row played: purple means "been through this story" */
.reading-entry.read,
.reading-entry-game.played {
    border-color: var(--read-edge);
}

.reading-num {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    color: var(--gold);
    text-align: center;
}

.reading-cover {
    width: 48px;
    height: 72px;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--surface-bar);
    cursor: pointer;
}

.reading-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.reading-info {
    min-width: 0;
}

.reading-title {
    display: block;
    max-width: 100%;
    padding: 0;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-base);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.reading-title:hover {
    color: var(--gold);
}

.reading-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-top: 0.3rem;
    font-size: var(--fs-sm);
    color: var(--text-3);
}

.reading-meta .primary {
    color: var(--text-2);
}

.reading-owned {
    color: var(--owned);
}

.reading-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: var(--fs-sm);
    color: var(--text-2);
}

.reading-sources {
    margin-top: 1.5rem;
    font-size: var(--fs-xs);
    color: var(--text-3);
    line-height: 1.6;
}

.reading-sources a {
    color: var(--text-2);
}

.reading-section {
    margin: 1.75rem 0 0.75rem;
}

/* Era / release-year sections fold under their heading */
.reading-fold > summary {
    list-style: none;
    cursor: pointer;
}

.reading-fold > summary::-webkit-details-marker {
    display: none;
}

.reading-fold > summary:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

.reading-fold .reading-section > span:first-child::before {
    content: '';
    display: inline-block;
    width: 0.45em;
    height: 0.45em;
    margin: 0 0.75em 0.15em 0.1em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
}

.reading-fold[open] .reading-section > span:first-child::before {
    transform: rotate(45deg);
}

/* Folded sections stack closer, as a compact list of eras (not a
   character's family tree, a section among the page's others) */
.reading-fold:not(.ftree-section) > summary .reading-section {
    margin-top: 1.25rem;
}

.reading-fold:not([open]) > summary .reading-section {
    margin-bottom: 0;
}

.reading-fold > summary:hover .reading-section {
    border-bottom-color: var(--gold-deep);
}

.reading-list-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

.reading-fold-all {
    margin: 0 0 0.5rem auto;
    font-size: var(--fs-md);
}

.reading-up-next {
    margin-bottom: 0.5rem;
}

.reading-entry.flash,
.game-dlc.flash {
    animation: reading-flash 1.6s ease;
}

/* Games among the books: a compact marker row, indented to start under the
   book covers like the Games tab's DLC rows, with a gold kind line on top,
   no number, and a Played switch where a book has Read. The gold stripe is
   a background, not a box-shadow, so the flash doesn't hide it */
.reading-entry-game {
    grid-template-columns: 48px minmax(0, 1fr) auto;   /* a book cover's width */
    gap: var(--s3);
    margin-left: calc(2.5rem + var(--s4));
    padding: var(--s2) var(--s4) var(--s2) var(--s3);
    background: linear-gradient(var(--gold), var(--gold)) left / 3px 100% no-repeat, var(--surface-card);
}

/* Two columns (2 × 520px + the 1rem gap): the row is a cell beside a book,
   where an indent means nothing, so it starts flush */
@container (min-width: 1056px) {
    .reading-entry-game {
        margin-left: 0;
    }
}

.reading-entry-game .game-kind {
    display: block;
    margin-bottom: 2px;
}

.reading-entry-game .reading-title {
    font-size: var(--fs-md);
}

.reading-entry-game .reading-cover {
    width: 48px;
}

/* Box art is wider than a book cover: keep its shape so the logo isn't cut */
.reading-entry-game .reading-game-cover {
    height: auto;
    aspect-ratio: 3 / 4;
}

.reading-game-cover svg {
    width: 22px;
    height: 22px;
}

.reading-game-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

a.reading-title {
    text-decoration: none;
}

.reading-game-label {
    color: var(--gold);
}

.reading-switch {
    margin-bottom: 0.5rem;
}

/* ---- DLC covers without art of their own (js/utils.js dlcCoverHTML) ----
   The game's box art, blurred and darkened, under the gold controller icon:
   every DLC has art, and it reads as part of its game. The art is scaled up
   a little so the blur's soft edge stays outside the box */
.cover-ph {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--surface-bar);
    color: var(--gold);
}

.cover-ph img.cover-ph-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(1.5px) brightness(0.42) saturate(0.85);
    transform: scale(1.1);
}

.cover-ph svg {
    position: relative;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

/* ---- DLC cards (a game's page, js/games-view.js) ---- */
.game-dlc-group + .game-dlc-group {
    margin-top: var(--s5);
}

.game-dlc-group .label {
    display: block;
    margin-bottom: var(--s2);
}

.game-dlc-list {
    list-style: none;
    display: grid;
    gap: var(--s3);
}

/* A card: the cover across the top, then the Played tick beside the name
   and facts. The tick comes first in the markup, so it is still the first
   thing in the card for a keyboard or screen reader */
.game-dlc {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-areas:
        "cover cover"
        "check body";
    align-items: start;
    align-content: start;
    gap: var(--s2);
    padding: var(--s2);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.game-dlc.played {
    border-color: var(--read-edge);
}

.game-dlc .list-check {
    grid-area: check;
}

.game-dlc .game-dlc-cover {
    grid-area: cover;
    width: 100%;
}

.game-dlc .game-dlc-cover svg {
    width: 40px;
    height: 40px;
}

.game-dlc .cover-ph img.cover-ph-art {
    filter: blur(3px) brightness(0.4) saturate(0.85);
}

.game-dlc .game-dlc-body {
    grid-area: body;
}

/* Small cover, or the controller icon for DLCs without one (also the game
   rows on a character's page) */
.game-dlc-cover {
    display: grid;
    place-items: center;
    width: 36px;
    aspect-ratio: 3 / 4;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--gold-tint-2);
    color: var(--gold);
}

.game-dlc-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-dlc-cover svg {
    width: 20px;
    height: 20px;
}

.game-dlc-body {
    display: block;
    min-width: 0;
}

.game-dlc-name {
    color: var(--text);
    font-size: var(--fs-md);
    font-weight: 600;
}

.game-dlc .game-dlc-name {
    display: block;
    line-height: 1.3;
}

/* The facts stack, one to a line: the card is narrow */
.game-dlc .reading-meta {
    flex-direction: column;
    gap: 0;
    margin-top: var(--s1);
    font-size: var(--fs-xs);
    line-height: 1.45;
}

.game-dlc-episodes {
    display: flex;
    flex-direction: column;
    margin-top: var(--s1);
    color: var(--text-2);
    font-size: var(--fs-xs);
    line-height: 1.45;
}

.game-dlc-date {
    color: var(--text-3);
}

@keyframes reading-flash {
    0%, 40% { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-glow); }
    100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0); }
}

/* ---- Games View (js/games-view.js) ---- */
#gamesView {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
}

.games-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2) var(--s3);
    margin-bottom: var(--s3);
}

.games-search {
    flex: 0 1 320px;
    min-width: min(240px, 100%);
}

.games-kinds {
    margin-bottom: var(--s5);
}

/* The kind line on cards and timeline rows, like an item card's game line */
.game-kind {
    color: var(--gold);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

/* No cover yet: the controller icon on a gold tint */
.game-nocover {
    display: grid;
    place-items: center;
    background: var(--gold-tint-2);
    color: var(--gold);
}

/* Release order: box art cards */
.games-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: var(--s5);
}

.game-tile {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.game-tile:hover {
    transform: translateY(-3px);
    border-color: var(--gold-deep);
    box-shadow: var(--glow-card);
    background: var(--surface-card-hover);
}

/* Played (purple, like read): the edge, plus a "Played" badge in the card */
.game-tile.played,
.games-tl-card.played,
.games-tl-dlc.played {
    border-color: var(--read-edge);
}

.game-tile.played:hover,
.games-tl-card.played:hover,
.games-tl-dlc.played:hover {
    border-color: var(--read);
}

/* overflow: hidden keeps the 3:4 box when a cover's own shape is taller */
.game-tile-cover {
    display: block;
    aspect-ratio: 3 / 4;   /* box art */
    overflow: hidden;
    background: var(--surface-bar);
}

.game-tile-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-tile-cover.game-nocover svg {
    width: 40%;
    height: auto;
}

.game-tile-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--s1);
    min-width: 0;
    padding: var(--s3) var(--s4) var(--s4);
}

/* Three lines: every name starts "Assassin's Creed", and the words that tell
   games apart ("Black Flag Resynced") come last */
.game-tile-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-base);
    font-weight: 600;
    line-height: 1.3;
}

.game-tile-meta {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.game-tile-foot {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1) var(--s2);
    margin-top: auto;
    padding-top: var(--s2);
}

/* Story order: a year rail with game cards and dashed DLC rows. The rail
   sits halfway between the year column and the cards. */
.games-tl-list {
    --tl-year: 96px;
    --tl-gap: var(--s6);
    position: relative;
    list-style: none;
    display: grid;
    gap: var(--s3);
    max-width: 1100px;
}

.games-tl-list::before {
    content: '';
    position: absolute;
    top: var(--s2);
    bottom: var(--s2);
    left: calc(var(--tl-year) + var(--tl-gap) / 2 - 1px);
    width: 2px;
    background: var(--line);
}

.games-tl-row {
    position: relative;
    display: grid;
    grid-template-columns: var(--tl-year) minmax(0, 1fr);
    column-gap: var(--tl-gap);
    align-items: start;
}

.games-tl-year {
    padding-top: var(--s3);
    color: var(--gold);
    font-family: var(--font-data);
    font-size: var(--fs-sm);
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.games-tl-dot {
    position: absolute;
    top: calc(var(--s3) + var(--s1));
    left: calc(var(--tl-year) + var(--tl-gap) / 2 - 6px);
    width: 12px;
    height: 12px;
    border: 2px solid var(--gold);
    border-radius: 50%;
    background: var(--surface-page);
}

.games-tl-dot-dlc {
    left: calc(var(--tl-year) + var(--tl-gap) / 2 - 4px);
    width: 8px;
    height: 8px;
    border-color: var(--gold-deep);
}

.games-tl-card {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--s4);
    padding: var(--s3) var(--s4) var(--s3) var(--s3);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.games-tl-card:hover {
    border-color: var(--gold-deep);
    background: var(--surface-card-hover);
}

.games-tl-cover {
    display: block;
    width: 88px;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: var(--r-sm);
    background: var(--surface-bar);
}

.games-tl-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.games-tl-cover.game-nocover svg {
    width: 36px;
    height: 36px;
}

.games-tl-body {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    min-width: 0;
}

.games-tl-title {
    margin: 0;
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 600;
    line-height: 1.3;
}

.games-tl-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--s4);
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.games-tl-note {
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.games-tl-dlcs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1) var(--s2);
    margin-top: var(--s1);
}

/* A long DLC name is cut off rather than widening a narrow card */
.games-tl-dlcs .badge {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 20px;
}

.games-tl-counts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--s1);
    color: var(--text-3);
    font-size: var(--fs-sm);
    white-space: nowrap;
}

.games-tl-counts b {
    color: var(--text-2);
    font-family: var(--font-data);
    font-weight: 600;
}

/* A DLC with its own place in the lore: a gold stripe like the game markers
   in Complete Lore, indented under the rail */
.games-tl-dlc {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;   /* under the game cards' 88px */
    align-items: center;
    gap: var(--s3);
    margin-left: var(--s5);
    padding: var(--s2) var(--s4) var(--s2) var(--s3);
    background: linear-gradient(var(--gold), var(--gold)) left / 3px 100% no-repeat, var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.games-tl-dlc:hover {
    border-color: var(--gold);
}

.games-tl-dlc .game-dlc-cover {
    width: 100%;
}

.games-tl-dlc .game-dlc-cover svg {
    width: 26px;
    height: 26px;
}

.games-tl-dlc-name {
    color: var(--text);
    font-size: var(--fs-md);
    font-weight: 600;
}

/* A game's page: the character page's header card (.character-head) with
   the box art in the portrait's place, then its characters (the character
   page's compact rows), its DLCs and its items */
.game-head-cover {
    display: block;
    grid-row: span 5;   /* facts, description, links, Played, owned bar */
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: var(--r-md);
}

.game-head-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-head-cover.game-nocover svg {
    width: 40%;
    height: auto;
}

/* A game page's Played row: the switch, the date they finished it (while
   played) and how many of its DLCs are played */
.game-played {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s3) var(--s5);
    margin-top: var(--s4);
    color: var(--text-2);
    font-size: var(--fs-md);
}

.game-played .toggle-label {
    width: auto;
    gap: var(--s3);
}

.game-played-date {
    display: flex;
    align-items: center;
    gap: var(--s2);
}

.game-played-date label {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.game-played-dlcs {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.game-played-dlcs .progress-count {
    color: var(--text-2);
}

/* The Games tab's "N / M played" bar, above the cards (as wide as a
   header card's owned bar) */
.games-progress {
    max-width: 420px;
    margin-bottom: var(--s4);
}

/* A header card's links (a game's or a character's page): Complete Lore,
   the collection */
.head-card-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2) var(--s5);
    margin-top: var(--s4);
    font-size: var(--fs-md);
}

/* A header card's share button (A.headShareHTML): the round icon button in
   the card's top right corner, where the item window has its own, level
   with the badge. First in the card's markup, so Tab reaches it before the
   links below. */
.head-card-share {
    position: absolute;
    top: var(--s4);
    right: var(--s4);
}

/* The cast: a character page's game rows, with a portrait in the cover's place */
.game-character {
    grid-template-columns: 48px minmax(0, 1fr);
}

/* "Show all N characters" folds a long cast on phones only */
.game-cast-more {
    display: none;
}

/* The DLC cards: as many 180px columns as fit, so a release date stays on
   one line (150px on phones, for two columns) */
.game-dlcs .game-dlc-list {
    grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
    gap: var(--s4) var(--s3);
}

@media (max-width: 768px) {
    .game-dlcs .game-dlc-list {
        grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
    }
}

@media (max-width: 768px) {
    #gamesView {
        padding: 1rem 1rem 3rem;
    }

    .games-search {
        flex: 1 1 100%;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
        gap: var(--s3);
    }

    .game-tile-body {
        padding: var(--s2) var(--s3) var(--s3);
    }

    .game-tile-title {
        font-size: var(--fs-md);
    }

    .games-tl-list {
        --tl-year: 56px;
        --tl-gap: var(--s4);
    }

    .games-tl-card {
        grid-template-columns: 64px minmax(0, 1fr);
        gap: var(--s3);
    }

    .games-tl-cover {
        width: 64px;
    }

    /* The counts move under the text */
    .games-tl-counts {
        grid-column: 2;
        flex-direction: row;
        gap: var(--s3);
    }

    /* The game cards' covers are 64px here: the DLC rows' stay smaller */
    .games-tl-dlc {
        grid-template-columns: 48px minmax(0, 1fr) auto;
        margin-left: 0;
    }
}

/* ---- Characters View (js/characters-view.js) ---- */
/* The list and a character's page share the wide container: the page
   ends in a grid of item cards */
#charactersView {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
}

/* Faction chips, then game chips: two .chip-rows read as one filter */
.characters-groups {
    margin-bottom: var(--s3);
}

.characters-games {
    margin-bottom: var(--s5);
}

/* No portraits yet: text cards, the whole card one link */
.character-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: var(--s4);
}

.character-card {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    height: 100%;
    padding: var(--s4);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.character-card:hover {
    transform: translateY(-3px);
    border-color: var(--gold-deep);
    box-shadow: var(--glow-card);
    background: var(--surface-card-hover);
}

/* Portrait beside the name; the description and pills run full width below */
.character-card-top {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: start;
    gap: var(--s3);
}

.character-card-id {
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    min-width: 0;
}

/* Head-and-shoulders portrait, 3:4 (300x400 WebP in images/characters/) */
.character-portrait {
    display: block;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: var(--r-sm);
    background: var(--surface-bar);
}

.character-portrait img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* No portrait yet: the emblem on a gold tint, like an item card without a photo */
.character-portrait-none {
    display: grid;
    place-items: center;
    background: var(--gold-tint-2);
    color: var(--gold-deep);
}

.character-portrait-none svg {
    width: 45%;
    height: auto;
}

.character-card-name {
    margin: 0;
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 600;
    line-height: 1.3;
}

.character-card-meta {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.character-card-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: var(--s1);
    color: var(--text-2);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

/* A character's page: header card (portrait; badge, facts, description, owned) */
.character-head {
    position: relative;   /* the corner share button (.head-card-share) */
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    align-content: start;
    column-gap: var(--s5);
    max-width: 760px;
    padding: var(--s5);
    margin-bottom: var(--s5);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

/* The portrait spans the facts, description, links and owned bar beside
   it; on phones the description, links and bar run full width below it */
.character-head-portrait {
    grid-row: span 4;
}

.character-head .modal-meta {
    margin-bottom: var(--s3);
}

/* "Templar · Historical figure" is wider than the facts column at 360px:
   let it wrap rather than run out of the card */
.character-head .modal-badge {
    height: auto;
    min-height: 20px;
    padding-block: 2px;
    line-height: 16px;
    white-space: normal;
}

/* The badge shares its line with the corner share button (.head-card-share)
   and stops short of it. A character with no side has an empty row: hidden
   here, and on phones it keeps the facts below the button. */
.character-head .modal-badges-row {
    padding-right: calc(var(--s6) + var(--s1));
}

.character-head .modal-badges-row:empty {
    display: none;
}

.character-description {
    max-width: 75ch;
    margin: 0;
    color: var(--text-2);
    line-height: 1.6;
}

.character-progress {
    display: flex;
    align-items: center;
    gap: var(--s3);
    max-width: 420px;
    margin-top: var(--s4);
}

.character-progress .progress {
    flex: 1;
}

.character-progress-label {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

/* The games they appear in (and a game's characters): compact rows like a
   game page's DLCs */
.character-games {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: var(--s3);
}

.character-game {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: start;
    gap: var(--s3);
    height: 100%;
    padding: var(--s2) var(--s3);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.character-game:hover {
    border-color: var(--gold-deep);
    background: var(--surface-card-hover);
}

.character-game .game-kind,
.character-game .game-dlc-name {
    display: block;
}

.character-none {
    color: var(--text-2);
}

/* Item modal: "Characters" links, comma separated */
.modal-characters-row {
    display: contents;
}

.modal-characters-row .modal-reading-name:not(:last-child)::after {
    content: ',';
}

/* A character page's Family row: "Arbaaz Mir (father), Pyara Kaur
   (mother)"; each relative is one item of the wrapping .modal-meta-value */
.character-relative:not(:last-child)::after {
    content: ',';
}

.character-relation {
    color: var(--text-3);
}

@media (max-width: 768px) {
    #charactersView {
        padding: 1rem 1rem 3rem;
    }

    .character-head {
        grid-template-columns: 96px minmax(0, 1fr);
        column-gap: var(--s4);
        padding: var(--s4);
    }

    /* The card's padding is smaller here: the share button moves with it,
       so it stays level with the badge */
    .head-card-share {
        top: var(--s2);
        right: var(--s2);
    }

    .character-head .modal-badges-row:empty {
        display: flex;
        min-height: var(--s5);
    }

    .character-head-portrait {
        grid-row: auto;
        margin-bottom: var(--s3);
    }

    .character-head .character-description,
    .character-head .character-progress,
    .character-head .head-card-links {
        grid-column: 1 / -1;
    }

    /* The facts are long (platforms, re-releases): they run full width
       under the cover */
    .game-head {
        grid-template-columns: minmax(0, 1fr);
    }

    .game-head-cover {
        grid-row: auto;
        width: 96px;
        margin-bottom: var(--s3);
    }

    .game-cast.is-folded > li:nth-child(n + 7) {
        display: none;
    }

    .game-cast.is-folded + .game-cast-more {
        display: inline-flex;
        margin-top: var(--s3);
    }
}

/* ---- Family tree (a character's page, js/family-tree.js) ----
   The people are a list of links placed by the script, over one SVG of
   lines. The script works out the places from its own sizes (it has to,
   to draw the lines); the look is here. The section folds under its
   heading with Reading Order's .reading-fold. */
/* As wide as its tree, never narrower than the header card above it */
.ftree-panel {
    width: fit-content;
    min-width: min(760px, 100%);
    max-width: 100%;
    padding: var(--s5);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow-x: auto;   /* a safety net: the tree is sized to fit */
}

.ftree {
    position: relative;
    margin: 0 auto;
}

.ftree-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

/* Solid: parent and child, and a couple. Line widths and dashes are in
   the drawing's own px, like the script's sizes. */
.ftree-line,
.ftree-ring {
    fill: none;
    stroke: var(--line-control);
    stroke-width: 1.5;
    stroke-linejoin: round;
}

/* Dashed: many generations between */
.ftree-line.is-far {
    stroke-dasharray: 6 5;
}

/* Dotted: adopted */
.ftree-line.is-adopted {
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 0.1 5;
}

.ftree-people {
    list-style: none;
}

.ftree-person {
    position: absolute;
}

.ftree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text);
    text-align: center;
    text-decoration: none;
    border-radius: var(--r-sm);
}

.ftree-portrait {
    width: var(--ft-pw);
    margin-bottom: var(--s1);
    border: 1px solid var(--line-strong);
    transition: var(--transition);
}

/* Wraps inside its cell; one word longer than the cell (Ratonhnhaké:ton)
   stays whole and overhangs evenly on both sides */
.ftree-name {
    max-width: 100%;
    min-width: min-content;
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.25;
    transition: var(--transition);
}

.ftree-born {
    color: var(--text-3);
    font-size: var(--fs-xs);
    line-height: 1.3;
}

/* The three smallest sizes (a big tree, or a phone) */
.ftree.is-small .ftree-name {
    font-size: var(--fs-xs);
}

.ftree.is-small .ftree-born {
    font-size: var(--fs-label);
}

a.ftree-node:hover .ftree-portrait {
    border-color: var(--gold-deep);
}

a.ftree-node:hover .ftree-name {
    color: var(--gold);
}

/* The character whose page this is: selected, so gold, and not a link */
.ftree-node.is-current .ftree-portrait {
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.ftree-node.is-current .ftree-name {
    color: var(--gold);
}

.ftree-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s2) var(--s5);
    margin-top: var(--s5);
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.ftree-legend span {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
}

.ftree-key {
    flex: none;
    width: 28px;
    height: 8px;
}

.ftree-key-ring {
    width: 8px;
}

@media (max-width: 768px) {
    .ftree-panel {
        padding: var(--s3) var(--s2);
    }
}

/* ---- By Series (list of series, and a series page's extra links) ---- */
.series-progress .progress {
    width: 100%;
}

/* Series page: breadcrumb, header card, pager */
.reading-crumbs {
    margin-bottom: var(--s4);
}

.series-head {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: var(--s5);
    padding: var(--s5);
    margin-bottom: var(--s5);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

.series-head-cover {
    display: block;
    aspect-ratio: 2 / 3;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--surface-bar);
}

.series-head-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.series-head-body {
    display: grid;
    align-content: start;
    gap: var(--s2);
    min-width: 0;
}

.series-head-title {
    color: var(--text);
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    line-height: 1.2;
}

.series-head-meta {
    color: var(--text-2);
    font-size: var(--fs-sm);
}

/* "Collected in": the reprints the list leaves out */
.series-head-editions {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--s2);
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.series-head-editions ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1) var(--s4);
    min-width: 0;
    list-style: none;
}

.series-head-editions .link {
    text-align: left;
}

.series-head .reading-progress {
    max-width: 340px;
    margin-top: var(--s1);
}

.series-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2) var(--s4);
    margin-top: var(--s2);
    font-size: var(--fs-sm);
}

.series-head-actions .reading-up-next {
    margin-bottom: 0;
}

.series-pager {
    display: flex;
    justify-content: space-between;
    gap: var(--s4);
    margin-top: var(--s5);
    padding-top: var(--s4);
    border-top: 1px solid var(--line);
    font-size: var(--fs-md);
}

/* Moving between the series list and a series page (and the character
   list and a character's page) */
.reading-page-enter,
.characters-page-enter {
    animation: readingPageEnter var(--t) ease-out;
}

@keyframes readingPageEnter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.series-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr));
    gap: 0.5rem 1rem;
}

.series-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) minmax(90px, 140px);
    align-items: center;
    gap: var(--s4);
    padding: var(--s3) var(--s4);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.series-row:hover {
    border-color: var(--gold-deep);
    background: var(--surface-card-hover);
}

.series-row.done {
    border-color: var(--read-edge);
}

.series-cover {
    display: block;
    width: 40px;
    height: 60px;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--surface-bar);
}

.series-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.series-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.series-name {
    overflow: hidden;
    color: var(--text);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.series-row:hover .series-name {
    color: var(--gold);
}

.series-meta {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.series-progress {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}

@media (max-width: 768px) {
    #readingView {
        padding: 1rem 1rem 3rem;
    }

    .reading-entry {
        grid-template-columns: 2rem 40px 1fr auto;
        gap: 0.6rem;
        padding: 0.6rem 0.75rem;
    }

    .series-row {
        grid-template-columns: 34px 1fr 76px;
        gap: 0.6rem;
        padding: 0.5rem 0.75rem;
    }

    .series-cover {
        width: 34px;
        height: 51px;
    }

    .reading-num {
        font-size: 0.95rem;
    }

    .reading-cover {
        width: 40px;
        height: 60px;
    }

    .reading-entry-game {
        grid-template-columns: 40px minmax(0, 1fr) auto;   /* a book cover's width here */
        margin-left: calc(2rem + 0.6rem);
        padding: var(--s2) 0.75rem var(--s2) var(--s3);
    }

    .reading-entry-game .reading-cover {
        width: 40px;
    }

    .reading-toggle-text {
        display: none;
    }

    .reading-progress {
        flex: 1 1 100%;
    }

    .timeline-inner {
        flex-wrap: nowrap;
        padding-inline: 1rem;
    }
}

.profile-header {
    padding-bottom: var(--s4);
    border-bottom: 1px solid var(--line);
}

.profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1) var(--s5);
    font-size: var(--fs-md);
    color: var(--text-2);
}

.profile-stat {
    color: var(--gold);
    font-family: var(--font-data);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---- Leaderboard ----
   One card per collector at every width, as in the design mockup: rank;
   name and update date; items, % and a progress bar. One column (the view
   is capped and centred, see #leaderboardView); the whole card opens the
   profile. */
.leaderboard-list {
    display: grid;
    gap: var(--s2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.lb-card {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto auto;
    grid-template-areas:
        "rank name count pct"
        "rank date bar bar";
    align-items: center;
    gap: 2px var(--s3);
    padding: var(--s3) var(--s4);
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.lb-card:hover {
    border-color: var(--gold-deep);
    background: var(--surface-card-hover);
}

.lb-card .medal {
    grid-area: rank;
}

.lb-name {
    grid-area: name;
    min-width: 0;
    overflow: hidden;
    color: var(--gold);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-date {
    grid-area: date;
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.lb-count,
.lb-pct {
    font-family: var(--font-data);
    font-size: var(--fs-sm);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.lb-count {
    grid-area: count;
    color: var(--text-2);
}

.lb-pct {
    grid-area: pct;
    color: var(--text);
}

.lb-bar {
    grid-area: bar;
    width: 140px;
    justify-self: end;
}

.medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-3);
    font-family: var(--font-data);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.medal.gold { background: rgba(255, 215, 0, 0.14); color: #ffd700; }
.medal.silver { background: rgba(192, 192, 192, 0.14); color: #c0c0c0; }
.medal.bronze { background: rgba(205, 127, 50, 0.16); color: #d98c45; }

/* In a line of text (the collection's top collectors) */
.medal-sm {
    width: 20px;
    height: 20px;
    font-size: var(--fs-label);
}

.leaderboard-cta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: -0.5rem 0 1.25rem;
    color: var(--text-3);
    font-size: var(--fs-md);
}

/* "Loading...", "No collectors yet" and errors: plain text across the list */
.leaderboard-loading {
    grid-column: 1 / -1;
    padding: var(--s7) var(--s4);
    color: var(--text-2);
    text-align: center;
}

@media (max-width: 600px) {
    .lb-card {
        padding: var(--s3);
    }

    .lb-bar {
        width: 84px;
    }

    /* Page titles fit on one line */
    .page-title {
        font-size: var(--fs-xl);
    }
}

/* ---- Back to Top ---- */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 42px;
    height: 42px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    z-index: 100;
    box-shadow: var(--shadow-pop);
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ---- Animations ---- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.item-card {
    animation: fadeInUp 0.4s ease backwards;
}

/* Stagger animation for first 20 visible items */
.item-card:nth-child(1) { animation-delay: 0.02s; }
.item-card:nth-child(2) { animation-delay: 0.04s; }
.item-card:nth-child(3) { animation-delay: 0.06s; }
.item-card:nth-child(4) { animation-delay: 0.08s; }
.item-card:nth-child(5) { animation-delay: 0.10s; }
.item-card:nth-child(6) { animation-delay: 0.12s; }
.item-card:nth-child(7) { animation-delay: 0.14s; }
.item-card:nth-child(8) { animation-delay: 0.16s; }
.item-card:nth-child(9) { animation-delay: 0.18s; }
.item-card:nth-child(10) { animation-delay: 0.20s; }
.item-card:nth-child(11) { animation-delay: 0.22s; }
.item-card:nth-child(12) { animation-delay: 0.24s; }

/* ---- Responsive ---- */
/* With the logo subtitle, the header's row is 1574px of page when "Publish
   collection" and the account button both show (1590 of window with a
   classic scrollbar). Below that it would break onto two rows, so the
   subtitle goes. A breakpoint of the header's own, because its content
   sets it: re-measure if the nav gains a link or a button gets longer. */
@media (max-width: 1600px) {
    .logo-subtitle {
        display: none;
    }
}

/* Mid-width: the collection toolbar may no longer fit on one line: the
   search shares its row with the layout toggle, and the filters get a row
   of their own (phones do the same, behind "Filters") */
@media (max-width: 1520px) {
    .filter-group {
        order: 5;
        flex-basis: 100%;
    }
}

/* Narrower: tabs move to their own full-width row under the logo. Like the
   subtitle's, the width is where logo, nav, meter, "Publish collection" and
   the account button stop fitting on one row (1341px of page). It was 1180,
   where only a published collector's header fitted. */
@media (max-width: 1360px) {
    .header-inner {
        flex-wrap: wrap;
        row-gap: 0.5rem;
        padding-right: 0;
    }

    /* Five links don't fit a phone: the row scrolls sideways inside itself
       (like a chip row) and setActiveNav() keeps the current one in view */
    .main-nav {
        order: 3;
        width: 100%;
        margin: 0;
        gap: 0;
        border-top: 1px solid var(--line);
        padding-top: 0.25rem;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .main-nav-link {
        flex: 1;
        justify-content: center;
        padding: 0.55rem 0.25rem;
    }

    .main-nav-link.active::after {
        left: 20%;
        right: 20%;
    }
}

@media (max-width: 1024px) {
    .modal-content {
        grid-template-columns: 1fr !important;
    }
    .modal.landscape {
        max-width: 980px;
    }
    .modal-image-section {
        min-height: 250px;
        border-radius: var(--r-xl) var(--r-xl) 0 0;
    }
    /* One column: the photo scrolls away with the rest */
    .modal-gallery {
        position: relative;
        top: auto;
        max-height: none;
    }
    /* Single-column layout puts the gallery under the floating share/close
       buttons — move the image counter to the opposite corner. */
    .gallery-counter {
        right: auto;
        left: 10px;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: 0.75rem 1rem;
    }

    /* Rows: logo + meter, then the action buttons, then the tabs */
    .header-stats {
        display: contents;
    }

    .progress-meter {
        margin-left: auto;
        min-width: 150px;
    }

    .collection-actions {
        order: 2;
        position: relative;
        width: 100%;
        justify-content: center;
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        gap: 0.3rem;
    }

    /* Menu centred under the button row, so it never runs off-screen */
    .account-control {
        position: static;
    }

    .account-menu {
        left: 50%;
        right: auto;
        width: min(280px, calc(100vw - 2rem));
        transform: translateX(-50%);
    }

    .main-nav-link {
        font-size: var(--fs-label);
        letter-spacing: 1px;
    }

    .toolbar {
        padding: 0.75rem 1rem;
        top: auto;
        position: relative;
    }

    /* Search on top, then Filters + layout; the filters open below */
    .toolbar-inner {
        flex-wrap: wrap;
        gap: var(--s2);
    }

    .filters-toggle {
        display: inline-flex;
        flex: 1;
    }

    .toolbar:not(.filters-open) .filter-group {
        display: none;
    }

    .toolbar.filters-open .filters-toggle {
        border-color: var(--gold-deep);
        color: var(--gold);
    }

    .search-container {
        min-width: 100%;
    }

    .filter-group {
        order: 5;
        width: 100%;
        flex-direction: column;
    }

    .multi-select {
        width: 100%;
        max-width: none;
    }

    .multi-select-dropdown {
        width: 100%;
    }

    .multi-select-options {
        max-height: 220px;
    }

    .filter-select {
        width: 100%;
    }

    .form-row-group {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 1rem;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }

    .modal {
        margin: 1rem;
        max-height: 95vh;
    }

    .modal-overlay {
        padding: 0;
    }

    .items-grid.list-view .item-card {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .items-grid.list-view .card-image {
        display: contents;
    }

    .items-grid.list-view .card-image img,
    .items-grid.list-view .card-image .placeholder-icon {
        width: 56px;
        height: 56px;
    }

    .items-grid.list-view .card-badges {
        flex-basis: 100%;
        margin: calc(-1 * var(--s1)) 0 var(--s3) calc(56px + var(--s3) + var(--s4));
    }

    /* Rows stack on phones, so the id stays at the end of the game line */
    .items-grid.list-view .card-game-row {
        align-self: stretch;
        margin-bottom: 0;
    }

    /* Keep the id clear of the NEW sticker in the row's top-right corner */
    .items-grid.list-view .badge-new ~ .card-body .card-game-row {
        padding-right: var(--s7);
    }

    .items-grid.list-view .card-body {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--s1);
    }
}

@media (max-width: 768px) {
    .series-head {
        grid-template-columns: 64px minmax(0, 1fr);
        gap: var(--s4);
        padding: var(--s4);
    }
}

.add-modal-content {
    padding: 2rem;
}

.add-modal-title {
    margin-bottom: var(--s1);
    padding-right: 2.5rem;   /* clear of the close button */
    color: var(--gold);
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 700;
    line-height: 1.25;
}

.add-modal-subtitle {
    margin-bottom: var(--s5);
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-row label {
    color: var(--text-3);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row textarea,
.form-row select {
    min-height: var(--h-md);
    padding: 0.5rem var(--s3);
    background: var(--surface-page);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    transition: var(--transition);
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
    border-color: var(--gold);
}

.form-row textarea {
    resize: vertical;
}

.form-row select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 2rem;
}

.form-row-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-hint {
    color: var(--text-3);
    font-size: var(--fs-xs);
}


.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--s3);
    margin-top: var(--s2);
    padding-top: var(--s4);
    border-top: 1px solid var(--line);
}

.form-actions .btn-danger {
    margin-right: auto;
}

@media (max-width: 480px) {
    .logo-text h1 {
        font-size: 1.4rem;
    }

    .logo-area {
        gap: 0.6rem;
    }

    .ac-symbol {
        width: 40px;
        height: 40px;
    }

    .progress-meter {
        min-width: 0;
    }

    .main-nav-link {
        font-size: var(--fs-label);
        letter-spacing: 0.5px;
    }

    .stat-number {
        font-size: var(--fs-lg);
    }

    .items-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 400px) {
    /* Four tabs don't fit as "Reading Order"; its aria-label keeps the name */
    .nav-long {
        display: none;
    }

    .progress-meter {
        padding: 0.35rem 0.3rem;
    }

    .progress-meter-count {
        font-size: 0.9rem;
    }

    .progress-meter-label {
        letter-spacing: 1px;
    }

    .progress-meter-pct {
        font-size: var(--fs-xs);
    }
}

/* ---- Accounts & Sync (auth.js, sync.js) ---- */
.account-control {
    position: relative;
}

.account-btn .account-chevron {
    width: 12px;
    height: 12px;
    margin-left: -0.1rem;
    opacity: 0.7;
}

.account-btn[aria-expanded="true"] .account-chevron {
    transform: rotate(180deg);
}

.account-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.account-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold-deep);
    color: var(--gold);
    font-family: var(--font-data);
    font-size: var(--fs-label);
    font-weight: 700;
}

.sync-dot {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid var(--surface-page);
    background: var(--text-3);
}

.sync-dot.is-synced { background: var(--owned); }
.sync-dot.is-syncing { background: var(--gold); animation: sync-pulse 1s ease-in-out infinite; }
.sync-dot.is-pending { background: var(--cond-good); }
.sync-dot.is-error { background: var(--danger); }

@keyframes sync-pulse {
    50% { opacity: 0.3; }
}

.account-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    padding: var(--s1) 0;
    background: var(--surface-bar);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    z-index: 200;
}

.account-menu-email {
    padding: 0.5rem 0.9rem 0.15rem;
    color: var(--text);
    font-size: var(--fs-md);
    font-weight: 600;
    word-break: break-all;
}

.account-menu-status {
    padding: 0 0.9rem 0.5rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid var(--line);
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.account-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 36px;
    padding: 0 var(--s4);
    background: none;
    border: none;
    color: var(--text-2);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.account-menu-item:hover {
    background: var(--surface-card-hover);
    color: var(--gold);
}

.account-menu-item:focus-visible {
    outline-offset: -2px;
}

.account-menu-signin {
    padding: 0.5rem 0.9rem 0.6rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.account-menu-signin .google-signin-btn {
    width: 100%;
    justify-content: center;
}

.account-menu-hint {
    margin-top: 0.4rem;
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.account-menu-sep {
    height: 1px;
    margin: 0.3rem 0;
    background: var(--line);
}

.account-menu-item.danger {
    margin-top: var(--s1);
    border-top: 1px solid var(--line);
    color: var(--danger-text);
}

.account-menu-item.danger:hover {
    background: var(--danger-solid);
    color: #fff;
}

.sync-banner {
    padding: var(--s3) 2rem;
    background: linear-gradient(90deg, var(--gold-tint-2), rgba(201, 168, 76, 0.04));
    border-bottom: 1px solid var(--gold-deep);
}

.sync-banner-inner {
    max-width: calc(1600px - 4rem);   /* lines up with the content: see .header-inner */
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.sync-banner-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    color: var(--gold);
}

.sync-banner p {
    flex: 1;
    margin: 0;
    color: var(--text);
    font-size: var(--fs-md);
}

/* Google's dark-theme "Sign in with Google" button (branding guidelines) */
.google-signin-btn {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 12px;
    background: #131314;
    border: 1px solid #8E918F;
    border-radius: 20px;
    color: #E3E3E3;
    font-family: Roboto, Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.google-signin-btn:hover {
    background: #1f1f20;
}

.google-signin-btn .google-g {
    width: 20px;
    height: 20px;
}

.merge-question {
    margin-bottom: 0.75rem;
    color: var(--text-2);
    font-size: var(--fs-md);
}

.merge-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.merge-options button {
    width: 100%;
}

.merge-backup {
    margin-top: 1rem;
    text-align: center;
}

@media (max-width: 768px) {
    .sync-banner {
        padding: 0.6rem 1rem;
    }

    .sync-banner-inner {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .sync-banner p {
        flex: 1 1 calc(100% - 70px);
        font-size: var(--fs-md);
    }

    .sync-banner-close {
        order: 2;
    }

    .google-signin-btn {
        order: 3;
        margin-left: calc(22px + 0.6rem);
    }
}

@media (max-width: 480px) {
    .google-signin-btn {
        flex: 1;
        justify-content: center;
        margin-left: 0;
    }
}

.share-auto-note,
.share-signin-hint {
    margin: 0.25rem 0 0.5rem;
    text-align: center;
}

/* ---- Privacy page ---- */
.logo-text .logo-title {
    display: block;
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 4px;
    text-transform: uppercase;
    line-height: 1;
}

.legal-page {
    position: relative;
    max-width: 760px;
    margin: 0 auto;
    padding: 2.5rem 2rem 3rem;
    color: var(--text-2);
    line-height: 1.7;
}

.legal-page h1 {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    color: var(--gold);
    margin-bottom: 0.25rem;
}

.legal-page h2 {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    color: var(--text);
    margin: 2rem 0 0.5rem;
    scroll-margin-top: 6rem;   /* a link to a section (privacy.html#search) lands below the sticky header */
}

.legal-page p,
.legal-page li {
    font-size: 0.95rem;
}

.legal-page p {
    margin-bottom: 0.75rem;
}

.legal-page ul {
    margin: 0 0 0.75rem 1.25rem;
}

.legal-page li {
    margin-bottom: 0.35rem;
}

.legal-page strong {
    color: var(--text);
}

.legal-page a {
    color: var(--gold);
}

.legal-updated {
    color: var(--text-3);
    font-size: var(--fs-sm) !important;
}

@media (max-width: 768px) {
    .legal-page {
        padding: 1.5rem 1rem 2rem;
    }
}

/* ---- Print: the inventory (account menu → Print inventory) ----
   Filled by printInventory() in collection.js. The print rules apply only
   while <body> has .printing-inventory, so printing any other page of the
   site is unchanged. Dark on white, the one place the site is; sizes are
   in pt and mm: paper. */
.print-inventory {
    display: none;
}

@media print {
    body.printing-inventory > *:not(.print-inventory) {
        display: none !important;
    }

    body.printing-inventory {
        min-height: 0;
        background: var(--print-paper);
        color: var(--print-ink);
    }

    body.printing-inventory .print-inventory {
        display: block;
        page: inventory;
        font-family: var(--font-body);
        font-size: 9pt;
        line-height: 1.35;
    }

    .print-title {
        font-family: var(--font-display);
        font-size: 16pt;
        font-weight: 700;
        line-height: 1.2;
    }

    .print-meta {
        margin-top: 1mm;
        font-size: 8pt;
    }

    .print-summary {
        margin: 3mm 0 5mm;
        font-size: 10pt;
        font-weight: 600;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
    }

    /* The header row repeats on every page; a row never splits */
    .print-table thead {
        display: table-header-group;
    }

    .print-table tr {
        break-inside: avoid;
    }

    .print-table th,
    .print-table td {
        padding: 1.5mm 2mm 1.5mm 0;
        text-align: left;
        vertical-align: middle;
        overflow-wrap: anywhere;
    }

    .print-table th:last-child,
    .print-table td:last-child {
        padding-right: 0;
    }

    .print-table th {
        border-bottom: 0.75pt solid var(--print-ink);
        font-size: 7pt;
        font-weight: 700;
        letter-spacing: var(--tracking-label);
        text-transform: uppercase;
    }

    .print-table td {
        border-bottom: 0.5pt solid var(--print-line);
    }

    .print-table .print-figure {
        text-align: right;
    }

    .print-table td.print-figure {
        font-family: var(--font-data);
        font-size: 8pt;
        font-variant-numeric: tabular-nums;
    }

    .print-col-photo {
        width: 13mm;
    }

    .print-col-condition {
        width: 19mm;
    }

    .print-col-box {
        width: 9mm;
    }

    .print-col-copies {
        width: 14mm;
    }

    .print-col-paid {
        width: 24mm;
    }

    .print-col-acquired {
        width: 22mm;
    }


    .print-table img {
        display: block;
        width: 10mm;
        height: 13mm;
        object-fit: cover;
    }

    .print-name {
        display: block;
        font-weight: 600;
    }

    .print-sub {
        display: block;
        font-size: 7.5pt;
    }
}

@page inventory {
    margin: 15mm;
}
