:root {
    --bb-retention-ink: #f6f7ff;
    --bb-retention-muted: #aeb7db;
    --bb-retention-panel: #171c36;
    --bb-retention-well: #0b0e1a;
    --bb-retention-line: #343d69;
    --bb-retention-green: #00e5a8;
    --bb-retention-green-dark: #005744;
    --bb-retention-pink: #ff6b9d;
    --bb-retention-blue: #27d7f2;
    --bb-retention-danger: #ff5470;
}

.bb-retention-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: grid;
    place-items: center;
    overflow-y: auto;
    padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem max(1rem, env(safe-area-inset-bottom, 0px));
    background: rgba(4, 6, 18, 0.86);
    backdrop-filter: blur(7px);
    animation: bb-retention-fade 180ms ease-out both;
}

.bb-retention-overlay,
.bb-retention-overlay * {
    box-sizing: border-box;
}

.bb-retention-modal {
    position: relative;
    width: min(100%, 392px);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.25rem;
    border: 1px solid var(--bb-retention-line);
    border-radius: 14px;
    background: linear-gradient(180deg, #21294d 0%, var(--bb-retention-panel) 48%, #0b0e1a 100%);
    box-shadow: 0 8px 0 #070a18, 0 24px 64px rgba(0, 0, 0, 0.56);
    color: var(--bb-retention-ink);
    text-align: center;
    scrollbar-width: thin;
    animation: bb-retention-pop 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.bb-retention-mark,
.bb-pix-bonus-banner-icon,
.bb-retention-toast-icon {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
}

.bb-retention-mark {
    width: 65px;
    height: 47px;
    margin: 0 auto 0.8rem;
    padding: 7px;
    border: 1px solid var(--bb-retention-line);
    border-radius: 12px;
    background: var(--bb-retention-well);
    box-shadow: 0 5px 0 #070a18;
}

.bb-retention-mark i,
.bb-pix-bonus-banner-icon i,
.bb-retention-toast-icon i {
    min-width: 0;
    min-height: 0;
    border-radius: 2px;
    background: var(--bb-retention-green);
    box-shadow: inset 2px 2px rgba(255, 255, 255, 0.32), inset -2px -2px rgba(0, 0, 0, 0.2);
}

.bb-retention-mark i:first-child,
.bb-pix-bonus-banner-icon i:first-child,
.bb-retention-toast-icon i:first-child {
    grid-column: 2;
}

.bb-retention-context {
    margin-bottom: 0.35rem;
    color: var(--bb-retention-green);
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.14em;
}

.bb-retention-title {
    margin: 0;
    color: var(--bb-retention-ink);
    font-size: clamp(1.42rem, 7vw, 1.72rem);
    font-weight: 900;
    letter-spacing: -0.035em;
    line-height: 1.05;
}

.bb-retention-subtitle {
    margin: 0.42rem 0 0.8rem;
    color: var(--bb-retention-pink);
    font-size: 0.86rem;
    font-weight: 850;
    letter-spacing: 0.015em;
}

.bb-retention-text {
    margin: 0 0 1rem;
    color: var(--bb-retention-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.bb-retention-text strong,
.bb-retention-text .bb-retention-highlight {
    color: var(--bb-retention-green);
    font-weight: 800;
}

.bb-retention-box {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 0.8rem;
    padding: 0.9rem;
    border: 1px solid rgba(163, 176, 230, 0.15);
    border-radius: 12px;
    background: var(--bb-retention-well);
    text-align: left;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.32);
}

.bb-retention-row,
.bb-retention-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.bb-retention-row {
    color: var(--bb-retention-muted);
    font-size: 0.84rem;
}

.bb-retention-row strong {
    flex: 0 0 auto;
    color: var(--bb-retention-ink);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.bb-retention-row.bonus,
.bb-retention-row.bonus strong {
    color: var(--bb-retention-green);
    font-weight: 800;
}

.bb-retention-total {
    margin-top: 0.1rem;
    padding-top: 0.72rem;
    border-top: 1px dashed rgba(163, 176, 230, 0.24);
    color: var(--bb-retention-ink);
    font-size: 0.88rem;
    font-weight: 800;
}

.bb-retention-total strong {
    flex: 0 0 auto;
    color: var(--bb-retention-green);
    font-size: 1.22rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
}

.bb-retention-timer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
    padding: 0.58rem 0.7rem;
    border: 1px solid rgba(255, 111, 159, 0.3);
    border-radius: 12px;
    background: rgba(255, 111, 159, 0.09);
    color: #ff9cbd;
    font-size: 0.67rem;
    font-weight: 850;
    letter-spacing: 0.08em;
}

.bb-retention-timer strong {
    color: #ffc4d7;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.bb-retention-actions {
    display: grid;
    gap: 0.6rem;
}

.bb-retention-cta,
.bb-retention-secondary,
.bb-retention-dismiss {
    min-height: 44px;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.035em;
    cursor: pointer;
}

.bb-retention-cta {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 0;
    border-radius: 12px;
    background: var(--bb-retention-green);
    box-shadow: 0 5px 0 var(--bb-retention-green-dark);
    color: #03261c;
}

.bb-retention-secondary {
    width: 100%;
    padding: 0.72rem 0.9rem;
    border: 1px solid var(--bb-retention-line);
    border-radius: 12px;
    background: #20294e;
    color: var(--bb-retention-ink);
}

.bb-retention-dismiss {
    min-height: 34px;
    padding: 0.35rem 0.6rem;
    border: 0;
    background: transparent;
    color: #8892b9;
    font-size: 0.72rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.bb-retention-cta:hover:not(:disabled),
.bb-retention-secondary:hover:not(:disabled) {
    filter: brightness(1.08);
}

.bb-retention-cta:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 2px 0 var(--bb-retention-green-dark);
}

.bb-retention-cta:disabled {
    opacity: 0.58;
    cursor: wait;
}

.bb-retention-cta:focus-visible,
.bb-retention-secondary:focus-visible,
.bb-retention-dismiss:focus-visible,
.bb-retention-code:focus-visible {
    outline: 3px solid var(--bb-retention-blue);
    outline-offset: 3px;
}

.bb-retention-code {
    display: block;
    width: 100%;
    min-height: 92px;
    resize: none;
    margin: 1rem 0;
    padding: 0.75rem;
    border: 1px solid var(--bb-retention-line);
    border-radius: 12px;
    background: var(--bb-retention-well);
    color: #dce4ff;
    font: 600 0.72rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
    overflow-wrap: anywhere;
}

.bb-retention-modal--reserved .bb-retention-context { color: var(--bb-retention-blue); }
.bb-retention-modal--reserved .bb-retention-mark i { background: var(--bb-retention-blue); }

.bb-pix-bonus-banner {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid rgba(32, 229, 173, 0.35);
    border-radius: 12px;
    background: rgba(32, 229, 173, 0.09);
    text-align: left;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 220ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bb-pix-bonus-banner.visible { opacity: 1; transform: translateY(0); }

.bb-pix-bonus-banner--error {
    border-color: rgba(255, 99, 121, 0.4);
    background: rgba(255, 99, 121, 0.09);
}

.bb-pix-bonus-banner-icon,
.bb-retention-toast-icon {
    flex: 0 0 auto;
    width: 32px;
    height: 24px;
    margin-top: 2px;
}

.bb-pix-bonus-banner--error .bb-pix-bonus-banner-icon i,
.bb-retention-toast--error .bb-retention-toast-icon i { background: var(--bb-retention-danger); }
.bb-retention-toast--info .bb-retention-toast-icon i { background: var(--bb-retention-blue); }

.bb-pix-bonus-banner-body,
.bb-retention-toast-body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.22rem;
}

.bb-pix-bonus-banner-title,
.bb-retention-toast-title {
    color: var(--bb-retention-green);
    font-size: 0.88rem;
    font-weight: 850;
}

.bb-pix-bonus-banner--error .bb-pix-bonus-banner-title,
.bb-retention-toast--error .bb-retention-toast-title { color: var(--bb-retention-danger); }
.bb-retention-toast--info .bb-retention-toast-title { color: var(--bb-retention-blue); }

.bb-pix-bonus-banner-text,
.bb-retention-toast-text {
    color: var(--bb-retention-muted);
    font-size: 0.78rem;
    line-height: 1.42;
}

.bb-retention-toast {
    position: fixed;
    top: max(1rem, env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 10100;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    width: min(calc(100% - 2rem), 420px);
    padding: 0.9rem;
    border: 1px solid rgba(32, 229, 173, 0.35);
    border-radius: 12px;
    background: #111730;
    box-shadow: 0 6px 0 #070a18, 0 18px 44px rgba(0, 0, 0, 0.46);
    color: var(--bb-retention-ink);
    opacity: 0;
    transform: translate(-50%, -10px);
    transition: opacity 220ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.bb-retention-toast--info { border-color: rgba(69, 200, 255, 0.35); }
.bb-retention-toast--error { border-color: rgba(255, 99, 121, 0.4); }
.bb-retention-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.bb-retention-toast.leaving { opacity: 0; transform: translate(-50%, -7px); }

@keyframes bb-retention-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bb-retention-pop {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 560px) {
    .bb-retention-overlay {
        align-items: end;
        padding: 0;
    }

    .bb-retention-modal {
        width: 100%;
        max-height: calc(100dvh - env(safe-area-inset-top, 0px));
        padding: 1.1rem 1rem max(1rem, env(safe-area-inset-bottom, 0px));
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -12px 44px rgba(0, 0, 0, 0.48);
    }

    .bb-retention-mark { width: 58px; height: 42px; }

    .bb-retention-toast {
        top: auto;
        bottom: max(1rem, env(safe-area-inset-bottom, 0px));
        transform: translate(-50%, 10px);
    }

    .bb-retention-toast.visible { transform: translate(-50%, 0); }
    .bb-retention-toast.leaving { transform: translate(-50%, 7px); }
}

@media (prefers-reduced-motion: reduce) {
    .bb-retention-overlay,
    .bb-retention-modal { animation: none; }

    .bb-pix-bonus-banner,
    .bb-retention-toast { transition: none; }
}
