.live-leaderboard {
    --leader-bg: #07111f;
    --leader-panel: rgba(14, 29, 49, 0.92);
    --leader-line: rgba(155, 184, 222, 0.2);
    --leader-text: #f4f8ff;
    --leader-muted: #9eb0c9;
    --leader-gold: #ffd15c;
    position: relative;
    color: var(--leader-text);
    min-height: 75vh;
}

.live-leaderboard::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 50% 15%, rgba(255, 197, 61, 0.12), transparent 35%),
        radial-gradient(circle at 8% 70%, rgba(49, 196, 141, 0.1), transparent 27%),
        linear-gradient(145deg, #06101d, #0d1c30 52%, #07111f);
}

.leaderboard-heading,
.ranking-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.leaderboard-heading {
    margin-bottom: 30px;
}

.leaderboard-heading h1,
.ranking-panel h2 {
    margin: 4px 0;
    line-height: 1.05;
}

.leaderboard-heading h1 {
    font-size: clamp(2rem, 5vw, 4.7rem);
    letter-spacing: -0.055em;
}

.leaderboard-kicker {
    color: var(--leader-gold);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.2em;
}

.leaderboard-subtitle,
.event-progress-text {
    margin: 8px 0 0;
    color: var(--leader-muted);
}

.live-status {
    min-width: 135px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 3px 9px;
    padding: 12px 16px;
    border: 1px solid rgba(49, 196, 141, 0.4);
    border-radius: 16px;
    background: rgba(9, 28, 35, 0.86);
    color: #8fffd3;
    font-weight: 900;
    letter-spacing: 0.12em;
}

.live-status small {
    grid-column: 1 / -1;
    color: var(--leader-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0;
}

.live-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #31c48d;
    box-shadow: 0 0 0 0 rgba(49, 196, 141, 0.7);
    animation: livePulse 1.7s infinite;
}

.leaderboard-error {
    margin-bottom: 20px;
    padding: 14px 18px;
    border: 1px solid rgba(240, 82, 82, 0.55);
    border-radius: 12px;
    background: rgba(100, 31, 43, 0.7);
}

.podium {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: end;
    gap: 18px;
    min-height: 465px;
    margin: 0 auto 28px;
}

.podium-loading,
.ranking-loading {
    grid-column: 1 / -1;
    align-self: center;
    padding: 35px;
    text-align: center;
    color: var(--leader-muted);
}

.podium-card {
    --team-accent: #7891b5;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    padding: 25px 20px 0;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--team-accent) 45%, transparent);
    border-radius: 24px 24px 12px 12px;
    background:
        radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--team-accent) 20%, transparent), transparent 45%),
        var(--leader-panel);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
    text-align: center;
    transition: transform 300ms ease, border-color 300ms ease;
}

.podium-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 25%, rgba(255, 255, 255, 0.06) 45%, transparent 65%);
    transform: translateX(-100%);
    animation: podiumShine 7s infinite;
}

.podium-card.rank-1 {
    min-height: 430px;
    border-color: rgba(255, 209, 92, 0.62);
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 209, 92, 0.26), transparent 45%),
        linear-gradient(180deg, rgba(33, 42, 58, 0.98), rgba(15, 28, 47, 0.98));
    transform: translateY(-15px);
}

.podium-card.rank-2 { min-height: 350px; }
.podium-card.rank-3 { min-height: 315px; }

.podium-card:hover {
    transform: translateY(-8px);
}

.podium-card.rank-1:hover {
    transform: translateY(-23px);
}

.podium-medal {
    font-size: clamp(2.5rem, 5vw, 4.2rem);
    line-height: 1;
    filter: drop-shadow(0 7px 13px rgba(0, 0, 0, 0.35));
}

.podium-place {
    margin-top: 10px;
    color: var(--leader-gold);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.14em;
}

.podium-card h2 {
    margin: 15px 0 4px;
    font-size: clamp(1.35rem, 3vw, 2.1rem);
    overflow-wrap: anywhere;
}

.podium-theme {
    min-height: 2.4em;
    margin: 0;
    color: var(--leader-muted);
    font-size: 0.9rem;
}

.podium-score {
    margin-top: 15px;
    font-size: clamp(3rem, 7vw, 5.9rem);
    font-weight: 950;
    line-height: 0.95;
    letter-spacing: -0.075em;
    text-shadow: 0 8px 28px color-mix(in srgb, var(--team-accent) 25%, transparent);
}

.podium-score-label {
    margin-top: 8px;
    color: var(--leader-muted);
    font-size: 0.75rem;
}

.podium-progress-meta {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 18px;
    color: var(--leader-muted);
    font-size: 0.7rem;
}

.podium-progress,
.ranking-progress {
    width: 100%;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
}

.podium-progress {
    height: 7px;
    margin: 7px 0 18px;
}

.podium-progress span,
.ranking-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--team-accent), color-mix(in srgb, var(--team-accent) 55%, white));
    transition: width 600ms ease;
}

.podium-base {
    width: calc(100% + 40px);
    min-height: 70px;
    margin-top: auto;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, color-mix(in srgb, var(--team-accent) 68%, #17263a), #132137);
    border-top: 1px solid color-mix(in srgb, var(--team-accent) 55%, transparent);
}

.podium-card.rank-1 .podium-base { min-height: 105px; }
.podium-card.rank-2 .podium-base { min-height: 78px; }

.podium-base span {
    font-size: 3.2rem;
    font-weight: 950;
    opacity: 0.9;
}

.tie-badge {
    display: inline-block;
    margin-left: 5px;
    padding: 3px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
}

.ranking-panel {
    padding: 22px;
    border: 1px solid var(--leader-line);
    border-radius: 22px;
    background: rgba(9, 21, 36, 0.9);
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.25);
}

.ranking-panel h2 {
    font-size: clamp(1.5rem, 3vw, 2.3rem);
}

.ranking-list {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.ranking-row {
    --team-accent: #7891b5;
    display: grid;
    grid-template-columns: 64px minmax(170px, 1fr) auto minmax(100px, auto);
    gap: 15px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--team-accent) 30%, transparent);
    border-radius: 16px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--team-accent) 10%, transparent), rgba(16, 29, 48, 0.78));
}

.ranking-position {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
}

.ranking-position strong {
    font-size: 2rem;
}

.ranking-position small {
    color: var(--team-accent);
}

.ranking-team h3 {
    margin: 0;
    font-size: 1.08rem;
}

.ranking-team p {
    margin: 3px 0 8px;
    color: var(--leader-muted);
    font-size: 0.78rem;
}

.ranking-progress { height: 5px; }

.ranking-breakdown {
    display: flex;
    gap: 8px;
}

.ranking-breakdown span {
    min-width: 66px;
    padding: 7px 9px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.055);
    text-align: center;
    font-weight: 800;
}

.ranking-breakdown small,
.ranking-total small {
    display: block;
    color: var(--leader-muted);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.ranking-breakdown .penalty {
    color: #ff9b9b;
}

.ranking-total {
    text-align: right;
}

.ranking-total strong {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.theme-environment { --team-accent: #38d996; }
.theme-school_pride { --team-accent: #58a8ff; }
.theme-heritage { --team-accent: #ff9d57; }
.theme-general { --team-accent: #9caed0; }

.rank-changed,
.ranking-row-changed {
    animation: rankMove 850ms ease;
}

.score-flash {
    animation: scoreFlash 700ms ease;
}

@keyframes livePulse {
    0% { box-shadow: 0 0 0 0 rgba(49, 196, 141, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(49, 196, 141, 0); }
    100% { box-shadow: 0 0 0 0 rgba(49, 196, 141, 0); }
}

@keyframes podiumShine {
    0%, 72% { transform: translateX(-120%); }
    90%, 100% { transform: translateX(120%); }
}

@keyframes rankMove {
    0% { opacity: 0.45; transform: translateY(18px) scale(0.97); }
    100% { opacity: 1; }
}

@keyframes scoreFlash {
    0%, 100% { color: inherit; text-shadow: inherit; }
    50% { color: #fff1ae; text-shadow: 0 0 24px rgba(255, 209, 92, 0.9); }
}

@media (max-width: 900px) {
    .podium {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }

    .podium-card {
        padding-inline: 12px;
    }

    .podium-base {
        width: calc(100% + 24px);
    }

    .ranking-row {
        grid-template-columns: 52px minmax(150px, 1fr) auto;
    }

    .ranking-breakdown {
        grid-column: 2 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 700px) {
    .leaderboard-heading,
    .ranking-panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .live-status {
        width: 100%;
    }

    .podium {
        display: flex;
        min-height: 0;
        flex-direction: column;
        align-items: stretch;
    }

    .podium-card.rank-1 { order: 1; }
    .podium-card.rank-2 { order: 2; }
    .podium-card.rank-3 { order: 3; }

    .podium-card,
    .podium-card.rank-1,
    .podium-card.rank-2,
    .podium-card.rank-3 {
        min-height: 0;
        transform: none;
    }

    .podium-card:hover,
    .podium-card.rank-1:hover {
        transform: none;
    }

    .podium-base,
    .podium-card.rank-1 .podium-base,
    .podium-card.rank-2 .podium-base {
        min-height: 62px;
    }

    .ranking-panel {
        padding: 14px;
    }

    .ranking-row {
        grid-template-columns: 45px minmax(0, 1fr) auto;
        gap: 9px;
        padding: 12px 10px;
    }

    .ranking-breakdown {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 3px;
    }

    .ranking-total strong {
        font-size: 1.55rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
