/* Badges (js/badges.js): medals, the badge row, the gallery and the unlock celebration. */

.cfb-chip,
.cfb-more,
.cfb-pop,
.cfb-overlay,
.cfb-toast,
.cfb-shelf,
.cfb-mini {
    --cfb-ink: #0f172a;
    --cfb-text: #475569;
    --cfb-muted: #64748b;
    --cfb-faint: #94a3b8;
    --cfb-line: #e8edf1;
    --cfb-teal: #11a191;
    --cfb-teal-deep: #0b7a6e;
    --cfb-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --cfb-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Finishes: one per level ---------- */
.cfb-tier-bronze, .cfb-tag-bronze, .cfb-step-bronze, .cfb-dot-bronze {
    --t1: #f8d9bb; --t2: #c8834a; --t3: #8c5426; --t-ink: #5a3214; --t-glow: rgba(200, 131, 74, 0.5);
}
.cfb-tier-silver, .cfb-tag-silver, .cfb-step-silver, .cfb-dot-silver {
    --t1: #f8fafc; --t2: #b3bdc8; --t3: #76828f; --t-ink: #384350; --t-glow: rgba(118, 130, 143, 0.45);
}
.cfb-tier-gold, .cfb-tag-gold, .cfb-step-gold, .cfb-dot-gold {
    --t1: #fff3c4; --t2: #efb726; --t3: #a3700a; --t-ink: #5c3d00; --t-glow: rgba(239, 183, 38, 0.55);
}
.cfb-tier-platinum, .cfb-tag-platinum, .cfb-step-platinum, .cfb-dot-platinum {
    --t1: #f0f7ff; --t2: #a9c1d8; --t3: #62809d; --t-ink: #2b4157; --t-glow: rgba(98, 128, 157, 0.45);
}
.cfb-tier-ruby, .cfb-tag-ruby, .cfb-step-ruby, .cfb-dot-ruby {
    --t1: #ffd3dd; --t2: #f43f5e; --t3: #9f1239; --t-ink: #7f1031; --t-glow: rgba(244, 63, 94, 0.45);
}
.cfb-tier-sapphire, .cfb-tag-sapphire, .cfb-step-sapphire, .cfb-dot-sapphire {
    --t1: #d6e5ff; --t2: #3b82f6; --t3: #1e3a8a; --t-ink: #1e3a8a; --t-glow: rgba(59, 130, 246, 0.45);
}
.cfb-tier-diamond, .cfb-tag-diamond, .cfb-step-diamond, .cfb-dot-diamond {
    --t1: #e0f7ff; --t2: #a78bfa; --t3: #6d5bd0; --t-ink: #3b2f8f; --t-glow: rgba(167, 139, 250, 0.5);
}
.cfb-tier-locked, .cfb-tag-locked {
    --t1: #f1f5f9; --t2: #cbd5e1; --t3: #94a3b8; --t-ink: #64748b; --t-glow: rgba(148, 163, 184, 0.3);
}

/* ---------- Badge colours ---------- */
.cfb-hue-reviewer  { --h1: #99f6e4; --h2: #14b8a6; --h3: #0f766e; }
.cfb-hue-attendee  { --h1: #c7d2fe; --h2: #6366f1; --h3: #3730a3; }
.cfb-hue-likes     { --h1: #fecdd3; --h2: #f43f5e; --h3: #be123c; }
.cfb-hue-connector { --h1: #fde68a; --h2: #f59e0b; --h3: #c2410c; }
.cfb-hue-explorer  { --h1: #bae6fd; --h2: #0ea5e9; --h3: #075985; }
.cfb-hue-allset    { --h1: #a7f3d0; --h2: #10b981; --h3: #047857; }
.cfb-hue-founding  { --h1: #e9d5ff; --h2: #a855f7; --h3: #6b21a8; }

/* ---------- Medal ---------- */
.cfb-medal {
    --cfb-size: 48px;
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: var(--cfb-size);
    height: var(--cfb-size);
    vertical-align: middle;
}

.cfb-medal-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 215deg, var(--t1), var(--t2) 22%, var(--t1) 42%, var(--t3) 68%, var(--t2) 86%, var(--t1));
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.55),
        0 calc(var(--cfb-size) * 0.14) calc(var(--cfb-size) * 0.32) calc(var(--cfb-size) * -0.12) var(--t-glow),
        0 1px 2px rgba(15, 23, 42, 0.12);
}

.cfb-tier-diamond .cfb-medal-ring {
    background: conic-gradient(from 0deg, #a5f3fc, #c4b5fd, #fbcfe8, #fde68a, #a7f3d0, #a5f3fc);
}

.cfb-medal-core {
    position: absolute;
    inset: calc(var(--cfb-size) * 0.09);
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
    background: radial-gradient(120% 120% at 30% 20%, var(--h1) 0%, var(--h2) 52%, var(--h3) 100%);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, 0.45),
        inset 0 -3px 7px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(15, 23, 42, 0.08);
    color: #fff;
}

.cfb-medal-core svg {
    position: relative;
    z-index: 1;
    width: 46%;
    height: 46%;
    stroke-width: 2;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.28));
}

/* Light sweeping across the face on hover */
.cfb-medal-core::after {
    content: "";
    position: absolute;
    inset: -40%;
    background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.6) 50%, transparent 62%);
    transform: translateX(-85%);
    transition: transform 0.85s var(--cfb-ease-out, ease-out);
    pointer-events: none;
}

.cfb-chip:hover .cfb-medal-core::after,
.cfb-chip:focus-visible .cfb-medal-core::after,
.cfb-tile:hover .cfb-medal-core::after,
.cfb-tile:focus-visible .cfb-medal-core::after,
.cfb-mini-medal:hover .cfb-medal-core::after,
.cfb-card:hover .cfb-medal-core::after,
.cfb-toast.is-open .cfb-medal-core::after {
    transform: translateX(85%);
}

.cfb-toast.is-open .cfb-medal-core::after {
    transition-delay: 0.65s;
    transition-duration: 1.1s;
}

.cfb-medal-count {
    position: absolute;
    right: calc(var(--cfb-size) * -0.08);
    bottom: calc(var(--cfb-size) * -0.08);
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: max(19px, calc(var(--cfb-size) * 0.4));
    height: max(19px, calc(var(--cfb-size) * 0.4));
    padding: 0 5px;
    box-sizing: border-box;
    border: 2px solid #fff;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--t1) 0%, var(--t2) 100%);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
    color: var(--t-ink);
    font-size: clamp(10px, calc(var(--cfb-size) * 0.21), 14px);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    line-height: 1;
}

.cfb-tier-ruby .cfb-medal-count,
.cfb-tier-sapphire .cfb-medal-count {
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.cfb-tier-diamond .cfb-medal-count {
    background: linear-gradient(135deg, #e0f2fe, #ede9fe 50%, #fce7f3);
}

/* Locked: a quiet grey version with a padlock */
.cfb-tier-locked .cfb-medal-core {
    background: radial-gradient(120% 120% at 30% 20%, #f8fafc 0%, #e2e8f0 60%, #cbd5e1 100%);
    color: #94a3b8;
}

.cfb-tier-locked .cfb-medal-core svg {
    filter: none;
    opacity: 0.8;
}

.cfb-tier-locked .cfb-medal-ring {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(15, 23, 42, 0.08);
}

.cfb-medal-lock {
    position: absolute;
    right: calc(var(--cfb-size) * -0.04);
    bottom: calc(var(--cfb-size) * -0.04);
    z-index: 2;
    display: grid;
    place-items: center;
    width: max(20px, calc(var(--cfb-size) * 0.36));
    height: max(20px, calc(var(--cfb-size) * 0.36));
    border: 2px solid #fff;
    border-radius: 50%;
    background: #64748b;
    color: #fff;
    box-sizing: border-box;
}

.cfb-medal-lock svg {
    width: 55%;
    height: 55%;
    stroke-width: 2.4;
}

/* ---------- Badge row ---------- */
.cfb-chip,
.cfb-more {
    position: relative;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.35s var(--cfb-ease-spring);
}

.cfb-chip:hover,
.cfb-chip:focus-visible {
    transform: translateY(-3px) scale(1.06);
}

.cfb-chip:focus-visible,
.cfb-more:focus-visible {
    outline: 3px solid rgba(17, 161, 145, 0.45);
    outline-offset: 3px;
}

.cfb-chip:active {
    transform: translateY(-1px) scale(0.98);
}

.cfb-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    box-sizing: border-box;
    border: 1.5px dashed rgba(11, 122, 110, 0.35);
    background: rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: var(--cfb-teal-deep);
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.35s var(--cfb-ease-spring), background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.cfb-more svg {
    width: 20px;
    height: 20px;
}

.cfb-more:hover,
.cfb-more:focus-visible {
    border-style: solid;
    border-color: rgba(17, 161, 145, 0.55);
    background: #fff;
    box-shadow: 0 8px 20px -10px rgba(11, 122, 110, 0.55);
    transform: translateY(-2px);
}

.cfb-more-tip {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    padding: 5px 9px;
    border-radius: 8px;
    background: #0f172a;
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, -3px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.cfb-more:hover .cfb-more-tip,
.cfb-more:focus-visible .cfb-more-tip {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* No badge yet: a pill that invites the first one */
.cfb-more.cfb-more-start {
    width: auto;
    height: 40px;
    gap: 8px;
    padding: 0 16px 0 13px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
}

.cfb-more.cfb-more-start svg {
    width: 17px;
    height: 17px;
}

/* First render: badges rise in one after another */
.is-entering > .cfb-chip,
.is-entering > .cfb-more {
    animation: cfb-rise 0.6s var(--cfb-ease-out) both;
    animation-delay: calc(var(--cfb-i, 0) * 70ms + 80ms);
}

@keyframes cfb-rise {
    from { opacity: 0; transform: translateY(8px) scale(0.8); }
    to { opacity: 1; transform: none; }
}

/* Just unlocked: a pop and two rings of light */
.cfb-chip.is-new {
    animation: cfb-pop 0.9s var(--cfb-ease-spring) both;
}

.cfb-chip.is-new::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    box-shadow: 0 0 0 0 var(--cfb-glow, rgba(17, 161, 145, 0.55));
    animation: cfb-ring 1.4s ease-out 0.5s 2;
    pointer-events: none;
}

@keyframes cfb-pop {
    0% { opacity: 0; transform: scale(0.3) rotate(-30deg); }
    60% { opacity: 1; transform: scale(1.15) rotate(6deg); }
    100% { transform: none; }
}

@keyframes cfb-ring {
    0% { box-shadow: 0 0 0 0 rgba(17, 161, 145, 0.5); }
    100% { box-shadow: 0 0 0 16px rgba(17, 161, 145, 0); }
}

/* ---------- Popover ---------- */
.cfb-pop {
    --cfb-arrow-x: 50%;
    position: fixed;
    z-index: 100030;
    width: 250px;
    box-sizing: border-box;
    padding: 14px 16px 15px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 20px 44px -16px rgba(15, 23, 42, 0.32);
    color: var(--cfb-ink);
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
    transform-origin: var(--cfb-arrow-x) 0;
    transition: opacity 0.18s ease, transform 0.22s var(--cfb-ease-out);
    pointer-events: none;
}

.cfb-pop.is-open {
    opacity: 1;
    transform: none;
}

.cfb-pop::before {
    content: "";
    position: absolute;
    top: -6px;
    left: calc(var(--cfb-arrow-x) - 6px);
    width: 12px;
    height: 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    border-left: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 3px 0 0 0;
    background: #fff;
    transform: rotate(45deg);
}

.cfb-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cfb-pop-name {
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.cfb-pop-summary {
    margin: 4px 0 11px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--cfb-text);
}

.cfb-pop-summary:last-child {
    margin-bottom: 0;
}

.cfb-pop-next {
    margin-top: 7px;
    font-size: 12px;
    color: var(--cfb-muted);
}

/* ---------- Shared bits ---------- */
.cfb-tag {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 3px 9px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--t1), color-mix(in srgb, var(--t2) 38%, var(--t1)));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--t2) 35%, transparent);
    color: var(--t-ink);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.3;
    text-transform: uppercase;
    white-space: nowrap;
}

.cfb-bar {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f5;
}

.cfb-bar > span {
    display: block;
    height: 100%;
    min-width: 7px;
    border-radius: inherit;
    background: linear-gradient(90deg, color-mix(in srgb, var(--h2) 55%, #fff), var(--h2) 65%, var(--h3));
    transform-origin: left center;
    animation: cfb-grow 0.9s var(--cfb-ease-out) 0.15s both;
}

.cfb-bar > span[style="width:0%"] {
    min-width: 0;
}

@keyframes cfb-grow {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* ---------- Gallery ---------- */
.cfb-overlay {
    position: fixed;
    inset: 0;
    z-index: 100020; /* above the header (50000), sign-up/login (60000) and site dropdowns */
    display: flex;
    justify-content: center;
    padding: 28px;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    backdrop-filter: blur(8px) saturate(120%);
    opacity: 0;
    /* !important: several pages ship a catch-all `body > *:not(#aiModal)... { transition: filter }` rule */
    transition: opacity 0.3s var(--cfb-ease-out) !important;
}

.cfb-overlay.is-open {
    opacity: 1;
}

.cfb-overlay.is-closing {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease-in !important;
}

.cfb-sheet {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: auto 0;
    overflow: hidden;
    border-radius: 26px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 40px 80px -24px rgba(15, 23, 42, 0.45);
    color: var(--cfb-ink);
    opacity: 0;
    transform: translateY(18px) scale(0.96);
    transition: transform 0.5s var(--cfb-ease-out), opacity 0.32s var(--cfb-ease-out);
}

.cfb-overlay.is-open .cfb-sheet {
    opacity: 1;
    transform: none;
}

/* Switching between one badge and the gallery: out quickly, back in with the entrance */
.cfb-overlay.is-open .cfb-sheet.is-swapping {
    opacity: 0;
    transform: translateY(8px) scale(0.975);
    transition: transform 0.17s ease-in, opacity 0.17s ease-in;
}

.cfb-overlay.is-closing .cfb-sheet {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    transition: transform 0.24s ease-in, opacity 0.2s ease-in;
}

.cfb-sheet.is-quiet,
.cfb-sheet.is-quiet * {
    animation: none !important;
}

.cfb-sheet-head {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 30px 32px 24px;
    background: linear-gradient(135deg, #dcf6f3 0%, #f7f3ff 100%);
}

.cfb-sheet-title {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--cfb-ink);
}

.cfb-sheet-sub {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--cfb-text);
}

.cfb-close {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    margin: -4px -6px 0 0;
    padding: 0;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.75);
    color: var(--cfb-text);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.cfb-close svg {
    width: 18px;
    height: 18px;
}

.cfb-close:hover {
    background: #fff;
    color: var(--cfb-ink);
    transform: rotate(90deg);
}

.cfb-close:focus-visible {
    outline: 3px solid rgba(17, 161, 145, 0.45);
    outline-offset: 2px;
}

.cfb-sheet-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px 28px;
    flex-wrap: wrap;
    padding: 18px 32px;
    border-bottom: 1px solid var(--cfb-line);
}

.cfb-sheet-score {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--cfb-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.cfb-sheet-score strong {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    background: linear-gradient(135deg, #11a191, #7c5cf0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cfb-legend-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 7px;
}

.cfb-legend-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cfb-faint);
}

.cfb-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cfb-legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--cfb-text);
}

.cfb-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: conic-gradient(from 215deg, var(--t1), var(--t2) 30%, var(--t3) 65%, var(--t1));
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.cfb-dot-diamond {
    background: conic-gradient(#a5f3fc, #c4b5fd, #fbcfe8, #fde68a, #a5f3fc);
}

.cfb-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    padding: 24px 32px 32px;
    list-style: none;
}

.cfb-card {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 18px 20px 16px 18px;
    border: 1px solid var(--cfb-line);
    border-radius: 20px;
    background: #fff;
    animation: cfb-card-in 0.5s var(--cfb-ease-out) both;
    animation-delay: calc(var(--cfb-i, 0) * 45ms + 80ms);
    transition: box-shadow 0.25s ease, transform 0.25s var(--cfb-ease-out), border-color 0.25s ease;
}

.cfb-card:hover {
    border-color: #dfe6eb;
    box-shadow: 0 16px 34px -22px rgba(15, 23, 42, 0.35);
    transform: translateY(-2px);
}

.cfb-card.is-locked {
    background: #fafbfc;
}

@keyframes cfb-card-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.cfb-card-medal {
    padding-top: 2px;
    transition: transform 0.4s var(--cfb-ease-spring);
}

.cfb-card:hover .cfb-card-medal {
    transform: rotate(-6deg) scale(1.04);
}

.cfb-card-body {
    flex: 1 1 auto;
    min-width: 0;
}

.cfb-card-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.cfb-card-name {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--cfb-ink);
}

.cfb-card-summary {
    margin: 5px 0 11px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--cfb-text);
}

.cfb-card.is-locked .cfb-card-name {
    color: #334155;
}

.cfb-card-next {
    margin-top: 7px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--cfb-muted);
}

.cfb-ladder {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.cfb-step {
    display: flex;
    align-items: center;
    flex: 1 1 0;
    min-width: 0;
}

.cfb-step:first-child {
    flex: 0 0 auto;
}

.cfb-step + .cfb-step::before {
    content: "";
    flex: 1 1 auto;
    height: 2px;
    min-width: 6px;
    margin: 0 4px;
    border-radius: 2px;
    background: #e2e8f0;
}

.cfb-step.is-done + .cfb-step::before {
    background: linear-gradient(90deg, var(--t2), var(--t2));
    opacity: 0.55;
}

.cfb-step > span {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    min-width: 30px;
    height: 24px;
    padding: 0 7px;
    box-sizing: border-box;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: var(--cfb-faint);
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cfb-step.is-done > span {
    border-color: transparent;
    background: linear-gradient(135deg, var(--t1), var(--t2));
    color: var(--t-ink);
    box-shadow: 0 2px 6px -2px var(--t-glow);
}

.cfb-step-ruby.is-done > span,
.cfb-step-sapphire.is-done > span {
    color: #fff;
}

.cfb-step-diamond.is-done > span {
    background: linear-gradient(135deg, #cffafe, #ddd6fe 50%, #fbcfe8);
}

.cfb-step.is-next > span {
    border: 1.5px dashed var(--t2);
    color: var(--t3);
}

.cfb-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 12px;
}

.cfb-card-how {
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--cfb-faint);
}

.cfb-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--cfb-teal-deep);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: gap 0.2s ease, color 0.2s ease;
}

.cfb-card-cta svg {
    width: 14px;
    height: 14px;
}

.cfb-card-cta:hover {
    gap: 8px;
    color: var(--cfb-teal);
}

/* ---------- One badge ---------- */
.cfb-sheet--badge {
    max-width: 420px;
    text-align: center;
}

.cfb-sheet--badge > .cfb-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    margin: 0;
}

.cfb-badge-hero {
    position: relative;
    display: grid;
    place-items: center;
    padding: 44px 24px 30px;
    overflow: hidden;
    background:
        radial-gradient(closest-side at 50% 58%, var(--h1) 0%, transparent 100%),
        linear-gradient(135deg, #dcf6f3 0%, #f7f3ff 100%);
}

/* Slow rays behind the medal */
.cfb-badge-hero::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 58%;
    width: 340px;
    height: 340px;
    margin: -170px 0 0 -170px;
    background: repeating-conic-gradient(rgba(255, 255, 255, 0.6) 0deg 7deg, transparent 7deg 20deg);
    -webkit-mask-image: radial-gradient(closest-side, #000 22%, transparent 100%);
    mask-image: radial-gradient(closest-side, #000 22%, transparent 100%);
    animation: cfb-rays 48s linear infinite;
}

@keyframes cfb-rays {
    to { transform: rotate(360deg); }
}

.cfb-badge-hero .cfb-medal {
    filter: drop-shadow(0 14px 22px var(--t-glow, rgba(15, 23, 42, 0.25)));
}

.cfb-overlay.is-open .cfb-badge-medal {
    animation: cfb-medal-pop 0.75s var(--cfb-ease-spring) 0.06s both;
}

@keyframes cfb-medal-pop {
    from { opacity: 0; transform: scale(0.55) rotate(-16deg); }
    to { opacity: 1; transform: none; }
}

.cfb-badge-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 28px 4px;
}

.cfb-badge-name {
    margin: 10px 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--cfb-ink);
}

.cfb-badge-summary {
    margin: 0;
    font-size: 0.97rem;
    line-height: 1.45;
    color: var(--cfb-text);
}

.cfb-badge-progress {
    width: 100%;
    box-sizing: border-box;
    margin-top: 20px;
    padding: 14px 16px 16px;
    border: 1px solid var(--cfb-line);
    border-radius: 16px;
    background: #fafbfc;
    text-align: left;
}

.cfb-badge-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 9px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cfb-faint);
}

.cfb-badge-count {
    font-size: 0.85rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--cfb-ink);
    font-variant-numeric: tabular-nums;
}

.cfb-badge-next {
    margin-top: 8px;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--cfb-muted);
}

.cfb-badge-progress .cfb-ladder {
    margin-top: 14px;
}

.cfb-badge-how {
    margin: 16px 0 0;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--cfb-faint);
}

.cfb-badge-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    margin-top: 16px;
    padding: 0 20px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cfb-teal), var(--cfb-teal-deep));
    box-shadow: 0 10px 22px -12px rgba(11, 122, 110, 0.7);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s var(--cfb-ease-out), box-shadow 0.2s ease;
}

.cfb-badge-cta svg {
    width: 16px;
    height: 16px;
}

.cfb-badge-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px -12px rgba(11, 122, 110, 0.75);
}

.cfb-badge-foot {
    margin-top: 22px;
    padding: 16px 28px 22px;
    border-top: 1px solid var(--cfb-line);
}

.cfb-badge-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border: 1px solid var(--cfb-line);
    border-radius: 999px;
    background: #fff;
    color: var(--cfb-teal-deep);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.cfb-badge-all svg {
    width: 16px;
    height: 16px;
    transition: transform 0.25s var(--cfb-ease-out);
}

.cfb-badge-all:hover {
    border-color: rgba(17, 161, 145, 0.35);
    background: #f0fbf9;
}

.cfb-badge-all:hover svg:last-child {
    transform: translateX(3px);
}

.cfb-badge-all:focus-visible,
.cfb-badge-cta:focus-visible {
    outline: 3px solid rgba(17, 161, 145, 0.45);
    outline-offset: 2px;
}

.cfb-badge-owner {
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cfb-faint);
}

/* ---------- Someone's badges on their profile: a shelf of tiles ---------- */
.cfb-shelf {
    --cfb-shelf-bleed: 0px; /* pages set this to let the phone carousel reach the card's edges */
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid rgba(15, 23, 42, 0.07);
    text-align: left;
}

.cfb-shelf-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cfb-shelf-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cfb-text);
}

.cfb-shelf-title > svg {
    width: 18px;
    height: 18px;
    color: var(--cfb-teal);
}

.cfb-shelf-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    box-sizing: border-box;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    color: var(--cfb-teal-deep);
    font-size: 11.5px;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.cfb-shelf-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--cfb-teal-deep);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, gap 0.2s ease;
}

.cfb-shelf-all svg {
    width: 15px;
    height: 15px;
}

.cfb-shelf-all:hover {
    gap: 9px;
    background: rgba(255, 255, 255, 0.7);
}

.cfb-shelf-track {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.cfb-tile {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 100%;
    padding: 7px 18px 7px 7px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 22px -16px rgba(15, 23, 42, 0.4);
    color: var(--cfb-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.3s var(--cfb-ease-out), box-shadow 0.3s ease, background-color 0.3s ease;
}

.cfb-tile .cfb-medal {
    transition: transform 0.45s var(--cfb-ease-spring);
}

.cfb-tile:hover {
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 16px 30px -16px rgba(15, 23, 42, 0.45);
    transform: translateY(-2px);
}

.cfb-tile:hover .cfb-medal {
    transform: rotate(-8deg) scale(1.06);
}

.cfb-tile:focus-visible {
    outline: 3px solid rgba(17, 161, 145, 0.45);
    outline-offset: 2px;
}

.cfb-tile-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cfb-tile-name {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
}

.cfb-tile-sub {
    display: flex;
    flex-wrap: wrap;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}

.cfb-tile-tier {
    color: var(--t-ink);
}

.cfb-tile-value {
    color: var(--cfb-muted);
    font-weight: 500;
}

.cfb-tile-value::before {
    content: "·";
    margin: 0 5px;
    color: var(--cfb-faint);
}

.cfb-entering .cfb-shelf {
    animation: cfb-fade-in 0.45s var(--cfb-ease-out) both;
}

.cfb-entering .cfb-shelf-track > li {
    animation: cfb-tile-in 0.6s var(--cfb-ease-spring) both;
    animation-delay: calc(var(--cfb-i, 0) * 60ms + 120ms);
}

@keyframes cfb-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes cfb-tile-in {
    from { opacity: 0; transform: translateY(10px) scale(0.92); }
    to { opacity: 1; transform: none; }
}

/* Phones: a swipeable cabinet of upright tiles */
@media (max-width: 768px) {
    .cfb-shelf {
        margin-top: 22px;
        padding-top: 16px;
    }

    .cfb-shelf-track {
        flex-wrap: nowrap;
        gap: 10px;
        margin: 12px calc(var(--cfb-shelf-bleed) * -1) 0;
        padding: 4px var(--cfb-shelf-bleed) 12px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--cfb-shelf-bleed);
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .cfb-shelf-track::-webkit-scrollbar {
        display: none;
    }

    .cfb-shelf-track > li {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    .cfb-tile {
        flex-direction: column;
        justify-content: flex-start;
        gap: 10px;
        width: 116px;
        padding: 14px 8px 12px;
        border-radius: 20px;
        text-align: center;
    }

    .cfb-tile .cfb-medal {
        --cfb-size: 52px !important;
    }

    .cfb-tile-text {
        align-items: center;
        gap: 4px;
        width: 100%;
    }

    .cfb-tile-name {
        white-space: normal;
        font-size: 0.86rem;
    }

    .cfb-tile-sub {
        flex-direction: column;
        align-items: center;
        gap: 1px;
    }

    .cfb-tile-value::before {
        content: none;
    }
}

/* ---------- Someone's badges on a card: a row of small medals ---------- */
.cfb-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 6px;
    vertical-align: middle;
}

.cfb-mini-medal,
.cfb-mini-more {
    position: relative;
    border-radius: 999px;
    cursor: pointer;
    outline: none;
    transition: transform 0.35s var(--cfb-ease-spring), background-color 0.2s ease, color 0.2s ease;
}

.cfb-mini-medal {
    display: inline-flex;
    line-height: 0;
}

.cfb-mini-medal .cfb-medal-count {
    display: none;
}

.cfb-mini-medal:hover,
.cfb-mini-medal:focus-visible {
    z-index: 1;
    transform: translateY(-2px) scale(1.14);
}

.cfb-mini-medal:focus-visible,
.cfb-mini-more:focus-visible {
    box-shadow: 0 0 0 3px rgba(17, 161, 145, 0.4);
}

.cfb-mini-more {
    display: inline-grid;
    place-items: center;
    min-width: 30px;
    height: 26px;
    padding: 0 8px;
    box-sizing: border-box;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: var(--cfb-text);
    font-size: 11.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cfb-mini-more:hover {
    background: #e9f8f6;
    color: var(--cfb-teal-deep);
}

.cfb-entering .cfb-mini-medal,
.cfb-entering .cfb-mini-more {
    animation: cfb-tile-in 0.55s var(--cfb-ease-spring) both;
    animation-delay: calc(var(--cfb-i, 0) * 50ms);
}

.cfb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 64px 24px;
    color: var(--cfb-muted);
    font-size: 0.95rem;
}

.cfb-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(17, 161, 145, 0.2);
    border-top-color: var(--cfb-teal);
    border-radius: 50%;
    animation: cfb-spin 0.8s linear infinite;
}

@keyframes cfb-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Celebration toast ---------- */
.cfb-toast {
    position: fixed;
    top: 88px;
    right: 24px;
    z-index: 100025;
    display: flex;
    align-items: center;
    gap: 16px;
    width: min(410px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 18px 46px 18px 18px;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 22px;
    background:
        radial-gradient(240px 140px at 0% 0%, rgba(45, 212, 191, 0.16), transparent 70%),
        radial-gradient(260px 160px at 100% 100%, rgba(167, 139, 250, 0.14), transparent 70%),
        rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 28px 60px -20px rgba(15, 23, 42, 0.4);
    color: var(--cfb-ink);
    opacity: 0;
    transform: translateY(-14px) scale(0.96);
    transition: opacity 0.35s var(--cfb-ease-out), transform 0.5s var(--cfb-ease-spring) !important;
}

.cfb-toast.is-open {
    opacity: 1;
    transform: none;
}

.cfb-toast.is-closing {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.25s ease-in, transform 0.3s ease-in !important;
    pointer-events: none;
}

.cfb-toast-medals {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

/* Soft halo behind the medal */
.cfb-toast-medals::before {
    content: "";
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(250, 204, 21, 0.35), rgba(45, 212, 191, 0.12) 60%, transparent);
    opacity: 0;
    pointer-events: none;
}

.cfb-toast.is-open .cfb-toast-medals::before {
    animation: cfb-halo 2.4s ease-out 0.3s both;
}

@keyframes cfb-halo {
    0% { opacity: 0; transform: scale(0.6); }
    30% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0.55; transform: scale(1); }
}

.cfb-toast .cfb-medal {
    opacity: 0;
}

.cfb-toast.is-open .cfb-medal {
    animation: cfb-medal-in 0.95s var(--cfb-ease-spring) 0.12s both;
}

.cfb-toast.is-stack .cfb-medal + .cfb-medal {
    margin-left: -20px;
}

.cfb-toast.is-stack .cfb-medal {
    border-radius: 50%;
    box-shadow: 0 0 0 3px #fff;
}

.cfb-toast.is-open .cfb-toast-medal-1 { animation-delay: 0.24s; }
.cfb-toast.is-open .cfb-toast-medal-2 { animation-delay: 0.36s; }

@keyframes cfb-medal-in {
    0% { opacity: 0; transform: scale(0.25) rotate(-40deg); }
    55% { opacity: 1; transform: scale(1.14) rotate(8deg); }
    78% { transform: scale(0.97) rotate(-2deg); }
    100% { opacity: 1; transform: none; }
}

.cfb-toast-body {
    min-width: 0;
}

.cfb-toast-kicker {
    display: inline-block;
    margin-bottom: 3px;
    background: linear-gradient(90deg, #0b7a6e, #7c5cf0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.cfb-toast-title {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.3;
    color: var(--cfb-ink);
}

.cfb-toast-text {
    margin-top: 3px;
    font-size: 0.84rem;
    line-height: 1.45;
    color: var(--cfb-text);
}

.cfb-toast-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--cfb-teal-deep);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: gap 0.2s ease, color 0.2s ease;
}

.cfb-toast-cta svg {
    width: 15px;
    height: 15px;
}

.cfb-toast-cta:hover {
    gap: 9px;
    color: var(--cfb-teal);
}

.cfb-toast-cta:focus-visible,
.cfb-toast-close:focus-visible {
    outline: 3px solid rgba(17, 161, 145, 0.45);
    outline-offset: 3px;
    border-radius: 6px;
}

.cfb-toast-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--cfb-faint);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.cfb-toast-close svg {
    width: 15px;
    height: 15px;
}

.cfb-toast-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--cfb-ink);
}

.cfb-toast-timer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, #2dd4bf, #11a191 40%, #a78bfa);
    opacity: 0.75;
    transform-origin: left center;
}

.cfb-toast.is-open .cfb-toast-timer {
    animation: cfb-timer var(--cfb-toast-ms, 7000ms) linear both;
}

.cfb-toast.is-paused .cfb-toast-timer {
    animation-play-state: paused;
}

@keyframes cfb-timer {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.cfb-confetti {
    position: fixed;
    inset: 0;
    z-index: 100030;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
    .cfb-overlay {
        padding: 12px;
    }

    .cfb-sheet {
        border-radius: 22px;
    }

    .cfb-sheet-head {
        padding: 22px 20px 18px;
    }

    .cfb-sheet-title {
        font-size: 1.35rem;
    }

    .cfb-sheet-summary {
        padding: 16px 20px;
    }

    .cfb-legend-wrap {
        align-items: flex-start;
    }

    .cfb-legend {
        justify-content: flex-start;
    }

    .cfb-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        padding: 16px 16px 20px;
    }

    .cfb-card {
        gap: 14px;
        padding: 16px;
    }

    .cfb-card .cfb-medal {
        --cfb-size: 56px !important;
    }

    .cfb-badge-hero {
        padding: 40px 20px 26px;
    }

    .cfb-badge-body {
        padding: 20px 20px 4px;
    }

    .cfb-badge-foot {
        margin-top: 20px;
        padding: 14px 20px 18px;
    }

    .cfb-toast {
        top: 76px;
        right: 16px;
        left: 16px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cfb-chip,
    .cfb-more,
    .cfb-card,
    .cfb-card-medal,
    .cfb-sheet,
    .cfb-pop,
    .cfb-toast,
    .cfb-medal-core::after {
        transition: none !important;
    }

    .is-entering > .cfb-chip,
    .is-entering > .cfb-more,
    .cfb-chip.is-new,
    .cfb-chip.is-new::after,
    .cfb-card,
    .cfb-bar > span,
    .cfb-toast.is-open .cfb-medal,
    .cfb-toast.is-open .cfb-toast-medals::before,
    .cfb-badge-hero::before,
    .cfb-overlay.is-open .cfb-badge-medal {
        animation: none !important;
    }

    .cfb-toast .cfb-medal {
        opacity: 1;
    }

    .cfb-chip:hover,
    .cfb-chip:focus-visible,
    .cfb-card:hover,
    .cfb-card:hover .cfb-card-medal,
    .cfb-tile:hover,
    .cfb-tile:hover .cfb-medal,
    .cfb-mini-medal:hover,
    .cfb-mini-medal:focus-visible {
        transform: none;
    }
}
