.apf-loyalty-contest {
    --contest-accent: #d4af37;
    --contest-rgb: 212, 175, 55;
    position: fixed;
    left: 22px;
    bottom: 22px;
    width: min(390px, calc(100vw - 44px));
    z-index: 29950;
    direction: rtl;
    font-family: "Cairo", sans-serif;
    color: #f8f8fa;
    border: 1px solid rgba(var(--contest-rgb), .52);
    border-radius: 22px;
    background:
        linear-gradient(145deg, rgba(var(--contest-rgb), .10), transparent 40%),
        radial-gradient(circle at 15% 0%, rgba(var(--contest-rgb), .17), transparent 38%),
        linear-gradient(180deg, rgba(18, 18, 22, .98), rgba(8, 8, 11, .98));
    box-shadow:
        0 24px 65px rgba(0, 0, 0, .48),
        0 0 0 1px rgba(255, 255, 255, .025) inset,
        0 0 38px rgba(var(--contest-rgb), .13);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    isolation: isolate;
    transform-origin: bottom left;
    animation: apfContestEnter .55s cubic-bezier(.2, .8, .2, 1) both;
}

html[data-apf-market="forex"] .apf-loyalty-contest {
    --contest-accent: #d4af37;
    --contest-rgb: 212, 175, 55;
}

html[data-apf-market="futures"] .apf-loyalty-contest {
    --contest-accent: #10b981;
    --contest-rgb: 16, 185, 129;
}

html[data-apf-market="crypto"] .apf-loyalty-contest {
    --contest-accent: #3b82f6;
    --contest-rgb: 59, 130, 246;
}

.apf-loyalty-contest[hidden] {
    display: none !important;
}

.apf-loyalty-contest::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -3;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), transparent 75%);
}

.apf-loyalty-contest::after {
    content: "";
    position: absolute;
    inset: -1px;
    z-index: -2;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(120deg, transparent 15%, rgba(var(--contest-rgb), .28), transparent 55%);
    opacity: .45;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    padding: 1px;
    mask-composite: exclude;
    -webkit-mask-composite: xor;
}

.apf-loyalty-contest__glow {
    position: absolute;
    left: -75px;
    top: -95px;
    width: 220px;
    height: 220px;
    z-index: -2;
    border-radius: 50%;
    background: rgba(var(--contest-rgb), .22);
    filter: blur(58px);
    opacity: .7;
    pointer-events: none;
    transition: background-color .25s ease;
}

.apf-loyalty-contest__scan {
    position: absolute;
    top: -55%;
    right: -35%;
    width: 40%;
    height: 210%;
    z-index: -1;
    pointer-events: none;
    transform: rotate(23deg);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.09), transparent);
    animation: apfContestSweep 5.5s ease-in-out infinite;
}

.apf-loyalty-contest__close {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    z-index: 4;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 50%;
    background: rgba(255, 255, 255, .045);
    color: rgba(255, 255, 255, .62);
    cursor: pointer;
    transition: .2s ease;
}

.apf-loyalty-contest__close:hover,
.apf-loyalty-contest__close:focus-visible {
    color: #fff;
    border-color: rgba(var(--contest-rgb), .5);
    background: rgba(var(--contest-rgb), .12);
    outline: none;
}

.apf-loyalty-contest__close svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.apf-loyalty-contest__topline,
.apf-loyalty-contest__hero,
.apf-loyalty-contest__rule,
.apf-loyalty-contest__meta,
.apf-loyalty-contest__cta,
.apf-loyalty-contest__draw {
    position: relative;
    z-index: 1;
}

.apf-loyalty-contest__topline {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 16px 16px 8px 50px;
}

.apf-loyalty-contest__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: -.2px;
    color: #fff;
}

.apf-loyalty-contest__eyebrow svg {
    width: 18px;
    height: 18px;
    fill: var(--contest-accent);
    filter: drop-shadow(0 0 10px rgba(var(--contest-rgb), .45));
}


.apf-loyalty-contest__hero {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 13px;
    padding: 4px 16px 12px;
}

.apf-loyalty-contest__prize {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    white-space: nowrap;
    color: var(--contest-accent);
    text-shadow: 0 0 22px rgba(var(--contest-rgb), .22);
}

.apf-loyalty-contest__prize strong {
    font-size: 42px;
    font-weight: 900;
    line-height: .95;
    letter-spacing: -2px;
}

.apf-loyalty-contest__prize span {
    font-size: 24px;
    font-weight: 800;
    opacity: .72;
}

.apf-loyalty-contest__copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.apf-loyalty-contest__copy strong {
    font-size: 17px;
    font-weight: 900;
    line-height: 1.35;
    color: #fff;
}

.apf-loyalty-contest__copy span {
    font-size: 10.5px;
    font-weight: 700;
    color: rgba(255,255,255,.58);
}

.apf-loyalty-contest__rule {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 16px 11px;
    padding: 10px 11px;
    border: 1px solid rgba(var(--contest-rgb), .20);
    border-radius: 13px;
    background: rgba(255,255,255,.028);
    font-size: 11.5px;
    font-weight: 700;
    color: rgba(255,255,255,.72);
}

.apf-loyalty-contest__rule b {
    color: var(--contest-accent);
    font-weight: 900;
}

.apf-loyalty-contest__rule-icon {
    width: 25px;
    height: 25px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(var(--contest-rgb), .10);
    color: var(--contest-accent);
}

.apf-loyalty-contest__rule-icon svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.apf-loyalty-contest__meta {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 0 16px 11px;
}

.apf-loyalty-contest__dates {
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(255,255,255,.72);
    font-size: 11px;
    font-weight: 700;
}

.apf-loyalty-contest__dates svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    fill: var(--contest-accent);
}

.apf-loyalty-contest__dates b {
    color: #fff;
    font-weight: 900;
}

.apf-loyalty-contest__countdown {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 31px;
    padding: 5px 8px;
    border-radius: 10px;
    background: rgba(var(--contest-rgb), .09);
    border: 1px solid rgba(var(--contest-rgb), .18);
    white-space: nowrap;
}

.apf-loyalty-contest__countdown span {
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,.55);
}

.apf-loyalty-contest__countdown b {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-size: 11.5px;
    font-weight: 900;
    color: var(--contest-accent);
}

.apf-loyalty-contest__cta {
    display: grid;
    grid-template-columns: 36px 1fr 18px;
    align-items: center;
    gap: 10px;
    margin: 0 12px;
    padding: 10px 11px;
    text-decoration: none;
    color: #0a0a0c;
    border-radius: 14px;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--contest-accent) 88%, #fff),
        var(--contest-accent)
    );
    box-shadow: 0 10px 24px rgba(var(--contest-rgb), .18);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.apf-loyalty-contest__cta:hover,
.apf-loyalty-contest__cta:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(var(--contest-rgb), .28);
    filter: brightness(1.05);
    outline: none;
}

.apf-loyalty-contest__telegram {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--contest-accent);
    background: #0c0c0f;
    box-shadow: 0 5px 12px rgba(0,0,0,.22);
}

.apf-loyalty-contest__telegram svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.apf-loyalty-contest__cta-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.apf-loyalty-contest__cta-copy strong {
    font-size: 12.5px;
    line-height: 1.35;
    font-weight: 900;
}

.apf-loyalty-contest__cta-copy small {
    font-size: 8.5px;
    line-height: 1.4;
    font-weight: 700;
    opacity: .68;
}

.apf-loyalty-contest__arrow {
    width: 17px;
    height: 17px;
    fill: currentColor;
    opacity: .78;
}

.apf-loyalty-contest__draw {
    padding: 8px 16px 12px;
    text-align: center;
    font-size: 9.5px;
    font-weight: 700;
    color: rgba(255,255,255,.47);
}

.apf-loyalty-contest__draw b {
    color: rgba(255,255,255,.78);
    font-weight: 900;
}

.apf-loyalty-contest.is-ended .apf-loyalty-contest__countdown {
    background: rgba(var(--contest-rgb), .14);
}

.apf-loyalty-contest.is-ended .apf-loyalty-contest__rule {
    opacity: .68;
}

@keyframes apfContestEnter {
    from {
        opacity: 0;
        transform: translate3d(-18px, 20px, 0) scale(.96);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes apfContestSweep {
    0%, 72% { transform: translateX(0) rotate(23deg); opacity: 0; }
    80% { opacity: .5; }
    100% { transform: translateX(-560px) rotate(23deg); opacity: 0; }
}

@media (max-width: 700px) {
    .apf-loyalty-contest {
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        width: auto;
        border-radius: 18px;
        transform-origin: bottom center;
    }

    .apf-loyalty-contest__topline {
        padding: 12px 12px 5px 44px;
    }

    .apf-loyalty-contest__hero {
        grid-template-columns: auto 1fr;
        gap: 10px;
        padding: 2px 12px 8px;
    }

    .apf-loyalty-contest__prize strong {
        font-size: 34px;
    }

    .apf-loyalty-contest__prize span {
        font-size: 20px;
    }

    .apf-loyalty-contest__copy strong {
        font-size: 14px;
    }

    .apf-loyalty-contest__copy span {
        font-size: 9px;
    }

    .apf-loyalty-contest__rule {
        margin: 0 12px 8px;
        padding: 8px 9px;
        font-size: 10.5px;
    }

    .apf-loyalty-contest__meta {
        padding: 0 12px 8px;
        gap: 7px;
    }

    .apf-loyalty-contest__dates,
    .apf-loyalty-contest__countdown {
        font-size: 9.5px;
    }

    .apf-loyalty-contest__countdown span {
        display: none;
    }

    .apf-loyalty-contest__cta {
        margin: 0 9px;
        padding: 8px 9px;
    }

    .apf-loyalty-contest__draw {
        padding: 6px 12px 9px;
    }
}

@media (max-width: 390px) {
    .apf-loyalty-contest__hero {
        gap: 8px;
    }

    .apf-loyalty-contest__prize strong {
        font-size: 31px;
    }

    .apf-loyalty-contest__copy strong {
        font-size: 13px;
    }

    .apf-loyalty-contest__rule span:not(.apf-loyalty-contest__rule-icon) {
        font-size: 9.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apf-loyalty-contest,
    .apf-loyalty-contest__scan {
        animation: none !important;
    }

    .apf-loyalty-contest__cta {
        transition: none;
    }
}

/* Countdown v3: keep Arabic day label and numeric clock in isolated boxes to avoid RTL/LTR bidi mixing. */
.apf-loyalty-contest__time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    direction: rtl;
    unicode-bidi: isolate;
}

.apf-loyalty-contest__days {
    display: inline-flex;
    align-items: center;
    direction: rtl;
    unicode-bidi: isolate;
    white-space: nowrap;
    font-size: 10.5px;
    font-weight: 900;
    color: var(--contest-accent);
}

.apf-loyalty-contest__days[hidden] {
    display: none !important;
}

.apf-loyalty-contest__clock {
    display: inline-block;
    direction: ltr;
    unicode-bidi: isolate;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: .15px;
    font-size: 11.5px;
    font-weight: 900;
    color: var(--contest-accent);
}

@media (max-width: 700px) {
    .apf-loyalty-contest__countdown {
        gap: 5px;
    }

    .apf-loyalty-contest__time {
        gap: 4px;
    }

    .apf-loyalty-contest__days,
    .apf-loyalty-contest__clock {
        font-size: 10px;
    }
}
