/* Banner di compleanno degli atleti (js/birthday_celebration.js). */
.birthday-dialog {
    width: min(460px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #f1f8ff 100%);
    color: var(--navy, #111827);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.45);
    text-align: center;
}

.birthday-dialog::backdrop {
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
}

.birthday-panel {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 0 22px 22px;
    overflow-y: auto;
    max-height: calc(100dvh - 32px);
}

.birthday-stage {
    position: relative;
    width: calc(100% + 44px);
    height: 210px;
    margin: 0 -22px;
    overflow: hidden;
    background: radial-gradient(circle at 50% 120%, #1d4ed8 0%, #172554 55%, #0b1220 100%);
}

.birthday-title {
    margin: 8px 0 0;
    font-size: 1.6rem;
    line-height: 1.2;
}

.birthday-names {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--primary, #1d4ed8);
    font-size: 1.2rem;
    font-weight: 700;
}

.birthday-message {
    margin: 0;
    color: #475569;
}

.birthday-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 6px;
}

.birthday-close-button,
.birthday-secondary-button {
    padding: 11px 18px;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.birthday-close-button {
    border: 0;
    background: linear-gradient(135deg, var(--blue, #3ca9ff), var(--primary, #1d4ed8));
    color: #fff;
}

.birthday-secondary-button {
    border: 1px solid var(--primary, #1d4ed8);
    background: #fff;
    color: var(--primary, #1d4ed8);
}

.birthday-secondary-button:disabled {
    cursor: default;
    opacity: 0.7;
}

/* X di chiusura in alto a destra, sopra la scena animata. */
.birthday-dialog-x {
    position: absolute;
    z-index: 5;
    top: 10px;
    right: 10px;
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.7);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.birthday-dialog-x:hover,
.birthday-dialog-x:focus-visible {
    background: rgba(15, 23, 42, 0.92);
}

/* ---- Torta -------------------------------------------------------------- */
.birthday-cake {
    position: absolute;
    left: 50%;
    bottom: 18px;
    width: 180px;
    height: 170px;
    transform: translateX(-50%);
}

.birthday-cake-plate {
    position: absolute;
    left: -14px;
    right: -14px;
    bottom: 0;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(180deg, #e2e8f0, #94a3b8);
}

.birthday-cake-layer {
    position: absolute;
    left: 0;
    right: 0;
    border-radius: 12px 12px 8px 8px;
}

.birthday-cake-layer--bottom {
    bottom: 8px;
    height: 52px;
    background: linear-gradient(180deg, #f9a8d4 0 18%, #fbcfe8 18% 100%);
}

.birthday-cake-layer--top {
    left: 18px;
    right: 18px;
    bottom: 58px;
    height: 44px;
    background: linear-gradient(180deg, #fde68a 0 22%, #fef3c7 22% 100%);
}

.birthday-cake-top {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 96px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 0 rgba(244, 114, 182, 0.35);
}

.birthday-candles {
    position: absolute;
    left: 30px;
    right: 30px;
    bottom: 104px;
    display: flex;
    justify-content: space-between;
}

.birthday-candle {
    position: relative;
    width: 9px;
    height: 34px;
    border-radius: 3px;
    background: repeating-linear-gradient(180deg, #3ca9ff 0 6px, #ffffff 6px 12px);
}

.birthday-flame {
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: 12px;
    height: 20px;
    margin-left: -6px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: radial-gradient(circle at 50% 70%, #fff7ae 0%, #fbbf24 45%, #f97316 75%, transparent 100%);
    box-shadow: 0 0 14px 4px rgba(251, 191, 36, 0.55);
    transform-origin: 50% 100%;
    animation: birthday-flicker 0.6s ease-in-out infinite alternate;
    animation-delay: calc(var(--candle-index, 0) * -0.13s);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.birthday-dialog.is-blown .birthday-flame {
    opacity: 0;
    transform: scale(0.2) translateY(-10px);
    animation: none;
}

@keyframes birthday-flicker {
    from {
        transform: scale(1) rotate(-3deg);
    }

    to {
        transform: scale(1.12, 0.92) rotate(3deg);
    }
}

/* ---- Coriandoli e palloncini -------------------------------------------- */
.birthday-confetti {
    position: absolute;
    top: -16px;
    left: var(--x);
    width: 8px;
    height: 14px;
    border-radius: 2px;
    opacity: 0.9;
    animation: birthday-confetti-fall var(--duration) linear var(--delay) infinite;
}

@keyframes birthday-confetti-fall {
    to {
        transform: translate(var(--drift), 250px) rotate(var(--rotation));
    }
}

.birthday-balloons {
    position: absolute;
    inset: 0;
}

.birthday-balloon {
    position: absolute;
    bottom: -90px;
    left: calc(8% + var(--balloon-index) * 19%);
    width: 46px;
    height: 58px;
    border-radius: 50% 50% 48% 48%;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.7) 0 12%, var(--balloon-color) 13%);
    animation: birthday-balloon-rise 6s ease-in-out infinite;
    animation-delay: calc(var(--balloon-index) * -1.1s);
}

.birthday-balloon::after {
    position: absolute;
    left: 50%;
    top: 100%;
    width: 1px;
    height: 46px;
    background: rgba(255, 255, 255, 0.6);
    content: "";
}

@keyframes birthday-balloon-rise {
    0% {
        transform: translate(0, 0) rotate(-4deg);
    }

    50% {
        transform: translate(12px, -170px) rotate(5deg);
    }

    100% {
        transform: translate(-6px, -330px) rotate(-3deg);
    }
}

.birthday-party-emoji {
    position: absolute;
    left: 50%;
    top: 50%;
    font-size: 5rem;
    line-height: 1;
    transform: translate(-50%, -50%);
    animation: birthday-bounce 1.2s ease-in-out infinite;
}

@keyframes birthday-bounce {
    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -60%) scale(1.08);
    }
}

/* ---- Scritte fluttuanti e festoni (senza riquadro) ------------------------ */
.birthday-dialog--floating {
    width: 100vw;
    width: 100dvw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #fff;
}

.birthday-dialog--floating::backdrop {
    background: rgba(8, 15, 30, 0.55);
    backdrop-filter: blur(3px);
}

.birthday-dialog--floating .birthday-panel {
    position: static;
    height: 100%;
    max-height: none;
    box-sizing: border-box;
    align-content: center;
    padding: 90px 20px 40px;
    overflow: hidden;
}

.birthday-dialog--floating .birthday-stage {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    margin: 0;
    background: transparent;
    pointer-events: none;
}

.birthday-dialog--floating .birthday-title,
.birthday-dialog--floating .birthday-names,
.birthday-dialog--floating .birthday-message,
.birthday-dialog--floating .birthday-actions {
    position: relative;
    z-index: 2;
}

.birthday-dialog--floating .birthday-title {
    font-size: clamp(2.2rem, 8vw, 4.4rem);
    background: linear-gradient(90deg, #fde68a, #ff8ad8, #7ecbff, #fde68a);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.45));
    animation: birthday-float 3.2s ease-in-out infinite, birthday-shine 6s linear infinite;
}

.birthday-dialog--floating .birthday-names {
    color: #fff;
    font-size: clamp(1.4rem, 5vw, 2.4rem);
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
    animation: birthday-float 3.2s ease-in-out -1.1s infinite;
}

.birthday-dialog--floating .birthday-message {
    color: #e0f2fe;
    font-size: clamp(1rem, 3.2vw, 1.4rem);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
    animation: birthday-float 3.2s ease-in-out -2.2s infinite;
}

.birthday-dialog--floating .birthday-close-button {
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
}

.birthday-dialog--floating .birthday-dialog-x {
    position: fixed;
    top: 16px;
    right: 16px;
}

@keyframes birthday-float {
    0%,
    100% {
        transform: translateY(0) rotate(-1deg);
    }

    50% {
        transform: translateY(-12px) rotate(1deg);
    }
}

@keyframes birthday-shine {
    to {
        background-position: 300% 0;
    }
}

.birthday-garland {
    position: absolute;
    top: 0;
    display: flex;
    width: 52%;
    justify-content: space-around;
    padding-top: 6px;
    transform-origin: 50% 0;
    animation: birthday-garland-swing 4s ease-in-out infinite;
}

.birthday-garland::before {
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    height: 40px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 0 0 50% 50%;
    content: "";
}

.birthday-garland--left {
    left: 0;
}

.birthday-garland--right {
    right: 0;
    animation-delay: -2s;
}

.birthday-flag {
    position: relative;
    width: 0;
    height: 0;
    margin-top: calc(14px + (4 - var(--flag-index) * 1) * (4 - var(--flag-index) * 1) * -1.6px + 26px);
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 30px solid var(--flag-color);
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}

@keyframes birthday-garland-swing {
    0%,
    100% {
        transform: rotate(-1.5deg);
    }

    50% {
        transform: rotate(1.5deg);
    }
}

.birthday-streamer {
    position: absolute;
    top: -80px;
    left: var(--x);
    width: 6px;
    height: 70px;
    border-radius: 6px;
    opacity: 0.85;
    animation: birthday-streamer-fall var(--duration) linear var(--delay) infinite;
}

@keyframes birthday-streamer-fall {
    0% {
        transform: translate(0, 0) rotate(0deg) skewX(0deg);
    }

    25% {
        transform: translate(18px, 28vh) rotate(25deg) skewX(12deg);
    }

    50% {
        transform: translate(-14px, 56vh) rotate(-20deg) skewX(-12deg);
    }

    75% {
        transform: translate(16px, 84vh) rotate(18deg) skewX(10deg);
    }

    100% {
        transform: translate(0, 115vh) rotate(-10deg) skewX(0deg);
    }
}

.birthday-dialog--floating .birthday-confetti {
    animation-name: birthday-confetti-fall-screen;
}

@keyframes birthday-confetti-fall-screen {
    to {
        transform: translate(var(--drift), 110vh) rotate(var(--rotation));
    }
}

@media (prefers-reduced-motion: reduce) {
    .birthday-flame,
    .birthday-confetti,
    .birthday-balloon,
    .birthday-party-emoji,
    .birthday-garland,
    .birthday-streamer,
    .birthday-dialog--floating .birthday-title,
    .birthday-dialog--floating .birthday-names,
    .birthday-dialog--floating .birthday-message {
        animation: none;
    }

    .birthday-streamer {
        display: none;
    }

    .birthday-confetti {
        display: none;
    }
}
