.vault-body {
    color: #f8e7b0;
    background-color: #140c06;
    background-image:
        radial-gradient(ellipse 70% 45% at 50% 18%, rgba(245, 197, 66, 0.18), transparent 58%),
        radial-gradient(circle at 50% 100%, rgba(92, 51, 23, 0.55), transparent 42%),
        linear-gradient(180deg, rgba(20, 12, 6, 0.55), rgba(8, 5, 2, 0.88)),
        var(--chest-photo, none),
        linear-gradient(180deg, #2a1608 0%, #0d0804 100%);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.vault {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(100%, 42rem);
    height: 100%;
    margin: 0 auto;
    padding: calc(0.55rem + env(safe-area-inset-top)) 0.7rem calc(0.45rem + env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow: hidden;
}

.vault-orbit {
    pointer-events: none;
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.treasure-bit {
    --bit-scale: clamp(0.9, calc(0.55 + 100vw / 900px), 2);
    position: absolute;
    top: -12%;
    left: var(--bit-left, 10%);
    overflow: hidden;
    opacity: 0.95;
    mix-blend-mode: screen;
    transform-origin: center center;
    animation: treasureFall var(--bit-dur, 10s) linear infinite;
    animation-delay: var(--bit-delay, 0s);
}

.treasure-bit::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    background-repeat: no-repeat;
}

.treasure-bit-tongpan {
    width: 54px;
    height: 60px;
    -webkit-mask-image: radial-gradient(ellipse 21px 25px at 50% 50%, #000 86%, transparent 100%);
    mask-image: radial-gradient(ellipse 21px 25px at 50% 50%, #000 86%, transparent 100%);
}

.treasure-bit-tongpan::before {
    width: 162px;
    height: 120px;
    background-image: var(--tongpan-sheet);
    background-size: 162px 120px;
    animation: tongpanSheet 0.72s linear infinite;
    animation-delay: var(--spin-delay, 0s);
}

.treasure-bit-yuanbao {
    width: 40px;
    height: 42px;
    -webkit-mask-image: radial-gradient(ellipse 16px 18px at 50% 52%, #000 84%, transparent 100%);
    mask-image: radial-gradient(ellipse 16px 18px at 50% 52%, #000 84%, transparent 100%);
}

.treasure-bit-yuanbao::before {
    width: 120px;
    height: 126px;
    background-image: var(--yuanbao-img);
    background-size: 120px 126px;
    animation: yuanbaoSheet 0.84s linear infinite;
    animation-delay: var(--spin-delay, 0s);
}

.vault-top {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
}

.vault-brand {
    min-width: 0;
}

.vault-eyebrow {
    margin: 0 0 0.15rem;
    color: #ffe082;
    font-family: 'Noto Serif SC', serif;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
}

.vault-brand h1 {
    margin: 0;
    color: #ffe9a8;
    font-family: Cinzel, 'Noto Serif SC', serif;
    font-size: clamp(1.55rem, 7vw, 2.1rem);
    letter-spacing: 0.06em;
    text-shadow: 0 0 18px rgba(245, 197, 66, 0.45);
}

.vault-sub {
    margin: 0.12rem 0 0;
    color: #f3d48a;
    font-family: 'Noto Serif SC', serif;
    font-size: 0.82rem;
    letter-spacing: 0.2em;
}

.vault-token {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 4.2rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid rgba(245, 197, 66, 0.55);
    border-radius: 0.7rem;
    background: rgba(20, 12, 6, 0.62);
    box-shadow: inset 0 0 12px rgba(245, 197, 66, 0.12);
}

.vault-token strong {
    color: #ffe082;
    font-family: Cinzel, serif;
    font-size: 1.2rem;
    line-height: 1;
}

.vault-token small {
    margin-top: 0.15rem;
    color: #d4b56a;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
}

.vault-stage {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
}

.vault-dais {
    pointer-events: none;
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: 12%;
    height: 38%;
    border-radius: 50%;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(245, 197, 66, 0.28), transparent 62%),
        radial-gradient(ellipse at 50% 80%, rgba(0, 0, 0, 0.55), transparent 70%);
    filter: blur(0.5px);
}

.chest-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.2rem, 1.4vh, 0.7rem) clamp(0.35rem, 2.2vw, 1.1rem);
    width: min(100%, calc((100dvh - 11rem) * 1.15));
}

.chest-btn {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1.18 / 1;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.chest-btn.is-disabled {
    pointer-events: none;
}

.chest-sprite {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 52% 55%;
    filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.5));
    mix-blend-mode: screen;
    transform-origin: 50% 80%;
    transition: transform 0.18s ease;
}

.chest-btn:not(.is-open):hover .chest-sprite,
.chest-btn:not(.is-open):focus .chest-sprite {
    transform: translateY(-4px) scale(1.05);
}

.chest-btn.is-opening .chest-sprite {
    animation: chestShake 0.16s ease-in-out 2;
}

.chest-hint {
    position: absolute;
    left: 50%;
    bottom: 6%;
    transform: translateX(-50%);
    color: rgba(255, 233, 176, 0.8);
    font-size: clamp(0.5rem, 2.4vw, 0.72rem);
    letter-spacing: 0.08em;
    text-shadow: 0 1px 4px #000;
    white-space: nowrap;
}

.chest-btn.is-open .chest-hint,
.chest-btn.is-opening .chest-hint {
    opacity: 0;
}

.chest-prize {
    position: absolute;
    left: 50%;
    top: 18%;
    width: 42%;
    transform: translateX(-50%);
    pointer-events: none;
}

.chest-prize .prize-img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(255, 213, 79, 0.8));
}

.chest-btn.is-open .chest-prize {
    animation: prizePop 0.4s ease-out;
}

.vault-cta {
    position: relative;
    z-index: 2;
    margin-top: 0.65rem;
    padding: 0.55rem 1.4rem;
    border: 1px solid #f5c542;
    border-radius: 999px;
    color: #3a2208;
    background: linear-gradient(180deg, #ffe082, #d4a017);
    font-family: Cinzel, 'Noto Serif SC', serif;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    cursor: pointer;
}

.vault.no-tokens .chest-btn {
    opacity: 0.5;
    pointer-events: none;
}

.vault-winners {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
    min-height: 2.4rem;
    padding: 0.35rem 0.2rem 0.15rem;
}

.vault-winners-label {
    flex-shrink: 0;
    color: #f5c542;
    font-family: Cinzel, serif;
    font-size: 0.62rem;
    letter-spacing: 0.16em;
}

.vault-ticker-wrap {
    overflow: hidden;
    flex: 1;
    min-width: 0;
    mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.vault-ticker {
    display: flex;
    gap: 1.4rem;
    width: max-content;
    color: #f8e7b0;
    font-size: 0.72rem;
    animation: ticker 18s linear infinite;
}

.vault-ticker span {
    white-space: nowrap;
}

@keyframes treasureFall {
    0% {
        transform: translate3d(0, 0, 0) scale(calc(var(--bit-size, 0.5) * var(--bit-scale, 1)));
    }
    50% {
        transform: translate3d(calc(var(--bit-dir, 1) * var(--bit-drift, 24px)), 62vh, 0) scale(calc(var(--bit-size, 0.5) * var(--bit-scale, 1)));
    }
    100% {
        transform: translate3d(calc(var(--bit-dir, 1) * var(--bit-drift, 24px) * -0.4), 128vh, 0) scale(calc(var(--bit-size, 0.5) * var(--bit-scale, 1)));
    }
}

@keyframes tongpanSheet {
    0%, 16.66% { transform: translate3d(0, 0, 0); }
    16.67%, 33.32% { transform: translate3d(-54px, 0, 0); }
    33.33%, 49.98% { transform: translate3d(-108px, 0, 0); }
    49.99%, 66.64% { transform: translate3d(0, -60px, 0); }
    66.65%, 83.30% { transform: translate3d(-54px, -60px, 0); }
    83.31%, 100% { transform: translate3d(-108px, -60px, 0); }
}

@keyframes yuanbaoSheet {
    0%, 14.28% { transform: translate3d(0, 0, 0); }
    14.29%, 28.56% { transform: translate3d(-40px, 0, 0); }
    28.57%, 42.84% { transform: translate3d(0, -42px, 0); }
    42.85%, 57.12% { transform: translate3d(-40px, -42px, 0); }
    57.13%, 71.40% { transform: translate3d(0, -84px, 0); }
    71.41%, 85.68% { transform: translate3d(-40px, -84px, 0); }
    85.69%, 100% { transform: translate3d(-80px, -84px, 0); }
}

@keyframes chestShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg); }
    75% { transform: rotate(8deg); }
}

@keyframes prizePop {
    from { opacity: 0; transform: translate(-50%, 14px) scale(0.4); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes ticker {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@media (min-width: 768px) {
    .vault {
        width: min(100%, 48rem);
        padding: 1rem 1.25rem 0.85rem;
    }

    .chest-grid {
        width: min(100%, calc((100dvh - 12rem) * 1.18));
    }
}

@media (min-width: 1100px) {
    .vault {
        width: min(100%, 56rem);
    }

    .chest-grid {
        width: min(100%, 44rem, calc((100dvh - 12rem) * 1.18));
    }
}
