/* ================================================================
   MOBILE-ONLY STYLES (< 768px)
   Optimized for performance, compact layout, and UX
   ================================================================ */

@media (max-width: 768px) {
    /* ===== BASE MOBILE RESETS ===== */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    body {
        font-size: 15px;
        line-height: 1.6;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }

    /* Noise texture overlay removed for cleaner mobile rendering */

    /* ===== COMPACT HEADER (48px height) ===== */
    header {
        padding: 0 !important;
        min-height: 48px;
    }

    header .container {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    header h1 {
        font-size: 1rem !important;
        line-height: 1.3 !important;
        letter-spacing: -0.01em;
    }

    header .w-10.h-10 {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }

    header .w-10.h-10 i {
        font-size: 0.75rem !important;
    }

    /* ===== MAIN CONTENT SPACING ===== */
    main {
        padding: 0.5rem 0 !important;
    }

    section.mb-8 {
        margin-bottom: 0.5rem !important;
    }

    section h2 {
        font-size: 1.1rem !important;
        margin-bottom: 0.25rem !important;
    }

    /* ===== COMPACT COUNT BAR ===== */
    .flex.justify-between.items-center.mb-4 {
        flex-direction: column !important;
        gap: 0.25rem !important;
        margin-bottom: 0.3rem !important;
    }

    .flex.justify-between.items-center.mb-4 .text-sm {
        font-size: 0.78rem !important;
        color: rgba(248, 250, 252, 0.55) !important;
    }

    .flex.justify-between.items-center.mb-4 > div:last-child {
        display: none !important;
    }

    /* ===== STICKY FILTER BUTTON BAR ===== */
    .flex.flex-col.md\:flex-row.justify-between {
        gap: 0.4rem !important;
        background: rgba(10, 10, 18, 0.7);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-radius: 0.75rem;
        padding: 0.5rem 0.75rem;
        margin: 0 0 0.5rem 0;
    }

    #toggleFilters {
        min-height: 40px !important;
        font-size: 0.78rem !important;
        padding: 0 1rem !important;
        border-radius: 2rem !important;
        background: rgba(139, 92, 246, 0.15) !important;
        border: 1px solid rgba(139, 92, 246, 0.4) !important;
        color: #c4b5fd !important;
        transition: all 0.15s ease;
        position: relative;
    }

    #toggleFilters:active {
        transform: scale(0.95);
        background: rgba(139, 92, 246, 0.3) !important;
    }

    /* Filter count badge */
    #filterCountBadge {
        position: absolute;
        top: -6px;
        right: -6px;
        min-width: 18px;
        height: 18px;
        border-radius: 9px;
        background: linear-gradient(135deg, #8b5cf6, #3b82f6);
        color: white;
        font-size: 0.6rem;
        font-weight: 700;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
        animation: badgePop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    #filterCountBadge.visible {
        display: flex;
    }

    @keyframes badgePop {
        0% { transform: scale(0); }
        60% { transform: scale(1.2); }
        100% { transform: scale(1); }
    }

    /* ===== FORCE GRID ONLY (hide table) ===== */
    #tableView, #tableViewBtn, #gridViewBtn {
        display: none !important;
    }

    #gridView {
        display: block !important;
    }

    /* ===== 2-COLUMN GRID LAYOUT ===== */
    #itemsGrid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.45rem !important;
        padding: 0 !important;
    }

    /* ===== HOLOGRAPHIC GRID CARDS ===== */
    .skeleton-card, #itemsGrid > div.bg-wlDark {
        padding: 0.4rem !important;
    }

    #itemsGrid > div.item-card {
        position: relative;
        padding: 0 !important;
        border-radius: 0.75rem !important;
        overflow: hidden !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
        background: #0d0d14 !important;
        backdrop-filter: blur(20px) saturate(1.8);
        -webkit-backdrop-filter: blur(20px) saturate(1.8);
        box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
        transition: transform 0.1s ease-out, box-shadow 0.2s ease, border-color 0.2s ease;
        will-change: transform;
        contain: layout style paint;
        content-visibility: auto;
        contain-intrinsic-size: 120px;
    }

    /* Rarity shimmer animation */
    #itemsGrid > div.item-card::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: linear-gradient(105deg, transparent 30%, rgba(139,92,246,0.08) 45%, rgba(139,92,246,0.15) 50%, rgba(139,92,246,0.08) 55%, transparent 70%);
        background-size: 200% 100%;
        animation: shimmerSweep 3s ease-in-out infinite;
        pointer-events: none;
        z-index: 1;
    }

    @keyframes shimmerSweep {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }

    /* Image halo with rarity glow */
    #itemsGrid > div.item-card::after {
        content: '';
        position: absolute;
        top: 0.35rem;
        left: 0.35rem;
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 0.45rem;
        z-index: 0;
        filter: blur(8px);
        opacity: 0.4;
    }

    #itemsGrid > div.item-card.rar-common::after { background: rgba(148,163,184,0.3); }
    #itemsGrid > div.item-card.rar-uncommon::after { background: rgba(16,185,129,0.4); }
    #itemsGrid > div.item-card.rar-rare::after { background: rgba(59,130,246,0.5); }
    #itemsGrid > div.item-card.rar-epic::after { background: rgba(139,92,246,0.5); }
    #itemsGrid > div.item-card.rar-legendary::after { 
        background: rgba(245,158,11,0.6); 
        animation: legendaryPulse 2s ease-in-out infinite; 
    }

    @keyframes legendaryPulse {
        0%, 100% { opacity: 0.4; transform: scale(1); }
        50% { opacity: 0.7; transform: scale(1.15); }
    }

    /* Card tap feedback */
    #itemsGrid > div.item-card:active {
        transform: scale(0.96) !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
    }

    /* Rarity neon glows */
    #itemsGrid > div.item-card.rar-common  { 
        box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 12px rgba(148,163,184,0.08); 
        border-color: rgba(148,163,184,0.15) !important; 
    }
    #itemsGrid > div.item-card.rar-uncommon { 
        box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 12px rgba(16,185,129,0.1); 
        border-color: rgba(16,185,129,0.25) !important; 
    }
    #itemsGrid > div.item-card.rar-rare { 
        box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 12px rgba(59,130,246,0.12); 
        border-color: rgba(59,130,246,0.3) !important; 
    }
    #itemsGrid > div.item-card.rar-epic { 
        box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 16px rgba(139,92,246,0.15); 
        border-color: rgba(139,92,246,0.35) !important; 
    }
    #itemsGrid > div.item-card.rar-legendary { 
        box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 20px rgba(245,158,11,0.18); 
        border-color: rgba(245,158,11,0.4) !important; 
    }

    /* Card inner layout */
    #itemsGrid > div.item-card > .flex.items-start {
        position: relative;
        padding: 0.5rem 0.45rem 0.25rem;
        margin: 0 !important;
        z-index: 2;
    }

    #itemsGrid > div.item-card > .flex.items-start > img:first-child,
    #itemsGrid > div.item-card .w-16.h-16 {
        width: 2.5rem !important;
        height: 2.5rem !important;
        border-radius: 0.45rem !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.4);
        margin-right: 0.35rem !important;
        position: relative;
        z-index: 2;
        background: rgba(10,10,18,0.6);
    }

    /* Card text area */
    #itemsGrid > div.item-card h4 {
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        line-height: 1.3 !important;
        margin-bottom: 0.15rem !important;
        color: #f8fafc !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 6rem;
        letter-spacing: -0.01em;
    }

    #itemsGrid > div.item-card .text-xs.text-wlLight.text-opacity-70,
    #itemsGrid > div.item-card .flex.items-center.text-xs {
        font-size: 0.65rem !important;
        color: rgba(248,250,252,0.5) !important;
        margin-bottom: 0.15rem;
    }

    /* Stat chips */
    #itemsGrid > div.item-card .grid.grid-cols-2 {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.2rem !important;
        padding: 0 0.4rem !important;
        margin: 0 0 0.2rem 0 !important;
    }

    #itemsGrid > div.item-card .grid.grid-cols-2 > div {
        background: rgba(139, 92, 246, 0.08) !important;
        border: 1px solid rgba(139, 92, 246, 0.12);
        border-radius: 0.3rem !important;
        padding: 0.18rem 0.35rem !important;
        font-size: 0.62rem !important;
        color: rgba(196, 181, 253, 0.8) !important;
    }

    /* View Details capsule button */
    #itemsGrid > div.item-card > button {
        width: calc(100% - 0.8rem) !important;
        margin: 0 0.4rem 0.4rem !important;
        border-radius: 2rem !important;
        font-size: 0.7rem !important;
        font-weight: 500;
        padding: 0.4rem 0 !important;
        letter-spacing: 0.01em;
        text-align: center;
        background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(59,130,246,0.12)) !important;
        border: 1px solid rgba(139,92,246,0.25) !important;
        color: #c4b5fd !important;
        transition: all 0.15s ease;
        position: relative;
        overflow: hidden;
        z-index: 2;
    }

    #itemsGrid > div.item-card > button:active {
        transform: scale(0.96);
        border-color: rgba(139,92,246,0.5) !important;
        color: #fff !important;
    }

    /* ===== CARD ENTRANCE ANIMATION ===== */
    @keyframes cardUp {
        from { opacity: 0; transform: translateY(16px); }
        to { opacity: 1; transform: translateY(0); }
    }

    #itemsGrid > div.item-card {
        animation: cardUp 0.35s ease both;
    }

    /* Staggered entrance */
    #itemsGrid > div.item-card:nth-child(1) { animation-delay: 0.02s; }
    #itemsGrid > div.item-card:nth-child(2) { animation-delay: 0.04s; }
    #itemsGrid > div.item-card:nth-child(3) { animation-delay: 0.06s; }
    #itemsGrid > div.item-card:nth-child(4) { animation-delay: 0.08s; }
    #itemsGrid > div.item-card:nth-child(5) { animation-delay: 0.10s; }
    #itemsGrid > div.item-card:nth-child(6) { animation-delay: 0.12s; }
    #itemsGrid > div.item-card:nth-child(7) { animation-delay: 0.14s; }
    #itemsGrid > div.item-card:nth-child(8) { animation-delay: 0.16s; }

    /* ===== LEGENDARY GLOW ANIMATION ===== */
    @keyframes legendaryGlow {
        0%, 100% { 
            box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 20px rgba(245,158,11,0.18), 0 0 4px rgba(245,158,11,0.1); 
        }
        50% { 
            box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 28px rgba(245,158,11,0.3), 0 0 10px rgba(245,158,11,0.15); 
        }
    }

    #itemsGrid > div.item-card.rar-legendary {
        animation: legendaryGlow 3s ease-in-out infinite, cardUp 0.35s ease both !important;
    }

    /* ===== COMPACT QUICK STATS (single line) ===== */
    #quickStats {
        border-radius: 0.5rem !important;
        padding: 0.5rem 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }

    #quickStats h3 {
        display: none !important;
    }

    #quickStats .grid {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        justify-content: center !important;
    }

    #quickStats .grid > div {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.25rem !important;
        padding: 0.25rem 0.5rem !important;
        background: rgba(139, 92, 246, 0.08) !important;
        border-radius: 1rem !important;
        border: 1px solid rgba(139, 92, 246, 0.15) !important;
    }

    #quickStats .text-3xl {
        font-size: 0.9rem !important;
        margin-bottom: 0 !important;
    }

    #quickStats .text-sm {
        font-size: 0.68rem !important;
    }

    /* ===== MINIMAL FOOTER ===== */
    footer {
        padding: 1rem 0 !important;
    }

    footer .container > .grid {
        display: block !important;
        text-align: center !important;
        margin-bottom: 0 !important;
    }

    footer .container > .grid > div {
        display: none !important;
    }

    footer .container > .grid > div:first-child {
        display: block !important;
    }

    footer .pt-6 {
        padding-top: 0.5rem !important;
    }

    footer .pt-6 p {
        font-size: 0.65rem !important;
    }

    footer .flex.space-x-4 {
        justify-content: center !important;
        margin-top: 0.5rem !important;
    }

    footer .flex.space-x-4 a {
        width: 2rem !important;
        height: 2rem !important;
    }

    footer h4,
    footer .mb-4,
    footer .space-y-2,
    footer .flex > input,
    footer .flex > button {
        display: none !important;
    }

    /* ===== MOBILE FILTER BOTTOM SHEET ===== */
    #filtersDropdown.filter-dropdown {
        margin-bottom: 0 !important;
        pointer-events: none;
        max-height: 0 !important;
        overflow: hidden !important;
        opacity: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    #mobileFilterSheet {
        position: fixed;
        left: 0; 
        right: 0;
        bottom: 0;
        z-index: 2000;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        display: block;
        pointer-events: none;
    }

    #mobileFilterSheet.open {
        transform: translateY(0);
        pointer-events: auto;
    }

    #mobileFilterSheet.dragging {
        transition: none !important;
    }

    #mobileFilterSheet * {
        pointer-events: auto;
    }

    #mobileFilterSheet .sheet-inner {
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 1.5rem 1.5rem 0 0;
        background: linear-gradient(180deg, rgba(20, 20, 35, 0.98) 0%, rgba(13, 13, 20, 0.99) 100%);
        border: 1px solid rgba(139, 92, 246, 0.1);
        border-bottom: none;
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
    }

    /* Drag handle */
    #mobileFilterSheet .sheet-handle {
        width: 2.5rem;
        height: 0.3rem;
        background: rgba(255,255,255,0.25);
        border-radius: 0.15rem;
        margin: 0.6rem auto 0;
        cursor: grab;
        transition: width 0.2s, background 0.2s;
    }

    #mobileFilterSheet .sheet-handle:active {
        width: 3rem;
        background: rgba(139,92,246,0.4);
    }

    /* Sheet header */
    #mobileFilterSheet .sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.85rem 1rem 0.65rem;
        border-bottom: 1px solid rgba(139, 92, 246, 0.1);
    }

    #mobileFilterSheet .sheet-header h3 {
        font-size: 1.05rem;
        font-weight: 700;
        color: #f8fafc;
        letter-spacing: -0.01em;
    }

    #mobileFilterSheet .sheet-close {
        width: 2.25rem; 
        height: 2.25rem;
        border-radius: 0.6rem;
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.08);
        color: #94a3b8;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.15s;
    }

    #mobileFilterSheet .sheet-close:active {
        transform: scale(0.9);
        background: rgba(239,68,68,0.15);
        border-color: rgba(239,68,68,0.2);
        color: #f87171;
    }

    /* Active filter chips */
    #mobileFilterSheet .active-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        padding: 0.5rem 1rem;
    }

    #mobileFilterSheet .active-chip {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
        border-radius: 1rem;
        background: rgba(139,92,246,0.2);
        border: 1px solid rgba(139,92,246,0.4);
        color: #c4b5fd;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        animation: chipIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes chipIn {
        from { opacity: 0; transform: scale(0.8) translateY(4px); }
        to { opacity: 1; transform: scale(1) translateY(0); }
    }

    #mobileFilterSheet .active-chip .chip-x {
        width: 1rem; 
        height: 1rem;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(239,68,68,0.2);
        font-size: 0.55rem;
        cursor: pointer;
    }

    /* Collapsible filter sections */
    #mobileFilterSheet .filter-section {
        padding: 0;
        margin-bottom: 0;
    }

    .filter-section-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s;
        border-bottom: 1px solid rgba(255,255,255,0.04);
    }

    .filter-section-header:active {
        background: rgba(139, 92, 246, 0.06);
    }

    .filter-section-header .section-title {
        font-size: 0.78rem;
        font-weight: 600;
        color: rgba(248,250,252,0.7);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .filter-section-header .section-title .chevron {
        font-size: 0.55rem;
        width: 1rem;
        height: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.3rem;
        background: rgba(255,255,255,0.05);
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                    background 0.2s ease,
                    color 0.2s ease;
        color: rgba(248,250,252,0.35);
    }

    .filter-section.expanded .filter-section-header .section-title .chevron {
        transform: rotate(180deg);
        background: rgba(139, 92, 246, 0.2);
        color: #c4b5fd;
    }

    /* Expanded section gets a subtle top highlight */
    .filter-section.expanded .filter-section-header {
        border-bottom-color: rgba(139, 92, 246, 0.08);
    }

    .filter-section-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .filter-section.expanded .filter-section-content {
        max-height: 400px;
    }

    .filter-section-content-inner {
        padding: 0 1rem 0.65rem;
    }

    /* ===== FILTER FORM CONTROLS — POLISHED ===== */

    /* Shared input/select base */
    #mobileFilterSheet input[type="text"],
    #mobileFilterSheet input[type="number"],
    #mobileFilterSheet select {
        width: 100%;
        min-height: 44px;
        padding: 0.65rem 0.85rem;
        font-size: 0.85rem;
        font-weight: 400;
        font-family: 'Poppins', sans-serif;
        color: #f8fafc;
        background: rgba(30, 41, 59, 0.7);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0.75rem;
        outline: none;
        transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
        -webkit-appearance: none;
        appearance: none;
    }

    #mobileFilterSheet input:focus,
    #mobileFilterSheet select:focus {
        border-color: rgba(139, 92, 246, 0.6);
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
        background: rgba(30, 41, 59, 0.9);
    }

    #mobileFilterSheet input::placeholder {
        color: rgba(248, 250, 252, 0.35);
    }

    /* Search input with search icon styling */
    #mobileFilterSheet .filter-section-content-inner > input[type="text"] {
        padding-left: 2.5rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(139,92,246,0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 0.85rem center;
        background-size: 1rem;
    }

    /* Select dropdown custom arrow */
    #mobileFilterSheet select {
        padding-right: 2.5rem;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(196,181,253,0.6)' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.85rem center;
        background-size: 1rem;
    }

    /* Select option styling */
    #mobileFilterSheet select option {
        background: #1e293b;
        color: #f8fafc;
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    /* Level range inputs — side by side with pill styling */
    .filter-section-content-inner .flex.items-center {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        background: rgba(30, 41, 59, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 0.75rem;
        padding: 0.35rem;
    }

    .filter-section-content-inner .flex.items-center input[type="number"] {
        flex: 1;
        min-height: 40px;
        text-align: center;
        font-weight: 500;
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 0.5rem;
        padding: 0.5rem 0.25rem;
    }

    .filter-section-content-inner .flex.items-center input[type="number"]:focus {
        background: rgba(15, 23, 42, 0.9);
        border-color: rgba(139, 92, 246, 0.5);
        box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
    }

    /* "to" separator between min/max */
    .filter-section-content-inner .flex.items-center span {
        font-size: 0.7rem;
        font-weight: 500;
        color: rgba(139, 92, 246, 0.6);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    /* Stat filter label */
    #mobileFilterSheet .filter-section-content-inner label {
        display: block;
        font-size: 0.72rem;
        font-weight: 500;
        color: rgba(248, 250, 252, 0.5);
        margin-bottom: 0.35rem;
        margin-top: 0.5rem;
        letter-spacing: 0.01em;
    }

    /* Section divider line between sections */
    .filter-section:not(:last-of-type) {
        border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    }

    /* Quick filter chips */
    #mobileFilterSheet .quick-filters {
        display: flex;
        gap: 0.3rem;
        padding: 0.4rem 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-bottom: 1px solid rgba(255,255,255,0.04);
    }

    #mobileFilterSheet .quick-filters::-webkit-scrollbar { 
        display: none; 
    }

    .quick-filter-chip {
        flex-shrink: 0;
        font-size: 0.68rem;
        padding: 0.32rem 0.65rem;
        border-radius: 1rem;
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.12);
        color: rgba(248,250,252,0.6);
        cursor: pointer;
        transition: all 0.15s;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }

    .quick-filter-chip i { 
        font-size: 0.55rem; 
    }

    .quick-filter-chip.selected {
        background: rgba(139,92,246,0.2);
        border-color: rgba(139,92,246,0.5);
        color: #c4b5fd;
    }

    .quick-filter-chip:active { 
        transform: scale(0.95); 
    }

    /* Filter count text */
    #mobileFilterSheet .filter-count-text {
        font-size: 0.68rem;
        color: rgba(248,250,252,0.4);
        padding: 0.3rem 1rem;
    }

    /* Base material pills */
    #mobileFilterSheet .base-pills {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        max-height: 7rem;
        overflow-y: auto;
        padding: 0.2rem 0;
    }

    #mobileFilterSheet .base-pill {
        font-size: 0.72rem;
        padding: 0.3rem 0.6rem;
        border-radius: 0.5rem;
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.1);
        color: rgba(248,250,252,0.6);
        cursor: pointer;
        transition: all 0.15s;
    }

    #mobileFilterSheet .base-pill.selected {
        background: rgba(139,92,246,0.2);
        border-color: rgba(139,92,246,0.5);
        color: #c4b5fd;
    }

    #mobileFilterSheet .base-pill:active {
        transform: scale(0.95);
    }

    /* Sticky action bar */
    #mobileFilterSheet .sheet-actions {
        display: flex;
        gap: 0.6rem;
        padding: 0.85rem 1rem;
        padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0.5rem));
        position: sticky;
        bottom: 0;
        background: linear-gradient(to top, rgba(10,10,18,0.98), rgba(10,10,18,0.8));
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(139, 92, 246, 0.08);
    }

    #mobileFilterSheet .sheet-actions button {
        flex: 1;
        min-height: 46px;
        border-radius: 0.85rem;
        font-size: 0.85rem;
        font-weight: 600;
        font-family: 'Poppins', sans-serif;
        letter-spacing: 0.01em;
        border: none;
        cursor: pointer;
        transition: all 0.15s;
    }

    #mobileFilterSheet .sheet-actions .btn-reset {
        background: rgba(255,255,255,0.06);
        color: rgba(248,250,252,0.6);
        border: 1px solid rgba(255,255,255,0.1);
    }

    #mobileFilterSheet .sheet-actions .btn-reset:active {
        transform: scale(0.97);
        background: rgba(255,255,255,0.1);
    }

    #mobileFilterSheet .sheet-actions .btn-apply {
        background: linear-gradient(135deg, #8b5cf6, #6366f1);
        color: white;
        box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
    }

    #mobileFilterSheet .sheet-actions .btn-apply:active {
        transform: scale(0.97);
        opacity: 0.9;
        box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
    }

    /* ===== HYBRID FAB SYSTEM ===== */
    #fabFilterContainer,
    #fabNavContainer {
        display: flex !important;
        transform: translateY(0);
        opacity: 1;
        transition: all 0.3s ease;
        /* Safe area for notched phones */
        bottom: calc(env(safe-area-inset-bottom, 0.5rem) + 1.5rem) !important;
    }

    #fabFilterContainer {
        right: calc(env(safe-area-inset-right, 0.5rem) + 1.5rem) !important;
    }

    #fabNavContainer {
        left: calc(env(safe-area-inset-left, 0.5rem) + 1.5rem) !important;
    }

    /* FAB scroll hide animation */
    #fabFilterContainer.hide-fab,
    #fabNavContainer.hide-fab {
        transform: translateY(80px);
        opacity: 0;
        transition: all 0.3s ease;
        pointer-events: none;
    }

    /* ===== TACTILE TOUCH ANIMATIONS ===== */
    
    /* Global: disable tap highlight, enable smooth touch */
    button, a, [role="button"], .item-card, .quick-filter-chip, .base-pill, .tab-btn {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        touch-action: manipulation;
    }

    /* ===== FAB BUTTONS - DESIGNED WITH LABEL + GLASS MORPHISM ===== */
    #fabFilterBtn,
    #fabNavBtn {
        width: auto !important;
        height: auto !important;
        min-height: 3rem;
        display: flex !important;
        align-items: center;
        gap: 0.4rem;
        padding: 0.55rem 0.85rem;
        position: relative;
        overflow: hidden;
        border-radius: 1.5rem;
        transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                    background 0.15s ease;
        will-change: transform, box-shadow;
        border: 1px solid rgba(255, 255, 255, 0.12);
        backdrop-filter: blur(16px) saturate(1.8);
        -webkit-backdrop-filter: blur(16px) saturate(1.8);
    }

    #fabFilterBtn {
        background: rgba(139, 92, 246, 0.2) !important;
        box-shadow: 0 4px 20px rgba(139, 92, 246, 0.25),
                    0 1px 3px rgba(0, 0, 0, 0.2),
                    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    }

    #fabNavBtn {
        background: rgba(16, 185, 129, 0.2) !important;
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.25),
                    0 1px 3px rgba(0, 0, 0, 0.2),
                    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    }

    /* FAB label text */
    #fabFilterBtn .fab-label,
    #fabNavBtn .fab-label {
        font-size: 0.7rem;
        font-weight: 600;
        color: rgba(248, 250, 252, 0.9);
        white-space: nowrap;
        letter-spacing: 0.01em;
    }

    #fabFilterBtn i,
    #fabNavBtn i {
        font-size: 0.8rem !important;
    }

    /* FAB badge repositioned for pill shape */
    #fabFilterBadge {
        top: -4px !important;
        right: -4px !important;
    }

    /* Press down - button sinks into surface */
    #fabFilterBtn:active,
    #fabNavBtn:active {
        transform: scale(0.93) !important;
        transition: transform 0.08s ease-out;
    }

    #fabFilterBtn:active {
        background: rgba(139, 92, 246, 0.35) !important;
        box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3) !important;
    }

    #fabNavBtn:active {
        background: rgba(16, 185, 129, 0.35) !important;
        box-shadow: 0 2px 12px rgba(16, 185, 129, 0.3) !important;
    }

    /* Ripple effect on FAB buttons */
    #fabFilterBtn::after,
    #fabNavBtn::after {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
        transform: scale(0);
        opacity: 0;
        pointer-events: none;
    }

    #fabFilterBtn:active::after,
    #fabNavBtn:active::after {
        animation: fabRipple 0.35s ease-out;
    }

    @keyframes fabRipple {
        0% { 
            transform: scale(0); 
            opacity: 0.8; 
        }
        100% { 
            transform: scale(2.5); 
            opacity: 0; 
        }
    }

    /* Icon press animation */
    #fabFilterBtn i,
    #fabNavBtn i {
        transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #fabFilterBtn:active i,
    #fabNavBtn:active i {
        transform: scale(0.9);
    }

    /* FAB badge counter */
    @keyframes fabBadgePop {
        0% { transform: scale(0); }
        60% { transform: scale(1.3); }
        100% { transform: scale(1); }
    }

    #fabFilterBadge {
        animation: fabBadgePop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* ===== FAB NAV DRAWER - SPRING ANIMATION ===== */
    #fabNavDrawer {
        transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
        transform-origin: bottom left;
    }

    #fabNavDrawer.open {
        transform: scale(1);
        opacity: 1;
        pointer-events: auto;
    }

    #fabNavDrawer:not(.open) {
        transform: scale(0.75) translateY(20px);
        opacity: 0;
        pointer-events: none;
    }

    /* Nav drawer items - tactile press */
    #fabNavDrawer a {
        position: relative;
        overflow: hidden;
        transition: background-color 0.1s ease, transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #fabNavDrawer a:active {
        transform: scale(0.97);
        background-color: rgba(139, 92, 246, 0.1) !important;
    }

    /* Nav drawer item icon press */
    #fabNavDrawer a i {
        transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #fabNavDrawer a:active i {
        transform: scale(0.85);
    }

    /* Staggered entrance for nav items */
    #fabNavDrawer.open a {
        animation: navItemSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
    }

    #fabNavDrawer.open a:nth-child(1) { animation-delay: 0.03s; }
    #fabNavDrawer.open a:nth-child(2) { animation-delay: 0.06s; }
    #fabNavDrawer.open a:nth-child(3) { animation-delay: 0.09s; }
    #fabNavDrawer.open a:nth-child(4) { animation-delay: 0.12s; }
    #fabNavDrawer.open a:nth-child(5) { animation-delay: 0.15s; }
    #fabNavDrawer.open a:nth-child(6) { animation-delay: 0.18s; }
    #fabNavDrawer.open a:nth-child(7) { animation-delay: 0.21s; }
    #fabNavDrawer.open a:nth-child(8) { animation-delay: 0.24s; }

    @keyframes navItemSlideIn {
        from { 
            opacity: 0; 
            transform: translateX(-15px); 
        }
        to { 
            opacity: 1; 
            transform: translateX(0); 
        }
    }

    /* Nav drawer overlay fade */
    #fabNavOverlay {
        transition: opacity 0.25s ease;
    }

    /* ===== IMMERSIVE MODAL (Full-screen bottom sheet) ===== */
    #itemModal {
        padding: 0 !important;
        align-items: flex-end !important;
    }

    #itemModal > div.relative {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        display: flex;
        flex-direction: column;
        animation: none !important;
    }

    /* Modal pull-down indicator */
    #modalPullIndicator {
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(-100%);
        width: 2.5rem;
        height: 0.3rem;
        background: rgba(255,255,255,0.2);
        border-radius: 0.15rem;
        z-index: 100;
        transition: transform 0.2s, width 0.2s, background 0.2s;
        pointer-events: none;
    }

    #modalPullIndicator.active {
        transform: translateX(-50%) translateY(0);
        width: 3rem;
        background: rgba(139,92,246,0.5);
    }

    /* Modal header */
    #itemModal > div.relative > .flex-shrink-0 {
        background: rgba(10, 10, 18, 0.92) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        padding: 0.6rem 0.75rem !important;
        border-bottom: 1px solid rgba(255,255,255,0.06);
        flex-shrink: 0 !important;
        z-index: 10;
    }

    #modalItemTitle {
        font-size: 0.82rem !important;
        font-weight: 600 !important;
        color: #f8fafc !important;
    }

    #closeModal, #backModal {
        width: 2.25rem !important;
        height: 2.25rem !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        border-radius: 50% !important;
        background: rgba(255,255,255,0.06);
        color: #94a3b8;
        transition: all 0.15s;
    }

    #closeModal:active, #backModal:active {
        transform: scale(0.9);
        background: rgba(239,68,68,0.2);
    }

    /* Modal content scroll area */
    #itemModal > div.relative > .flex-grow {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0 !important;
        flex: 1;
    }

    /* Tab bar at bottom */
    #modalTabBar {
        display: flex;
        background: rgba(10, 10, 18, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid rgba(255,255,255,0.06);
        flex-shrink: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    #modalTabBar .tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 0.25rem 0.4rem;
        background: none;
        border: none;
        color: rgba(248,250,252,0.4);
        font-size: 0.6rem;
        font-weight: 500;
        transition: all 0.2s;
        position: relative;
        cursor: pointer;
    }

    #modalTabBar .tab-btn i {
        font-size: 1.1rem;
        margin-bottom: 0.15rem;
        transition: all 0.2s;
    }

    #modalTabBar .tab-btn.active {
        color: #c4b5fd;
    }

    #modalTabBar .tab-btn.active i {
        color: #8b5cf6;
        transform: scale(1.1);
    }

    #modalTabBar .tab-btn.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 2px;
        background: linear-gradient(90deg, transparent, #8b5cf6, transparent);
        border-radius: 1px;
    }

    #modalTabBar .tab-btn:active {
        transform: scale(0.95);
    }

    /* Progress dots */
    #modalProgressDots {
        display: flex;
        justify-content: center;
        gap: 0.4rem;
        padding: 0.4rem 0;
        background: rgba(10,10,18,0.5);
    }

    #modalProgressDots .dot {
        width: 6px;
        height: 6px;
        border-radius: 3px;
        background: rgba(255,255,255,0.15);
        transition: all 0.3s;
    }

    #modalProgressDots .dot.active {
        width: 18px;
        background: linear-gradient(90deg, #8b5cf6, #3b82f6);
        border-radius: 3px;
    }

    /* Tab content panels */
    .modal-tab-content {
        display: none;
    }

    .modal-tab-content.active {
        display: block;
        animation: tabFadeIn 0.3s ease;
    }

    @keyframes tabFadeIn {
        from { opacity: 0; transform: translateY(8px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* ===== TAB 1: INFO — ITEM SHOWCASE ===== */
    #modalContent .item-showcase {
        padding: 1.5rem 1rem !important;
        margin-bottom: 0 !important;
        border-radius: 0 !important;
        background: linear-gradient(180deg, rgba(30,30,50,0.6) 0%, rgba(10,10,18,0.8) 100%) !important;
        border: none !important;
        text-align: center;
        position: relative;
        overflow: hidden;
    }

    /* Ambient rarity glow behind showcase */
    #modalContent .item-showcase::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 8rem;
        height: 8rem;
        border-radius: 50%;
        filter: blur(40px);
        opacity: 0.3;
        pointer-events: none;
    }

    #modalContent .item-showcase.rar-common::before { background: rgba(148,163,184,0.4); }
    #modalContent .item-showcase.rar-uncommon::before { background: rgba(16,185,129,0.5); }
    #modalContent .item-showcase.rar-rare::before { background: rgba(59,130,246,0.5); }
    #modalContent .item-showcase.rar-epic::before { background: rgba(139,92,246,0.5); }
    #modalContent .item-showcase.rar-legendary::before { 
        background: rgba(245,158,11,0.6); 
        animation: ambientPulse 3s ease-in-out infinite; 
    }

    @keyframes ambientPulse {
        0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
        50% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.1); }
    }

    #modalContent .item-image-wrapper {
        width: 5rem !important;
        height: 5rem !important;
        margin: 0 auto 0.75rem !important;
        position: relative;
        z-index: 1;
        animation: itemFloat 3s ease-in-out infinite;
    }

    @keyframes itemFloat {
        0%, 100% { transform: translateY(0) rotate(0deg); }
        25% { transform: translateY(-4px) rotate(1deg); }
        75% { transform: translateY(-2px) rotate(-1deg); }
    }

    /* Glow ring around item image */
    #modalContent .item-image-wrapper::after {
        content: '';
        position: absolute;
        inset: -8px;
        border-radius: 50%;
        border: 2px solid rgba(139,92,246,0.2);
        animation: glowRing 3s ease-in-out infinite;
    }

    @keyframes glowRing {
        0%, 100% { opacity: 0.3; transform: scale(1); }
        50% { opacity: 0.6; transform: scale(1.05); }
    }

    #modalContent h3 {
        font-size: 1.15rem !important;
        margin-bottom: 0.5rem !important;
        position: relative;
        z-index: 1;
    }

    /* Info cards grid */
    #modalContent .grid.grid-cols-2.md\:grid-cols-4 {
        gap: 0.4rem !important;
        padding: 0.75rem !important;
    }

    #modalContent .info-card {
        padding: 0.5rem 0.6rem !important;
        border-radius: 0.6rem !important;
        background: rgba(255,255,255,0.03) !important;
        border: 1px solid rgba(255,255,255,0.06) !important;
        text-align: center;
    }

    #modalContent .info-card-label {
        font-size: 0.6rem !important;
        color: rgba(248,250,252,0.35) !important;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    #modalContent .info-card-value {
        font-size: 0.9rem !important;
        font-weight: 600;
    }

    /* Count-up animation */
    #modalContent .info-card-value.counting {
        animation: countPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes countPop {
        0% { transform: scale(0.8); opacity: 0; }
        60% { transform: scale(1.1); }
        100% { transform: scale(1); opacity: 1; }
    }

    /* Stat bars */
    #modalContent .stat-bar-container {
        padding: 0.5rem 0.6rem !important;
        border-radius: 0.5rem !important;
        background: rgba(10,10,18,0.5) !important;
        border: 1px solid rgba(255,255,255,0.04) !important;
        margin-bottom: 0.35rem !important;
    }

    #modalContent .stat-bar-label span:first-child {
        font-size: 0.65rem !important;
        color: rgba(248,250,252,0.4) !important;
    }

    #modalContent .stat-bar-label span:last-child {
        font-size: 0.8rem !important;
        font-weight: 600;
    }

    #modalContent .stat-bar-fill {
        background: linear-gradient(90deg, #8b5cf6, #06b6d4) !important;
        border-radius: 1rem !important;
    }

    /* Description */
    #modalContent .item-description {
        padding: 0.6rem 0.75rem !important;
        font-size: 0.78rem !important;
        line-height: 1.55 !important;
        border-left-color: rgba(139,92,246,0.3) !important;
        background: rgba(139,92,246,0.04) !important;
    }

    /* Section titles */
    #modalContent .modal-section {
        padding-bottom: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    #modalContent .modal-section-title {
        font-size: 0.85rem !important;
        gap: 0.4rem !important;
    }

    #modalContent .modal-section-title i {
        font-size: 0.8rem !important;
    }

    /* Badges */
    #modalContent .rarity-badge {
        padding: 0.2rem 0.5rem !important;
        font-size: 0.65rem !important;
    }

    #modalContent .item-type-tag {
        font-size: 0.65rem !important;
        padding: 0.15rem 0.4rem !important;
    }

    /* ===== TAB 2: RECIPES ===== */
    #modalContent .flex.flex-wrap.gap-2 {
        flex-direction: column !important;
        gap: 0.35rem !important;
        padding: 0.75rem !important;
    }

    #modalContent .flex.flex-wrap.gap-2 > div {
        width: 100% !important;
    }

    #modalContent .flex.flex-wrap.gap-2 select {
        width: 100% !important;
        min-height: 40px !important;
        font-size: 16px !important;
    }

    /* Recipe cards */
    #modalContent .bg-wlDark.rounded-lg {
        padding: 0.6rem !important;
        margin-bottom: 0.5rem !important;
        border-radius: 0.6rem !important;
        border: 1px solid rgba(255,255,255,0.04) !important;
    }

    #modalContent .w-12.h-12 {
        width: 2.5rem !important;
        height: 2.5rem !important;
        border-radius: 50% !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    #modalContent .text-sm.font-medium {
        font-size: 0.75rem !important;
    }

    /* Recipe pagination */
    #modalContent .flex.items-center.justify-between.mt-4 {
        flex-direction: column !important;
        gap: 0.35rem !important;
    }

    #modalContent .flex.justify-center.gap-1 button {
        min-height: 34px !important;
        min-width: 34px !important;
        padding: 0.3rem 0.5rem !important;
        font-size: 0.72rem !important;
        border-radius: 0.5rem !important;
    }

    /* ===== TAB 3: BUILDER ===== */
    #modalContent .builder-slot,
    #modalContent .flex.items-center.gap-2 {
        flex-direction: column !important;
        gap: 0.4rem !important;
    }

    #modalContent .bg-wlDarker.rounded-lg {
        padding: 0.6rem !important;
        margin-bottom: 0.4rem !important;
        border-radius: 0.6rem !important;
    }

    /* ===== PAGINATION CENTERED ===== */
    .flex.flex-col.md\:flex-row.items-center.justify-between {
        flex-direction: column !important;
        gap: 0.6rem !important;
    }

    #pagination, #paginationGrid {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }

    #pagination button,
    #paginationGrid button {
        min-height: 32px !important;
        min-width: 32px !important;
        padding: 0.25rem 0.5rem !important;
        font-size: 0.72rem !important;
        border-radius: 0.45rem !important;
    }

    /* ===== SKELETON GRID CARDS ===== */
    .skeleton-grid-card {
        background: #1a1a2e;
        border-radius: 0.75rem;
        padding: 0.5rem;
        border: 1px solid rgba(255, 255, 255, 0.06);
        overflow: hidden;
    }

    .skeleton-grid-card .skeleton-image {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 0.45rem;
        margin-bottom: 0.35rem;
    }

    .skeleton-grid-card .skeleton-title {
        height: 0.7rem;
        width: 70%;
        border-radius: 0.25rem;
        margin-bottom: 0.3rem;
    }

    .skeleton-grid-card .skeleton-subtitle {
        height: 0.55rem;
        width: 50%;
        border-radius: 0.25rem;
        margin-bottom: 0.4rem;
    }

    .skeleton-grid-card .skeleton-chip {
        height: 0.6rem;
        width: 45%;
        border-radius: 0.3rem;
        margin-bottom: 0.2rem;
    }

    .skeleton-grid-card .skeleton-chip:nth-child(5) {
        width: 40%;
    }

    .skeleton-grid-card .skeleton-button {
        height: 1.75rem;
        border-radius: 2rem;
        width: 100%;
        margin-top: 0.35rem;
    }

    .skeleton::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(90deg, 
            transparent 0%, 
            rgba(59, 130, 246, 0.15) 50%, 
            transparent 100%);
        animation: shimmer 1.5s ease-in-out infinite;
    }

    @keyframes shimmer {
        0% { transform: translateX(-100%); }
        100% { transform: translateX(100%); }
    }

    /* ===== EMPTY STATE ===== */
    #itemsGrid .col-span-2.sm\:col-span-3.lg\:col-span-4.xl\:col-span-5 {
        grid-column: 1 / -1 !important;
    }

    /* ===== RIPPLE EFFECT ===== */
    .ripple {
        position: relative;
        overflow: hidden;
    }

    .ripple::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(139, 92, 246, 0.15);
        transform: translate(-50%, -50%);
        transition: width 0.5s ease-out, height 0.5s ease-out, opacity 0.5s ease-out;
        opacity: 0;
        pointer-events: none;
    }

    .ripple:active::after {
        width: 200%;
        height: 200%;
        opacity: 1;
        transition: 0s;
    }

    /* ===== REDUCED MOTION ===== */
    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
        #itemsGrid > div.item-card {
            animation: none !important;
        }
        #itemsGrid > div.item-card::before {
            animation: none !important;
        }
        #modalContent .item-image-wrapper {
            animation: none !important;
        }
    }

    /* ===== PULL-TO-ANIMATE STATS ===== */
    @keyframes statReveal {
        from { opacity: 0; transform: translateX(-12px); }
        to { opacity: 1; transform: translateX(0); }
    }

    #modalContent .stat-bar-container {
        animation: statReveal 0.4s ease both;
    }

    #modalContent .stat-bar-container:nth-child(2) { animation-delay: 0.05s; }
    #modalContent .stat-bar-container:nth-child(3) { animation-delay: 0.1s; }
    #modalContent .stat-bar-container:nth-child(4) { animation-delay: 0.15s; }
    #modalContent .stat-bar-container:nth-child(5) { animation-delay: 0.2s; }
    #modalContent .stat-bar-container:nth-child(6) { animation-delay: 0.25s; }
    #modalContent .stat-bar-container:nth-child(7) { animation-delay: 0.3s; }
    #modalContent .stat-bar-container:nth-child(8) { animation-delay: 0.35s; }

    /* ===== TOUCH FEEDBACK ===== */
    button:active, a:active, [role="button"]:active, .item-card:active {
        transform: scale(0.96) !important;
    }

    input:active, select:active {
        border-color: rgba(139,92,246,0.5) !important;
    }
}

/* ===== PRESET FILTER CAROUSEL ENHANCEMENTS ===== */
.preset-filter-carousel {
    display: none;
}
@media (max-width: 768px) {
    .preset-filter-carousel {
        display: flex !important;
        gap: 0.35rem !important;
        padding: 0.4rem 0.75rem !important;
        margin-bottom: 0.25rem !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-snap-type: x mandatory;
        background: rgba(10, 10, 18, 0.5);
        border-radius: 0.5rem;
    }
    .preset-filter-carousel::-webkit-scrollbar { display: none; }
    .preset-filter-chip {
        flex-shrink: 0;
        font-size: 0.68rem;
        padding: 0.35rem 0.65rem;
        border-radius: 1rem;
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.12);
        color: rgba(248,250,252,0.6);
        cursor: pointer;
        transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 0.3rem;
        scroll-snap-align: start;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
    .preset-filter-chip i { font-size: 0.6rem; }
    .preset-filter-chip.active {
        background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(59,130,246,0.25));
        border-color: rgba(139,92,246,0.5);
        color: #c4b5fd;
        box-shadow: 0 2px 8px rgba(139,92,246,0.15);
    }
    .preset-filter-chip:active { transform: scale(0.94); }
}

/* ===== SEARCH HISTORY BAR ===== */
.search-history-bar {
    display: none;
}
@media (max-width: 768px) {
    .search-history-bar {
        display: flex !important;
        gap: 0.3rem !important;
        padding: 0.3rem 0.75rem !important;
        margin-bottom: 0.2rem !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .search-history-bar::-webkit-scrollbar { display: none; }
    .search-history-chip {
        flex-shrink: 0;
        font-size: 0.6rem;
        padding: 0.2rem 0.5rem;
        border-radius: 1rem;
        background: rgba(255,255,255,0.04);
        border: 1px solid rgba(255,255,255,0.08);
        color: rgba(248,250,252,0.4);
        cursor: pointer;
        transition: all 0.15s ease;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        -webkit-tap-highlight-color: transparent;
    }
    .search-history-chip:active {
        background: rgba(139,92,246,0.15);
        color: #c4b5fd;
        transform: scale(0.95);
    }
    .search-history-chip .chip-x-btn {
        width: 1rem; height: 1rem;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(239,68,68,0.15);
        font-size: 0.5rem;
        color: rgba(239,68,68,0.6);
    }
}

/* ===== RECENTLY VIEWED BAR ===== */
.recently-viewed-bar { display: none; }
@media (max-width: 768px) {
    .recently-viewed-bar {
        display: block !important;
        padding: 0.4rem 0.75rem !important;
        margin-bottom: 0.3rem !important;
    }
    .recently-viewed-bar .rv-label {
        font-size: 0.6rem;
        color: rgba(248,250,252,0.3);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.3rem;
    }
    .recently-viewed-scroll {
        display: flex;
        gap: 0.4rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-snap-type: x mandatory;
        padding-bottom: 0.2rem;
    }
    .recently-viewed-scroll::-webkit-scrollbar { display: none; }
    .recently-viewed-item {
        flex-shrink: 0;
        width: 3.5rem;
        scroll-snap-align: start;
        display: flex;
        flex-direction: column;
        align-items: center;
        cursor: pointer;
        transition: transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .recently-viewed-item:active { transform: scale(0.92); }
    .recently-viewed-item img {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 0.45rem;
        object-fit: contain;
        background: rgba(10,10,18,0.4);
        border: 1px solid rgba(255,255,255,0.06);
    }
    .recently-viewed-item span {
        font-size: 0.5rem;
        color: rgba(248,250,252,0.5);
        margin-top: 0.15rem;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 3.5rem;
    }
}

/* ===== PEAK HINT BAR ===== */
#filterPeekBar {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0px));
    height: 6px;
    background: linear-gradient(90deg, rgba(139,92,246,0.3), rgba(59,130,246,0.3), rgba(139,92,246,0.3));
    background-size: 200% 100%;
    animation: peekShimmer 3s ease-in-out infinite;
    z-index: 49;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    display: none;
}
#filterPeekBar.visible { opacity: 0.8; cursor: pointer; pointer-events: auto; height: 12px; }

@keyframes peekShimmer {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

/* ===== FILTER SYNC INDICATOR ===== */
.filter-sync-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(139,92,246,0.2);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}
.filter-sync-indicator.visible {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.filter-sync-indicator i { color: #c4b5fd; font-size: 1.2rem; }

/* ===== STAT SPARKLINES ===== */
.stat-sparkline {
    display: block;
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.15rem;
}
.stat-sparkline-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, #8b5cf6, #06b6d4);
    transition: width 0.5s ease;
}

/* ===== CARD STAT BARS ===== */
.card-stat-row {
    display: flex;
    gap: 0.2rem;
    padding: 0 0.4rem;
    margin: 0 0 0.15rem 0;
}
.card-stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.card-stat-label {
    font-size: 0.45rem;
    color: rgba(248,250,252,0.3);
    text-transform: uppercase;
}
.card-stat-value {
    font-size: 0.52rem;
    font-weight: 600;
}
.card-stat-bar {
    height: 2px;
    background: rgba(255,255,255,0.08);
    border-radius: 1px;
    overflow: hidden;
}
.card-stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #06b6d4);
    border-radius: 1px;
}

/* ===== AUTO-HIDING HEADER ===== */
header.scroll-hide {
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
header.scroll-show {
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== TACTILE RIPPLE ===== */
.tactile-ripple { position: relative; overflow: hidden; }
.tactile-ripple .ripple-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.2);
    transform: scale(0);
    animation: tactileRippleExpand 0.4s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}
@keyframes tactileRippleExpand {
    to { transform: scale(4); opacity: 0; }
}

/* ===== MAGNETIC TAP ===== */
.magnetic-tap { position: relative; }
.magnetic-tap::before {
    content: '';
    position: absolute;
    inset: -6px;
    z-index: -1;
    border-radius: inherit;
}
.magnetic-tap.proximity-glow {
    --glow-color: rgba(139,92,246,0.1);
    box-shadow: 0 0 12px var(--glow-color);
    transition: box-shadow 0.15s ease;
}

/* ===== DIAGONAL CASCADE ===== */
@keyframes cascadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== LIVE FILTER FLASH ===== */
@keyframes filterFlash {
    0% { opacity: 0.3; filter: brightness(1.5); }
    100% { opacity: 1; filter: brightness(1); }
}
.filter-updating { animation: filterFlash 0.3s ease-out; }

/* ===== EXTRA SMALL SCREENS (<=420px) ===== */
@media (max-width: 420px) {
    #itemsGrid { 
        gap: 0.35rem !important; 
    }

    #itemsGrid > div.item-card > .flex.items-start {
        padding: 0.35rem 0.3rem 0.2rem !important;
    }

    #itemsGrid > div.item-card > .flex.items-start > img:first-child,
    #itemsGrid > div.item-card .w-16.h-16 {
        width: 2.15rem !important;
        height: 2.15rem !important;
        border-radius: 0.35rem !important;
    }

    #itemsGrid > div.item-card h4 {
        font-size: 0.67rem !important;
        max-width: 4.5rem !important;
    }

    #itemsGrid > div.item-card .text-xs.text-wlLight.text-opacity-70,
    #itemsGrid > div.item-card .flex.items-center.text-xs {
        font-size: 0.53rem !important;
    }

    #itemsGrid > div.item-card .grid.grid-cols-2 > div {
        font-size: 0.5rem !important;
        padding: 0.1rem 0.25rem !important;
    }

    #itemsGrid > div.item-card > button {
        font-size: 0.6rem !important;
        padding: 0.28rem 0 !important;
    }

    #modalContent .item-image-wrapper {
        width: 4rem !important;
        height: 4rem !important;
    }

    #modalContent h3 {
        font-size: 1rem !important;
    }

    /* FAB smaller on compact screens */
    #fabFilterBtn,
    #fabNavBtn {
        width: 3rem !important;
        height: 3rem !important;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
    #itemModal {
        align-items: center !important;
    }
    
    #itemModal > div.relative {
        max-height: 90vh !important;
        width: 90vw !important;
        border-radius: 1rem !important;
    }
}
/* ===== MOBILE PERFORMANCE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    /* 1. Remove expensive backdrop-blur filters */
    .blur-bg, 
    #mobileFilterSheet .sheet-inner,
    #itemModal > div.relative {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    /* 2. Disable infinite animations (Shimmer/Glow) to save CPU/Battery */
    #itemsGrid > div.item-card::before, /* Rarity shimmer */
    #itemsGrid > div.item-card::after,  /* Image halo */
    #itemsGrid > div.item-card.rar-legendary /* Legendary pulse */
    {
        animation: none !important;
    }
    
    /* 3. Remove box-shadows from cards (expensive to render) */
    #itemsGrid > div.item-card {
        box-shadow: none !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

    /* 4. Prevent layout shift on images by enforcing aspect ratio */
    #itemsGrid > div.item-card .w-16.h-16,
    #itemsGrid > div.item-card img {
        width: 2.5rem !important;
        height: 2.5rem !important;
        min-width: 2.5rem;
        aspect-ratio: 1 / 1;
    }
    
    /* 5. Fix Filter Sheet CLS - Give it a defined initial state */
    #mobileFilterSheet .sheet-inner {
        min-height: 50vh; /* Prevents it from jumping height */
    }
}
/* ================================================================
   MOBILE LAYOUT OVERRIDES
   ================================================================ */
@media (max-width: 768px) {
    
    /* --- 1. RECENTLY VIEWED FIX --- */
    /* Force block layout so label sits on top of the items */
    .recently-viewed-bar {
        display: block !important;
        padding: 0.4rem 0.75rem !important;
        margin-bottom: 0.3rem !important;
    }
    .recently-viewed-bar .rv-label {
        display: block !important;
        margin-bottom: 0.3rem !important;
    }
    .recently-viewed-scroll {
        display: flex !important;
        gap: 0.4rem !important;
        overflow-x: auto !important;
    }

    /* --- 2. SORT BUTTON & COUNT POSITIONING --- */
    /* Make the main container a row with space-between */
    .flex.flex-col.sm\:flex-row.justify-between {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
    }

    /* Hide the View Toggle buttons (Grid/Table) */
    .flex.flex-col.md\:flex-row.justify-between > div:last-child > .flex.space-x-2 {
        display: none !important;
    }

    /* Ensure Item Count is visible and pushed to the right */
    .flex.flex-col.md\:flex-row.justify-between > div:last-child > .text-sm {
        display: block !important;
        text-align: right !important;
        width: auto !important;
        margin-left: auto !important; /* Push to far right */
    }

    /* --- 3. SHOW MOBILE ELEMENTS --- */
    #mobileSortBtn,
    #fabFilterContainer,
    #fabNavContainer,
    .preset-filter-carousel {
        display: flex !important;
    }
    /* Removed .search-history-bar from here to allow "block" display in Section 1 */

    /* --- 4. SORT BUTTON STYLING (Legendary Look) --- */
    #mobileSortBtn {
        align-items: center;
        gap: 0.4rem;
        min-height: 36px;
        padding: 0.35rem 0.65rem;
        border-radius: 2rem;
        background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(59,130,246,0.12)) !important;
        border: 1px solid rgba(139,92,246,0.3) !important;
        color: #c4b5fd !important;
        font-size: 0.72rem !important;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 2px 12px rgba(139,92,246,0.15);
        -webkit-tap-highlight-color: transparent;
        flex-shrink: 0;
    }

    #mobileSortBtn:active {
        transform: scale(0.95);
        background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(59,130,246,0.25)) !important;
        border-color: rgba(139,92,246,0.5) !important;
        color: #fff !important;
    }

    /* --- 5. FIX "REFRESH ICON" (Filter Sync) --- */
    /* Hide the sync indicator by default on mobile */
    .filter-sync-indicator {
        display: none !important;
    }
    /* Only show it if JS adds the .visible class */
    .filter-sync-indicator.visible {
        display: flex !important;
        position: fixed;
        top: 50%; left: 50%;
        transform: translate(-50%, -50%);
        z-index: 3000;
        background: rgba(139,92,246,0.2);
        border-radius: 50%;
        width: 48px; height: 48px;
        align-items: center; justify-content: center;
    }
}