:root {
    color-scheme: dark;
    --bg: #000;
    --surface: #141414;
    --surface-raised: #222;
    --line: #333;
    --text: #f5f5f5;
    --muted: #a3a3a3;
    --accent: #e0bb4f;
    --accent-text: #000;
    --danger: #ff6b6b;
    --silver: #d0d0d0;
    --bronze: #d08b4f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 {
    margin: 0 0 .5rem;
    line-height: 1.2;
}

h1 {
    font-size: 1.75rem;
}

h1:focus {
    outline: none;
}

h2 {
    font-size: 1.15rem;
}

a {
    color: var(--accent);
}

small {
    font-weight: 400;
    font-size: .85rem;
}

.muted {
    color: var(--muted);
}

.center {
    text-align: center;
}

.error,
.validation-message {
    color: var(--danger);
}

/* Layout */
.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .25rem 1rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--line);
}

.brand {
    color: var(--text);
    font-weight: 700;
    letter-spacing: .02em;
    text-decoration: none;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem 1rem;
}

.nav a {
    color: var(--muted);
    text-decoration: none;
    padding: .25rem 0;
}

.nav a.active {
    color: var(--accent);
}

.nav form {
    margin: 0;
}

.page {
    width: 100%;
    max-width: 44rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: .75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.login {
    max-width: 24rem;
    margin: 2rem auto;
}

/* Controls */
.btn {
    min-height: 2.75rem;
    padding: .5rem 1rem;
    color: var(--text);
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: .5rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    display: inline-block;
}

.btn:disabled {
    opacity: .5;
    cursor: default;
}

.btn-primary {
    color: var(--accent-text);
    background: var(--accent);
    border-color: var(--accent);
}

.btn-danger {
    color: #000;
    background: var(--danger);
    border-color: var(--danger);
}

.btn-wide {
    width: 100%;
}

.link-button {
    padding: .25rem 0;
    color: var(--muted);
    background: none;
    border: 0;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

input,
select {
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding: .5rem .75rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: .5rem;
    font: inherit;
}

:is(a, button, input, select):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.field {
    display: block;
    margin-bottom: 1rem;
}

.field span {
    display: block;
    margin-bottom: .25rem;
    color: var(--muted);
}

.check {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
    cursor: pointer;
}

.check input {
    width: 1.25rem;
    min-height: 1.25rem;
    height: 1.25rem;
    padding: 0;
    accent-color: var(--accent);
}

.row {
    display: flex;
    gap: .5rem;
    margin-bottom: .5rem;
}

.row input {
    flex: 2;
}

.row select {
    flex: 1.25;
}

.row .btn {
    flex: none;
}

.choice {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: .75rem;
    margin: 1rem 0;
}

.choice .btn {
    min-height: 4.5rem;
    font-size: 1.15rem;
    overflow-wrap: anywhere;
}

@media (max-width: 30rem) {
    .row:has(select) {
        flex-wrap: wrap;
    }

    .row:has(select) input {
        flex-basis: 100%;
    }

    .row select {
        flex: 1 1 7rem;
        width: auto;
    }
}

.game-picker {
    margin: 1rem 0 0;
    text-align: left;
}

/* Match */
.kicker {
    margin: 0 0 .25rem;
    color: var(--muted);
    font-size: .9rem;
}

.game-name {
    color: var(--accent);
    font-size: 2.25rem;
    overflow-wrap: anywhere;
}

.versus {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: .25rem .75rem;
    font-size: 1.35rem;
    margin: .5rem 0 1.5rem;
}

/* Standings */
.table-scroll {
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: .75rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    padding: .6rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

th {
    color: var(--muted);
    font-weight: 600;
    vertical-align: bottom;
}

th small {
    display: block;
}

td small {
    margin-left: .35rem;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Draws */
.points-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: .25rem 1.5rem;
}

.points-list li {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    overflow-wrap: anywhere;
}

.draws {
    list-style: none;
    margin: .75rem 0 0;
    padding: 0;
}

.draw {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
    margin-bottom: .75rem;
    padding: 1rem;
}

.draw-info {
    display: flex;
    flex-direction: column;
    flex: 1 1 14rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.draw-game {
    color: var(--accent);
    font-size: 1.1rem;
}

.draw-status {
    color: var(--muted);
}

.draw-locked {
    flex: 0 1 11rem;
}

.draw-confirm {
    flex: 1 1 100%;
}

.draw-confirm p {
    margin: 0;
}

.draw-confirm .choice {
    margin: .75rem 0 0;
}

.draw-confirm .choice .btn {
    min-height: 2.75rem;
    font-size: 1rem;
}

/* Podium */
.podium {
    list-style: none;
    margin: 1rem 0;
    padding: 0;
    display: grid;
    gap: .75rem;
}

.podium li {
    display: grid;
    grid-template-columns: 3.5rem 1fr auto;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: .75rem;
}

.podium-rank {
    font-weight: 700;
    font-size: 1.25rem;
}

.podium-name {
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.podium-1 {
    border-left-color: var(--accent) !important;
}

.podium-1 .podium-rank {
    color: var(--accent);
}

.podium-2 {
    border-left-color: var(--silver) !important;
}

.podium-2 .podium-rank {
    color: var(--silver);
}

.podium-3 {
    border-left-color: var(--bronze) !important;
}

.podium-3 .podium-rank {
    color: var(--bronze);
}

/* Blazor */
.blazor-error-boundary {
    padding: 1rem;
    color: #fff;
    background: #b32121;
}

.blazor-error-boundary::after {
    content: "Something went wrong.";
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    padding: .75rem 2.5rem .75rem 1rem;
    color: var(--text);
    background: #3a1212;
}

#blazor-error-ui .reload {
    margin-left: .5rem;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: .6rem;
    right: .75rem;
    cursor: pointer;
}

/* Winner celebration (see js/celebrate.js) */
.choice .btn-primary {
    transition: transform .1s ease, filter .1s ease;
}

.choice .btn-primary:active:not(:disabled) {
    transform: scale(.95);
    filter: brightness(1.15);
}

.confetti {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.celebration {
    position: fixed;
    top: 30%;
    left: 50%;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    max-width: calc(100vw - 2rem);
    padding: 1rem 1.75rem;
    color: var(--accent-text);
    background: var(--accent);
    border-radius: 1rem;
    box-shadow: 0 0 2.5rem rgb(224 187 79 / .55);
    text-align: center;
    pointer-events: none;
    animation: celebration-pop 2.2s ease forwards;
}

.celebration strong {
    font-size: 1.6rem;
    overflow-wrap: anywhere;
}

.celebration span {
    font-weight: 600;
}

@keyframes celebration-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
    12% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    20% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(.95); }
}

@media (prefers-reduced-motion: reduce) {
    .choice .btn-primary:active:not(:disabled) {
        transform: none;
    }

    @keyframes celebration-pop {
        0% { opacity: 0; transform: translate(-50%, -50%); }
        10%, 85% { opacity: 1; transform: translate(-50%, -50%); }
        100% { opacity: 0; transform: translate(-50%, -50%); }
    }
}

/* Live standings (see js/standings.js) */
.table-scroll:has(.standings) {
    /* Rows glide vertically while they move; that must not show a vertical scrollbar. */
    overflow-y: hidden;
}

.standings tbody tr {
    position: relative;
    background: var(--surface);
}

/* The script counts the shown value up to data-value; Blazor renders both, so it reads right without the script. */
.count {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.count::before {
    content: attr(data-shown);
}

.rank-badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.9rem;
    height: 1.9rem;
    padding: 0 .4rem;
    border-radius: 999px;
    font-weight: 700;
}

.rank-1 .rank-badge {
    color: var(--accent-text);
    background: var(--accent);
    box-shadow: 0 0 .9rem rgb(224 187 79 / .6);
}

.rank-2 .rank-badge {
    color: #000;
    background: var(--silver);
}

.rank-3 .rank-badge {
    color: #000;
    background: var(--bronze);
}

.standings tbody tr.rank-1 {
    background: linear-gradient(90deg, rgb(224 187 79 / .22), rgb(224 187 79 / .04) 70%), var(--surface);
}

.standings tbody tr.rank-1 td:first-child {
    box-shadow: inset 4px 0 0 var(--accent);
}

.standings tr.rank-1 .player-name {
    color: var(--accent);
    font-weight: 700;
}

.standings tr.rank-1 .count[data-count="total"] {
    color: var(--accent);
    font-size: 1.15rem;
}

.crown {
    display: inline-block;
    margin-right: .35rem;
    animation: crown-bob 2.4s ease-in-out infinite;
}

@keyframes crown-bob {
    0%, 100% { transform: translateY(0) rotate(-6deg); }
    50% { transform: translateY(-3px) rotate(6deg); }
}

.celebration-big {
    padding: 1.25rem 2rem;
    animation-duration: 3.4s;
}

.celebration-big strong {
    font-size: 2rem;
}

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