:root {
    /* Light neutral-paper identity — not a "mode." The product's register is a
       curated paper catalog: warm near-black ink, Honey as the one warm signal,
       rarity by hue + gem + label. The bg is true-neutral (chroma 0) by design:
       a warm-yellow tint would land in the cream/sand band (OKLCH L 0.84–0.97,
       chroma < 0.06, hue 40–100), the AI-slop default. Warmth lives in accent,
       ink, and type — never the surface. */
    --bg: #f7f7f6;
    --bg-soft: #efeee8;
    --panel: var(--bg-soft);
    --panel-solid: #e8e7e1;
    --border: rgba(26, 23, 20, 0.10);
    --border-strong: rgba(26, 23, 20, 0.18);
    --text: #1a1714;
    --muted: #6b665e;
    --accent: #f0a868;            /* Honey — FILL only (1.87:1 as text on bg) */
    --accent-2: #d88a4a;          /* Honey hover fill */
    --accent-soft: rgba(240, 168, 104, 0.12);
    --accent-warm-deep: #955622;  /* Honey-as-text / borders / focus (5.43:1) */
    --shadow: 0 1px 2px rgba(26, 23, 20, 0.06);
    --shadow-card: 0 1px 3px rgba(26, 23, 20, 0.08);
    --radius-lg: 12px;
    --radius-md: 8px;
    --font-display: "Bricolage Grotesque", sans-serif;
    --font-mono: "Spline Sans Mono", monospace;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);

    /* Spacing (page rhythm). Component-internal micro-spacing stays literal. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Type scale — consolidates ~18 ad-hoc sizes onto one modular ladder. */
    --text-2xs: 0.62rem;
    --text-xs: 0.7rem;
    --text-sm: 0.78rem;
    --text-md: 0.82rem;
    --text-base: 0.9rem;
    --text-lg: 1.02rem;
    --text-xl: clamp(1rem, 2vw, 1.2rem);
    --text-2xl: clamp(2.2rem, 6vw, 3.75rem);

    /* Radii — soft rounded chrome (~10px) over crisp card objects (~5px).
       Not stadium pills (999px); the soft-chrome / crisp-card contrast is the
       system — objects you handle stay rectangular, the chrome is friendlier. */
    --radius-button: 10px;
    --radius-card: 5px;

    /* Motion — durations + easings reused across components. */
    --t-fast: 0.15s;
    --t-med: 0.2s;
    --t-slow: 0.25s;
    --t-flip: 0.7s;
    --t-tear: 0.35s;   /* pack-wrapper tear on open */
    --t-deal: 0.5s;    /* dealt-card entrance out of the torn pack */
    --ease-out: ease;
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-flip: cubic-bezier(0.25, 0.85, 0.3, 1);
    --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);  /* premium deceleration for the Panini motion */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

    /* Dark ink on Honey fills (primary buttons, active chips, toast action). */
    --text-on-accent: #241608;

    /* Pack accent = Honey everywhere; the thinkers violet override is retired. */
    --pack-accent: var(--accent);
    --pack-accent-2: var(--accent-2);

    /* Rarity ladder + Panini finish. The tier is carried by hue + gem + label AND
       by an earned foil/glow finish: common is matte (foil, no glow), rare/epic
       take a tier-colored foil + frame glow, legendary adds a holographic sheen.
       -2 stays the text-safe mate. */
    --rarity-common: #9a948a;
    --rarity-common-2: #6b665e;
    --rarity-rare: #2f5d9e;
    --rarity-rare-2: #2f5d9e;
    --rarity-epic: #7a4cc0;
    --rarity-epic-2: #5f3aa0;
    --rarity-legendary: #b8821a;
    --rarity-legendary-2: #8a5e10;

    /* Metallic foil per tier — the revealed card's base material + Collect bar.
       Overdrive pass: 5–6 stops with specular ridges so the metal reads as struck
       foil rather than a flat tint, while staying inside each tier's hue. */
    --foil-common: linear-gradient(135deg, #ece9e3 0%, #c4bfb4 28%, #b6b1a7 50%, #d4cfc5 70%, #dedacf 100%);
    --foil-rare: linear-gradient(135deg, #82a8de 0%, #4a78bf 28%, #2f5d9e 50%, #4a78bf 72%, #82a8de 100%);
    --foil-epic: linear-gradient(135deg, #b99be6 0%, #9569d6 28%, #7a4cc0 50%, #9569d6 72%, #b99be6 100%);
    --foil-legendary: linear-gradient(135deg, #fbe7b4 0%, #f3d788 22%, #d29a25 48%, #b8821a 58%, #e8c262 78%, #9b6c14 100%);

    /* Diagonal specular sheen layered over every foil so the surface catches light.
       Kept white-on-tint (not a gradient-TEXT) — it is a material highlight, never type. */
    --foil-sheen: linear-gradient(115deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 68%, rgba(255, 255, 255, 0.20) 100%);

    /* Rarity frame glow on the revealed card (common = none, base stays matte). */
    --glow-rare: 0 0 12px rgba(47, 93, 158, 0.45);
    --glow-epic: 0 0 14px rgba(122, 76, 192, 0.5);
    --glow-legendary: 0 0 18px rgba(184, 130, 26, 0.6), 0 0 36px rgba(184, 130, 26, 0.22);

    /* Legendary-only moving holo sheen — a wider spectral band chased across the
       photo so the rainbow reads as a true holo chase, not a single soft band. */
    --holo-legendary: linear-gradient(110deg,
        rgba(255, 90, 90, 0) 8%,
        rgba(255, 90, 90, 0.42) 18%,
        rgba(255, 170, 90, 0.5) 27%,
        rgba(255, 230, 96, 0.55) 36%,
        rgba(120, 255, 150, 0.55) 46%,
        rgba(96, 180, 255, 0.55) 56%,
        rgba(200, 120, 255, 0.5) 66%,
        rgba(200, 120, 255, 0) 82%);

    /* Foil pack-wrapper gradients by tier — Standard matte → Lucky silver/blue → Mythic gold. */
    --pack-foil-standard: linear-gradient(158deg, #efeee8 0%, #e2dfd6 52%, #d6d2c9 100%);
    --pack-foil-hourly: linear-gradient(158deg, #f7e3c8 0%, #eecf9d 46%, #d9ae62 72%, #f4e0bd 100%);
    --pack-foil-daily: linear-gradient(158deg, #e3d3f8 0%, #b085ea 46%, #6a3fa8 72%, #d0b4f2 100%);
    /* Lucky: silver-blue steel. The 158deg run ends dark on purpose — the
       tile's white text is bottom-aligned, so the last stops must hold ≥4.5:1. */
    --pack-foil-lucky: linear-gradient(158deg, #c9ccd4 0%, #8b94a4 40%, #586376 66%, #47505f 100%);
    /* Mythic: same text-safety rule as Lucky — gold foil, but the bottom
       stops (where the name and odds line sit) stay dark gold. */
    --pack-foil-mythic: linear-gradient(158deg, #f4d98e 0%, #c9962f 40%, #8a5e10 64%, #6e4a0c 100%);
    --foil-pack-back: linear-gradient(155deg, #f0a868 0%, #d88a4a 48%, #955622 100%);

    /* Height reserved for the card's bottom Collect bar (the body placard sits above it). */
    --card-collect-h: 46px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 16px;
}

body {
    font-family: var(--font-display);
    color: var(--text);
    background: var(--bg);
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
    /* ponytail: guard so a lone fixed-width control (sort menu, search field) can't force phone horizontal scroll */
    overflow-x: hidden;
}

button,
input,
select {
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

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

/* Skip link — off-screen until keyboard-focused, then slides into view. */
.skip-link {
    position: absolute;
    left: var(--space-2);
    top: var(--space-2);
    z-index: 100;
    transform: translateY(-200%);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-button);
    background: var(--accent);
    color: var(--text-on-accent);
    font-weight: 700;
    text-decoration: none;
    transition: transform var(--t-med) var(--ease-out);
}

.skip-link:focus-visible {
    transform: translateY(0);
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 3px;
}

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

/* --- Footer contact --- */

.app-footer {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 0 0 28px;
}

.app-footer-line {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.app-footer-mail {
    color: inherit;
    font-weight: 600;
    text-underline-offset: 3px;
}

/* --- Hero & panels --- */

.hero,
.panel {
    background: var(--panel);
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "copy"
        "showcase"
        "facts";
    gap: var(--space-5);
    padding: 30px;
    border-radius: var(--radius-lg);
    margin-bottom: 22px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}

.hero-copy { grid-area: copy; }
.hero-showcase { grid-area: showcase; }
.hero-facts { grid-area: facts; }

/* Wide screens: copy on the left, the fanned-card showcase on the right, with
   the facts row spanning full width beneath. */
@media (min-width: 880px) {
    .hero {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
        grid-template-areas:
            "copy showcase"
            "facts facts";
        align-items: center;
    }
}

.eyebrow {
    margin: 0 0 10px;
    font-size: var(--text-sm);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
}

.hero h1,
.panel-head h2 {
    margin: 0;
    line-height: 1.2;
    color: var(--text);
}

.hero h1 {
    max-width: 18ch;
    font-size: var(--text-2xl);
    font-weight: 800;
    letter-spacing: -0.025em;
}

.hero-text,
.panel-copy {
    color: var(--muted);
    line-height: 1.6;
}

.hero-text {
    max-width: 60ch;
    font-size: var(--text-lg);
    font-weight: 300;
}

/* --- App shell: topbar + view tabs ------------------------------------- */

/* One page, three views (packs / collection / influence). The sticky topbar
   keeps the segmented tabs reachable from any scroll depth; it sits below the
   drawers (80), toast (60), and skip link (100) in the z-index scale. */
.app-topbar {
    position: sticky;
    top: var(--safe-top);
    z-index: 20;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.app-topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: var(--space-3) 0;
}

.app-wordmark {
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.view-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: var(--bg-soft);
}

.view-tab {
    border: 1px solid transparent;
    border-radius: calc(var(--radius-button) - 3px);
    background: transparent;
    color: var(--text);
    padding: 6px 14px;
    min-height: 34px;
    font-size: var(--text-md);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out);
}

.view-tab:hover {
    background: rgba(26, 23, 20, 0.04);
}

.view-tab.is-active {
    background: var(--accent);
    color: var(--text-on-accent);
    font-weight: 700;
}

.view-tab:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 2px;
}

/* Account chip: Google sign-in offer for guests, email + sign out once
   linked. Quiet secondary-button vocabulary so it never competes with tabs. */
.account-btn {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: var(--bg-soft);
    color: var(--text);
    padding: 6px 14px;
    min-height: 34px;
    font-size: var(--text-md);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out);
}

/* Google avatar inside the signed-in account chip. Inline-block keeps the
   button's nowrap/ellipsis behavior intact on narrow screens. */
.account-avatar {
    display: inline-block;
    width: 22px;
    height: 22px;
    margin-right: 8px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: -6px;
    background: var(--bg-soft);
}

.account-btn:hover {
    background: rgba(26, 23, 20, 0.04);
}

.account-btn:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .account-btn {
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* View panels swap in place; [hidden] must always beat the panel display. */
[data-view-panel][hidden] {
    display: none !important;
}

[data-view-panel]:focus {
    outline: none;
}

@media (max-width: 640px) {
    .app-topbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .app-wordmark {
        text-align: center;
    }

    .view-tabs {
        justify-content: stretch;
    }

    .view-tab {
        flex: 1 1 0;
        padding-inline: 8px;
        white-space: nowrap;
    }
}

/* --- Hero showcase: a fanned trio of sealed-tier cards --- */

/* The showcase is a decorative stage, not chrome — the handled-object vocabulary
   of the real pack cards. Each mini card carries its tier's foil + frame glow +
   gem, fanned across the stage. The Legendary card adds the prismatic holo
   gradient so it reads as the top-tier pull you're chasing. Purely ornamental:
   aria-hidden + pointer-events:none in the markup, and it holds still — the
   finish speaks, the stage doesn't dance. */
.hero-showcase {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    perspective: 1000px;
}

/* A sealed foil card: the tier's metal fill + rarity edge + bezel, the same
   layered frame as a real pulled card. Inherits --rarity/--foil/--glow per tier. */
.hero-card {
    --rarity: var(--rarity-common);
    --foil: var(--foil-common);
    --glow: none;

    position: relative;
    width: clamp(120px, 16vw, 168px);
    aspect-ratio: 300 / 430;
    border-radius: var(--radius-card);
    background: var(--foil);
    border: 2px solid var(--rarity);
    /* Same struck-metal bezel as .pack-card-front. */
    box-shadow:
        var(--glow),
        inset 0 0 0 1px rgba(255, 255, 255, 0.30),
        inset 0 0 0 4px rgba(26, 23, 20, 0.32),
        inset 0 0 0 5px rgba(255, 255, 255, 0.14),
        inset 0 2px 3px rgba(255, 255, 255, 0.25);
    overflow: hidden;
}

.hero-card-rare {
    --rarity: var(--rarity-rare);
    --foil: var(--foil-rare);
    --glow: var(--glow-rare);
}

.hero-card-epic {
    --rarity: var(--rarity-epic);
    --foil: var(--foil-epic);
    --glow: var(--glow-epic);
}

.hero-card-legendary {
    --rarity: var(--rarity-legendary);
    --foil: var(--foil-legendary);
    --glow: var(--glow-legendary);
}

/* Fan the three cards: outer two tilted back, Legendary front + center. The
   stage holds still — the foils, glows, and gems carry the tier story on their
   own, and an ornament that never stops moving is noise, not life. */
.hero-card-rare {
    margin-right: -34px;
    transform: rotate(-12deg) translateY(10px);
    z-index: 1;
}

.hero-card-epic {
    margin-right: -34px;
    transform: rotate(0deg) translateY(-4px);
    z-index: 2;
}

.hero-card-legendary {
    transform: rotate(12deg) translateY(0);
    z-index: 3;
}

/* The "?" sealed-pack medallion + the tier gem sit on each card front. The
   medallion reuses the .pack-card-back::after vocabulary so it reads as a
   face-down pull. */
.hero-card::before {
    content: "?";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 14px rgba(255, 255, 255, 0.55);
    opacity: 0.92;
}

.hero-card::after {
    content: "";
    position: absolute;
    top: 10px;
    left: 10px;
    width: 13px;
    height: 13px;
    background: var(--rarity);
    box-shadow: 0 0 6px var(--rarity);
}

/* Gem shape escalates with the tier — same cheap, readable tell as real cards. */
.hero-card[data-rarity="rare"]::after {
    transform: rotate(45deg);
    border-radius: 2px;
}

.hero-card[data-rarity="epic"]::after {
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.hero-card[data-rarity="legendary"]::after {
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* Legendary holo finish on the showcase card — the same prismatic gradient as
   a real Legendary pull, held static (the moving sheen is earned by the reveal,
   not by sitting in the hero). The ::before is the "?" medallion, so the holo
   gradient rides its own element. */
.hero-card-legendary {
    isolation: isolate;
}

.hero-card-legendary::before {
    z-index: 2;
}

.hero-card-legendary::after {
    z-index: 3;
}

.hero-card-holo {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: var(--holo-legendary);
    background-size: 300% 100%;
    mix-blend-mode: screen;
    opacity: 0.6;
    pointer-events: none;
}

/* --- Hero quick-facts row --- */

/* Honest mono-typeset stats, pulled from the economy constants. The dot
   separators match the cataloging layer's mono register. */
.hero-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.hero-facts-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hero-facts-item strong {
    color: var(--text);
    font-weight: 700;
}

.hero-facts-sep {
    color: var(--accent-warm-deep);
    opacity: 0.6;
}

.panel {
    padding: 24px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: var(--space-4);
    margin-bottom: 18px;
}

.panel-head h2 {
    font-size: var(--text-xl);
    font-weight: 700;
}

.panel-copy {
    max-width: 42ch;
    margin: 0;
    text-align: left;
}

/* Cataloging layer — Spline Sans Mono for numeric data + tracked tags. */
.eyebrow,
.rarity-legend-label,
.rarity-legend-threshold,
.pack-card-rarity-bar,
.pack-card-rarity-label,
.collection-card-rarity,
.pack-card-reach,
.collection-card-reach,
.coin-balance,
.pack-source-label,
.pack-card-link,
.collection-card-link,
.duplicates-stack-rarity,
.duplicates-stack-count,
.collection-sort-label,
.collection-sort-current,
.pack-card-back-label,
.pack-card-no-thumb,
.collection-card-no-thumb {
    font-family: var(--font-mono);
}

/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    min-height: 52px;
    padding: 14px 18px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    touch-action: manipulation;
    transition: transform var(--t-fast) var(--ease-out), opacity var(--t-med) var(--ease-out), background var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.btn:hover {
    transform: translateY(-1px);
    background: rgba(26, 23, 20, 0.04);
}

.btn:focus-visible,
.chip-button:focus-visible,
.pack-card:focus-visible,
.pack-card-collect:focus-visible,
.pack-card-link:focus-visible,
.collection-card-sell:focus-visible,
.collection-card-link:focus-visible,
.drawer-close:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 3px;
}

.btn:disabled {
    cursor: progress;
    opacity: 0.6;
    transform: none;
}

.btn-primary {
    background: var(--pack-accent);
    color: var(--text-on-accent);
    border-color: var(--pack-accent);
    font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
    background: var(--pack-accent-2);
    border-color: var(--pack-accent-2);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
}

.collection-card-sell {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border: 1px solid var(--accent-warm-deep);
    border-radius: var(--radius-button);
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-warm-deep);
    background: var(--accent-soft);
    min-height: 44px;
    cursor: pointer;
    transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.collection-card-sell:hover {
    background: var(--accent);
    color: var(--text-on-accent);
}

/* --- Pack tiles (click a pack to open it) --- */

.pack-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-bottom: 18px;
}

/* A pack tile reads as a sealed foil pack — a handled object, not chrome — with
   a perforated tear strip, a stacked-cards emblem, and a tier-earned foil that
   escalates Standard (matte) → Lucky (silver/blue glow) → Mythic (gold glow). */
.pack-tile {
    --tile-fg: var(--text);
    --tile-mut: var(--muted);
    --pack-glow: var(--shadow-card);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 4px;
    padding: 22px 18px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-card);
    background: var(--pack-foil-standard);
    color: var(--tile-fg);
    text-align: left;
    cursor: pointer;
    min-height: 184px;
    overflow: hidden;
    box-shadow: var(--pack-glow);
    transition: transform var(--t-fast) var(--ease-out), filter var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.pack-tile[data-pack-type="lucky"],
.pack-tile[data-pack-type="mythic"],
.pack-tile[data-pack-type="daily"] {
    --tile-fg: #fff;
    --tile-mut: rgba(255, 255, 255, 0.78);
}

/* Hourly: the free ritual pull — a warm Honey-tinted wrapper that reads as the
   same family as the paid tiers but clearly "yesterday's paper" once claimed. */
.pack-tile[data-pack-type="hourly"] {
    background: var(--pack-foil-hourly);
    --pack-glow: 0 0 14px rgba(240, 168, 104, 0.4);
}

/* Daily: the free premium pull — a violet arcane foil that signals it outranks
   the paid Lucky tier while staying distinct from the gold Mythic wrapper. */
.pack-tile[data-pack-type="daily"] {
    background: var(--pack-foil-daily);
    --pack-glow: 0 0 18px rgba(128, 82, 196, 0.55), 0 0 36px rgba(176, 133, 234, 0.25);
}

.pack-tile[data-pack-type="hourly"].is-claimed,
.pack-tile[data-pack-type="daily"].is-claimed {
    filter: grayscale(0.85);
    opacity: 0.62;
    cursor: not-allowed;
}

/* Cooldown clock on the claimed free tiles — same mono cost slot, tabular
   digits so the per-second tick doesn't shimmer. */
.pack-tile.is-claimed .pack-tile-cost {
    font-variant-numeric: tabular-nums;
}

.pack-tile[data-pack-type="lucky"] {
    background: var(--pack-foil-lucky);
    --pack-glow: 0 0 16px rgba(91, 102, 120, 0.45);
}

.pack-tile[data-pack-type="mythic"] {
    background: var(--pack-foil-mythic);
    background-size: 200% 200%;
    --pack-glow: 0 0 20px rgba(184, 130, 26, 0.6), 0 0 40px rgba(240, 216, 142, 0.25);
    animation: foil-drift 7s var(--ease-in-out) infinite alternate;
}

/* Hover sheen sweeps the foil — the wrapper's "pick me up" life. The ::after is
   owned by the loading spinner while a pack opens, so the sheen stays out of its
   way (and out of the disabled tiles). */
.pack-tile:not(.is-loading)::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 38%, rgba(255, 255, 255, 0.32) 50%, transparent 62%);
    transform: translateX(-120%);
    opacity: 0;
    pointer-events: none;
}

.pack-tile:hover:not(:disabled):not(.is-loading)::after {
    opacity: 1;
    animation: tile-sheen 0.7s var(--ease-out-quart);
}

@keyframes tile-sheen {
    from { transform: translateX(-120%); }
    to { transform: translateX(120%); }
}

/* Perforated tear strip near the top; currentColor adapts to the tier's text. */
.pack-tile::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 12px;
    right: 12px;
    border-top: 2px dashed currentColor;
    opacity: 0.4;
    pointer-events: none;
}

/* Stacked-cards emblem — three fanned mini cards signaling "contains cards". */
.pack-tile-emblem {
    position: absolute;
    top: 22px;
    right: 16px;
    width: 20px;
    height: 26px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(26, 23, 20, 0.3);
    border-radius: 2px;
    transform: rotate(8deg);
    transition: transform var(--t-med) var(--ease-out);
}

.pack-tile-emblem::before,
.pack-tile-emblem::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(26, 23, 20, 0.3);
    border-radius: 2px;
}

.pack-tile-emblem::before { transform: rotate(-6deg) translate(-3px, 1px); }
.pack-tile-emblem::after { transform: rotate(-14deg) translate(-6px, 2px); }

/* The stacked-cards emblem lifts and tilts when you hover the wrapper — the
   "cards inside" rustle as you reach for it. */
.pack-tile:hover:not(:disabled) .pack-tile-emblem {
    transform: rotate(11deg) translateY(-2px);
}

.pack-tile:hover:not(:disabled) {
    transform: translateY(-3px);
    filter: brightness(1.05);
    border-color: var(--accent-warm-deep);
}

.pack-tile:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 3px;
}

.pack-tile:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Subtle marker on the last-opened pack. */
.pack-tile.is-last {
    border-color: var(--accent-warm-deep);
}

/* Pack-open theatre — the foil wrapper "tears" the instant it's clicked: a quick
   brightness flash + pop. One-shot, tile-box level only (so it survives the
   is-loading content-hide during the fetch). Added/removed in JS; killed under
   reduced-motion. The shorthand overrides Mythic's ambient foil-drift for the
   ~0.35s tear, then drift resumes when the class leaves. */
.pack-tile.is-tearing {
    animation: pack-tear var(--t-tear) var(--ease-out-expo);
}

@keyframes pack-tear {
    0%   { transform: scale(1) translateY(0); filter: brightness(1); }
    35%  { transform: scale(1.035) translateY(-2px); filter: brightness(1.55); }
    100% { transform: scale(1) translateY(0); filter: brightness(1); }
}

.pack-tile-name {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--tile-fg);
}

.pack-tile-cost {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tile-fg);
    opacity: 0.9;
}

.pack-tile-odds {
    margin-top: 2px;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    line-height: 1.4;
    color: var(--tile-mut);
}

/* Honest odds disclosure — a quiet <details> under the pack tiles. Collapsed
   it's a small mono affordance in Honey-deep; opened, a hairline footnote panel
   that names the reach-weighting mechanic and admits the whiff case. Mirrors
   the sort <details>'s hairline + Honey-deep focus treatment. */
.pack-odds-details {
    margin: 0 0 var(--space-4) 0;
}

.pack-odds-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--accent-warm-deep);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.04em;
    cursor: pointer;
    list-style: none;
}

.pack-odds-summary::-webkit-details-marker {
    display: none;
}

.pack-odds-summary::after {
    content: "›";
    transform: rotate(90deg);
    transition: transform var(--t-fast) var(--ease-out);
}

.pack-odds-details[open] .pack-odds-summary::after {
    transform: rotate(-90deg);
}

.pack-odds-summary:hover {
    border-color: var(--accent-warm-deep);
}

.pack-odds-summary:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 3px;
}

.pack-odds-body {
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
    max-width: 72ch;
}

.pack-odds-body p {
    margin: 0;
    color: var(--text);
    font-size: var(--text-sm);
    line-height: 1.55;
}

.pack-odds-body p + p {
    margin-top: var(--space-2);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.chip-button {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--text);
    padding: 8px 14px;
    font-size: var(--text-md);
    font-weight: 500;
    cursor: pointer;
    min-height: 36px;
    transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out), transform var(--t-fast) var(--ease-out);
}

.chip-button:hover {
    border-color: var(--accent-warm-deep);
    transform: translateY(-1px);
}

.chip-button.is-active {
    background: var(--pack-accent);
    border-color: var(--pack-accent);
    color: var(--text-on-accent);
    font-weight: 700;
}

/* --- Rarity legend --- */

.rarity-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-bottom: 18px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
}

.rarity-legend-label {
    margin-right: 4px;
    font-size: var(--text-xs);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
}

.rarity-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    --rarity: var(--rarity-common);
    --rarity-2: var(--rarity-common-2);
}

.rarity-legend-item[data-rarity="rare"] { --rarity: var(--rarity-rare); --rarity-2: var(--rarity-rare-2); }
.rarity-legend-item[data-rarity="epic"] { --rarity: var(--rarity-epic); --rarity-2: var(--rarity-epic-2); }
.rarity-legend-item[data-rarity="legendary"] { --rarity: var(--rarity-legendary); --rarity-2: var(--rarity-legendary-2); }

.rarity-legend-gem {
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
    border-radius: 2px;
    background: var(--rarity);
    box-shadow: inset 0 0 0 1px rgba(26, 23, 20, 0.12);
    flex: none;
}

.rarity-legend-name {
    font-size: var(--text-sm);
    color: var(--text);
    font-weight: 500;
}

.rarity-legend-threshold {
    font-size: var(--text-xs);
    color: var(--rarity-2);
    font-weight: 600;
}

/* Reach = rarity bridge. Lives in the legend (always in the DOM) so touch users
   and screen readers can reach it, unlike the title-tooltip-only version. */
.rarity-legend-caption {
    flex-basis: 100%;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: var(--text-xs);
    line-height: 1.4;
}

/* --- Pack actions --- */

.pack-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: 20px;
}

/* Loading spinner on the pack tile clicked to open. The tile is disabled
   during open; this overrides the disabled dim and hides the tile's content
   (keeping its shape) so only the spinner shows. */
.pack-tile.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 1;
}

.pack-tile.is-loading > * {
    visibility: hidden;
}

/* Hide the tear strip too so the loading state shows only the spinner. */
.pack-tile.is-loading::before {
    opacity: 0;
}

.pack-tile.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(26, 23, 20, 0.28);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: pack-spinner 0.6s linear infinite;
}

@keyframes pack-spinner {
    to { transform: rotate(360deg); }
}

/* Legendary holo sheen — a rainbow band chased across the photo. */
@keyframes holo-shear {
    0% { background-position: 0% 0%; }
    100% { background-position: 300% 0%; }
}

.pack-source-label {
    margin: 0;
    color: var(--muted);
    font-size: var(--text-md);
    line-height: 1.4;
    flex: 1 1 100%;
}

/* --- Pack Card Grid --- */

.pack-cards {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(12px, 3vw, 24px);
    justify-content: center;
    min-height: 0;
    margin-bottom: 16px;
}

/* --- Individual Pack Card --- */

.pack-card {
    /*
      Rarity drives the color story. Each rarity re-binds --rarity / --rarity-2
      plus the Panini finish tokens --foil (base material), --glow (revealed
      frame glow), and --holo (Legendary-only sheen). Common is the matte
      default: foil, but no glow and no holo. --reveal-lift / --reveal-scale
      stage the rarity-earned "pop" when a card lands face-up.
    */
    --rarity: var(--rarity-common);
    --rarity-2: var(--rarity-common-2);
    --foil: var(--foil-common);
    --glow: none;
    --holo: none;
    --reveal-lift: 0px;
    --reveal-scale: 1;

    position: relative;
    isolation: isolate; /* aura (::before) + bloom (::after) layer behind/over the flip without leaking past siblings */
    width: clamp(210px, 60vw, 300px);
    aspect-ratio: 300 / 430;
    perspective: 1000px;
    cursor: pointer;
    border-radius: var(--radius-card);
    transition: transform var(--t-slow) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}

/* Dealt entrance when a fresh pack resolves (skipped for skeletons): the five
   cards deal out of the torn pack. Each starts at the clicked tile's position
   (--deal-x/--deal-y, set in JS on the grid and inherited here), fanned by a
   per-card --deal-fan, and settles face-down into its slot. Outer-card transform
   + opacity only, so it never fights the flip's 3D on the inner (.pack-card-inner). */
.pack-card:not(.is-skeleton) {
    animation: card-deal var(--t-deal) var(--ease-out-expo) backwards;
}

.pack-card:nth-child(1) { animation-delay: 0ms;   --deal-fan: -7deg; }
.pack-card:nth-child(2) { animation-delay: 70ms;  --deal-fan: -3deg; }
.pack-card:nth-child(3) { animation-delay: 140ms; --deal-fan: 0deg; }
.pack-card:nth-child(4) { animation-delay: 210ms; --deal-fan: 3deg; }
.pack-card:nth-child(5) { animation-delay: 280ms; --deal-fan: 7deg; }

@keyframes card-deal {
    from { opacity: 0; transform: translate(var(--deal-x, 0px), var(--deal-y, 0px)) rotate(var(--deal-fan, 0deg)) scale(0.82); }
    to { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
}

/* Gentle lift while a card is still face-down. */
.pack-card:not(.is-revealed):hover {
    transform: translateY(-4px);
}

/* Earned rarity glow — applied to the outer card so it reads reliably regardless
   of the 3D flip, and only once revealed (face-down stays unmarked). Common has
   --glow: none, so the base tier stays matte. The transform is the rarity-earned
   "pop" (lift + scale); animation:none cancels the entrance so this transition
   owns transform from the moment a card is flipped. */
.pack-card.is-revealed {
    /* Drop shadow joins the rarity glow so the card lifts off the page as it
       lands (the overdrive "weight settle"). Common has --glow:none but still
       earns the depth cue — a shadow is not a rarity finish. */
    box-shadow: var(--glow), 0 14px 22px rgba(26, 23, 20, 0.22);
    transform: translateY(var(--reveal-lift)) scale(var(--reveal-scale));
    animation: none;
}

/* Earned aura — a rarity halo that blooms up behind revealed Rare/Epic/Legendary
   cards. Painted on the outer (non-flipping) host so it sits steadily behind the
   flip; Common skips it (--glow is none, the base tier stays matte). Opacity/scale
   is animated (not box-shadow) so the pulse stays smooth. */
.pack-card::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: calc(var(--radius-card) + 6px);
    background: radial-gradient(closest-side, var(--rarity), transparent 72%);
    filter: blur(10px);
    opacity: 0;
    z-index: 0;
    pointer-events: none;
}

.pack-card[data-rarity="rare"].is-revealed::before,
.pack-card[data-rarity="epic"].is-revealed::before {
    animation: glow-pulse 3s var(--ease-in-out) infinite;
}

.pack-card[data-rarity="legendary"].is-revealed::before {
    animation: glow-pulse 2.4s var(--ease-in-out) infinite;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 0.28; transform: scale(0.96); }
    50% { opacity: 0.62; transform: scale(1.06); }
}

/* Legendary "pull" payoff — a one-shot light bloom that flashes over the card
   the instant it lands face-up, then fades. The earned moment for the top tier. */
.pack-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius-card);
    background: radial-gradient(closest-side, rgba(255, 255, 255, 0.9), transparent 60%);
    opacity: 0;
    z-index: 2;
    pointer-events: none;
}

.pack-card[data-rarity="legendary"].is-revealed::after {
    animation: legendary-bloom 0.9s var(--ease-out-expo) forwards;
    animation-delay: 0.18s;
}

@keyframes legendary-bloom {
    0% { opacity: 0; transform: scale(0.82); }
    25% { opacity: 0.85; }
    100% { opacity: 0; transform: scale(1.3); }
}

/* --glint-strength scales the one-shot reveal flash up the ladder so the apex
   tier lands brightest; --reveal-lift/--reveal-scale are the overdrive-escalated
   "pop" (still expo, no bounce). Common stays matte: no glow, no glint boost. */
.pack-card[data-rarity="rare"] {
    --rarity: var(--rarity-rare);
    --rarity-2: var(--rarity-rare-2);
    --foil: var(--foil-rare);
    --glow: var(--glow-rare);
    --reveal-lift: -5px;
    --reveal-scale: 1.015;
    --glint-strength: 0.42;
}

.pack-card[data-rarity="epic"] {
    --rarity: var(--rarity-epic);
    --rarity-2: var(--rarity-epic-2);
    --foil: var(--foil-epic);
    --glow: var(--glow-epic);
    --reveal-lift: -7px;
    --reveal-scale: 1.025;
    --glint-strength: 0.58;
}

.pack-card[data-rarity="legendary"] {
    --rarity: var(--rarity-legendary);
    --rarity-2: var(--rarity-legendary-2);
    --foil: var(--foil-legendary);
    --glow: var(--glow-legendary);
    --holo: var(--holo-legendary);
    --reveal-lift: -10px;
    --reveal-scale: 1.04;
    --glint-strength: 0.82;
}

.pack-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform var(--t-flip) var(--ease-flip);
    transform-style: preserve-3d;
    z-index: 1; /* sit above the aura (::before, z0); bloom (::after, z2) sits above this */
}

/* Subtle cascade when revealing cards in sequence — Reveal all only. The
   delay lives on .pack-cards.is-cascading so a manually flipped card answers
   immediately instead of lagging behind its own click. */
.pack-cards.is-cascading .pack-card:nth-child(2) .pack-card-inner { transition-delay: 70ms; }
.pack-cards.is-cascading .pack-card:nth-child(3) .pack-card-inner { transition-delay: 140ms; }
.pack-cards.is-cascading .pack-card:nth-child(4) .pack-card-inner { transition-delay: 210ms; }
.pack-cards.is-cascading .pack-card:nth-child(5) .pack-card-inner { transition-delay: 280ms; }

.pack-card.is-revealed .pack-card-inner {
    transform: rotateY(180deg);
}

.pack-card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Card Back (face-down) --- */

.pack-card-back {
    transform: translateZ(0); /* ponytail: promote to its own layer so iOS Safari honors backface-visibility after the flip */
    align-items: center;
    justify-content: center;
    /* Sealed-foil back: honey foil base + embossed diagonal lattice + a soft
       spotlight, so it reads as struck metal in the same vocabulary as the front. */
    background:
        radial-gradient(120% 90% at 50% 40%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 62%),
        var(--foil-sheen),
        repeating-linear-gradient(
            -45deg,
            rgba(255, 255, 255, 0.10) 0 1px,
            rgba(255, 255, 255, 0) 1px 9px
        ),
        repeating-linear-gradient(
            45deg,
            rgba(26, 23, 20, 0.09) 0 1px,
            rgba(26, 23, 20, 0) 1px 9px
        ),
        var(--foil-pack-back);
    border: 1px solid var(--accent-warm-deep);
    /* The front's layered metallic bezel: polished edge → dark recess →
       honey-deep inner ring. Face and back share one frame language. */
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.30),
        inset 0 0 0 4px rgba(26, 23, 20, 0.30),
        inset 0 0 0 5px var(--accent-warm-deep);
    color: #fff;
}

/* Medallion ring behind the "?" — a struck seal on the foil. */
.pack-card-back::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(84px, 46%, 112px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.62);
    box-shadow:
        inset 0 0 0 5px rgba(26, 23, 20, 0.14),
        inset 0 0 18px rgba(255, 255, 255, 0.22),
        0 0 0 6px rgba(26, 23, 20, 0.12);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* "?" medallion — a glowing foil mark on the sealed pack back. */
.pack-card-back::after {
    content: "?";
    position: relative;
    z-index: 1;
    font-size: 3.2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 14px rgba(255, 255, 255, 0.55);
    opacity: 0.92;
    transition: transform var(--t-med) var(--ease-out);
}

.pack-card:hover .pack-card-back::after {
    transform: scale(1.08);
}

/* iOS WebKit doesn't hide a face's pseudo-element via the host's
   backface-visibility (the property isn't inherited); set it on the pseudo
   itself so the "?" doesn't bleed through the flip. */
.pack-card-back::after {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.pack-card-back-label {
    position: absolute;
    bottom: 16px;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
    opacity: 0.9;
}

/* --- Card Front (revealed) --- */

.pack-card-front {
    transform: rotateY(180deg);
    /* Face-down cards keep the front out of the accessibility tree and
       hit-testing: backface-visibility hides paint, not focus or taps on the
       article link inside. The front becomes visible (and focusable) only on
       reveal, at flip start — backface-visibility still keeps it unpainted
       until the card has turned past 90deg. */
    visibility: hidden;
    /* Foil base + specular sheen layered together = struck-metal surface. */
    background: var(--foil), var(--foil-sheen);
    border: 2px solid var(--rarity);
    /* Layered metallic bezel: rarity edge → dark recess → rarity-tinted inner
       ring → polished-metal inner edge → soft top sheen. A struck metal frame. */
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.34),
        inset 0 0 0 4px rgba(26, 23, 20, 0.34),
        inset 0 0 0 5px var(--rarity),
        inset 0 0 0 6px rgba(255, 255, 255, 0.16),
        inset 0 2px 4px rgba(255, 255, 255, 0.30);
    cursor: default;
}

.pack-card.is-revealed .pack-card-front {
    visibility: visible;
}

/* Legendary-only holo sheen chased across the photo (other tiers skip this rule
   entirely — --holo is none elsewhere). Painted below the banner/placard text. */
.pack-card[data-rarity="legendary"] .pack-card-front::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: var(--holo-legendary);
    background-size: 300% 100%;
    mix-blend-mode: screen;
    opacity: 0.6;
    pointer-events: none;
    animation: holo-shear 5s linear infinite;
}

/* Reveal glare — a one-shot diagonal shine that sweeps the card as it lands
   face-up (the earned pack-pull moment). Same screen-blend pattern as the holo;
   clipped by the face's overflow; sits above the banner/placard for a beat. */
.pack-card-front::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 52%;
    background: linear-gradient(105deg, transparent 0%, rgba(255, 255, 255, 0.72) 50%, transparent 100%);
    transform: translateX(-180%) rotate(8deg);
    mix-blend-mode: screen;
    opacity: 0;
    z-index: 6;
    pointer-events: none;
}

.pack-card.is-revealed .pack-card-front::after {
    animation: card-glare 0.85s var(--ease-out-quart) forwards;
    animation-delay: 0.18s;
}

@keyframes card-glare {
    0% { transform: translateX(-180%) rotate(8deg); opacity: 0; }
    15% { opacity: 0.95; }
    100% { transform: translateX(340%) rotate(8deg); opacity: 0; }
}

/* Ambient foil life — the Legendary card's gold fill drifts slowly, a gentle
   shimmer (not the old conic spin). Mythic pack wrapper shares the drift. */
.pack-card[data-rarity="legendary"] .pack-card-front {
    background-size: 200% 200%;
    animation: foil-drift 7s var(--ease-in-out) infinite alternate;
}

@keyframes foil-drift {
    from { background-position: 0% 0%; }
    to { background-position: 100% 100%; }
}

/* --- Overdrive: tilt, reveal flash, sparkle particles, pull celebration ---
   Each piece is reveal-gated or tier-gated so it reads as earned motion, and
   every one collapses under prefers-reduced-motion (foil/glow/aura stay). */

/* Tilt wrapper between the host (perspective + reveal-pop) and the flipping
   inner. It inherits --tilt-x/--tilt-y — set on the host from JS (0 when idle,
   or under reduced-motion / coarse pointer) — so the tilt stays decoupled from
   both the reveal-pop transform on .pack-card and the rotateY flip on inner. */
.pack-card-tilt {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
    transform-style: preserve-3d;
    transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
    transition: transform 0.12s var(--ease-out-quart);
    will-change: transform;
}

/* One-shot reveal flash — a white radial bloom over the just-landed face,
   tier-scaled via --glint-strength (common dim → legendary bright). Sits above
   the photo/scrims; the glare sweep paints above it. */
.pack-card-glint {
    position: absolute;
    inset: 0;
    z-index: 4;
    border-radius: inherit;
    background: radial-gradient(closest-side, rgba(255, 255, 255, 0.9), transparent 62%);
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}

.pack-card.is-revealed .pack-card-glint {
    animation: glint-burst 0.55s var(--ease-out-expo) forwards;
    animation-delay: 0.22s;
}

@keyframes glint-burst {
    0%   { opacity: 0; transform: scale(0.6); }
    35%  { opacity: var(--glint-strength, 0.3); }
    100% { opacity: 0; transform: scale(1.3); }
}

/* Sparkle particles — spans spawned by JS on reveal, flung outward from the
   card center by per-spark --px/--py/--pr, removed on animationend. Clipped to
   the front face (overflow hidden) so the burst reads as contained energy.
   Legendary adds a few long-lived ambient twinkles after the one-shot burst. */
.pack-card-particles {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.pack-spark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    margin: -2.5px 0 0 -2.5px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, var(--rarity) 75%);
    box-shadow: 0 0 6px var(--rarity);
    opacity: 0;
    transform: translate(0, 0) scale(0.4);
    animation: particle-fly 0.7s var(--ease-out-quart) forwards;
}

.pack-spark--ambient {
    top: var(--ay, 50%);
    left: var(--ax, 50%);
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
    transform: translate(0, 0) scale(0.6);
    animation: sparkle-ambient 2.6s var(--ease-in-out) infinite;
}

@keyframes particle-fly {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.4); }
    18%  { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--px, 0px), var(--py, 0px)) scale(0.2) rotate(var(--pr, 0deg)); }
}

@keyframes sparkle-ambient {
    0%, 100% { opacity: 0; transform: scale(0.6); }
    50%      { opacity: 0.85; transform: scale(1); }
}

/* Pull celebration — a tier-hued bloom from the screen edges on an
   Epic/Legendary reveal (the earned "big pull" moment). The apex tier layers a
   prismatic flare sweep. Rare/Common earn no screen flash, preserving the
   ladder. Off-card (fixed), pointer-events:none, aria-hidden in markup. */
.pack-cards.is-punching {
    animation: grid-punch 0.6s var(--ease-out-expo);
}

@keyframes grid-punch {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.015); }
    100% { transform: scale(1); }
}

.pull-flash {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    --flash-hue: var(--rarity-legendary);
    background: radial-gradient(120% 120% at 50% 50%, transparent 52%, var(--flash-hue) 100%);
    mix-blend-mode: screen;
}

.pull-flash.is-flashing {
    animation: pull-flash 0.9s var(--ease-out-expo) forwards;
}

.pull-flash.is-legendary::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg,
        rgba(255, 90, 90, 0) 10%,
        rgba(255, 170, 90, 0.35) 26%,
        rgba(255, 230, 96, 0.4) 38%,
        rgba(120, 255, 150, 0.4) 50%,
        rgba(96, 180, 255, 0.4) 62%,
        rgba(200, 120, 255, 0.35) 74%,
        rgba(200, 120, 255, 0) 90%);
    mix-blend-mode: screen;
    opacity: 0;
}

.pull-flash.is-legendary.is-flashing::after {
    animation: prismatic-flare 0.9s var(--ease-out-expo) forwards;
}

@keyframes pull-flash {
    0%   { opacity: 0; }
    18%  { opacity: 0.55; }
    100% { opacity: 0; }
}

@keyframes prismatic-flare {
    0%   { opacity: 0; transform: translateX(-12%); }
    30%  { opacity: 0.9; }
    100% { opacity: 0; transform: translateX(12%); }
}

/* --- Card Art (full-bleed portrait) --- */

.pack-card-art {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: var(--foil);
    z-index: 1;
}

/* Vignette + spot gloss over the portrait — the standard Panini photo finish.
   Sits beneath the text scrim (::after), which still carries overlay contrast. */
.pack-card-art::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        radial-gradient(120% 90% at 50% 30%, transparent 55%, rgba(26, 23, 20, 0.34) 100%),
        linear-gradient(115deg, rgba(255, 255, 255, 0.22) 0%, transparent 28%, transparent 72%, rgba(255, 255, 255, 0.12) 100%);
    pointer-events: none;
}

.pack-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 22%;
    display: block;
}

.pack-card-no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.10em;
}

/* Shade the top and bottom bands so overlay text clears AA contrast over any
   photo; the middle portrait stays bright. */
.pack-card-art::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(26, 23, 20, 0.55) 0%, rgba(26, 23, 20, 0) 22%, rgba(26, 23, 20, 0) 66%, rgba(26, 23, 20, 0.80) 100%);
    pointer-events: none;
}

/* --- Top banner overlay: gem + reach "rating" + rarity label, over the photo --- */

.pack-card-rarity-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(26, 23, 20, 0.5), rgba(26, 23, 20, 0));
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Jeweled gem — a flat rarity hue read as a cut jewel: an internal radial facet
   + specular highlight, an inner gleam, and the outer rarity halo. The per-tier
   clip-path/rotate (below) still carries the shape ladder. */
.pack-card-gem {
    width: 13px;
    height: 13px;
    background:
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 46%),
        var(--rarity);
    box-shadow: 0 0 6px var(--rarity), inset 0 0 2px rgba(255, 255, 255, 0.45);
    flex: none;
}

/* Gem shape escalates with the tier — a cheap, readable Panini tell that pairs
   with the hue + label, so rarity is never carried by color alone. */
.pack-card[data-rarity="common"] .pack-card-gem {
    border-radius: 3px;
}

.pack-card[data-rarity="rare"] .pack-card-gem {
    transform: rotate(45deg);
    border-radius: 2px;
}

.pack-card[data-rarity="epic"] .pack-card-gem {
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.pack-card[data-rarity="legendary"] .pack-card-gem {
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* Big "rating" number — the reach, the card's one honest stat. */
.pack-card-rating {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.pack-card-rarity-label {
    line-height: 1;
    margin-left: auto;
}

/* --- Bottom placard overlay: title + Wikipedia link, above the Collect bar --- */

.pack-card-body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--card-collect-h);
    z-index: 3;
    padding: 14px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: linear-gradient(0deg, rgba(26, 23, 20, 0.86) 0%, rgba(26, 23, 20, 0.55) 62%, rgba(26, 23, 20, 0) 100%);
}

.pack-card-title {
    font-size: var(--text-lg);
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.pack-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.pack-card-link {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    text-decoration: none;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-button);
    background: rgba(255, 255, 255, 0.08);
    transition: background var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.pack-card-link:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.75);
}

/* Full-width Collect bar at the card's bottom edge. Solid dark + white text
   keeps contrast stable across every tier's foil; the rarity hue edges the top. */
.pack-card-collect {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 11px 12px;
    border: none;
    border-top: 2px solid var(--rarity);
    background: rgba(26, 23, 20, 0.92);
    color: #fff;
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: var(--card-collect-h);
    transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out);
}

.pack-card-collect:hover {
    background: rgba(26, 23, 20, 1);
}

.pack-card-collect.is-collected {
    background: rgba(26, 23, 20, 0.7);
    color: rgba(255, 255, 255, 0.7);
    cursor: default;
}

/* Server-routed duplicates read as a quieter verdict than "Collected" —
   same bar geometry, dimmer edge, so the shelf still owns the color. */
.pack-card-collect.is-duplicate {
    border-top-color: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

/* --- Skeleton (loading) --- */

.pack-card.is-removed {
    /* Collected cards leave the grid; display:none drops them from layout
       so the grid reflows, and keeps them matched to querySelectorAll so
       the index-based reveal logic stays aligned mid-pack. */
    display: none;
}

/* Collected card settles toward the shelf — a brief shrink + fade before
   .is-removed reflows the grid. Applied by settlePackCard (JS), which adds
   .is-removed on animationend. The `to`-only keyframe starts from the card's
   current revealed transform (the rarity pop), so there's no snap at frame 0. */
.pack-card.is-collecting {
    pointer-events: none;
    animation: card-collect 0.32s var(--ease-out-quart) forwards;
}

@keyframes card-collect {
    to { opacity: 0; transform: scale(0.9) translateY(8px); }
}

.pack-card.is-skeleton {
    cursor: default;
    border-radius: var(--radius-card);
}

.pack-card.is-skeleton:focus-visible {
    outline: none;
}

.pack-card.is-skeleton .pack-card-inner {
    transform: none;
    border-radius: var(--radius-card);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--bg-soft);
}

/* Quiet shimmer while the pack is in flight — motion as loading state, not a
   frozen frame. Reuses the tile-sheen sweep vocabulary; killed under reduced-motion. */
.pack-card.is-skeleton .pack-card-inner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 35%, rgba(26, 23, 20, 0.05) 50%, transparent 65%);
    transform: translateX(-120%);
    animation: skeleton-shimmer 1.4s var(--ease-in-out) infinite;
}

@keyframes skeleton-shimmer {
    from { transform: translateX(-120%); }
    to { transform: translateX(120%); }
}

/* --- Pack Status --- */

.pack-status {
    text-align: center;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: var(--text-base);
    line-height: 1.5;
    min-height: 20px;
}

/* --- Collection Section --- */

.collection-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: 14px;
}

.collection-head h2 {
    margin: 0;
    font-size: var(--text-base);
    line-height: 1.3;
    color: var(--text);
    font-weight: 700;
}

.collection-stats {
    color: var(--muted);
    font-size: var(--text-md);
    line-height: 1.4;
}

/* Lineage sets — curated Lines of Influence groups tracked as collection
   goals. Honey-deep border + warm wash mark a completed set. */
.lineage-sets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 14px;
}

.lineage-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    font-size: var(--text-xs);
    color: var(--muted);
}

.lineage-chip-count {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.04em;
}

.lineage-chip.is-complete {
    border-color: var(--accent-warm-deep);
    color: var(--accent-warm-deep);
    background: rgba(240, 168, 104, 0.14);
    font-weight: 600;
}

/* Influence chains — documented teacher→student lines the collection proves.
   Quieter than a completed lineage set: chains are many, so they read as a
   catalog row (ink text, hairline border) and let the Honey-deep arrow carry
   the "linked" meaning. Hidden entirely until the first chain closes. */
.chain-sets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 14px;
}

.chain-sets.hidden,
.lineage-sets.hidden {
    display: none;
}

.chain-sets-label {
    margin-right: 4px;
    font-size: var(--text-xs);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
}

.chain-sets-count {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 4px 0;
}

.chain-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    font-size: var(--text-xs);
    color: var(--text);
    background: transparent;
    cursor: pointer;
    transition: border-color var(--t-med) var(--ease-out), background var(--t-med) var(--ease-out), transform var(--t-fast) var(--ease-out);
}

.chain-chip:hover {
    border-color: var(--accent-warm-deep);
    background: rgba(26, 23, 20, 0.04);
    transform: translateY(-1px);
}

.chain-chip:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 2px;
}

.chain-chip-arrow {
    color: var(--accent-warm-deep);
    font-weight: 700;
}

/* One step from a chain — uncollected thinkers whose card would close a line
   already proven on one side. The dashed border reads as "not yet yours";
   the Honey count badge carries the payoff. Clicking jumps to the pack panel
   — pack categories are server-shuffled, so no specific pack is selectable. */
.chain-frontier {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 14px;
}

.chain-frontier.hidden {
    display: none;
}

.chain-frontier-label {
    margin-right: 4px;
    font-size: var(--text-xs);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
}

.chain-frontier-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 10px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-button);
    font-size: var(--text-xs);
    color: var(--text);
    background: transparent;
    cursor: pointer;
    transition: border-color var(--t-med) var(--ease-out), background var(--t-med) var(--ease-out), transform var(--t-fast) var(--ease-out);
}

.chain-frontier-chip:hover {
    border-color: var(--accent-warm-deep);
    background: rgba(26, 23, 20, 0.04);
    transform: translateY(-1px);
}

.chain-frontier-chip:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 2px;
}

.chain-frontier-count {
    padding: 0 6px;
    /* Crisp-object radius: the codebase refuses stadium pills on chrome. */
    border-radius: var(--radius-card);
    background: var(--accent);
    color: #1a1714;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 600;
}

.chain-frontier-more {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 4px 0;
}

.collection-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: 14px;
}

.collection-sort-details {
    position: relative;
    margin-left: auto;
}

.collection-sort-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--text);
    font-size: var(--text-md);
    font-weight: 500;
    cursor: pointer;
    list-style: none;
}

.collection-sort-summary::-webkit-details-marker {
    display: none;
}

.collection-sort-summary:hover {
    border-color: var(--accent-warm-deep);
}

.collection-sort-summary:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 3px;
}

.collection-sort-current {
    color: var(--accent-warm-deep);
    font-weight: 700;
}

.collection-sort-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 168px;
    padding: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--panel-solid);
    box-shadow: var(--shadow);
}

.collection-sort-menu .chip-button {
    min-width: 0;
    width: 100%;
    text-align: left;
    border-radius: var(--radius-md);
}

.collection-sort-label {
    font-size: var(--text-xs);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
}

.collection-search-field {
    display: inline-flex;
    align-items: center;
}

.collection-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    min-width: 36px;
    padding: 0 9px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--t-med) var(--ease-out), background var(--t-med) var(--ease-out);
}

.collection-search-toggle:hover {
    border-color: var(--accent-warm-deep);
    background: rgba(26, 23, 20, 0.04);
}

.collection-search-toggle:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 3px;
}

.collection-search-toggle-icon {
    flex: none;
}

.collection-search {
    border: 1px solid var(--border-strong);
    background: transparent;
    border-radius: var(--radius-button);
    min-height: 36px;
    color: var(--text);
    font-size: var(--text-md);
    outline: none;
    width: 0;
    min-width: 0;
    padding: 8px 0;
    margin-left: 0;
    border-width: 0;
    opacity: 0;
    visibility: hidden;
    /* width/padding/opacity/visibility carry the expand; border-width + margin
       snap instantly so two fewer layout properties animate. */
    transition: width var(--t-med) var(--ease-out), padding var(--t-med) var(--ease-out), opacity var(--t-med) var(--ease-out), visibility var(--t-med) var(--ease-out);
}

.collection-search-field.is-expanded .collection-search {
    width: 220px;
    padding: 8px 16px;
    border-width: 1px;
    margin-left: 8px;
    opacity: 1;
    visibility: visible;
}

.collection-search::placeholder {
    color: var(--muted);
}

.collection-search:focus {
    border-color: var(--accent-warm-deep);
    box-shadow: 0 0 0 1px var(--accent-warm-deep);
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: var(--space-3);
    min-height: 0;
}

.collection-empty {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: var(--text-base);
    line-height: 1.5;
    text-align: center;
    padding: 28px;
}

/* --- Collection Card --- */

.collection-card {
    --rarity: var(--rarity-common);
    --rarity-2: var(--rarity-common-2);

    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-top: 3px solid var(--rarity);
    border-radius: var(--radius-card);
    overflow: hidden;
    /* Skip paint/layout for offscreen cards so a full 100-card grid costs
       nothing until scrolled into view. Intrinsic size ≈ the auto-fill minmax
       width and a typical card height; only affects scroll-height estimates. */
    content-visibility: auto;
    contain-intrinsic-size: 168px 260px;
    background: var(--bg-soft);
    transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.collection-card[data-rarity="rare"] {
    --rarity: var(--rarity-rare);
    --rarity-2: var(--rarity-rare-2);
}

.collection-card[data-rarity="epic"] {
    --rarity: var(--rarity-epic);
    --rarity-2: var(--rarity-epic-2);
}

.collection-card[data-rarity="legendary"] {
    --rarity: var(--rarity-legendary);
    --rarity-2: var(--rarity-legendary-2);
}

.collection-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
    border-color: var(--border-strong);
    border-top-color: var(--rarity);
}

.collection-card-art {
    position: relative;
    height: 104px;
    overflow: hidden;
    background: var(--bg-soft);
}

.collection-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.collection-card-no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-soft);
    color: var(--muted);
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: 0.10em;
}

.collection-card-art::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(26, 23, 20, 0.30) 100%);
    pointer-events: none;
}

.collection-card-gem {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 11px;
    height: 11px;
    transform: rotate(45deg);
    border-radius: 2px;
    background: var(--rarity);
    z-index: 2;
}

.collection-card-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.collection-card-title {
    font-size: var(--text-md);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.collection-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-top: auto;
}

.collection-card-reach {
    font-size: var(--text-xs);
    color: var(--muted);
}

.collection-card-rarity {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-button);
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--bg-soft);
    color: var(--rarity-2);
    border: 1px solid var(--rarity);
}

.collection-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

/* "Student of … · Influenced …" strip on cards matching a Lines of Influence
   thinker. Names are buttons: selecting one jumps to the Influence graph with
   that thinker selected. Styled as plain text with a dotted honey-deep
   underline so the affordance reads without turning the shelf into link soup. */
.collection-card-lineage {
    margin-top: 4px;
    font-size: var(--text-xs);
    line-height: 1.35;
    color: var(--muted);
}

.collection-card-lineage-name {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: underline dotted var(--accent-warm-deep);
    text-underline-offset: 2px;
}

.collection-card-lineage-name:hover {
    color: var(--accent-warm-deep);
}

.collection-card-lineage-name:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 1px;
}

.collection-card-link {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    font-size: var(--text-2xs);
    color: var(--accent-warm-deep);
    text-decoration: none;
    background: transparent;
    min-height: 44px;
    transition: background var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.collection-card-link:hover {
    background: rgba(26, 23, 20, 0.04);
    border-color: var(--rarity);
}

/* --- Toast (transient feedback for sells, duplicates, near-cap) --- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + var(--space-5));
    transform: translate(-50%, 20px);
    z-index: 80;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    max-width: min(440px, calc(100vw - var(--space-7)));
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: var(--panel-solid);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: var(--text-sm);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--t-med) var(--ease-out), opacity var(--t-med) var(--ease-out), visibility 0s linear var(--t-med);
}

.toast.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
    transition: transform var(--t-med) var(--ease-out), opacity var(--t-med) var(--ease-out), visibility 0s;
}

.toast-text {
    flex: 1;
    min-width: 0;
}

.toast-action {
    flex: none;
    border: none;
    border-radius: var(--radius-button);
    background: var(--accent);
    color: var(--text-on-accent);
    padding: var(--space-2) var(--space-3);
    min-height: 44px;
    font-weight: 700;
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.toast-action:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 2px;
}

/* --- Daily-ritual status line (streak + pity promise) --- */

.ritual-status {
    margin: -8px 0 14px;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.04em;
    color: var(--muted);
}

/* --- Confirm dialog (influence-chain sell warning) --- */

.dialog {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    background: rgba(26, 23, 20, 0.42);
}

.dialog[hidden] {
    display: none;
}

.dialog-panel {
    width: min(420px, 100%);
    padding: var(--space-5);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-card);
    background: var(--panel-solid);
    box-shadow: var(--shadow);
}

.dialog-title {
    margin: 0 0 var(--space-2);
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
}

.dialog-body {
    margin: 0 0 var(--space-2);
    font-size: var(--text-sm);
    color: var(--text);
}

.dialog-detail {
    margin: 0 0 var(--space-2);
    padding-left: var(--space-5);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text);
}

.dialog-detail li {
    margin-bottom: 2px;
}

.dialog-footnote {
    margin: 0 0 var(--space-2);
    font-size: var(--text-xs);
    color: var(--muted);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

/* --- Empty-state call-to-action --- */

.collection-empty-cta {
    display: inline-block;
    margin-left: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--accent-warm-deep);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--accent-warm-deep);
    font: inherit;
    font-size: var(--text-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: background var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out);
}

.collection-empty-cta:hover {
    background: var(--accent);
    color: var(--text-on-accent);
}

.collection-empty-cta:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 2px;
}

/* --- First-run coachmark --- */

.coachmark {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--accent-warm-deep);
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    color: var(--text);
    font-size: var(--text-sm);
    line-height: 1.4;
}

.coachmark-text {
    flex: 1;
}

.coachmark-dismiss {
    flex: none;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--text);
    font-size: var(--text-base);
    line-height: 1;
    cursor: pointer;
    transition: background var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.coachmark-dismiss:hover {
    background: rgba(26, 23, 20, 0.04);
    border-color: var(--accent-warm-deep);
}

.coachmark-dismiss:focus-visible {
    outline: 2px solid var(--accent-warm-deep);
    outline-offset: 2px;
}

/* --- Craft panel --- */
.craft-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.craft-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
}

.craft-row-flow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.craft-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-button);
    border: 1px solid var(--rarity, var(--border-strong));
    /* Text-safe mate for AA on the panel-solid craft drawer; border + dot keep
       the bright --rarity. Mirrors .collection-card-rarity / .duplicates-stack-rarity. */
    color: var(--rarity-2, var(--rarity, var(--text)));
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.craft-chip::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--rarity, var(--muted));
}

.craft-chip[data-rarity="common"] { --rarity: var(--rarity-common-2); --rarity-2: var(--rarity-common-2); }
.craft-chip[data-rarity="rare"] { --rarity: var(--rarity-rare); --rarity-2: var(--rarity-rare-2); }
.craft-chip[data-rarity="epic"] { --rarity: var(--rarity-epic); --rarity-2: var(--rarity-epic-2); }
.craft-chip[data-rarity="legendary"] { --rarity: var(--rarity-legendary); --rarity-2: var(--rarity-legendary-2); }

.craft-arrow {
    color: var(--muted);
    font-family: var(--font-mono);
    font-weight: 700;
}

.craft-row-meta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
}

.craft-row-count {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

.craft-row-btn {
    min-height: 40px;
    padding: 8px 16px;
    font-size: var(--text-sm);
}

.craft-row-btn:disabled {
    cursor: not-allowed;
}

.craft-empty {
    margin: 0;
    color: var(--muted);
    font-size: var(--text-md);
}

/* --- Responsive --- */

@media (max-width: 880px) {
    .panel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel-copy {
        text-align: left;
    }

    .collection-sort-details {
        margin-left: 0;
    }

    .collection-search-field {
        margin-left: 0;
        width: 100%;
    }

    .collection-search-field.is-expanded .collection-search {
        width: 100%;
    }

    /* Four pack tiers wrap to a 2×2 grid once the row gets tight. */
    .pack-tiles {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .hero {
        padding: 18px;
        margin-bottom: 14px;
    }

    /* The fanned-card showcase is desktop eye-candy; on phone the hero copy
       needs the room, so the stage folds away (the real cards still show the
       rarity system once a pack is opened). */
    .hero-showcase {
        display: none;
    }

    .hero h1 {
        font-size: clamp(1.7rem, 7vw, 2.2rem);
    }

    .panel {
        padding: 16px;
        margin-bottom: 12px;
    }

    .page {
        padding: 18px 0 32px;
    }

    .collection-head {
        flex-wrap: wrap;
    }

    /* Phone pack: 2 cards per row. .pack-cards gap clamps to 12px at this
       width, so each card = 50% - 6px fills the row exactly. Five cards
       render as 2 + 2 + 1 (the lone 5th centers via justify-content). */
    .pack-card {
        width: calc(50% - 6px);
        /* Taller than the base 300/430 so the photo + overlays + Collect bar
           don't crush the title on the narrower 2-per-row card. */
        aspect-ratio: 300 / 480;
    }

    /* Pack wrappers stay 2-up on phone: five full-width 184px wrappers pushed
       the first card a full screen down the page. Two columns keep the
       pick-a-pack decision one thumb-flick from the deal. */
    .pack-tile {
        min-height: 156px;
        padding: 16px 14px 12px;
    }

    .pack-card-back::after {
        font-size: 2rem;
    }

    .pack-card-back::before {
        width: clamp(64px, 44%, 84px);
    }

    /* Scale internal content down for the ~157px-wide phone card. */
    .pack-card-rarity-bar {
        padding: 7px 10px;
        font-size: var(--text-2xs);
    }

    .pack-card-gem {
        width: 11px;
        height: 11px;
    }

    .pack-card-rating {
        font-size: var(--text-md);
    }

    .pack-card-body {
        padding: 12px 10px 6px;
        gap: 5px;
    }

    .pack-card-title {
        font-size: var(--text-md);
    }

    .pack-card-meta {
        gap: 6px;
    }

    .pack-card-link {
        font-size: var(--text-2xs);
        padding: 2px 6px;
    }

    .pack-card-collect {
        padding: 8px 10px;
        font-size: var(--text-xs);
    }

    /* Collection: 2 columns instead of 1 on phone (desktop keeps 168px). */
    .collection-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    /* Stack the link + sell pill full-width so both clear the 44px touch target. */
    .collection-card-actions {
        flex-direction: column;
    }
}

/* View Transitions glide for the collection grid — sort/filter/search morph
   cards to their new positions instead of popping. Inside a support guard so
   engines without the API ignore it; reduced-motion skips the transition in JS
   and repaints directly. */
@supports (view-transition-name: none) {
    ::view-transition-group(*) {
        animation-duration: 0.32s;
        animation-timing-function: cubic-bezier(0.25, 0.85, 0.3, 1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pack-card-inner {
        transition: transform var(--t-med) var(--ease-out);
    }

    /* Legendary holo sheen holds still (foil/glow stay — only motion stops). */
    .pack-card[data-rarity="legendary"] .pack-card-front::before {
        animation: none;
    }

    /* Panini theatre collapses to static finish: no entrance, glare, bloom,
       glow pulse, or foil drift. Foil/glow remain so rarity still reads; only
       motion stops. Specificity matches the rules above so the override takes. */
    .pack-card:not(.is-skeleton) {
        animation: none;
    }

    .pack-card.is-revealed {
        transform: none;
    }

    .pack-card[data-rarity="rare"].is-revealed::before,
    .pack-card[data-rarity="epic"].is-revealed::before,
    .pack-card[data-rarity="legendary"].is-revealed::before {
        animation: none;
        opacity: 0.4;
    }

    .pack-card[data-rarity="legendary"].is-revealed::before {
        opacity: 0.6;
    }

    .pack-card.is-revealed .pack-card-front::after,
    .pack-card[data-rarity="legendary"].is-revealed::after {
        animation: none;
        opacity: 0;
    }

    .pack-card[data-rarity="legendary"] .pack-card-front {
        animation: none;
    }

    .pack-tile[data-pack-type="mythic"] {
        animation: none;
    }

    .pack-tile.is-tearing {
        animation: none;
    }

    /* Hero showcase holds still by design now — nothing to stop. */

    /* Skeleton loading shimmer holds still. */
    .pack-card.is-skeleton .pack-card-inner::before {
        animation: none;
        display: none;
    }

    .collection-search {
        transition: none;
    }

    /* Toast slides in without the lift. */
    .toast {
        transform: translate(-50%, 0);
    }

    /* New delight motion collapses with the rest: no collect settle, no coin +N. */
    .pack-card.is-collecting {
        animation: none;
    }

    /* Overdrive theatre collapses too: no tilt, glint, particles, screen flash,
       or grid punch. Foil/glow/aura stay as static finish so rarity still reads;
       only motion stops. JS also skips tilt/particle/flash work in this mode. */
    .pack-card-tilt {
        transform: none;
        transition: none;
        will-change: auto;
    }

    .pack-card-glint,
    .pack-card-particles,
    .pull-flash {
        display: none;
    }

    .pack-cards.is-punching {
        animation: none;
    }

    .coin-delta {
        display: none;
    }
}

/* --- Coin balance + duplicates --- */

.panel-head-copy {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.coin-balance-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
}

.coin-balance {
    position: relative; /* anchor for the .coin-delta "+N" pulse */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 8px 14px;
    border: 1px solid var(--accent-warm-deep);
    border-radius: var(--radius-button);
    background: rgba(240, 168, 104, 0.16);
    color: var(--text-on-accent);
    font-size: var(--text-base);
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Flat bronze coin glyph — solid fill + engraved inner ring, no gradient/shine
   (same no-glow rule as the rarity gems). Number stays dark ink-on-Honey. */
.coin-balance-icon {
    flex: none;
    width: 14px;
    height: 14px;
    color: var(--accent-warm-deep);
}

.coin-balance-hint {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.02em;
    color: var(--muted);
    text-align: right;
}

/* Coin gain "+N" — a tactile pulse on the badge when coins arrive (sells,
   refunds). Honey-deep on Honey-soft so it clears contrast; rises and fades.
   Created/removed in JS (flashCoinDelta); hidden under reduced-motion. */
.coin-delta {
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    padding: 2px 6px;
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    color: var(--accent-warm-deep);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    pointer-events: none;
    animation: coin-delta-rise 0.85s var(--ease-out-quart) forwards;
}

@keyframes coin-delta-rise {
    0%   { opacity: 0; transform: translate(-50%, 4px); }
    25%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -16px); }
}

.duplicates-toggle,
.craft-toggle {
    min-height: 32px;
    padding: 4px 12px;
}

.drawer {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    justify-content: flex-end;
    background: rgba(26, 23, 20, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--t-med) var(--ease-out), visibility 0s linear 0.2s;
}

.drawer.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--t-med) var(--ease-out), visibility 0s;
}

.drawer-panel {
    display: flex;
    flex-direction: column;
    width: min(380px, 92vw);
    height: 100%;
    padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
    background: var(--panel-solid);
    border-left: 1px solid var(--border);
    border-top-left-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transform: translateX(100%);
    transition: transform var(--t-med) var(--ease-out);
    overflow: hidden;
}

.drawer.is-open .drawer-panel {
    transform: translateX(0);
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: 14px;
}

.drawer-close {
    flex: none;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-button);
    background: transparent;
    color: var(--text);
    font-size: var(--text-base);
    line-height: 1;
    cursor: pointer;
    transition: background var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.drawer-close:hover {
    background: rgba(26, 23, 20, 0.04);
    border-color: var(--border-strong);
}

.drawer-title {
    margin: 0;
    font-size: var(--text-sm);
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
}

.drawer-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    overflow-y: auto;
    min-height: 0;
}

.drawer-copy {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: var(--text-sm);
    line-height: 1.45;
}

.duplicates-stack {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: transparent;
    --rarity: var(--rarity-common);
    --rarity-2: var(--rarity-common-2);
}

.duplicates-stack[data-rarity="rare"] { --rarity: var(--rarity-rare); --rarity-2: var(--rarity-rare-2); }
.duplicates-stack[data-rarity="epic"] { --rarity: var(--rarity-epic); --rarity-2: var(--rarity-epic-2); }
.duplicates-stack[data-rarity="legendary"] { --rarity: var(--rarity-legendary); --rarity-2: var(--rarity-legendary-2); }

.duplicates-stack-gem {
    width: 9px;
    height: 9px;
    transform: rotate(45deg);
    border-radius: 2px;
    background: var(--rarity);
    flex: none;
}

.duplicates-stack-title {
    flex: 1;
    min-width: 0;
    font-size: var(--text-md);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.duplicates-stack-count {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--muted);
}

.duplicates-stack-rarity {
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    /* Text-safe mate: the bright --rarity mate fails contrast (#b8821a ≈ 2.8:1
       on the panel-solid drawer). --rarity-2 clears AA for every tier; the
       decorative dot/border keep the bright --rarity. Mirrors .collection-card-rarity. */
    color: var(--rarity-2);
}

@media (max-width: 540px) {
    .duplicates-stack {
        flex-wrap: wrap;
    }

    .duplicates-stack-title {
        white-space: normal;
    }
}

/* Touch targets: every tappable chrome control clears 44px on coarse
   pointers. Desktop keeps its denser sizes � this is input-method detection,
   not a phone-width guess. */
@media (pointer: coarse) {
    .view-tab,
    .account-btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    .chip-button {
        min-height: 44px;
        padding: 10px 16px;
    }

    .collection-search-toggle {
        min-height: 44px;
        min-width: 44px;
    }

    .duplicates-toggle,
    .craft-toggle,
    .pack-odds-summary {
        min-height: 44px;
    }
}
