:root{
    --bg:#f4f7fb;
    --card:#ffffff;
    --text:#1f2937;
    --muted:#667085;
    --line:#d8e1ec;
    --shadow:0 10px 28px rgba(15,23,42,.08);
    --blue:#173e62;
    --red:#ab1e1e;
}
*{ box-sizing:border-box; }

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

body{
    margin:0;
    font-family:"Inter", "Segoe UI", Arial, Helvetica, sans-serif;
    background:linear-gradient(180deg,#f6f9fc 0%,#edf3f9 100%);
    color:var(--text);
    display:flex;
    flex-direction:column;
    -webkit-font-smoothing:antialiased;
    text-rendering:optimizeLegibility;
}

button,
input,
select,
textarea{
    font:inherit;
}

body.music-mode{
    --mode:#173e62;
    --mode-soft:#eaf2fb;
}

body.games-mode{
    --mode:#ab1e1e;
    --mode-soft:#fdeeee;
}

.page-main{
    flex:1 0 auto;
}

.page-wrap{
    width:min(1320px, calc(100% - 24px));
    margin:16px auto 28px;
}

.page-top{
    display:grid;
    gap:14px;
    margin-bottom:16px;
}

.hero-intro{
    margin:6px 0 0;
    color:#374151;
    font-size:.95rem;
    line-height:1.55;
    max-width:760px;
}

.hero-link-row{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    margin-top:10px;
}

.hero-link-btn{
    display:inline-flex;
    align-items:center;
    padding:8px 12px;
    border-radius:999px;
    font-weight:800;
    background:#f4f7fb;
    border:1px solid #dbe5ef;
    color:#173e62;
    cursor:pointer;
    font:inherit;
}

.hero-link-btn:hover{
    background:#ebf2f9;
}

.hero-strip,
.filter-card{
    background:#fff;
    border:1px solid var(--line);
    border-radius:18px;
    box-shadow:var(--shadow);
}

.hero-strip{
    padding:14px 16px;
}
.hero-top{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;
    flex-wrap:wrap;
}
.hero-left{
    display:flex;
    flex-direction:column;
    gap:4px;
}
.section-title{
    margin:0;
    font-size:1.35rem;
    line-height:1.15;
    font-weight:800;
}
.section-subnote{
    color:var(--muted);
    font-size:.88rem;
}
.stats-strip{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    align-items:center;
}
.stat-pill{
    display:inline-flex;
    align-items:center;
    gap:6px;
    border:1px solid #dce5f0;
    background:#f8fbff;
    border-radius:999px;
    padding:5px 9px;
    font-size:.8rem;
    line-height:1;
}
.stat-pill-label{
    color:var(--muted);
    font-weight:700;
}
.stat-pill-value{
    color:#111827;
    font-weight:800;
}

.noscript-box{
    margin-top:16px;
}

.seo-link-row{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
}

.seo-link-row a{
    display:inline-flex;
    align-items:center;
    padding:8px 12px;
    border-radius:999px;
    text-decoration:none;
    font-weight:800;
    background:#f4f7fb;
    border:1px solid #dbe5ef;
    color:#173e62;
}

.seo-link-row a:hover{
    background:#ebf2f9;
}

.filter-card{
    padding:16px 18px 18px;
}
.filter-card-top{
    display:flex;
    justify-content:space-between;
    gap:12px;
    align-items:flex-start;
    flex-wrap:wrap;
    margin-bottom:12px;
}
.filter-title{
    margin:0;
    font-size:1.05rem;
    font-weight:800;
}
.filter-subnote{
    color:var(--muted);
    font-size:.88rem;
    margin-top:4px;
}
.view-toggle{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}
.view-toggle-btn{
    border:1px solid #ccd7e4;
    background:#fff;
    color:#1f2937;
    border-radius:999px;
    padding:8px 12px;
    font-weight:800;
    cursor:pointer;
}
.view-toggle-btn.active{
    background:var(--mode, var(--blue));
    color:#fff;
    border-color:var(--mode, var(--blue));
}

.filter-grid{
    display:grid;
    grid-template-columns:repeat(6, minmax(0,1fr));
    gap:12px;
    margin-bottom:12px;
}
.filter-field{
    display:flex;
    flex-direction:column;
    gap:6px;
}
.filter-label{
    font-size:.76rem;
    font-weight:800;
    letter-spacing:.04em;
    text-transform:uppercase;
    color:var(--muted);
}
.filter-input{
    width:100%;
    height:40px;
    border:1px solid #c7d3df;
    border-radius:10px;
    padding:0 10px;
    font-size:.93rem;
    background:#fff;
}
.filter-input:focus{
    outline:none;
    border-color:var(--mode, var(--blue));
    box-shadow:0 0 0 3px rgba(23,62,98,.10);
}
.filter-toggles{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    margin-bottom:12px;
}
.toggle-pill{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:10px 12px;
    border:1px solid var(--line);
    border-radius:999px;
    background:#f8fbfe;
    cursor:pointer;
    user-select:none;
    font-weight:700;
    font-size:.9rem;
}
.toggle-pill input{
    width:auto;
    height:auto;
    margin:0;
}
.filter-actions{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    flex-wrap:wrap;
}
.filter-helper{
    color:var(--muted);
    font-size:.88rem;
}
.filter-actions-right{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
}
.result-count{
    display:inline-flex;
    align-items:center;
    border:1px solid #dce5f0;
    background:#f8fbff;
    border-radius:999px;
    padding:8px 12px;
    font-size:.88rem;
    font-weight:800;
    color:#111827;
}
.btn-row{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}
.btn{
    border:none;
    border-radius:12px;
    padding:10px 16px;
    font-weight:800;
    cursor:pointer;
    transition:.15s ease;
}
.btn-primary{
    background:var(--mode, var(--blue));
    color:#fff;
}
.btn-primary:hover{ opacity:.93; }
.btn-secondary{
    background:#eef2f7;
    color:#111827;
}
.btn-secondary:hover{ background:#e4eaf2; }

/* ===== TILE VIEW ===== */
.product-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(210px, 1fr));
    gap:14px;
}
.product-card{
    display:flex;
    flex-direction:column;
    background:#fff;
    border:1px solid var(--line);
    border-radius:16px;
    box-shadow:var(--shadow);
    overflow:hidden;
    min-height:100%;
}
.product-card-link{
    text-decoration:none;
    color:inherit;
    display:flex;
    flex-direction:column;
    flex:1 1 auto;
}
.product-image-wrap{
    aspect-ratio:1 / 1;
    background:#f8fbff;
    border-bottom:1px solid #edf2f7;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    position:relative;
}
.product-image{
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
}
.no-image{
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    height:100%;
    color:#6b7280;
    font-weight:800;
    font-size:.94rem;
    background:linear-gradient(135deg,#f4f7fb,#eef3f9);
}
.sold-badge{
    position:absolute;
    top:8px;
    right:8px;
    background:#fff0f0;
    color:#a61b1b;
    border:1px solid #efb1b1;
    font-weight:800;
    font-size:.76rem;
    border-radius:999px;
    padding:5px 8px;
}
.product-body{
    padding:9px 11px 8px;
    display:flex;
    flex-direction:column;
    gap:4px;
    flex:1 1 auto;
}
.product-price-row{
    display:flex;
    align-items:baseline;
    gap:8px;
    flex-wrap:wrap;
    line-height:1.1;
}
.was-price{
    color:#8b95a7;
    text-decoration:line-through;
    font-weight:700;
    font-size:.84rem;
}
.current-price{
    color:#111827;
    font-size:.96rem;
    font-weight:800;
}
.product-meta-small{
    color:var(--muted);
    font-size:.8rem;
    font-weight:700;
}
.product-title{
    font-size:.94rem;
    font-weight:800;
    line-height:1.22;
    color:#111827;
    min-height:1.9em;
}
.product-footer{
    margin-top:auto;
    padding:0;
}

/* ===== LIST VIEW ===== */
.list-wrap{
    display:none;
    width:100%;
    overflow:auto;
    border:1px solid var(--line);
    border-radius:16px;
    background:#fff;
    box-shadow:var(--shadow);
}
.list-wrap.active{
    display:block;
}
.inventory-list{
    width:max-content;
    min-width:100%;
    border-collapse:collapse;
    table-layout:fixed;
    background:#fff;
}
.inventory-list th,
.inventory-list td{
    border-bottom:1px solid #eef2f7;
    padding:8px 9px;
    font-size:.92rem;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    vertical-align:middle;
}
.inventory-list thead th{
    position:sticky;
    top:0;
    z-index:2;
    background:#f5f8fc;
    font-weight:800;
}
.inventory-list tbody tr:nth-child(even){
    background:#fbfdff;
}
.inventory-list-link{
    color:#173e62;
    text-decoration:none;
    font-weight:700;
}
.inventory-list-link:hover{
    text-decoration:underline;
}

.list-games th:nth-child(1), .list-games td:nth-child(1){ width:12ch; max-width:12ch; }
.list-games th:nth-child(2), .list-games td:nth-child(2){ width:8ch; max-width:8ch; }
.list-games th:nth-child(3), .list-games td:nth-child(3){ width:18ch; max-width:18ch; }
.list-games th:nth-child(4), .list-games td:nth-child(4){ width:34ch; max-width:34ch; }
.list-games th:nth-child(5), .list-games td:nth-child(5){ width:24ch; max-width:24ch; }
.list-games th:nth-child(6), .list-games td:nth-child(6){ width:6ch; max-width:6ch; text-align:center; }

.list-music th:nth-child(1), .list-music td:nth-child(1){ width:12ch; max-width:12ch; }
.list-music th:nth-child(2), .list-music td:nth-child(2){ width:8ch; max-width:8ch; }
.list-music th:nth-child(3), .list-music td:nth-child(3){ width:18ch; max-width:18ch; }
.list-music th:nth-child(4), .list-music td:nth-child(4){ width:30ch; max-width:30ch; }
.list-music th:nth-child(5), .list-music td:nth-child(5){ width:12ch; max-width:12ch; }
.list-music th:nth-child(6), .list-music td:nth-child(6){ width:10ch; max-width:10ch; }
.list-music th:nth-child(7), .list-music td:nth-child(7){ width:10ch; max-width:10ch; }
.list-music th:nth-child(8), .list-music td:nth-child(8){ width:8ch; max-width:8ch; }
.list-music th:nth-child(9), .list-music td:nth-child(9){ width:8ch; max-width:8ch; }
.list-music th:nth-child(10), .list-music td:nth-child(10){ width:6ch; max-width:6ch; text-align:center; }

.scroll-top-btn{
    position:fixed;
    left:50%;
    bottom:20px;
    z-index:1500;
    border:none;
    border-radius:999px;
    padding:16px 26px;
    font-weight:900;
    font-size:1rem;
    background:var(--mode, var(--blue));
    color:#fff;
    box-shadow:0 10px 28px rgba(15,23,42,.18);
    cursor:pointer;
    opacity:0;
    visibility:hidden;
    transform:translateX(-50%) translateY(8px);
    transition:opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.scroll-top-btn.visible{
    opacity:1;
    visibility:visible;
    transform:translateX(-50%) translateY(0);
}

.scroll-top-btn:hover{
    opacity:.95;
}

@media (min-width: 701px){
    .inventory-list th,
    .inventory-list td{
        padding:2px 6px;
        font-size:.86rem;
        line-height:1.15;
    }

    .inventory-list thead th{
        padding-top:3px;
        padding-bottom:3px;
    }

    .inventory-list .add-btn{
        padding:3px 7px;
        min-height:0;
        font-size:.84rem;
        border-radius:7px;
    }
}

/* ===== SHARED BUTTON ===== */
.add-btn{
    width:100%;
    border:none;
    border-radius:0 0 16px 16px;
    padding:14px 14px;
    font-weight:900;
    font-size:.98rem;
    background:var(--mode, var(--blue));
    color:#fff;
    cursor:pointer;
    display:block;
    min-height:52px;
}
.add-btn:hover{ opacity:.93; }
.add-btn:disabled{
    background:#d4dbe4;
    color:#607086;
    cursor:not-allowed;
}

/* ===== STATUS ===== */
.status-box{
    margin-top:18px;
    padding:14px 16px;
    background:#fff;
    border:1px solid var(--line);
    border-radius:14px;
    box-shadow:var(--shadow);
    font-weight:700;
}
.status-box.muted{ color:var(--muted); }
.status-box.error{
    color:#8d1d1d;
    background:#fff1f1;
    border-color:#f1b8b8;
}
.load-sentinel{
    height:10px;
}

/* ===== CART ===== */
.cart-overlay{
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.6);
    backdrop-filter:blur(3px);
    display:none;
    align-items:center;
    justify-content:center;
    z-index:2000;
    padding:14px;
}
.cart-overlay.open{ display:flex; }

.cart-modal{
    width:min(920px, 100%);
    max-height:min(92vh, 900px);
    overflow:hidden;
    background:#fff;
    border-radius:20px;
    box-shadow:0 30px 80px rgba(0,0,0,.28);
    display:flex;
    flex-direction:column;
}
.cart-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    padding:18px 20px;
    border-bottom:1px solid var(--line);
}
.cart-title{
    margin:0;
    font-size:1.25rem;
}
.cart-close{
    border:none;
    background:#eef2f7;
    width:38px;
    height:38px;
    border-radius:999px;
    cursor:pointer;
    font-size:1rem;
    font-weight:800;
}
.cart-body{
    padding:18px 20px 8px;
    overflow:auto;
}
.cart-empty{
    border:1px dashed #cbd5e1;
    border-radius:16px;
    padding:22px;
    text-align:center;
    color:var(--muted);
    font-weight:700;
    background:#fafcff;
}
.cart-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}
.cart-item{
    border:1px solid var(--line);
    border-radius:16px;
    padding:14px;
    background:#fbfdff;
}
.cart-item-top{
    display:flex;
    justify-content:space-between;
    gap:12px;
    margin-bottom:10px;
}
.cart-item-title{
    margin:0;
    font-size:1rem;
    font-weight:800;
}
.cart-item-meta{
    color:var(--muted);
    font-size:.92rem;
    margin-top:4px;
}
.cart-item-price{
    white-space:nowrap;
}
.cart-item-bottom{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    flex-wrap:wrap;
}
.cart-qty{
    display:flex;
    align-items:center;
    gap:8px;
}
.qty-btn{
    width:34px;
    height:34px;
    border:none;
    border-radius:10px;
    background:#eef2f7;
    font-size:1rem;
    font-weight:800;
    cursor:pointer;
}
.qty-num{
    min-width:24px;
    text-align:center;
    font-weight:800;
}
.remove-btn{
    border:none;
    background:#fff1f1;
    color:#991b1b;
    border-radius:10px;
    padding:8px 12px;
    font-weight:700;
    cursor:pointer;
}
.cart-footer{
    border-top:1px solid var(--line);
    padding:18px 20px 20px;
    background:#fff;
}
.cart-summary{
    display:grid;
    grid-template-columns:1fr auto;
    gap:8px 16px;
    align-items:center;
    margin-bottom:14px;
}
.cart-summary-label{
    color:var(--muted);
    font-weight:700;
}
.cart-summary-value{
    text-align:right;
}
.cart-total-row{
    padding-top:6px;
    margin-top:2px;
    border-top:1px solid var(--line);
    font-weight:800;
    font-size:1.08rem;
}
.cart-actions{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    align-items:center;
    margin-top:14px;
}
.checkout-btn{
    border:none;
    border-radius:14px;
    padding:18px 24px;
    font-weight:900;
    cursor:pointer;
}
.checkout-primary{
    background:var(--mode, var(--blue));
    color:#fff;
    width:100%;
    font-size:1.15rem;
    min-height:58px;
}
.checkout-secondary{
    background:#e5e7eb;
    color:#111827;
    width:100%;
    font-size:1rem;
    min-height:48px;
}
.checkout-secondary:hover{
    background:#d1d5db;
}
.empty-cart-btn{
    background:#eef2f7;
    color:#111827;
    border:none;
    border-radius:12px;
    padding:12px 16px;
    font-weight:700;
    cursor:pointer;
}
.cart-tax-note{
    margin-top:8px;
    color:#374151;
    font-size:.92rem;
    font-weight:700;
}
.cart-message{
    margin-top:12px;
    padding:12px 14px;
    border-radius:12px;
    font-weight:700;
    display:none;
}
.cart-message.success{
    display:block;
    background:#ebfbf5;
    border:1px solid #b9e6d5;
    color:#0f5132;
}
.cart-message.error{
    display:block;
    background:#fff1f1;
    border:1px solid #f1b8b8;
    color:#8d1d1d;
}

@media (min-width: 1081px){
    body.music-mode .filter-grid{
        grid-template-columns:repeat(12, minmax(0,1fr));
    }

    body.music-mode .filter-field{
        grid-column:span 2;
    }

    body.music-mode .filter-field[data-field="Sleeve"],
    body.music-mode .filter-field[data-field="Record"]{
        grid-column:span 1;
    }
}

@media (max-width: 1080px){
    .filter-grid{
        grid-template-columns:repeat(3, minmax(0,1fr));
    }
}
@media (max-width: 700px){
    .scroll-top-btn{
        left:50%;
        bottom:12px;
        padding:15px 22px;
        font-size:.96rem;
    }
    .page-wrap{
        width:min(100%, calc(100% - 16px));
        margin-top:14px;
    }
    .hero-top{
        flex-direction:column;
        align-items:flex-start;
    }
    .filter-grid{
        grid-template-columns:repeat(2, minmax(0,1fr));
    }
    .product-grid{
        grid-template-columns:repeat(2, minmax(0,1fr));
        gap:12px;
    }
    .product-title{
        min-height:auto;
    }
    .filter-actions{
        flex-direction:column;
        align-items:flex-start;
    }
    .filter-actions-right{
        width:100%;
        justify-content:space-between;
    }
    .cart-item-top{
        flex-direction:column;
    }
    .cart-footer,
    .cart-body,
    .cart-header{
        padding-left:14px;
        padding-right:14px;
    }
}