:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0b0f17;
    color: #f8fafc;
    --bg: #0b0f17;
    --panel: #111827;
    --panel-soft: #151f2f;
    --border: rgba(148, 163, 184, .18);
    --muted: #94a3b8;
    --text: #f8fafc;
    --gold: #d6a84f;
    --gold-soft: rgba(214, 168, 79, .14);
    --green: #22c55e;
    --red: #ef4444;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
        radial-gradient(circle at top right, rgba(214,168,79,.16), transparent 34%),
        var(--bg);
    background-size: 44px 44px, 44px 44px, auto, auto;
}

body.modal-open {
    overflow: hidden;
}

.page {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 52px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    background: rgba(17,24,39,.88);
    border-radius: 16px;
    box-shadow: 0 18px 60px rgba(0,0,0,.24);
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #f2d38b, var(--gold));
    color: #14100a;
    font-weight: 950;
    letter-spacing: -.04em;
}

.brand strong {
    display: block;
    font-size: 16px;
    letter-spacing: .01em;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-balance {
    display: grid;
    gap: 2px;
    min-width: 116px;
    padding: 8px 12px;
    border: 1px solid rgba(214,168,79,.2);
    border-radius: 14px;
    background: rgba(214,168,79,.08);
}

.header-balance span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.header-balance strong {
    color: #f8d890;
    font-size: 16px;
}

.donate-menu {
    position: relative;
}

.donate-toggle {
    padding: 10px 14px;
    white-space: nowrap;
}

.donate-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 20;
    width: 230px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(8,13,22,.98);
    box-shadow: 0 24px 80px rgba(0,0,0,.42);
}

.donate-dropdown form {
    margin: 8px 0 0;
}

.donate-dropdown button {
    width: 100%;
}

.nav-status,
.sync-status,
.type {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    border-radius: 999px;
    padding: 8px 12px;
    border: 1px solid rgba(214,168,79,.24);
    background: var(--gold-soft);
    color: #f8d890;
    font-size: 13px;
    font-weight: 850;
}

.nav-status.connected,
.sync-status.connected {
    border-color: rgba(34,197,94,.24);
    background: rgba(34,197,94,.12);
    color: #86efac;
}

.hero {
    display: grid;
    grid-template-columns: 1.35fr .65fr;
    gap: 14px;
    padding: 22px 0 14px;
}

.hero-copy,
.hero-card,
.sync-panel,
.history-panel,
.card,
.lock-card {
    border: 1px solid var(--border);
    background: rgba(17,24,39,.84);
    border-radius: 22px;
    box-shadow: 0 20px 70px rgba(0,0,0,.22);
}

.hero-copy {
    padding: clamp(22px, 4vw, 36px);
}

.hero-card {
    padding: 22px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: linear-gradient(180deg, rgba(21,31,47,.92), rgba(17,24,39,.88));
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--gold);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .16em;
    text-transform: uppercase;
}

h1 {
    max-width: 720px;
    margin: 0 0 12px;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1;
    letter-spacing: -.05em;
}

h2 {
    margin: 0 0 10px;
    letter-spacing: -.035em;
}

.subtitle,
.hero-card p,
.sync-copy p,
.card p,
.lock-card p {
    color: var(--muted);
    line-height: 1.55;
}

.hero-card span {
    color: var(--muted);
}

.hero-card strong {
    display: block;
    margin: 6px 0;
    font-size: 24px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.primary-link,
.secondary-link,
button {
    border-radius: 14px;
    padding: 13px 16px;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
    transition: transform .16s ease, opacity .16s ease, border-color .16s ease, background .16s ease;
}

.primary-link,
button {
    border: 1px solid rgba(242,211,139,.3);
    background: linear-gradient(135deg, #f2d38b, var(--gold));
    color: #151008;
}

.secondary-link,
.test-button,
.category {
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text);
}

button:hover:not(:disabled),
.primary-link:hover,
.secondary-link:hover {
    transform: translateY(-1px);
}

.card .secondary-link {
    width: 100%;
    margin-top: 8px;
    background: rgba(255,255,255,.055);
    color: var(--text);
}

button:disabled {
    cursor: not-allowed;
    opacity: .45;
    transform: none;
}

.message {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(96,165,250,.18);
    background: rgba(96,165,250,.1);
    color: #bfdbfe;
}

.message.success {
    border-color: rgba(34,197,94,.18);
    background: rgba(34,197,94,.1);
    color: #bbf7d0;
}

.message.error {
    border-color: rgba(239,68,68,.2);
    background: rgba(239,68,68,.1);
    color: #fecaca;
}

.hidden {
    display: none !important;
}

.sync-panel {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 22px;
    padding: 24px;
    margin-bottom: 18px;
}

.history-panel {
    padding: 20px;
    margin-top: 18px;
}

.own-purchases {
    display: grid;
    gap: 10px;
}

.purchase-entry {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
}

.purchase-entry span {
    color: var(--muted);
}

.sync-form {
    display: grid;
    align-content: center;
    gap: 11px;
}

label {
    color: #e2e8f0;
    font-weight: 850;
}

input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(2,6,23,.44);
    color: white;
    padding: 14px 15px;
    outline: none;
}

input:focus {
    border-color: rgba(214,168,79,.55);
    box-shadow: 0 0 0 4px rgba(214,168,79,.08);
}

.shop-section {
    position: relative;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(17,24,39,.58);
}

.categories {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.category {
    padding: 9px 12px;
    border-radius: 999px;
}

.category.active {
    border-color: rgba(214,168,79,.46);
    background: var(--gold-soft);
    color: #f8d890;
}

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

.card {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    padding: 16px;
    overflow: hidden;
    border-radius: 18px;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(214,168,79,.26);
    box-shadow: 0 18px 54px rgba(0,0,0,.28), 0 0 34px rgba(214,168,79,.06);
}

.card.disabled {
    opacity: .45;
}

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

.card-body {
    min-height: 92px;
}

.card-body h2 {
    margin-bottom: 8px;
    font-size: 20px;
}

.card-body p {
    margin: 0;
    font-size: 14px;
}

.product-image {
    position: relative;
    width: calc(100% + 32px);
    height: 170px;
    margin: -16px -16px 14px;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    background:
        radial-gradient(circle at center, rgba(214,168,79,.08), transparent 55%),
        var(--panel-soft);
}

.product-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
}

.product-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(11,15,23,.42));
    pointer-events: none;
}

.empty-products {
    grid-column: 1 / -1;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(17,24,39,.58);
    color: var(--muted);
    text-align: center;
}

.icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(214,168,79,.12);
    font-size: 23px;
}

.type {
    border-color: rgba(148,163,184,.18);
    background: rgba(148,163,184,.1);
    color: #cbd5e1;
}

.price {
    display: block;
    margin: auto 0 12px;
    font-size: 25px;
    letter-spacing: -.04em;
}

.card form {
    margin-bottom: 8px;
}

.card button {
    width: 100%;
    margin-top: 8px;
}

.card .test-button {
    padding: 11px 14px;
    font-size: 13px;
}

.case-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background:
        radial-gradient(circle at 50% 28%, rgba(214,168,79,.14), transparent 34%),
        linear-gradient(180deg, rgba(5,7,13,.86), rgba(0,0,0,.82));
    overflow: auto;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3,7,18,.72);
    backdrop-filter: blur(10px);
}

.confirm-modal.hidden {
    display: none !important;
}

.confirm-box {
    width: min(440px, 100%);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background:
        radial-gradient(circle at top left, rgba(214,168,79,.15), transparent 38%),
        rgba(17,24,39,.96);
    box-shadow: 0 30px 90px rgba(0,0,0,.45);
}

.confirm-box h2 {
    margin-bottom: 10px;
}

.confirm-box p {
    color: var(--muted);
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.case-modal.hidden {
    display: none;
}

.case-modal:not(.hidden) {
    display: flex !important;
}

.case-shell {
    position: relative;
    z-index: 10000;
    width: min(1120px, 100%);
    border: 1px solid rgba(148,163,184,.16);
    border-radius: 24px;
    background:
        radial-gradient(circle at top, rgba(214,168,79,.08), transparent 36%),
        #05070d;
    box-shadow: 0 30px 120px rgba(0,0,0,.55), 0 0 80px rgba(214,168,79,.08);
    padding: 24px;
    min-height: 420px;
    color: var(--text);
    opacity: 1;
    visibility: visible;
}

.case-close {
    width: auto;
    margin-bottom: 18px;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0;
}

.case-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.case-head img {
    width: 74px;
    height: 74px;
    border-radius: 18px;
    object-fit: cover;
    box-shadow: 0 0 28px rgba(214,168,79,.2);
}

.case-head h2 {
    margin-bottom: 4px;
}

.case-head p:last-child {
    margin: 0;
    color: var(--muted);
}

.case-roller {
    position: relative;
    height: 250px;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,.12);
    border-radius: 16px;
    background:
        linear-gradient(90deg, rgba(5,7,13,.98), transparent 16%, transparent 84%, rgba(5,7,13,.98)),
        radial-gradient(circle at center, rgba(214,168,79,.18), transparent 38%),
        #080d16;
    box-shadow: inset 0 0 32px rgba(0,0,0,.55), 0 0 36px rgba(214,168,79,.08);
}

.case-track {
    display: flex;
    align-items: stretch;
    gap: 14px;
    height: 100%;
    padding: 20px 0;
    will-change: transform;
}

.case-loading {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #f8d890;
    font-weight: 950;
    letter-spacing: .04em;
}

.case-pointer {
    position: absolute;
    left: 50%;
    z-index: 3;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    filter: drop-shadow(0 0 10px rgba(248,216,144,.72));
}

.case-pointer.top {
    top: 0;
    border-top: 18px solid #f8d890;
}

.case-pointer.bottom {
    bottom: 0;
    border-bottom: 18px solid #f8d890;
}

.roll-item {
    flex: 0 0 170px;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    gap: 8px;
    align-items: center;
    justify-items: center;
    border: 1px solid rgba(148,163,184,.14);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.04), transparent),
        rgba(17,24,39,.82);
    padding: 12px;
    text-align: center;
}

.roll-item img {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 999px;
}

.roll-item strong {
    font-size: 13px;
}

.roll-item small,
.rarity {
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
}

.rarity {
    justify-self: stretch;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(148,163,184,.1);
}

.roll-item.rare {
    border-color: rgba(56,189,248,.34);
    box-shadow: inset 0 0 0 1px rgba(56,189,248,.08);
}

.roll-item.epic {
    border-color: rgba(168,85,247,.44);
    box-shadow: inset 0 0 0 1px rgba(168,85,247,.12), 0 0 38px rgba(168,85,247,.08);
}

.roll-item.legendary,
.roll-item.winner {
    border-color: rgba(214,168,79,.56);
    box-shadow: inset 0 0 0 1px rgba(214,168,79,.16), 0 0 42px rgba(214,168,79,.14);
}

.roll-item.winner {
    transform: scale(1.05);
    animation: winnerPulse 1s ease-in-out infinite alternate;
}

@keyframes winnerPulse {
    from {
        box-shadow: inset 0 0 0 1px rgba(214,168,79,.16), 0 0 42px rgba(214,168,79,.14);
    }

    to {
        box-shadow: inset 0 0 0 1px rgba(248,216,144,.36), 0 0 70px rgba(214,168,79,.34);
    }
}

.case-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 14px 0;
}

.case-actions button,
.case-actions .secondary-link,
.case-actions form {
    width: auto;
}

.case-actions form {
    margin: 0;
}

.case-result {
    margin-top: 14px;
    border: 1px solid rgba(214,168,79,.28);
    border-radius: 18px;
    background: var(--gold-soft);
    padding: 18px;
    text-align: center;
}

.case-result h2 {
    color: #f8d890;
}

.case-rewards {
    display: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.case-rewards.visible {
    display: grid;
}

.case-rewards .roll-item {
    min-height: 190px;
}

.lock-overlay {
    display: none;
}

.shop-section.locked .lock-overlay {
    position: absolute;
    inset: 72px 0 0;
    z-index: 5;
    display: grid;
    place-items: start center;
    padding-top: 42px;
    border-radius: 22px;
    background: rgba(11,15,23,.76);
    backdrop-filter: blur(10px);
}

.lock-card {
    max-width: 440px;
    padding: 28px;
    text-align: center;
}

.lock-icon {
    display: inline-flex;
    margin-bottom: 14px;
    border-radius: 999px;
    padding: 8px 12px;
    border: 1px solid rgba(214,168,79,.25);
    background: var(--gold-soft);
    color: #f8d890;
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .12em;
}

@media (max-width: 940px) {
    .hero,
    .sync-panel,
    .products,
    .case-rewards {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .case-modal {
        padding: 12px;
    }

    .case-shell {
        max-height: calc(100vh - 24px);
        overflow: auto;
    }

    .case-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .categories {
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .page {
        width: min(100% - 20px, 1240px);
        padding-top: 10px;
    }

    .topbar,
    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions,
    .header-balance,
    .donate-menu,
    .donate-toggle {
        width: 100%;
    }

    .donate-dropdown {
        left: 0;
        right: auto;
        width: 100%;
    }

    .hero-actions {
        flex-direction: column;
    }

    .products {
        grid-template-columns: 1fr;
    }

    .product-image {
        height: 110px;
    }
}
