/* ============================================
   RYLB Trade Hub — Styles
   Mobile-first, dark-themed trading interface
   ============================================ */

/* ============================================
   STATUS & TYPE COLOR VARIABLES
   ============================================ */
:root {
    /* Trade type colors */
    --trade-type-open: #4ade80;
    --trade-type-specific: #60a5fa;
    --trade-type-worth: #a78bfa;
    --trade-type-minishop: #fb923c;

    /* Trade status colors */
    --trade-status-open: #4ade80;
    --trade-status-waiting: #fbbf24;
    --trade-status-inprogress: #38bdf8;
    --trade-status-completed: #4ade80;
    --trade-status-cancelled: #f87171;
    --trade-status-blocked: #ef4444;

    /* Misc trade colors */
    --trade-discord: #5865F2;
    --trade-roblox: #E2231A;
    --trade-danger: #ef4444;
    --trade-notif-unread: rgba(255, 215, 0, 0.06);
}


/* ============================================
   LAYOUT — Main Container
   ============================================ */
.trade-hub {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: calc(var(--nav-height) + var(--space-md)) var(--space-md) var(--space-2xl);
    min-height: calc(100vh - 120px);
    position: relative;
}


/* ============================================
   TABS — Horizontal Tab Bar
   ============================================ */
.trade-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: var(--space-lg);
    padding: 6px;
    background: rgba(8, 8, 14, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow:
        0 6px 22px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 215, 0, 0.05) inset;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.trade-tabs::-webkit-scrollbar {
    display: none;
}

.trade-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.trade-tab:hover {
    color: var(--color-primary);
    background: rgba(255, 215, 0, 0.06);
}

.trade-tab:active {
    color: var(--color-primary);
}

.trade-tab.active {
    color: var(--color-primary);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 170, 40, 0.12));
    border-color: rgba(255, 215, 0, 0.38);
    box-shadow:
        0 0 0 1px rgba(255, 215, 0, 0.15) inset,
        0 4px 14px rgba(255, 215, 0, 0.2);
}

.trade-tab:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 10px;
}

.trade-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--trade-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
}

.trade-tab-content {
    display: none;
}

.trade-tab-content.active {
    display: block;
}


/* ============================================
   BUTTONS — All Trade Buttons
   ============================================ */
.trade-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast);
}

.trade-btn:active {
    opacity: 0.75;
}

.trade-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.trade-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.trade-btn-primary {
    background: var(--color-primary);
    color: var(--color-bg-darkest);
    border-color: var(--color-primary);
}

.trade-btn-primary:active {
    background: var(--color-primary-dark);
}

.trade-btn-danger {
    background: var(--trade-danger);
    color: #fff;
    border-color: var(--trade-danger);
}

.trade-btn-danger:active {
    background: #dc2626;
}

.trade-btn-secondary {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--color-text-secondary);
}

.trade-btn-secondary:active {
    background: rgba(255, 255, 255, 0.06);
}

.trade-btn-discord {
    background: var(--trade-discord);
    color: #fff;
    border-color: var(--trade-discord);
}

.trade-btn-discord:active {
    background: #4752c4;
}

.trade-btn-roblox {
    background: var(--trade-roblox);
    color: #fff;
    border-color: var(--trade-roblox);
}

.trade-btn-roblox:active {
    background: #c41d16;
}


/* ============================================
   TRADE CARDS
   ============================================ */

/* ============================================================================
   Admin Wheelspin Giveaway entrance card
   Pinned first in browse via rylb-trade sort. Animated gold→purple gradient
   border + pulsing glow + spinning wheel SVG. Same size as a regular card.
   ============================================================================ */
.trade-card-admin-event {
    position: relative;
    overflow: hidden;
    padding: 0 !important;
    background: linear-gradient(135deg, rgba(20, 18, 36, 0.96), rgba(40, 30, 60, 0.95)) !important;
    border: none !important;
    box-shadow: 0 0 22px rgba(168, 85, 247, 0.35), 0 0 38px rgba(255, 215, 0, 0.22) !important;
    animation: adminEventPulse 2.4s ease-in-out infinite;
    cursor: default;
}
@keyframes adminEventPulse {
    0%, 100% { box-shadow: 0 0 22px rgba(168, 85, 247, 0.35), 0 0 38px rgba(255, 215, 0, 0.22); }
    50%      { box-shadow: 0 0 32px rgba(168, 85, 247, 0.55), 0 0 54px rgba(255, 215, 0, 0.38); }
}
.trade-card-admin-event-border {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: conic-gradient(from var(--ae-angle, 0deg),
        #FFD700, #a855f7, #ff55c1, #FFD700, #a855f7, #FFD700);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    animation: adminEventSpin 6s linear infinite;
    pointer-events: none;
}
@property --ae-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes adminEventSpin { to { --ae-angle: 360deg; } }
.trade-card-admin-event-inner {
    position: relative;
    z-index: 1;
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.trade-card-admin-event-head {
    display: flex;
    align-items: center;
    gap: 12px;
}
.trade-card-admin-event-wheel {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
}
.trade-card-admin-event-wheel svg {
    width: 100%;
    height: 100%;
    animation: adminEventWheelSpin 4s linear infinite;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.5));
}
@keyframes adminEventWheelSpin { to { transform: rotate(360deg); } }
.trade-card-admin-event-titles {
    flex: 1;
    min-width: 0;
}
.trade-card-admin-event-label {
    font-size: 0.6rem;
    font-weight: 800;
    color: #FFD700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 2px;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
}
.trade-card-admin-event-name {
    font-size: 1.05rem;
    font-weight: 800;
    background: linear-gradient(90deg, #FFD700, #ff55c1, #a855f7, #FFD700);
    background-size: 200% 100%;
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
    animation: adminEventTitleShimmer 4s linear infinite;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@keyframes adminEventTitleShimmer { to { background-position: 200% 0; } }
.trade-card-admin-event-join {
    position: relative;
    display: block;
    margin-top: 4px;
    padding: 12px 16px;
    text-align: center;
    background: linear-gradient(135deg, #FFD700, #ff55c1);
    color: #1a0a2a;
    font-weight: 900;
    font-size: 0.92rem;
    letter-spacing: 0.05em;
    border-radius: 8px;
    text-decoration: none;
    transition: transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.4) inset, 0 6px 18px rgba(168, 85, 247, 0.5);
    overflow: hidden;
}
.trade-card-admin-event-join:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.6) inset, 0 8px 24px rgba(168, 85, 247, 0.75);
}
.trade-card-admin-event-join:active { transform: translateY(0); }
.trade-card-admin-event-join-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transform: translateX(-100%);
    animation: adminEventJoinSweep 2.6s ease-in-out infinite;
    pointer-events: none;
}
@keyframes adminEventJoinSweep {
    0% { transform: translateX(-100%); }
    60% { transform: translateX(100%); }
    100% { transform: translateX(100%); }
}
.trade-card-admin-event-disclaimer {
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 200, 200, 0.7);
    font-weight: 600;
    letter-spacing: 0.04em;
}

.trade-card {
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--trade-type-open);
    border-radius: var(--border-radius);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    transition: border-color var(--transition-fast);
    /* Skip rendering cards that are far off-screen — Browse can hold 50+
       cards in the DOM and painting them all every scroll frame stalls
       the compositor. `content-visibility: auto` lets Chrome defer paint
       for off-screen cards; `contain-intrinsic-size` reserves a placeholder
       height so the scrollbar doesn't jump as cards enter/leave viewport. */
    content-visibility: auto;
    contain-intrinsic-size: auto 380px;
}

/* Type-specific left border */
.trade-card[data-type="open"] { border-left-color: var(--trade-type-open); }
.trade-card[data-type="specific"] { border-left-color: var(--trade-type-specific); }
.trade-card[data-type="worth"] { border-left-color: var(--trade-type-worth); }
.trade-card[data-type="minishop"] { border-left-color: var(--trade-type-minishop); }

/* --- Card Header --- */
.trade-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    min-height: 44px;
}

.trade-card-header img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.trade-card-header-info {
    flex: 1;
    min-width: 0;
}

.trade-card-header-name {
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-primary);
}

.trade-card-header-sub {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.trade-card-header-level {
    font-weight: 600;
    color: var(--color-primary);
}

.trade-card-header-rep {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(255, 215, 0, 0.1);
    color: var(--color-primary);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

/* --- Card Badges --- */
/* Max 2 badges per row — grid lays them out in two fixed columns so any
   3rd/4th badge wraps cleanly to the next line instead of shrinking the
   existing two to fit. */
.trade-card-badges {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}
.trade-card-badges > * { min-width: 0; }

/* --- Card Type Badge --- */
.trade-card-type {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid currentColor;
}

.trade-card-type[data-type="open"] { color: var(--trade-type-open); }
.trade-card-type[data-type="specific"] { color: var(--trade-type-specific); }
.trade-card-type[data-type="worth"] { color: var(--trade-type-worth); }
.trade-card-type[data-type="minishop"] { color: var(--trade-type-minishop); }

/* --- Card Status Badge --- */
.trade-card-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trade-card-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.trade-card-status[data-status="open"] {
    color: var(--trade-status-open);
    background: rgba(74, 222, 128, 0.1);
}

.trade-card-status[data-status="inchat"] {
    color: var(--trade-type-specific);
    background: rgba(96, 165, 250, 0.1);
}

.trade-card-status[data-status="offered"] {
    color: var(--trade-type-worth);
    background: rgba(167, 139, 250, 0.1);
}

.trade-card-status[data-status="waiting"] {
    color: var(--trade-status-waiting);
    background: rgba(251, 191, 36, 0.1);
}

.trade-card-status[data-status="inprogress"] {
    color: var(--trade-status-inprogress);
    background: rgba(56, 189, 248, 0.1);
}

.trade-card-status[data-status="completed"] {
    color: var(--trade-status-completed);
    background: rgba(74, 222, 128, 0.1);
}

.trade-card-status[data-status="cancelled"] {
    color: var(--trade-status-cancelled);
    background: rgba(248, 113, 113, 0.1);
}

.trade-card-status[data-status="blocked"] {
    color: var(--trade-status-blocked);
    background: rgba(239, 68, 68, 0.1);
}

/* --- Card Items Grid --- */
.trade-card-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.trade-card-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-sm);
    background: var(--color-bg-dark);
    border-radius: var(--border-radius-sm);
    text-align: center;
}

.trade-card-item img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
}

.trade-card-item-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.2;
    word-break: break-word;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trade-card-item-mutation {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
}

.trade-card-item-mutation[data-mutation="candy"] { color: var(--mutation-candy); }
.trade-card-item-mutation[data-mutation="gold"] { color: var(--mutation-gold); }
.trade-card-item-mutation[data-mutation="diamond"] { color: var(--mutation-diamond); }
.trade-card-item-mutation[data-mutation="void"] { color: var(--mutation-void); }
.trade-card-item-mutation[data-mutation="normal"] { color: var(--mutation-normal); }

.trade-card-item-level {
    font-size: 0.6rem;
    color: var(--color-text-muted);
}

.trade-card-item-price {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* --- Card Actions --- */
.trade-card-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.trade-card-actions .trade-btn {
    flex: 1;
    min-width: 0;
}

/* --- Card Expand --- */
.trade-card-expand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    width: 100%;
    padding: var(--space-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.trade-card-expand:active {
    color: var(--color-primary);
    background: rgba(255, 215, 0, 0.06);
}

.trade-card-expand:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}


/* ============================================
   BRAINROT PICKER — Create Trade Modal
   ============================================ */
.brainrot-picker {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.brainrot-picker-search {
    width: 100%;
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.brainrot-picker-search:focus {
    border-color: var(--color-primary);
}

.brainrot-picker-search::placeholder {
    color: var(--color-text-muted);
}

.brainrot-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--space-sm);
    max-height: 320px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-xs);
}

.brainrot-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    padding: var(--space-sm);
    background: var(--color-bg-dark);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.brainrot-picker-item:active {
    background: rgba(255, 215, 0, 0.08);
}

.brainrot-picker-item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.brainrot-picker-item img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
}

.brainrot-picker-item span {
    font-size: 0.65rem;
    font-weight: 600;
    text-align: center;
    color: var(--color-text-secondary);
    line-height: 1.2;
    word-break: break-word;
}

.brainrot-picker-selected {
    border-color: var(--color-primary);
    background: rgba(255, 215, 0, 0.06);
}

.price-suggestion {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-style: italic;
    padding: var(--space-xs) 0;
}

.price-suggestion strong {
    color: var(--color-primary);
    font-style: normal;
}


/* Mutation overlay icon on trade-card-item brainrot tiles. High specificity
   so the generic `.trade-card-item img { width: 48px }` rule can't force
   the overlay to the full-size tile dimensions. */
.trade-card-item img.trade-card-item-mut,
.trade-create-item img.trade-card-item-mut {
    width: 12px;
    height: 12px;
    padding: 1px;
}


/* ============================================
   BROWSE FILTER — search button + modal
   ============================================ */
.trade-browse-filter-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(180deg, #2d8ef0 0%, #1a73d9 100%);
    color: #fff;
    border: 1px solid #1a73d9;
    border-radius: var(--border-radius-sm, 6px);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transition: background 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}
.trade-browse-filter-btn:hover {
    background: linear-gradient(180deg, #3ea0ff 0%, #2083e8 100%);
    box-shadow: 0 2px 6px rgba(42, 135, 232, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.trade-browse-filter-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.trade-browse-filter-btn-icon {
    flex-shrink: 0;
    color: #fff;
}
.trade-browse-filter-btn-label {
    white-space: nowrap;
}
.trade-browse-filter-btn-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #fff;
    color: #1a73d9;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}
.trade-browse-filter-btn--active {
    background: linear-gradient(180deg, #2083e8 0%, #0d5fc2 100%);
    border-color: #0d5fc2;
    box-shadow: 0 0 0 1px rgba(32, 131, 232, 0.35), 0 2px 6px rgba(32, 131, 232, 0.3);
}

/* My Trades tab pulse when an unverified MM approval is pending —
   converted from animated box-shadow (paint per frame) to opacity on a
   ::after pseudo with static box-shadow (GPU-composited, free). */
.trade-tab-mm-pending {
    position: relative;
}
.trade-tab-mm-pending::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.35);
    opacity: 0;
    pointer-events: none;
    animation: tradeMmPulseOpacity 1.6s ease-in-out infinite;
}
@keyframes tradeMmPulseOpacity {
    0%, 100% { opacity: 0; }
    50%      { opacity: 1; }
}

/* Shared blue button styling (alerts modal + anywhere else we want the same look) */
.trade-filter-btn-blue {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: linear-gradient(180deg, #2d8ef0 0%, #1a73d9 100%);
    color: #fff;
    border: 1px solid #1a73d9;
    border-radius: var(--border-radius-sm, 6px);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transition: background 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}
.trade-filter-btn-blue:hover {
    background: linear-gradient(180deg, #3ea0ff 0%, #2083e8 100%);
    box-shadow: 0 2px 6px rgba(42, 135, 232, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.trade-filter-btn-blue:active {
    transform: translateY(1px);
}

/* Modal shell */
.trade-filter-modal {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 300px;
}
.trade-filter-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
}
.trade-filter-tab {
    flex: 1;
    padding: 8px 10px;
    background: transparent;
    color: var(--color-text-muted, #999);
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.trade-filter-tab:hover {
    color: var(--color-text-primary, #fff);
    background: rgba(255, 255, 255, 0.04);
}
.trade-filter-tab.active {
    background: var(--color-primary, #ffd700);
    color: #1a1a1a;
}
.trade-filter-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}
.trade-filter-tab.active .trade-filter-tab-count {
    background: rgba(0, 0, 0, 0.25);
    color: #1a1a1a;
}

.trade-filter-tab-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Brainrots/Mutations tile grid */
.trade-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px;
    -webkit-overflow-scrolling: touch;
}
.trade-filter-grid--mutations {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.trade-filter-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 6px;
    background: var(--color-bg-dark, #151820);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--color-text-secondary, #c8c8d0);
    font-family: inherit;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
    -webkit-tap-highlight-color: transparent;
    border-left: 3px solid var(--tile-rarity, #444);
}
.trade-filter-tile:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-1px);
}
.trade-filter-tile img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px;
}
.trade-filter-tile-img-fallback {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
}
.trade-filter-tile-name {
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    color: var(--color-text-primary, #fff);
    word-break: break-word;
}
.trade-filter-tile--selected {
    border-color: var(--color-primary, #ffd700);
    background: rgba(255, 215, 0, 0.08);
    box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.35);
}
.trade-filter-tile-check {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary, #ffd700);
    color: #1a1a1a;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Rarity rows */
.trade-filter-grid--rarities {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px;
}
.trade-filter-rarity {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--color-bg-dark, #151820);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--rarity-color, #888);
    border-radius: 8px;
    color: var(--color-text-primary, #fff);
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.trade-filter-rarity:hover {
    background: rgba(255, 255, 255, 0.04);
}
.trade-filter-rarity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--rarity-color, #888);
    flex-shrink: 0;
    box-shadow: 0 0 6px var(--rarity-color, #888);
}
.trade-filter-rarity-name {
    flex: 1;
    font-weight: 600;
    color: var(--rarity-color, #fff);
}
.trade-filter-rarity-mult {
    font-size: 0.75rem;
    color: var(--color-text-muted, #999);
    font-weight: 600;
}
.trade-filter-rarity--selected {
    background: rgba(255, 215, 0, 0.06);
    border-color: var(--color-primary, #ffd700);
}
.trade-filter-rarity-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary, #ffd700);
    color: #1a1a1a;
    font-size: 0.78rem;
    font-weight: 700;
}

.trade-filter-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--color-text-muted, #999);
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.trade-filter-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.trade-filter-footer-right {
    display: flex;
    gap: 6px;
}

.trade-browse-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}
.trade-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 5px;
    border-radius: 14px;
    background: #2196F3;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}


/* ============================================
   CHAT PANEL
   ============================================ */
.trade-chat {
    display: flex;
    flex-direction: column;
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* Mobile: full-screen overlay */
.trade-chat-mobile {
    position: fixed;
    inset: 0;
    z-index: 1500;
    border-radius: 0;
    border: none;
}

/* Desktop: side panel (applied via media query below) */
.trade-chat-desktop {
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: 0;
    width: 400px;
    z-index: 1200;
    border-radius: 0;
    border-left: 1px solid rgba(255, 215, 0, 0.1);
    border-top: none;
    border-bottom: none;
    border-right: none;
}

/* --- Chat Header --- */
.trade-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    min-height: 56px;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.trade-chat-header-info {
    flex: 1;
    min-width: 0;
}

.trade-chat-header-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trade-chat-header-status {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.trade-chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.4rem;
    color: var(--color-text-secondary);
    background: rgba(255, 255, 255, 0.06);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition-fast);
}

.trade-chat-close:active {
    background: rgba(255, 255, 255, 0.12);
}

.trade-chat-close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* --- Chat Messages --- */
.trade-chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.trade-chat-message {
    max-width: 85%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
    background: var(--color-bg-dark);
    color: var(--color-text-primary);
    align-self: flex-start;
}

.trade-chat-message-meta {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.trade-chat-message-own {
    align-self: flex-end;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.15);
}

.trade-chat-message-system {
    align-self: center;
    max-width: 100%;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-style: italic;
    text-align: center;
    padding: var(--space-xs) var(--space-sm);
}

/* --- Chat Input --- */
.trade-chat-input {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-dark);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.trade-chat-input input,
.trade-chat-input textarea {
    flex: 1;
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    resize: none;
    transition: border-color var(--transition-fast);
}

.trade-chat-input input:focus,
.trade-chat-input textarea:focus {
    border-color: var(--color-primary);
}

.trade-chat-input input::placeholder,
.trade-chat-input textarea::placeholder {
    color: var(--color-text-muted);
}

.trade-chat-input .trade-btn {
    flex-shrink: 0;
}

/* --- Chat Readonly --- */
.trade-chat-readonly .trade-chat-input {
    opacity: 0.5;
    pointer-events: none;
}

.trade-chat-readonly .trade-chat-input::after {
    content: 'Chat ended';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.trade-chat-readonly .trade-chat-input {
    position: relative;
}


/* ============================================
   PROFILE POPUP
   ============================================ */
.trade-profile-popup {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: fadeIn 0.2s ease;
}

.trade-profile-popup-inner {
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--color-bg-card);
    border-top: 2px solid var(--color-primary);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    padding: var(--space-lg);
    animation: slideUp 0.25s ease;
}

/* --- Profile Header --- */
.trade-profile-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.trade-profile-header img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 215, 0, 0.3);
}

.trade-profile-header-info {
    flex: 1;
    min-width: 0;
}

.trade-profile-header-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text-primary);
}

.trade-profile-header-sub {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* --- Profile Stats --- */
.trade-profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.trade-profile-stat {
    text-align: center;
    padding: var(--space-sm);
    background: var(--color-bg-dark);
    border-radius: var(--border-radius-sm);
}

.trade-profile-stat-value {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--color-primary);
    line-height: 1.2;
}

.trade-profile-stat-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* --- Profile Badges --- */
.trade-profile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

/* --- Profile Actions --- */
.trade-profile-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.trade-profile-actions .trade-btn {
    flex: 1;
    min-width: 0;
}


/* ============================================
   NOTIFICATIONS
   ============================================ */
.trade-notif-card {
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--color-text-muted);
    border-radius: var(--border-radius);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    transition: background var(--transition-fast);
}

/* Notification type borders */
.trade-notif-card[data-type="offer"] { border-left-color: var(--trade-type-specific); }
.trade-notif-card[data-type="accepted"] { border-left-color: var(--trade-status-completed); }
.trade-notif-card[data-type="rejected"] { border-left-color: var(--trade-status-cancelled); }
.trade-notif-card[data-type="counter"] { border-left-color: var(--trade-type-worth); }
.trade-notif-card[data-type="chat"] { border-left-color: var(--trade-status-inprogress); }
.trade-notif-card[data-type="system"] { border-left-color: var(--color-text-muted); }

.trade-notif-unread {
    background: var(--trade-notif-unread);
}

.trade-notif-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.trade-notif-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-text-primary);
    flex: 1;
}

.trade-notif-time {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.trade-notif-body {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-sm);
}

.trade-notif-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.trade-notif-actions .trade-btn {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
}


/* ============================================
   USER CARDS — Middlemen & Traders
   ============================================ */
.trade-user-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-sm);
    min-height: 64px;
}

.trade-user-card img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.trade-user-info {
    flex: 1;
    min-width: 0;
}

.trade-user-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.trade-user-sub {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Online/offline dot */
.trade-user-online,
.trade-user-offline {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.trade-user-online {
    background: var(--trade-type-open);
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.trade-user-offline {
    background: var(--color-text-muted);
}

/* Verified / Unverified badge */
.trade-user-verified,
.trade-user-unverified {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.trade-user-verified {
    background: rgba(96, 165, 250, 0.12);
    color: var(--trade-type-specific);
    border: 1px solid rgba(96, 165, 250, 0.25);
}

.trade-user-unverified {
    background: rgba(239, 68, 68, 0.12);
    color: var(--trade-danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Reputation score */
.trade-user-rep {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: var(--space-xs) var(--space-sm);
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
}

.trade-user-rep-value {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--color-primary);
    line-height: 1;
}

.trade-user-rep-label {
    font-size: 0.55rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Favorite star */
.trade-user-star {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    color: var(--color-text-muted);
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition-fast);
}

.trade-user-star:active {
    color: var(--color-primary);
}

.trade-user-star:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.trade-user-star.active {
    color: var(--color-primary);
}


/* ============================================
   LEADERBOARD
   ============================================ */
.trade-leaderboard {
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: var(--space-lg);
}

.trade-leaderboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 215, 0, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.trade-leaderboard-header h3 {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text-primary);
}

.trade-leaderboard-toggle {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
}

.trade-leaderboard.collapsed .trade-leaderboard-toggle {
    transform: rotate(180deg);
}

.trade-leaderboard-body {
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.trade-leaderboard.collapsed .trade-leaderboard-body {
    display: none;
}

.trade-leaderboard-entry {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    min-height: 44px;
}

.trade-leaderboard-entry:last-child {
    border-bottom: none;
}

.trade-leaderboard-rank {
    min-width: 28px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-align: center;
    flex-shrink: 0;
}

/* Gold ranks for top 3 */
.trade-leaderboard-entry:nth-child(1) .trade-leaderboard-rank {
    color: #FFD700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.trade-leaderboard-entry:nth-child(2) .trade-leaderboard-rank {
    color: #C0C0C0;
    text-shadow: 0 0 6px rgba(192, 192, 192, 0.3);
}

.trade-leaderboard-entry:nth-child(3) .trade-leaderboard-rank {
    color: #CD7F32;
    text-shadow: 0 0 6px rgba(205, 127, 50, 0.3);
}

.trade-leaderboard-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trade-leaderboard-score {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-primary);
    white-space: nowrap;
    flex-shrink: 0;
}


/* ============================================
   FILTER BAR — Trade Filters
   ============================================ */
.trade-filter-bar {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    background: var(--color-bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--border-radius);
}

.trade-filter-bar::-webkit-scrollbar {
    display: none;
}

.trade-filter-input {
    min-height: 44px;
    min-width: 180px;
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast);
}

.trade-filter-input:focus {
    border-color: var(--color-primary);
}

.trade-filter-input::placeholder {
    color: var(--color-text-muted);
}

.trade-filter-select {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    padding-right: calc(var(--space-md) + 12px);
    background: var(--color-bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666680' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--transition-fast);
}

.trade-filter-select:focus {
    border-color: var(--color-primary);
}

.trade-filter-select option {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

.trade-filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--color-text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.trade-filter-toggle:active {
    background: rgba(255, 215, 0, 0.08);
}

.trade-filter-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.trade-filter-toggle.active {
    color: var(--color-primary);
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--color-primary);
}


/* ============================================
   MODALS — Trade Modals
   ============================================ */
/* Modal styles handled by injected CSS in pages-trade.js */
/* .trade-modal-overlay = fixed overlay backdrop */
/* .trade-modal = centered card content */

.trade-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.trade-modal-header h2 {
    font-size: 1.1rem;
    font-family: var(--font-primary);
    font-weight: 700;
    color: var(--color-text-primary);
}

.trade-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    background: rgba(255, 255, 255, 0.06);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition-fast);
    /* Guarantees click always lands on this button regardless of async
       image loads or scrollbar shifts happening in the modal body. */
    position: relative;
    z-index: 2;
}

.trade-modal-close:active {
    background: rgba(255, 255, 255, 0.12);
}

.trade-modal-close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.trade-modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-lg);
    /* Reserve scrollbar space on load so when async content (avatars, rep
       history) arrives and the scrollbar appears, the content width doesn't
       shift — previously the first X click would land during that shift
       and miss the target, requiring a second click. */
    scrollbar-gutter: stable;
}

.trade-modal-footer {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.trade-modal-footer .trade-btn {
    flex: 1;
}


/* ============================================
   AUTH SECTION
   ============================================ */
.trade-auth {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    min-height: 50vh;
}

.trade-auth h2 {
    font-family: var(--font-display);
    color: var(--color-primary);
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

.trade-auth p {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    max-width: 400px;
}

.trade-auth-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
    max-width: 300px;
}

.trade-auth-buttons .trade-btn {
    width: 100%;
}

.trade-auth-incomplete {
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: var(--border-radius);
    padding: var(--space-lg);
    text-align: center;
    margin-bottom: var(--space-lg);
}

.trade-auth-incomplete p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
}

.trade-auth-incomplete strong {
    color: var(--color-primary);
}


/* ============================================
   BADGE ICONS
   ============================================ */
.trade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.trade-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.trade-badge-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

/* Larger badges on profile */
.trade-profile-badges .trade-badge {
    width: 32px;
    height: 32px;
}

.trade-profile-badges .trade-badge-row {
    gap: var(--space-sm);
}


/* ============================================
   EMPTY & LOADING STATES
   ============================================ */
.trade-empty {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--color-text-muted);
}

.trade-empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.3;
}

.trade-empty-text {
    font-size: 0.95rem;
    margin-bottom: var(--space-md);
}

.trade-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
}

.trade-loading::after {
    content: '';
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 215, 0, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: var(--space-sm);
}


/* ============================================
   RESPONSIVE — 768px+ (Tablet)
   ============================================ */
@media (min-width: 768px) {
    .trade-hub {
        padding: calc(var(--nav-height) + var(--space-xl)) var(--space-lg) var(--space-2xl);
    }

    /* Tabs: no scroll needed, bigger tap targets */
    .trade-tab {
        padding: var(--space-sm) var(--space-lg);
        font-size: 0.9rem;
    }

    /* Trade cards: two columns */
    .trade-cards-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }

    .trade-cards-grid .trade-card {
        margin-bottom: 0;
    }

    /* Card items: slightly larger */
    .trade-card-items {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }

    /* Filter bar: flex wrap instead of scroll */
    .trade-filter-bar {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    /* Brainrot picker grid: bigger items */
    .brainrot-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        max-height: 400px;
    }

    /* Modal: handled by injected CSS */

    /* Profile popup: centered card */
    .trade-profile-popup {
        align-items: center;
        padding: var(--space-lg);
    }

    .trade-profile-popup-inner {
        max-width: 480px;
        border-radius: var(--border-radius);
        border-top: none;
        border: 1px solid rgba(255, 215, 0, 0.15);
    }

    /* Profile stats: 4 columns when space allows */
    .trade-profile-stats {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Notification actions: no wrap */
    .trade-notif-actions {
        flex-wrap: nowrap;
    }

    /* User cards: side by side layout */
    .trade-users-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }

    .trade-users-grid .trade-user-card {
        margin-bottom: 0;
    }

    /* Leaderboard entries: more space */
    .trade-leaderboard-entry {
        padding: var(--space-sm) var(--space-lg);
    }
}


/* ============================================
   RESPONSIVE — 1024px+ (Desktop)
   ============================================ */
@media (min-width: 1024px) {
    /* Trade cards: three columns */
    .trade-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Chat: use side panel layout, shift main content */
    .trade-hub.chat-open {
        padding-right: calc(400px + var(--space-lg));
    }

    /* Chat as side panel on desktop */
    .trade-chat-mobile {
        position: fixed;
        top: var(--nav-height);
        right: 0;
        bottom: 0;
        left: auto;
        width: 400px;
        border-radius: 0;
        border-left: 1px solid rgba(255, 215, 0, 0.1);
    }

    /* Modal: wider */
    .trade-modal-inner {
        max-width: 700px;
    }

    /* Brainrot picker: more columns */
    .brainrot-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        max-height: 450px;
    }

    /* User cards: three columns */
    .trade-users-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* ============================================
   RESPONSIVE — 1400px+ (Wide Desktop)
   ============================================ */
@media (min-width: 1400px) {
    .trade-hub {
        max-width: var(--max-width);
    }

    /* Trade cards: can fit more */
    .trade-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* User cards: four columns */
    .trade-users-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .trade-modal,
    .trade-modal-inner,
    .trade-profile-popup,
    .trade-profile-popup-inner {
        animation: none;
    }
}

/* ===========================================================
   Unified Leaderboard modal + top-left FAB button
   =========================================================== */
.trade-lb-fab {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 8;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 10px;
    border: 1px solid rgba(255, 215, 0, 0.45);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 140, 0, 0.08) 60%, rgba(0, 0, 0, 0.25));
    color: #FFD700;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(255, 180, 0, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: transform 120ms ease, box-shadow 120ms ease, background 200ms ease;
}
.trade-lb-fab:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 180, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.28), rgba(255, 140, 0, 0.14) 60%, rgba(0, 0, 0, 0.25));
}
.trade-lb-fab-icon { font-size: 1.05rem; line-height: 1; filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.45)); }
.trade-lb-fab-label { letter-spacing: 0.2px; }

@media (max-width: 480px) {
    .trade-lb-fab-label { display: none; }
    .trade-lb-fab { padding: 6px 10px; }
}

.trade-lb-modal { min-width: 320px; }

.trade-lb-hero {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.14), rgba(255, 140, 0, 0.06) 60%, rgba(0, 0, 0, 0.3));
    border: 1px solid rgba(255, 215, 0, 0.28);
    border-radius: 12px;
    margin-bottom: 12px;
}
.trade-lb-hero-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.55));
    flex-shrink: 0;
}
.trade-lb-hero-title { font-size: 1.15rem; font-weight: 800; color: #FFD700; letter-spacing: 0.3px; }
.trade-lb-hero-sub { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 2px; }

.trade-lb-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}
.trade-lb-tab {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 150ms ease, color 150ms ease;
}
.trade-lb-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.04); }
.trade-lb-tab-active {
    background: linear-gradient(135deg, rgba(88, 101, 242, 0.3), rgba(88, 101, 242, 0.12));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(88, 101, 242, 0.4);
}
.trade-lb-tab-icon { font-size: 0.9rem; }

.trade-lb-periods {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding: 3px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}
.trade-lb-period {
    flex: 1;
    padding: 5px 8px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}
.trade-lb-period:hover { color: #fff; }
.trade-lb-period-active {
    background: rgba(255, 255, 255, 0.08);
    color: #FFD700;
    box-shadow: inset 0 0 0 1px rgba(255, 215, 0, 0.25);
}

.trade-lb-empty, .trade-lb-error {
    padding: 32px 16px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}
.trade-lb-error { color: #f44336; }

/* Podium (top 3) — 2nd | 1st | 3rd */
.trade-lb-podium {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: 8px;
    align-items: end;
    padding: 16px 6px 10px;
    margin-bottom: 12px;
}
.trade-lb-podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.25));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease;
    position: relative;
}
.trade-lb-podium-slot:hover { transform: translateY(-2px); }
.trade-lb-podium-1 {
    border-color: rgba(255, 215, 0, 0.55);
    background: linear-gradient(180deg, rgba(255, 215, 0, 0.14), rgba(255, 140, 0, 0.06) 60%, rgba(0, 0, 0, 0.3));
    padding-top: 22px;
    box-shadow: 0 6px 22px rgba(255, 180, 0, 0.22);
}
.trade-lb-podium-2 {
    border-color: rgba(192, 192, 192, 0.5);
    background: linear-gradient(180deg, rgba(192, 192, 192, 0.14), rgba(0, 0, 0, 0.3));
}
.trade-lb-podium-3 {
    border-color: rgba(205, 127, 50, 0.5);
    background: linear-gradient(180deg, rgba(205, 127, 50, 0.14), rgba(0, 0, 0, 0.3));
}
.trade-lb-podium-medal { font-size: 1.6rem; line-height: 1; filter: drop-shadow(0 0 6px currentColor); }
.trade-lb-podium-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
}
.trade-lb-podium-1 .trade-lb-podium-avatar { border-color: #FFD700; width: 68px; height: 68px; }
.trade-lb-podium-2 .trade-lb-podium-avatar { border-color: #C0C0C0; }
.trade-lb-podium-3 .trade-lb-podium-avatar { border-color: #CD7F32; }
.trade-lb-podium-name {
    font-weight: 700;
    font-size: 0.82rem;
    text-align: center;
    line-height: 1.2;
    color: #fff;
    word-break: break-word;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    justify-content: center;
    flex-wrap: wrap;
}
.trade-lb-podium-stat { font-size: 0.75rem; color: var(--color-text-muted); }
.trade-lb-podium-stat-big { font-size: 1.1rem; font-weight: 700; color: #fff; }
.trade-lb-podium-rep { font-size: 0.7rem; font-weight: 600; }

/* Rest of the list (ranks 4+) */
.trade-lb-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 2px;
}
.trade-lb-row {
    display: grid;
    grid-template-columns: 38px 34px 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    cursor: pointer;
    transition: background 120ms ease;
}
.trade-lb-row:hover { background: rgba(255, 255, 255, 0.06); }
.trade-lb-row-rank { font-weight: 700; font-size: 0.82rem; color: var(--color-text-muted); }
.trade-lb-row-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: rgba(0, 0, 0, 0.3); }
.trade-lb-row-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.trade-lb-row-rep { font-size: 0.75rem; font-weight: 700; min-width: 38px; text-align: right; }
.trade-lb-row-stat { font-size: 0.78rem; font-weight: 600; color: var(--color-text-muted); min-width: 42px; text-align: right; }

.trade-lb-verified {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4CAF50;
    color: #000;
    font-size: 0.55rem;
    font-weight: 700;
    flex-shrink: 0;
}
