/* Trade page final override: loaded after site.css */

.trade-listings {
    --market-item-size: 4rem;
    --market-item-gap: 0.42rem;
    --trade-side-width: 12.85rem;
}

.trade-layout {
    grid-template-columns: minmax(0, 1fr);
}

.trade-filters {
    grid-template-columns: minmax(14rem, 1fr) minmax(0, 1fr);
}

.trade-item-filter input {
    width: 100%;
    box-sizing: border-box;
    min-height: 2.5rem;
    padding: 0.55rem 0.72rem;
    color: #071126;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 0.65rem;
    font: inherit;
}

.trade-rarity-filter select {
    width: 100%;
    box-sizing: border-box;
    min-height: 2.5rem;
    padding: 0.55rem 0.72rem;
    color: #071126;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 0.65rem;
    font: inherit;
}

.trade-rarity-filter select:focus {
    outline: 2px solid rgba(59, 130, 246, 0.3);
    outline-offset: 0;
}

.trade-item-filter input:focus {
    outline: 2px solid rgba(59, 130, 246, 0.3);
    outline-offset: 0;
}

.trade-listing.is-filtered-out {
    display: none;
}

/* Trade-page-only level badge sizing and hover hint */
.trade-page .trader-profile .profile-level-indicator {
    width: 1.2rem;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0;
    border-radius: 0.3rem;
    font-size: 0.52rem;
}

.trade-game-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.85rem;
}

.trade-game-nav a {
    display: inline-flex;
    min-height: 2.2rem;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.8rem;
    color: #33557a;
    background: rgba(148, 197, 253, 0.1);
    border: 1px solid rgba(148, 197, 253, 0.4);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
}

.trade-game-nav a.is-active {
    color: #ffffff;
    background: #0f2d57;
    border-color: #0f2d57;
}

.trade-sections {
    display: grid;
    gap: 1rem;
    min-width: 0;
}

.trade-game-section {
    display: grid;
    gap: 0.65rem;
    min-width: 0;
}

.trade-game-section__header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(203, 213, 225, 0.78);
    border-radius: 1rem;
    box-shadow: 0 0.75rem 2rem rgba(15, 23, 42, 0.08);
}

.trade-game-section__header p,
.trade-game-section__header h2,
.trade-game-section__header span {
    margin: 0;
}

.trade-game-section__header p {
    color: #0891b2;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.trade-game-section__header h2 {
    margin-top: 0.18rem;
    color: #071126;
    font-size: clamp(1.35rem, 3vw, 2.1rem);
    line-height: 1;
}

.trade-game-section__header span {
    display: block;
    margin-top: 0.35rem;
    color: #53657f;
    line-height: 1.45;
}

.trade-game-section__header strong {
    flex: 0 0 auto;
    padding: 0.45rem 0.75rem;
    color: #075985;
    background: #e0f2fe;
    border-radius: 999px;
    font-size: 0.8rem;
}

.trade-listings__header,
.trade-listing {
    grid-template-columns:
        minmax(13rem, 0.9fr)
        minmax(var(--trade-side-width), 1fr)
        minmax(var(--trade-side-width), 1fr)
        minmax(7rem, 0.45fr)
        1.5rem;
    column-gap: 1.25rem;
}

.trade-listing {
    min-height: calc(var(--market-item-size) + 1.7rem);
    align-items: center;
    padding-block: 0.85rem;
}

.trade-listing__header,
.trade-windows {
    display: contents;
}

.trader-profile {
    grid-row: 1;
    align-items: center;
}

.trader-profile > div {
    display: grid;
    min-width: 0;
    gap: 0.34rem;
}

.trader-profile h2 span,
.trader-profile > div > p:not(.trader-rating) {
    display: none;
}

.trader-rating {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    color: #51698a;
    font-size: 0.76rem;
    line-height: 1.2;
}

.trader-rating span {
    color: #f59e0b;
    font-size: 0.78rem;
    letter-spacing: 0;
}

.trader-rating strong {
    color: #071126;
    font-size: 0.78rem;
}

.trader-rating small {
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 800;
}

.trader-profile .trade-outcome {
    display: inline-flex;
    justify-self: start;
    margin-top: 0.1rem;
}

.trade-window__count {
    display: none;
}

.trade-window {
    position: relative;
    z-index: 2;
    isolation: isolate;
    overflow: visible;
    grid-row: 1;
    align-self: start;
    width: max-content;
    min-width: 0;
    height: auto;
    min-height: 0;
}

.trade-window--looking,
.trade-window[aria-label$="looking for" i] {
    grid-column: 2;
}

.trade-window--offering,
.trade-window[aria-label$="offering" i] {
    grid-column: 3;
}

.trade-item-grid {
    display: grid;
    grid-template-columns: repeat(3, var(--market-item-size));
    grid-auto-rows: var(--market-item-size);
    gap: var(--market-item-gap);
    width: max-content;
    max-width: var(--trade-side-width);
    height: auto;
    min-height: 0;
    align-content: start;
    align-items: start;
    justify-content: start;
    justify-items: start;
    overflow: visible;
}

.trade-item-grid--single {
    grid-template-columns: var(--market-item-size);
}

.trade-item-grid--pair {
    grid-template-columns: repeat(2, var(--market-item-size));
}

.trade-item-grid--triple,
.trade-item-grid--full {
    grid-template-columns: repeat(3, var(--market-item-size));
}

.market-slot {
    display: none;
}

.market-item {
    box-sizing: border-box;
    width: var(--market-item-size);
    height: var(--market-item-size);
    min-width: var(--market-item-size);
    min-height: 0;
    color: inherit;
    text-decoration: none;
    border-radius: 0.72rem;
}

.market-item::before {
    inset: 13%;
    border-radius: 0.52rem;
}

.market-item > strong {
    font-size: 1rem;
    letter-spacing: 0.08em;
}

.market-item__image {
    position: absolute;
    inset: 0.38rem;
    width: calc(100% - 0.76rem);
    height: calc(100% - 0.76rem);
    object-fit: contain;
    border-radius: 0.45rem;
    background: rgba(15, 23, 42, 0.14);
}

.market-item > small {
    right: 0.18rem;
    bottom: 0.18rem;
    padding: 0.12rem 0.28rem;
    font-size: 0.5rem;
}

.trader-avatar--four {
    background: linear-gradient(135deg, #065f46, #22c55e);
}

.trader-avatar--five {
    background: linear-gradient(135deg, #581c87, #38bdf8);
}

.trader-avatar--six {
    background: linear-gradient(135deg, #7c2d12, #facc15);
}

.trader-avatar--seven {
    background: linear-gradient(135deg, #be185d, #f9a8d4);
}

.trader-avatar--eight {
    background: linear-gradient(135deg, #111827, #f97316);
}

.trader-avatar--nine {
    background: linear-gradient(135deg, #155e75, #a7f3d0);
}

.trader-avatar--ten {
    background: linear-gradient(135deg, #312e81, #f59e0b);
}

.trader-avatar--eleven {
    background: linear-gradient(135deg, #334155, #60a5fa);
}

.market-item--venom {
    background: linear-gradient(135deg, #166534, #84cc16 55%, #4c1d95);
}

.market-item--spirit {
    background: linear-gradient(135deg, #fef3c7, #38bdf8 50%, #7c3aed);
}

.market-item--buddha {
    background: linear-gradient(135deg, #facc15, #f97316);
}

.market-item--portal {
    background: linear-gradient(135deg, #1e1b4b, #7c3aed 48%, #22d3ee);
}

.market-item--control {
    background: linear-gradient(135deg, #be123c, #fb7185 52%, #312e81);
}

.market-item--rumble {
    background: linear-gradient(135deg, #312e81, #4f46e5 52%, #facc15);
}

.market-item--owl {
    background: linear-gradient(135deg, #92400e, #fbbf24 52%, #fef3c7);
}

.market-item--turtle {
    background: linear-gradient(135deg, #065f46, #14b8a6);
}

.market-item--kangaroo {
    background: linear-gradient(135deg, #9a3412, #f59e0b);
}

.market-item--shadow {
    background: linear-gradient(135deg, #020617, #4338ca 52%, #e11d48);
}

.market-item--giraffe {
    background: linear-gradient(135deg, #f59e0b, #fef08a 48%, #92400e);
}

.market-item--limited {
    background: linear-gradient(135deg, #0f172a, #475569 52%, #f8fafc);
}

.market-item--limited-blue {
    background: linear-gradient(135deg, #082f49, #0284c7 52%, #bae6fd);
}

.market-item--ugc {
    background: linear-gradient(135deg, #6d28d9, #ec4899 52%, #f9a8d4);
}

.market-item--gear {
    background: linear-gradient(135deg, #334155, #64748b 52%, #cbd5e1);
}

.market-item--pass {
    background: linear-gradient(135deg, #14532d, #22c55e 52%, #bbf7d0);
}

.trade-listing::after {
    grid-row: 1;
    align-self: center;
}

.trade-listing__actions {
    position: relative;
    grid-column: 5;
    grid-row: 1;
    display: grid;
    justify-items: end;
    align-self: center;
}

.trade-menu {
    position: relative;
}

.trade-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.15rem;
    min-height: 2.15rem;
    padding: 0.25rem 0.45rem;
    color: #1e293b;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.trade-menu summary {
    list-style: none;
}

.trade-menu summary::-webkit-details-marker {
    display: none;
}

.trade-menu-trigger:hover,
.trade-menu[open] .trade-menu-trigger {
    color: #ffffff;
    background: #0f2d57;
    border-color: #0f2d57;
}

.trade-action-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 30;
    display: none;
    min-width: 10rem;
    padding: 0.35rem;
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.55rem;
    box-shadow: 0 0.75rem 1.8rem rgba(15, 23, 42, 0.28);
}

.trade-menu[open] .trade-action-menu {
    display: grid;
    gap: 0.2rem;
}

.trade-action-menu__item {
    display: block;
    padding: 0.45rem 0.55rem;
    color: #dbe7f6;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
}

.trade-action-menu__item::before {
    display: inline-block;
    width: 1rem;
    margin-right: 0.4rem;
    font-weight: 800;
    text-align: center;
    content: "•";
}

.trade-action-menu__item:hover {
    background: #1e293b;
}

.trade-action-menu__item--info {
    color: #e2e8f0;
}

.trade-action-menu__item--info::before {
    content: "i";
}

.trade-action-menu__item--counter {
    color: #fbbf24;
}

.trade-action-menu__item--counter::before {
    content: "↺";
}

.trade-action-menu__item--accept {
    color: #86efac;
}

.trade-action-menu__item--accept::before {
    content: "✓";
}

.trade-listings__header span:nth-child(5)::before {
    content: "...";
    color: #334155;
    font-weight: 800;
}

@media (max-width: 1120px) {
    .trade-filters {
        grid-template-columns: 1fr;
    }

    .trade-listings {
        overflow-x: auto;
    }

    .trade-listings__header,
    .trade-listing {
        min-width: 66rem;
    }
}

@media (max-width: 860px) {
    .trade-listings {
        --market-item-size: 3.65rem;
        --market-item-gap: 0.35rem;
        --trade-side-width: 11.65rem;
    }

    .trade-filters,
    .trade-game-section__header {
        grid-template-columns: 1fr;
    }

    .trade-filters {
        display: grid;
    }

    .trade-game-section__header {
        display: grid;
        align-items: start;
    }

    .trade-game-nav a {
        min-height: 2rem;
        padding-inline: 0.65rem;
        font-size: 0.78rem;
    }

    .trade-listing {
        min-width: 0;
        min-height: 0;
        align-items: start;
    }

    .trade-window--looking,
    .trade-window--offering,
    .trade-window[aria-label$="looking for" i],
    .trade-window[aria-label$="offering" i],
    .trader-profile {
        grid-column: auto;
    }

    .trade-listing__actions {
        position: static;
    }

    .trade-action-menu {
        right: auto;
        left: 0;
    }
}

@media (max-width: 640px) {
    .trade-listings {
        overflow: visible;
    }

    .trade-listings__header {
        display: none;
    }

    .trade-listing {
        grid-template-columns: 1fr !important;
        gap: 0.6rem;
        min-width: 0 !important;
        min-height: 0;
        padding: 0.8rem;
        border-radius: 0.8rem;
    }

    .trade-listing::after {
        grid-column: 1;
        justify-self: start;
        margin-top: 0.1rem;
        padding: 0.15rem 0.5rem;
        border-radius: 999px;
        background: rgba(15, 23, 42, 0.08);
        font-size: 0.74rem;
        font-weight: 700;
    }

    .trade-listing__header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .trade-windows {
        display: grid;
        gap: 0.55rem;
    }

    .trade-window--looking,
    .trade-window--offering,
    .trade-window[aria-label$="looking for" i],
    .trade-window[aria-label$="offering" i] {
        grid-column: 1 !important;
        width: 100%;
    }

    .trade-item-grid {
        grid-template-columns: repeat(auto-fill, minmax(3.1rem, 1fr));
        grid-auto-rows: 3.1rem;
        width: 100%;
        max-width: none;
        gap: 0.3rem;
    }

    .trade-listing__actions {
        width: auto !important;
        justify-self: end !important;
        transform: none;
    }
}

/* Hard override for legacy site.css action-column rules */
.trade-listing__actions::before,
.trade-listing__actions::after {
    content: none !important;
    display: none !important;
}

.trade-listing__actions > a,
.trade-listing__actions .fair-pill,
.trade-listing__actions .accept-link {
    display: none !important;
}

.trade-listing__actions .trade-menu-trigger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.trade-listing__actions .trade-action-menu {
    display: none !important;
}

.trade-menu[open] .trade-action-menu {
    display: grid !important;
}

.trade-listing__actions .trade-action-menu__item {
    display: flex !important;
    align-items: center;
    min-height: 0 !important;
    padding: 0.45rem 0.55rem;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0.35rem;
    line-height: 1.25;
}

/* Final menu placement + readability */
.trade-listings__header,
.trade-listing {
    grid-template-columns:
        minmax(13rem, 0.9fr)
        minmax(var(--trade-side-width), 1fr)
        minmax(var(--trade-side-width), 1fr)
        minmax(7rem, 0.45fr)
        2.5rem !important;
}

.trade-listing__actions {
    width: 2.4rem !important;
    justify-self: center !important;
    transform: translateX(-0.18rem);
}

.trade-listing__actions .trade-menu {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.trade-listings__header span:nth-child(5) {
    justify-self: center;
}

.trade-listing__actions .trade-action-menu__item {
    color: #f8fbff !important;
    background: rgba(30, 41, 59, 0.9) !important;
    border: 1px solid rgba(100, 116, 139, 0.9) !important;
}

.trade-listing__actions .trade-action-menu__item:hover {
    background: #334155 !important;
    border-color: #94a3b8 !important;
}

.trade-listing__actions .trade-action-menu__item::before {
    content: "\2022";
}

.trade-listing__actions .trade-action-menu__item--info {
    color: #f1f5f9 !important;
}

.trade-listing__actions .trade-action-menu__item--info::before {
    content: "i";
}

.trade-listing__actions .trade-action-menu__item--counter {
    color: #fcd34d !important;
}

.trade-listing__actions .trade-action-menu__item--counter::before {
    content: "\21BB";
}

.trade-listing__actions .trade-action-menu__item--accept {
    color: #86efac !important;
}

.trade-listing__actions .trade-action-menu__item--accept::before {
    content: "\2713";
}

/* Trade layer ordering (JS-driven classes, no :has selectors) */
.trade-sections,
.trade-game-section,
.trade-listings,
.trade-listing {
    overflow: visible !important;
}

.trade-listings {
    overflow-x: auto;
    overflow-y: visible !important;
}

.trade-listing {
    position: relative;
    isolation: isolate;
    z-index: 1;
}

.trade-listing.is-hover-row,
.trade-listing:focus-within {
    z-index: 20;
}

.trade-listing.is-menu-open {
    z-index: 40;
}

.trade-listing__actions {
    position: relative;
    z-index: 2 !important;
}

.trade-listing.is-menu-open .trade-listing__actions {
    z-index: 50 !important;
}

.trade-listing__actions .trade-action-menu {
    z-index: 60 !important;
}

.market-item {
    position: relative;
    z-index: 1;
}

.item-tooltip {
    z-index: 65 !important;
    pointer-events: none;
}

/* Dark mode: trade page */
:root[data-theme="dark"] .trade-body {
    color: #e5edf9;
    background:
        radial-gradient(circle at 12% 12%, rgba(37, 99, 235, 0.22), transparent 26rem),
        radial-gradient(circle at 90% 18%, rgba(14, 116, 144, 0.24), transparent 24rem),
        linear-gradient(135deg, #050914 0%, #091121 100%);
}

:root[data-theme="dark"] .trade-hero,
:root[data-theme="dark"] .trade-filters,
:root[data-theme="dark"] .trade-game-section__header,
:root[data-theme="dark"] .trade-listings {
    background: #0b172a;
    border-color: rgba(96, 165, 250, 0.3);
    box-shadow: 0 1rem 2.1rem rgba(2, 6, 23, 0.45);
}

:root[data-theme="dark"] .trade-eyebrow,
:root[data-theme="dark"] .trade-game-section__header p {
    color: #93c5fd;
}

:root[data-theme="dark"] .trade-hero h1,
:root[data-theme="dark"] .trade-game-section__header h2,
:root[data-theme="dark"] .trader-profile h2,
:root[data-theme="dark"] .trader-rating strong,
:root[data-theme="dark"] .trade-count {
    color: #f8fbff;
}

:root[data-theme="dark"] .trade-hero p,
:root[data-theme="dark"] .trade-game-section__header span,
:root[data-theme="dark"] .trader-rating,
:root[data-theme="dark"] .trader-rating small {
    color: #9fb3cc;
}

:root[data-theme="dark"] .trade-filter__heading h2,
:root[data-theme="dark"] .trade-filters h3 {
    color: #f8fbff;
}

:root[data-theme="dark"] .trade-filter__heading p,
:root[data-theme="dark"] .trade-filters p {
    color: #9fb3cc;
}

:root[data-theme="dark"] .trade-filter__heading button {
    color: #dbeafe;
    background: rgba(15, 31, 57, 0.85);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 0.55rem;
    padding: 0.25rem 0.55rem;
}

:root[data-theme="dark"] .trade-filter__heading button:hover {
    background: rgba(29, 78, 216, 0.25);
    border-color: rgba(147, 197, 253, 0.5);
}

:root[data-theme="dark"] .trade-search input,
:root[data-theme="dark"] .trade-search select,
:root[data-theme="dark"] .trade-item-filter input,
:root[data-theme="dark"] .trade-rarity-filter select {
    color: #dbeafe;
    background: #0f1f39;
    border-color: rgba(96, 165, 250, 0.34);
}

:root[data-theme="dark"] .trade-search input::placeholder,
:root[data-theme="dark"] .trade-item-filter input::placeholder {
    color: #8ea6c6;
}

:root[data-theme="dark"] .trade-listings__header {
    color: #dbeafe;
    background: #10233f;
    border-bottom-color: rgba(96, 165, 250, 0.28);
}

:root[data-theme="dark"] .trade-listing {
    background: #0d1b33;
    border-bottom-color: rgba(96, 165, 250, 0.2);
}

:root[data-theme="dark"] .trade-listing::after {
    color: #dbeafe;
}

:root[data-theme="dark"] .trade-window {
    background: transparent;
}

:root[data-theme="dark"] .trade-menu-trigger {
    color: #e2e8f0;
    background: #1e293b;
    border-color: #334155;
}

:root[data-theme="dark"] .trade-menu-trigger:hover,
:root[data-theme="dark"] .trade-menu[open] .trade-menu-trigger {
    color: #ffffff;
    background: #1d4ed8;
    border-color: #1d4ed8;
}

:root[data-theme="dark"] .trade-action-menu {
    background: #0f172a;
    border-color: rgba(148, 163, 184, 0.35);
}

:root[data-theme="dark"] .trade-action-menu__item {
    background: rgba(30, 41, 59, 0.92) !important;
    border-color: rgba(100, 116, 139, 0.9) !important;
}

:root[data-theme="dark"] .trade-action-menu__item:hover {
    background: #334155 !important;
    border-color: #94a3b8 !important;
}

:root[data-theme="dark"] .trade-listings__header span:nth-child(5)::before {
    color: #cbd5e1;
}

/* Mobile card-mode lock: kept at file end so it wins over earlier desktop/table rules */
@media (max-width: 760px) {
    .trade-listings {
        overflow: visible !important;
    }

    .trade-listings__header {
        display: none !important;
    }

    .trade-listing {
        display: block !important;
        min-width: 0 !important;
        min-height: 0 !important;
        padding: 0.9rem !important;
        border: 1px solid rgba(96, 165, 250, 0.16);
        border-radius: 0.7rem;
        background: rgba(12, 18, 30, 0.9) !important;
    }

    .trade-listing::after {
        display: none !important;
    }

    .trade-listing__header {
        display: flex !important;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.55rem;
    }

    .trade-windows {
        display: block !important;
        margin-top: 0.55rem;
    }

    .trade-window {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .trade-window + .trade-window {
        margin-top: 0.75rem !important;
        padding-top: 0.75rem !important;
        border-top: 1px solid rgba(148, 163, 184, 0.2);
    }

    .trade-window__top {
        display: grid !important;
        justify-content: start;
        gap: 0.12rem;
        margin-bottom: 0.5rem;
    }

    .trade-window__top h3 {
        margin: 0;
        font-size: 1.02rem;
        font-weight: 800;
        text-transform: none;
        letter-spacing: 0;
    }

    .trade-window__top span {
        display: none !important;
    }

    .trade-window__count {
        display: block;
        color: #9fb3cc;
        font-size: 0.9rem;
        font-weight: 700;
    }

    .trade-item-grid {
        display: flex !important;
        flex-wrap: wrap;
        gap: 0.45rem !important;
        width: 100% !important;
        max-width: none !important;
    }

    .market-item {
        width: 4.5rem !important;
        height: 4.5rem !important;
        min-width: 4.5rem !important;
    }

    .trader-rating,
    .trade-outcome {
        display: none !important;
    }

    .trade-listing__actions {
        display: none !important;
    }

    .trade-mobile-card-actions {
        display: flex;
        gap: 0.45rem;
        margin-top: 0.8rem;
    }

    .trade-mobile-card-actions a {
        display: inline-flex;
        flex: 1 1 0;
        min-height: 2.35rem;
        align-items: center;
        justify-content: center;
        padding: 0 0.85rem;
        color: #dbeafe;
        background: rgba(30, 41, 59, 0.72);
        border: 1px solid rgba(148, 163, 184, 0.32);
        border-radius: 0.5rem;
        font-size: 0.92rem;
        font-weight: 800;
        text-decoration: none;
    }

    .trade-mobile-card-actions .trade-mobile-card-actions__primary {
        color: #ffffff;
        background: #4361ee;
        border-color: rgba(99, 102, 241, 0.85);
    }

    .trade-item-grid .item-tooltip {
        position: absolute;
        left: 50%;
        bottom: calc(100% + 0.55rem);
        z-index: 4700 !important;
        width: min(86vw, 16rem);
        min-width: 0;
        transform: translate(-50%, 0.45rem);
        opacity: 0;
        pointer-events: none;
    }

    .trade-item-grid .item-tooltip::after {
        display: block;
    }

    .market-item.is-tooltip-open .item-tooltip,
    .market-item:focus .item-tooltip,
    .market-item:focus-visible .item-tooltip {
        position: fixed;
        left: var(--mobile-tooltip-left, 50%);
        top: var(--mobile-tooltip-top, auto);
        bottom: auto;
        opacity: 1;
        transform: translate(-50%, -100%);
    }
}

@media (min-width: 761px) {
    .trade-mobile-card-actions {
        display: none;
    }
}

.trade-mobile-dock {
    display: none;
}

/* Final phone-safe guardrail: ensure full trade cards are visible on narrow screens */
@media (max-width: 640px) {
    .trade-listings {
        overflow: visible !important;
    }

    .trade-listings__header {
        display: none !important;
    }

    .trade-listings__header,
    .trade-listing {
        grid-template-columns: 1fr !important;
        min-width: 0 !important;
    }

    .trade-listing {
        gap: 0.6rem !important;
        padding: 0.8rem !important;
    }

    .trade-listing__header {
        display: flex !important;
    }

    .trade-windows {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.55rem !important;
    }

    .trade-window,
    .trade-window--looking,
    .trade-window--offering {
        grid-column: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .trade-window__top {
        display: flex !important;
    }

    .trade-item-grid {
        width: 100% !important;
        max-width: none !important;
        grid-template-columns: repeat(auto-fill, minmax(3.1rem, 1fr)) !important;
        grid-auto-rows: 3.1rem !important;
    }

    .trade-listing__actions {
        width: auto !important;
        justify-self: end !important;
        transform: none !important;
    }
}

@media (max-width: 760px) {
    .trade-page {
        padding-bottom: calc(5.9rem + env(safe-area-inset-bottom, 0px));
    }

    .trade-mobile-dock {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 4600;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.2rem;
        padding: 0.38rem 0.42rem calc(0.38rem + env(safe-area-inset-bottom, 0px));
        background: rgba(5, 9, 20, 0.96);
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        backdrop-filter: blur(8px);
    }

    .trade-mobile-dock a {
        display: grid;
        justify-items: center;
        gap: 0.18rem;
        min-height: 3.05rem;
        align-content: center;
        color: #cbd5e1;
        text-decoration: none;
        border-radius: 0.55rem;
        font-weight: 700;
    }

    .trade-mobile-dock a span {
        font-size: 1.05rem;
        line-height: 1;
    }

    .trade-mobile-dock a b {
        font-size: 0.72rem;
        line-height: 1;
    }

    .trade-mobile-dock a.is-active {
        color: #ffffff;
        background: rgba(59, 130, 246, 0.2);
        border: 1px solid rgba(96, 165, 250, 0.35);
    }
}
