:root {
    --game-frame-width: 375px;
    --game-frame-height: 812px;
    --game-scale: 1;
    --game-screen-scale: var(--game-scale, var(--dice-scale, 1));
}

.game-stage {
    position: relative;
    width: calc(var(--game-frame-width) * var(--game-screen-scale));
    height: calc(var(--game-frame-height) * var(--game-screen-scale));
    overflow: hidden;
    background: #030623;
}

.game-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--game-frame-width);
    height: var(--game-frame-height);
    overflow: hidden;
    background: #030623;
    transform: scale(var(--game-screen-scale));
    transform-origin: top left;
}

.game-layer,
.layer {
    position: absolute;
}

.game-layer-img,
.layer-img {
    position: absolute;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    pointer-events: none;
    user-select: none;
}

.game-cover,
.cover {
    object-fit: cover;
}

.game-contain,
.contain {
    object-fit: contain;
}

.game-fill,
.fill {
    object-fit: fill;
}

.game-top-bar {
    position: absolute;
    top: 36px;
    left: 16px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 343px;
    height: 36px;
}

.game-top-back {
    position: relative;
    width: 46px;
    height: 36px;
    flex: 0 0 46px;
}

.game-top-icon {
    position: absolute;
    top: 0;
    left: 154px;
    width: 36px;
    height: 36px;
    overflow: hidden;
    border-radius: 6px;
}

.game-coin-pill {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 90px;
    height: 29px;
    gap: 4px;
    padding: 0 7px 0 6px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 15px;
    background: rgba(0, 15, 63, 0.7);
    color: #fff;
    font-size: 16px;
    line-height: 15px;
    white-space: nowrap;
}

.game-coin-pill img {
    width: 21px;
    height: 21px;
    flex: 0 0 21px;
    filter: drop-shadow(0 0 5px rgba(255, 197, 49, 0.45));
}

.game-coin-plus {
    color: #ffd15a;
    font-size: 22px;
    font-weight: 900;
    line-height: 18px;
    text-shadow: 0 0 8px rgba(255, 178, 47, 0.72);
}

.game-vs-badge {
    transform-origin: 50% 50%;
    will-change: transform, filter;
}

.game-vs-badge::after {
    position: absolute;
    inset: 14px 10px;
    content: '';
    border: 2px solid rgba(255, 213, 87, 0.68);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.62);
    filter: drop-shadow(0 0 10px rgba(255, 96, 243, 0.68));
}

.is-vs-impact .game-vs-badge,
.is-matching .vs-badge {
    animation: vs-drop-impact 900ms cubic-bezier(0.13, 0.92, 0.18, 1) both;
}

.is-vs-impact .game-vs-badge::after,
.is-matching .vs-badge::after {
    animation: vs-impact-ring 580ms ease-out 430ms both;
}

.is-screen-impact {
    animation: screen-impact-shake 520ms ease-out 420ms both;
}

.is-self-win-impact {
    animation: you-win-screen-smash 780ms cubic-bezier(0.14, 0.84, 0.18, 1)
        430ms both;
}

.game-countdown-number {
    transform-origin: center;
}

.game-countdown-number.is-ticking {
    animation: countdown-number-pop 980ms cubic-bezier(0.16, 0.95, 0.2, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .is-screen-impact,
    .is-self-win-impact,
    .is-vs-impact .game-vs-badge,
    .is-vs-impact .game-vs-badge::after,
    .is-matching .vs-badge,
    .is-matching .vs-badge::after {
        animation: none !important;
    }
}

@keyframes screen-impact-shake {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(var(--game-screen-scale));
    }
    12% {
        transform: translate3d(0, 9px, 0) scale(var(--game-screen-scale));
    }
    24% {
        transform: translate3d(-7px, -5px, 0) scale(var(--game-screen-scale));
    }
    36% {
        transform: translate3d(6px, 4px, 0) scale(var(--game-screen-scale));
    }
    50% {
        transform: translate3d(-4px, 2px, 0) scale(var(--game-screen-scale));
    }
    66% {
        transform: translate3d(3px, -2px, 0) scale(var(--game-screen-scale));
    }
    82% {
        transform: translate3d(-1px, 1px, 0) scale(var(--game-screen-scale));
    }
}

@keyframes vs-drop-impact {
    0% {
        opacity: 0;
        filter: brightness(1.9) drop-shadow(0 0 34px #ff79ff);
        transform: translateY(-640px) scale(4.8) rotate(-12deg);
    }
    34% {
        opacity: 1;
        filter: brightness(1.75) drop-shadow(0 0 32px #4cc9ff);
        transform: translateY(-120px) scale(2.35) rotate(5deg);
    }
    58% {
        opacity: 1;
        filter: brightness(1.62) drop-shadow(0 0 28px #ffd557);
        transform: translateY(22px) scale(0.78) rotate(2deg);
    }
    72% {
        filter: brightness(1.48) drop-shadow(0 0 24px #ff79ff);
        transform: translateY(-12px) scale(1.18) rotate(-1deg);
    }
    86% {
        filter: brightness(1.18) drop-shadow(0 0 14px #4cc9ff);
        transform: translateY(4px) scale(0.96) rotate(0.5deg);
    }
    100% {
        opacity: 1;
        filter: brightness(1);
        transform: translateY(0) scale(1) rotate(0);
    }
}

@keyframes vs-impact-ring {
    0% {
        opacity: 0.95;
        transform: scale(0.36);
    }
    100% {
        opacity: 0;
        transform: scale(1.92);
    }
}

@keyframes you-win-drop-impact {
    0% {
        opacity: 0;
        filter: brightness(1.9) drop-shadow(0 0 36px #ff79ff);
        transform: translateY(-650px) scale(3.9) rotate(-7deg);
    }
    34% {
        opacity: 1;
        filter: brightness(1.75) drop-shadow(0 0 32px #4cc9ff);
        transform: translateY(-122px) scale(2.05) rotate(4deg);
    }
    58% {
        opacity: 1;
        filter: brightness(1.55) drop-shadow(0 0 30px #ffd557);
        transform: translateY(28px) scale(0.78) rotate(1deg);
    }
    72% {
        filter: brightness(1.42) drop-shadow(0 0 24px #ff79ff);
        transform: translateY(-16px) scale(1.16) rotate(-0.8deg);
    }
    86% {
        filter: brightness(1.18) drop-shadow(0 0 16px #4cc9ff);
        transform: translateY(4px) scale(0.96) rotate(0.3deg);
    }
    100% {
        opacity: 1;
        filter: drop-shadow(0 5px 0 rgba(94, 17, 0, 0.9))
            drop-shadow(0 0 22px rgba(255, 205, 46, 0.9))
            drop-shadow(0 0 36px rgba(255, 77, 0, 0.78));
        transform: translateY(0) scale(1) rotate(0);
    }
}

@keyframes you-win-screen-smash {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(var(--game-screen-scale));
        filter: none;
    }
    12% {
        transform: translate3d(0, 14px, 0) scale(var(--game-screen-scale));
        filter: brightness(1.22) contrast(1.08);
    }
    24% {
        transform: translate3d(-12px, -8px, 0) scale(var(--game-screen-scale));
    }
    36% {
        transform: translate3d(10px, 7px, 0) scale(var(--game-screen-scale));
    }
    50% {
        transform: translate3d(-7px, 4px, 0) scale(var(--game-screen-scale));
    }
    66% {
        transform: translate3d(5px, -3px, 0) scale(var(--game-screen-scale));
        filter: brightness(1.08) contrast(1.03);
    }
    82% {
        transform: translate3d(-2px, 1px, 0) scale(var(--game-screen-scale));
    }
}

@keyframes you-win-screen-flash {
    0% {
        opacity: 0;
    }
    8% {
        opacity: 1;
    }
    22% {
        opacity: 0.46;
    }
    100% {
        opacity: 0;
    }
}

@keyframes you-win-floor-impact {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.38, 0.2);
    }
    16% {
        opacity: 1;
        transform: translateX(-50%) scale(1.05, 0.52);
    }
    58% {
        opacity: 0.62;
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) scale(1.32, 0.72);
    }
}

@keyframes search-orbit {
    0% {
        transform: rotate(0deg) translateX(var(--search-orbit-radius, 12px))
            rotate(0deg);
    }
    100% {
        transform: rotate(360deg) translateX(var(--search-orbit-radius, 12px))
            rotate(-360deg);
    }
}

@keyframes matching-center-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dice-roll-fallback {
    0% {
        transform: scale(0.88) rotate(0deg);
        opacity: 0.78;
    }
    50% {
        transform: scale(1.08) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0.88) rotate(360deg);
        opacity: 0.78;
    }
}

@keyframes countdown-number-pop {
    0% {
        opacity: 0;
        transform: scale(0.32);
        filter: drop-shadow(0 5px 0 rgba(94, 17, 0, 0.9))
            drop-shadow(0 0 8px rgba(255, 205, 46, 0.55));
    }
    24% {
        opacity: 1;
        transform: scale(1.18);
        filter: drop-shadow(0 5px 0 rgba(94, 17, 0, 0.9))
            drop-shadow(0 0 24px rgba(255, 229, 86, 1))
            drop-shadow(0 0 42px rgba(255, 77, 0, 0.86));
    }
    70% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.86);
    }
}
