:root {
    --bg: #0f1320;
    --bg-2: #161b2e;
    --panel: #1c2238;
    --border: #2b3354;
    --text: #eef1fb;
    --text-dim: #9aa3c4;
    --red: #ee1515;
    --red-dark: #c40c0c;
    --blue: #3b4cca;
    --gold: #ffcb05;
    --green: #2ecc71;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(
            900px 500px at 80% -10%,
            rgba(59, 76, 202, 0.25),
            transparent
        ),
        var(--bg);
    color: var(--text);
    font-family:
        "Segoe UI",
        -apple-system,
        BlinkMacSystemFont,
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    min-height: 100vh;
}

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 22px;
    background: rgba(15, 19, 32, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.brand-name span {
    color: var(--gold);
}

.pokeball {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(
        to bottom,
        var(--red) 0 47%,
        #111 47% 53%,
        #fff 53% 100%
    );
    border: 2px solid #111;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.pokeball::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 9px;
    background: #fff;
    border: 2px solid #111;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.search-box {
    flex: 1;
    display: flex;
    justify-content: center;
}

#search {
    width: 100%;
    max-width: 460px;
    height: 42px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    padding: 0 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

#search::placeholder {
    color: var(--text-dim);
}

#search:focus {
    border-color: var(--gold);
}

.cart-btn {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 46px;
    height: 42px;
    cursor: pointer;
    font-size: 19px;
    transition:
        transform 0.1s,
        border-color 0.15s;
}

.cart-btn:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg);
}

/* ---------- Main nav menu ---------- */
.mainnav {
    position: sticky;
    top: 67px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 8px 22px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.mainnav .nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: nowrap;
    transition:
        color 0.12s,
        background 0.12s;
}

.mainnav .nav-link:hover {
    color: var(--text);
    background: var(--panel-2, var(--bg-2));
}

.mainnav .nav-link.active {
    color: #1a1a1a;
    background: var(--gold);
}

.nav-divider {
    width: 1px;
    align-self: stretch;
    background: var(--border);
    margin: 4px 8px;
}

@media (max-width: 640px) {
    .mainnav {
        top: 0;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .nav-divider {
        display: none;
    }
}

/* ---------- Hero ---------- */
.hero {
    max-width: 1180px;
    margin: 0 auto;
    padding: 56px 22px 30px;
    display: flex;
    align-items: center;
    gap: 30px;
}

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

.kicker {
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 12px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 12px;
}

.hero h1 {
    font-size: clamp(28px, 4.5vw, 48px);
    line-height: 1.08;
    letter-spacing: -1px;
}

.hero .sub {
    margin: 18px 0 26px;
    color: var(--text-dim);
    font-size: 16px;
    max-width: 520px;
    line-height: 1.6;
}

.cta {
    display: inline-block;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    padding: 14px 28px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    transition: transform 0.12s;
}

.cta:hover {
    transform: translateY(-2px);
}

.hero-art {
    flex-shrink: 0;
    width: 280px;
    max-width: 38vw;
    filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.5));
    animation: float 4s ease-in-out infinite;
}

.hero-art img {
    width: 100%;
    height: auto;
    display: block;
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-14px);
    }
}

/* ---------- Filters ---------- */
.filters {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
}

.chip-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chip-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 700;
    margin-right: 2px;
}

.chip {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.12s;
    white-space: nowrap;
}

.chip:hover {
    color: var(--text);
    border-color: var(--gold);
}

.chip.active {
    background: var(--gold);
    color: #1a1a1a;
    border-color: var(--gold);
}

.sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-wrap label {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 700;
}

#sort {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

#sort:focus {
    border-color: var(--gold);
}

/* ---------- Catalog grid ---------- */
.catalog {
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 22px 70px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 22px;
}

.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition:
        transform 0.14s,
        border-color 0.14s,
        box-shadow 0.14s;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--gold);
    box-shadow: var(--shadow);
}

/* Stylized box art (generated, no external photo needed) */
.box-art {
    position: relative;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    overflow: hidden;
}

.box-art::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            circle at 30% 20%,
            rgba(255, 255, 255, 0.25),
            transparent 60%
        ),
        var(--art-color);
}

.box-art::after {
    content: "";
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 14px solid rgba(255, 255, 255, 0.12);
    right: -60px;
    bottom: -60px;
}

.product-svg {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.45));
}

/* Real product photo overlay (from images/<id>.jpg). When it loads it
   covers the whole art area; if it 404s the JS removes it and the SVG shows. */
.product-photo {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

/* When a real photo loads, show it on a clean white backing and hide the
   generated mockup layers so the full box is visible (not cropped). */
.box-art.has-photo {
    background: #ffffff;
}

.box-art.has-photo::before,
.box-art.has-photo::after,
.box-art.has-photo .product-svg,
.box-art.has-photo .box-type-tag {
    display: none;
}

.box-type-tag {
    position: absolute;
    bottom: 12px;
    z-index: 1;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 800;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 4px 10px;
    border-radius: 999px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.box-face {
    position: relative;
    z-index: 1;
    width: 130px;
    min-height: 150px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px 10px;
    text-align: center;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.box-face .mini-pokeball {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(
        to bottom,
        #fff 0 47%,
        rgba(0, 0, 0, 0.6) 47% 53%,
        rgba(255, 255, 255, 0.85) 53% 100%
    );
    border: 2px solid rgba(0, 0, 0, 0.5);
}

.box-face .face-set {
    font-weight: 800;
    font-size: 14px;
    line-height: 1.15;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.box-face .face-type {
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 700;
}

.era-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.low-stock {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
}

.card-body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.card-type {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gold);
    font-weight: 700;
}

.card-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

.card-blurb {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.45;
    flex: 1;
}

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

.card-price {
    font-size: 19px;
    font-weight: 800;
}

.add-btn {
    background: linear-gradient(135deg, var(--blue), #2a36a0);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition:
        transform 0.1s,
        filter 0.1s;
}

.add-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.add-btn:active {
    transform: scale(0.96);
}

.empty {
    text-align: center;
    color: var(--text-dim);
    padding: 60px 20px;
    font-size: 16px;
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 28px 22px;
    text-align: center;
}

.site-footer p {
    max-width: 720px;
    margin: 0 auto;
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.6;
}

/* ---------- Cart drawer ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 50;
    opacity: 1;
    transition: opacity 0.2s;
}

.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 400px;
    max-width: 92vw;
    background: var(--bg-2);
    border-left: 1px solid var(--border);
    z-index: 60;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}

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

.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.cart-header h2 {
    font-size: 18px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.icon-btn:hover {
    color: var(--text);
    background: var(--panel);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-dim);
    padding: 30px;
    font-size: 14px;
}

.cart-item {
    display: flex;
    gap: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
}

.ci-thumb {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--ci-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ci-thumb .mini-pokeball {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(
        to bottom,
        #fff 0 47%,
        rgba(0, 0, 0, 0.6) 47% 53%,
        rgba(255, 255, 255, 0.85) 53% 100%
    );
    border: 2px solid rgba(0, 0, 0, 0.5);
}

.ci-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ci-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
}

.ci-price {
    font-size: 12px;
    color: var(--text-dim);
}

.ci-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text);
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

.qty-btn:hover {
    border-color: var(--gold);
}

.qty-val {
    min-width: 22px;
    text-align: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ci-remove {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
}

.ci-remove:hover {
    color: var(--red);
}

.cart-footer {
    border-top: 1px solid var(--border);
    padding: 16px 20px 20px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
    font-size: 15px;
}

.cart-total span:last-child {
    font-size: 22px;
    font-weight: 800;
}

.checkout-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--green), #25a25a);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition:
        transform 0.1s,
        filter 0.1s;
}

.checkout-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.checkout-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---------- Checkout modal ---------- */
.checkout-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 30px 16px;
}

.checkout-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.checkout-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.checkout-head h2 {
    font-size: 18px;
}

.checkout-summary {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-dim);
}

.checkout-summary .cs-line {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 0;
}

.checkout-summary .cs-total {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
}

.checkout-form {
    padding: 16px 20px 20px;
}

.checkout-form .field {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.checkout-form .checkout-row {
    display: flex;
    gap: 12px;
}

.checkout-form .checkout-row .field {
    flex: 1;
}

.checkout-form label {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 700;
}

.checkout-form input,
.checkout-form textarea {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    width: 100%;
}

.checkout-form input:focus,
.checkout-form textarea:focus {
    border-color: var(--gold);
}

.checkout-form input:invalid:not(:placeholder-shown) {
    border-color: var(--red);
}

.checkout-form .checkout-btn {
    margin-top: 6px;
}

.checkout-fineprint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
    text-align: center;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111726;
    border: 1px solid var(--gold);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    z-index: 80;
    box-shadow: var(--shadow);
    opacity: 0;
    transition:
        opacity 0.2s,
        transform 0.2s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .hero {
        flex-direction: column-reverse;
        text-align: center;
        padding-top: 30px;
    }
    .hero .sub {
        margin-left: auto;
        margin-right: auto;
    }
    .hero-art {
        width: 180px;
    }
    .filters {
        flex-direction: column;
        align-items: flex-start;
    }
}
