:root {
    --rfg-red: #dc102a;
    --rfg-dark: #111111;
    --rfg-text: #1d2129;
    --rfg-card-bg: #ffffff;
    --rfg-card-border: #e9ebf0;
}

.rfg-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.rfg-overlay.rfg-open {
    display: flex !important;
    animation: rfgFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.rfg-overlay * {
    box-sizing: border-box;
}

.rfg-modal {
    position: relative;
    width: min(640px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 20px;
    padding: 38px 32px 34px;
    text-align: center;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--rfg-text);
}

/* Close button */
.rfg-close {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    border: none;
    background: #f1f3f6;
    border-radius: 50%;
    font-size: 22px;
    line-height: 36px;
    cursor: pointer;
    color: #4b5563;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.rfg-close:hover {
    background: var(--rfg-red);
    color: #ffffff;
    transform: rotate(90deg) scale(1.05);
}

.rfg-badge {
    display: inline-block;
    background: var(--rfg-red);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 6px 16px;
    border-radius: 999px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

.rfg-modal h2 {
    margin: 0 0 10px;
    color: var(--rfg-dark);
    font-size: 26px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.rfg-subtitle {
    margin: 0 0 26px;
    color: #6b7280;
    font-size: 15px;
    font-weight: 500;
}

.rfg-boxes {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin: 10px 0;
}

.rfg-boxes.rfg-hidden,
.rfg-result.rfg-hidden,
.rfg-subtitle.rfg-hidden,
.rfg-overlay [hidden] {
    display: none !important;
}

/* Luxury mystery box cards */
.rfg-box {
    position: relative;
    border: 2px solid var(--rfg-card-border);
    background: #f8fafc;
    border-radius: 16px;
    padding: 22px 14px 18px;
    cursor: pointer;
    flex: 1 1 110px;
    max-width: 140px;
    min-height: 148px;
    color: #1f2937;
    outline: none;
    user-select: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease, background-color 0.22s ease;
}

.rfg-box:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--rfg-red);
    background: #ffffff;
    box-shadow: 0 16px 36px rgba(220, 16, 42, 0.18), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.rfg-box.rfg-disabled {
    cursor: wait;
    opacity: 0.65;
    pointer-events: none;
}

.rfg-box-body {
    display: block;
    font-size: 56px;
    line-height: 1.1;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.12));
    transition: transform 0.2s ease;
}

.rfg-box:hover .rfg-box-body {
    transform: scale(1.1) rotate(4deg);
}

.rfg-box-number {
    display: block;
    margin-top: 12px;
    font-size: 12px;
    font-weight: 800;
    color: #374151;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.rfg-box:hover .rfg-box-number {
    color: var(--rfg-red);
}

/* Result Reveal View */
.rfg-result {
    padding: 10px 0;
}

.rfg-result-icon {
    font-size: 58px;
    line-height: 1;
    margin-bottom: 12px;
    animation: rfgPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.rfg-result-label {
    margin: 0;
    color: var(--rfg-red);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 2.5px;
    text-transform: uppercase;
}

.rfg-gift-image {
    display: block;
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin: 16px auto;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 6px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.rfg-gift-name {
    font-size: 20px;
    line-height: 1.35;
    margin: 12px auto 6px;
    color: var(--rfg-dark);
    font-weight: 800;
    max-width: 500px;
}

.rfg-result-text {
    color: #6b7280;
    margin: 0 0 24px;
    font-size: 15px;
}

.rfg-cart-button,
a.rfg-cart-button {
    display: inline-block;
    background: var(--rfg-red);
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 14px 34px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 18px rgba(220, 16, 42, 0.28);
    transition: all 0.2s ease;
}

.rfg-cart-button:hover,
a.rfg-cart-button:hover {
    background: #b50b21;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(220, 16, 42, 0.36);
}

.rfg-error {
    margin-top: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
}

.rfg-removed-message {
    position: fixed !important;
    right: 24px !important;
    bottom: 24px !important;
    z-index: 9999998 !important;
    background: #ffffff;
    border-left: 4px solid var(--rfg-red);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
    padding: 16px 20px;
    border-radius: 8px;
    max-width: 380px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    animation: rfgSlideUp 0.3s ease;
}

.rfg-free-qty {
    font-weight: 800;
    color: var(--rfg-red);
}

@keyframes rfgFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes rfgPop {
    0% { transform: scale(0.6); opacity: 0; }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

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

@keyframes rfgShake {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-6px) rotate(-3deg); }
    75% { transform: translateX(6px) rotate(3deg); }
}

.rfg-box.rfg-opening {
    animation: rfgShake 0.35s ease 2;
}

@media (max-width: 600px) {
    .rfg-modal {
        padding: 30px 18px 24px;
        border-radius: 16px;
    }
    .rfg-modal h2 {
        font-size: 22px;
    }
    .rfg-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }
    .rfg-boxes {
        gap: 10px;
    }
    .rfg-box {
        flex: 1 1 90px;
        min-height: 125px;
        padding: 14px 8px 12px;
    }
    .rfg-box-body {
        font-size: 44px;
    }
    .rfg-removed-message {
        left: 16px !important;
        right: 16px !important;
        bottom: 16px !important;
        max-width: none !important;
    }
}
