:root {
    font-family:
        "Poppins",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: #182b45;
    background: #f5f7fa;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
}

main {
    max-width: 42rem;
    margin: 1rem auto;
    padding: 0 0.75rem;
}

p,
h1,
h2,
h3 {
    margin: 0;
}

h1 {
    font-size: 1.375rem;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.week-number {
    margin-top: 0.25rem;
    color: #58677a;
    font-size: 0.875rem;
    font-weight: 600;
}

.stream-info {
    margin: 0.375rem 0 0.75rem;
    font-size: 0.75rem;
    color: #58677a;
}

.connection-spinner {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    vertical-align: -0.125rem;
    border: 2px solid #cbd5e1;
    border-top-color: #243f65;
    border-radius: 50%;
    animation: connection-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .connection-spinner {
        animation: none;
    }
}

#notice,
#chart-notice {
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fff;
    border: 1px solid #dce2ea;
    border-radius: 0.75rem;
}

.loser-card {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(100%, 22rem);
    min-height: 28rem;
    margin: 2rem auto 1.5rem;
    padding: 5rem clamp(2.5rem, 12vw, 3.5rem) 4rem;
    text-align: center;
    color: #492b09;
}

.loser-card::before {
    content: "";
    position: absolute;
    z-index: -2;
    inset: 0;
    background:
        linear-gradient(
            90deg,
            rgba(167, 187, 201, 0.22),
            rgba(255, 255, 255, 0.65) 7%,
            transparent 22%,
            transparent 78%,
            rgba(255, 255, 255, 0.65) 93%,
            rgba(167, 187, 201, 0.22)
        ),
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.35),
            rgba(198, 214, 225, 0.12)
        );
    clip-path: polygon(
        0 0,
        100% 0,
        87% 97%,
        85% 99%,
        80% 100%,
        20% 100%,
        15% 99%,
        13% 97%
    );
    border-radius: 0.6rem 0.6rem 0 0;
}

.loser-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    clip-path: polygon(
        0 0,
        100% 0,
        87% 97%,
        85% 99%,
        80% 100%,
        20% 100%,
        15% 99%,
        13% 97%
    );
    border-top: 5px solid rgba(255, 255, 255, 0.8);
    background:
        linear-gradient(
            to top,
            rgba(255, 255, 255, 0.75) 0 8px,
            rgba(255, 255, 255, 0.3) 8px 15px,
            transparent 15px
        ),
        linear-gradient(
            82deg,
            transparent 16%,
            rgba(255, 255, 255, 0.35) 17%,
            transparent 21%
        ),
        linear-gradient(
            -82deg,
            transparent 16%,
            rgba(255, 255, 255, 0.3) 17%,
            transparent 20%
        );
}

.beer-glass {
    position: absolute;
    z-index: -1;
    inset: -0.2rem 0 0;
    overflow: hidden;
    border-radius: 0.6rem 0.6rem 0 0;
    /* Only a small rounded cap extends above the rim. */
    clip-path: polygon(
        0 0,
        100% 0,
        100% 0.2rem,
        87% 97%,
        85% 99%,
        80% 100%,
        20% 100%,
        15% 99%,
        13% 97%,
        0 0.2rem
    );
    pointer-events: none;
}

.beer-liquid {
    position: absolute;
    inset: 2rem 0 0.5rem;
    background:
        linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.35),
            transparent 12%,
            transparent 85%,
            rgba(255, 255, 255, 0.25)
        ),
        linear-gradient(#ffe096, #f5b83e 55%, #e99b24);
    box-shadow: inset 0 -12px 24px rgba(170, 91, 0, 0.1);
    animation: beer-fill 3.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.beer-liquid::before,
.beer-liquid::after {
    content: "";
    position: absolute;
    left: -10%;
    width: 120%;
    border-radius: 45% 45% 35% 35% / 0.5rem;
}

.beer-liquid::before {
    top: -2rem;
    height: 2.5rem;
    background: #fff1ce;
    box-shadow: 0 5px 10px rgba(167, 100, 15, 0.1);
    animation:
        beer-sway 3s ease-in-out infinite alternate,
        beer-foam-settle 5s ease-out both;
}

.beer-liquid::after {
    top: -2rem;
    height: 2.25rem;
    background:
        radial-gradient(circle at 20% 70%, #f3e4c4 0 2px, transparent 3px),
        radial-gradient(circle at 65% 75%, #f3e4c4 0 3px, transparent 4px),
        radial-gradient(circle at 80% 60%, #f3e4c4 0 2px, transparent 3px),
        #fffaf0;
    animation:
        beer-sway 3s ease-in-out infinite alternate-reverse,
        beer-foam-settle 5s ease-out both;
}

.beer-bubbles {
    position: absolute;
    inset: 1rem 0 0;
    opacity: 0.6;
    background:
        radial-gradient(circle at 8% 85%, #fff5cf 0 3px, transparent 4px),
        radial-gradient(circle at 17% 45%, #fff5cf 0 2px, transparent 3px),
        radial-gradient(circle at 28% 92%, #fff5cf 0 2px, transparent 3px),
        radial-gradient(circle at 74% 65%, #fff5cf 0 3px, transparent 4px),
        radial-gradient(circle at 88% 35%, #fff5cf 0 2px, transparent 3px),
        radial-gradient(circle at 94% 80%, #fff5cf 0 4px, transparent 5px);
    animation: beer-bubbles 3s linear infinite;
}

@keyframes beer-fill {
    from {
        transform: translateY(calc(100% + 3rem));
    }
    to {
        transform: translateY(0);
    }
}

@keyframes beer-sway {
    from {
        transform: translateX(-2%) rotate(-1deg);
    }
    to {
        transform: translateX(2%) rotate(1deg);
    }
}

@keyframes beer-foam-settle {
    0%,
    20% {
        height: 6rem;
    }
    55% {
        height: 3.5rem;
    }
    /* Finish at each foam layer's own resting height. */
}

@keyframes beer-bubbles {
    from {
        transform: translateY(1rem);
        opacity: 0;
    }
    30% {
        opacity: 0.6;
    }
    to {
        transform: translateY(-2rem);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .beer-liquid,
    .beer-liquid::before,
    .beer-liquid::after,
    .beer-bubbles {
        animation: none;
    }
}

.loser-label {
    color: #69410e;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.loser-name {
    width: 100%;
    margin-top: 1rem;
    font-size: clamp(1.75rem, 6vw, 2.25rem);
    letter-spacing: -0.035em;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.loser-history {
    margin-top: 0.75rem;
    color: #69410e;
    font-size: 0.75rem;
}

.loser-loss-number {
    font-size: 1rem;
    font-weight: 600;
}

@keyframes loser-name-reveal {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .loser-name {
        /* Begin as the 3.6s pour reaches the center of the glass. */
        animation: loser-name-reveal 1.2s ease-out 0.6s both;
    }
}

.leaderboard {
    padding: 0;
    margin: 0;
    list-style: none;
    background: #fff;
    border: 1px solid #dce2ea;
    border-radius: 0.5rem;
    overflow: hidden;
}

.manager-card {
    display: flex;
    align-items: flex-start;
    padding: 0.4375rem 0.625rem;
    border-bottom: 1px solid #e7ebf1;
}

.manager-card:last-child {
    border-bottom: 0;
}

.rank {
    flex: 0 0 1.5rem;
    margin: 0.125rem 0.5rem 0 0;
    color: #58677a;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.manager-detail {
    flex: 1 1 0%;
    min-width: 0;
}

.manager-name {
    font-size: 0.8125rem;
    font-weight: 600;
    overflow-wrap: break-word;
    word-break: break-word;
}

.manager-identity {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
}

.manager-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
}

.manager-avatar {
    flex: 0 0 1.375rem;
    width: 1.375rem;
    height: 1.375rem;
    border-radius: 50%;
    object-fit: cover;
    background: #e8edf4;
}

.projected-points {
    flex: 0 0 auto;
    color: #58677a;
    font-size: 0.625rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.probability {
    display: flex;
    align-items: center;
    margin-top: 0;
}

.percentage {
    flex: 0 0 3rem;
    margin-left: 0.625rem;
    text-align: right;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
}

.bar-track {
    flex: 1 1 0%;
    min-width: 0;
    height: 0.375rem;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf4;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: #243f65;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.updated-at {
    margin-top: 0.5rem;
    color: #58677a;
    font-size: 0.75rem;
}

.counts-chart {
    max-width: 60rem;
}

.view-toggle {
    display: flex;
    width: fit-content;
    gap: 0.25rem;
    padding: 0.125rem;
    margin-bottom: 0.625rem;
    border-radius: 0.375rem;
    background: #e8edf4;
}

.view-toggle button {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    min-height: 28px;
    border: 0;
    border-radius: 0.25rem;
    background: transparent;
    color: #58677a;
    font: 600 0.6875rem "Poppins", sans-serif;
    cursor: pointer;
}

.view-toggle button[aria-pressed="true"] {
    color: #243f65;
    background: #fff;
}

.view-toggle button:focus-visible {
    outline: 2px solid #e99b24;
    outline-offset: 2px;
}

.counts-plot {
    position: relative;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #dce2ea;
    border-radius: 0.5rem;
}
