body.spb-popup-active {
    overflow: hidden;
}

:root {
    --spb-overlay-color: rgba(0,0,0,0.6);
}

.spb-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--spb-overlay-color);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.spb-popup-overlay[style*="display: flex"] {
    opacity: 1;
}

.spb-popup-banner {
    position: relative;
    background: #fff;
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    padding: 0 !important; /* Full background, no padding */
    max-width: min(90vw, 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Default gradient if no image */
.spb-popup-banner:not([style*="background-image"]) {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.spb-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: #333;
    line-height: 1;
    z-index: 100;
}

.spb-form-close-btn, .spb-success-close-btn {
    color: #333;
    text-shadow: none;
}

.spb-content-wrap { width: 100%; height: 100%; }
.spb-game-step { width: 100%; height: 100%; position: relative; }

.spb-ajax-form input {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}

.spb-ajax-form button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.spb-continue-btn:hover { transform: scale(1.05); }

.spb-success-step {
    animation: spbFadeIn 0.3s ease;
}

@keyframes spbFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Gift Box 3D Flip */
.spb-gift-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.spb-gift-box {
    width: 100px;
    height: 100px;
    perspective: 1000px;
    cursor: pointer;
    margin: 0 auto;
}

.spb-gift-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.spb-gift-box.is-flipped .spb-gift-inner {
    transform: rotateY(180deg);
}

.spb-gift-front, .spb-gift-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.spb-gift-front { background: transparent; }
.spb-gift-back {
    background: #e74c3c;
    color: #fff;
    transform: rotateY(180deg);
    font-weight: bold;
}

.spb-gift-front img { max-width: 80%; max-height: 80%; }

/* Lucky Wheel */
.spb-lucky-wheel { 
    position: absolute; 
    left: 50%;
    transform: translateX(-50%);
}
.spb-wheel-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spb-wheel-bg-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%; /* Slightly larger to act as a frame/background */
    height: 120%;
    object-fit: contain;
    z-index: 1;
    pointer-events: none;
}
.spb-wheel-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    z-index: 2;
}
.spb-wheel-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}
.spb-wheel-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.spb-wheel-btn-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.spb-wheel-pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid #fff; /* Color should ideally match btn bg or be white */
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.2));
}
.spb-wheel-btn .spb-wheel-pointer {
    border-bottom-color: inherit; /* Tries to match button color */
}

canvas { max-width: 100%; height: auto; display: block; margin: 0 auto; }

@media (max-width: 600px) {
    .spb-gift-grid { grid-template-columns: repeat(2, 1fr); }
}
