:root {
    color-scheme: light dark;

    --neutral-white: hsl(0, 0%, 100%);
    --neutral100: hsl(0, 0%, 95%);
    --neutral200: hsl(0, 0%, 90%);
    --neutral300: hsl(0, 0%, 80%);
    --neutral400: hsl(0, 0%, 70%);
    --neutral500: hsl(0, 0%, 60%);
    --neutral600: hsl(0, 0%, 45%);
    --neutral700: hsl(0, 0%, 35%);
    --neutral800: hsl(0, 0%, 20%);

    --text-color: light-dark(var(--neutral800), var(--neutral200));
    --text-muted: var(--neutral300);

    --bg-color: light-dark(var(--neutral100), var(--neutral800));
    --footer-color: var(--neutral400);
    --divider-color: var(--neutral300);

    --progress-background: light-dark(var(--neutral200), var(--neutral700));
    --progress-foreground: light-dark(var(--neutral400), var(--neutral500));
    --progress-shadow: 0 2px 5px light-dark(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.7)) inset;

    --card-bg: light-dark(var(--neutral-white), var(--neutral600));
    --card-shadow: light-dark(rgba(99, 99, 99, 0.2), rgba(0, 0, 0, 0.2)) 0px 2px 8px 0px;
    --card-corners: 5px;

    --live-color: light-dark(red, hsl(0, 100%, 35%));

    --transition-duration: 0.3s;

    --ATL: #e03a3e;
    --BKN: #000000;
    --BOS: #007a33;
    --CHA: #00788c;
    --CHI: #ce1141;
    --CLE: #860038;
    --DAL: #0053bc;
    --DEN: #0e2240;
    --DET: #c8102e;
    --GSW: #ffc72c;
    --HOU: #ce1141;
    --IND: #002d62;
    --LAC: #12173f;
    --LAL: #552583;
    --MEM: #5d76a9;
    --MIA: #98002e;
    --MIL: #00471b;
    --MIN: #0c2340;
    --NOP: #85714d;
    --NYK: #f58426;
    --OKC: #ef3b24;
    --ORL: #0077c0;
    --PHI: #006bb6;
    --PHX: #e56020;
    --POR: #e03a3e;
    --SAC: #5a2d81;
    --SAS: #c4ced4;
    --TOR: #ce1141;
    --UTA: #f9a01b;
    --WAS: #002b5c;
    --undefined: color-mix(in hsl, var(--card-bg) 85%, black);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    scroll-behavior: smooth;
}

body {
    font-family: 'Kanit', sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    font-size: 100%;
    min-height: inherit;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

@supports not (height: 100dvh) {
    html {
        height: -webkit-fill-available;
    }

    body {
        min-height: -webkit-fill-available;
    }
}

#container {
    display: flex;
    justify-content: center;
    column-gap: 3vw;
    padding: 0 3vw;
    width: 100vw;
    max-width: 100%;
}

.meter-container {
    width: 100%;
    background-color: var(--progress-background);
    border-radius: 10px;
    box-shadow: var(--progress-shadow);
    overflow: hidden;
    height: 20px;
    margin: 10px 0;
}

.meter-fill {
    background-color: var(--progress-foreground);
    border-radius: 10px;
    width: 0;
    transition: width var(--transition-duration);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--progress-background);
    overflow: clip;
    font-size: 0.9rem;
    height: 100%;
}

.lower {
    opacity: 0.7;
}

/*
-------------------------------------------------------------------
MAIN
-------------------------------------------------------------------
*/
main {
    width: 100%;
    max-width: 800px;
}

:is(h1, h2, h3) {
    text-transform: uppercase;
}

h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 0 0 10px 0;
}

h2 {
    font-size: clamp(1rem, 4vw, 1.5rem);
    margin: 0 0 10px 0;
}

h3 {
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin: 10px 0 0 0;
}

h4 {
    margin: 15px 0 0 0;
    text-transform: uppercase;
}

h5 {
    margin: 5px 0 0 0;
    font-size: 1rem;
    font-weight: 500;
}

a {
    color: inherit;
}

#info {
    display: flex;
    font-size: clamp(0.8rem, 3vw, 1.1rem);
    margin: 10px 0;
}

#info span {
    flex: 0 0 40%;
}

#info span:first-of-type {
    flex: 0 0 20%;
}

/*
-------------------------------------------------------------------
CARDS GENERAL
-------------------------------------------------------------------
*/

section {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 30px;
}

.card {
    display: flex;
    justify-content: center;
    background-color: var(--card-bg);
    box-shadow: var(--card-shadow);
    align-items: stretch;
    line-height: 150%;
    border-radius: var(--card-corners);
}

.card .abbr {
    display: none;
}

.date:empty::before {
    content: "loading";
    color: var(--text-muted);
}

main div span {
    text-wrap: balance;
}

.hidden,
.card .game-label:empty,
.card :where(.wl, .score):empty {
    display: none;
}

.card:has(.game-label:not(:empty)) {
    flex-wrap: wrap;
}

.card[data-clickable="true"]:hover {
    cursor: pointer;
}

/*
-------------------------------------------------------------------
PLAYOFFS and NBA CUP
-------------------------------------------------------------------
*/

#playoffs,
#cup {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#playoffs>div,
#cup>div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    flex: 0 1 32%;
    gap: 10px;
}

#playoffs #finals,
#cup #cup-final {
    align-items: center;
}

#playoffs #eastern,
#cup #cup-east {
    direction: rtl;
}

#playoffs .matchup,
#cup .matchup {
    --radius-first: 0 var(--card-corners) 0 0;
    --radius-last: 0 0 var(--card-corners) 0;
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
    border-radius: var(--card-corners);
    box-shadow: var(--card-shadow);
    min-height: 69px;
}

#playoffs #eastern .matchup,
#cup #cup-east .matchup {
    --radius-first: var(--card-corners) 0 0 0;
    --radius-last: 0 0 0 var(--card-corners);
}

#playoffs .semi-conference-finals {
    align-self: center;
}

#playoffs .conference-finals {
    align-self: flex-end;
}

#cup .east-semifinal,
#cup .west-semifinal {
    align-self: flex-end;
}

#playoffs :is(.teamA, .teamB) {
    display: flex;
    width: 75px;
}

#cup :is(.teamA, .teamB) {
    display: flex;
    width: clamp(75px, 20vw, 110px);
}

#playoffs :is(.teamA, .teamB)>div,
#cup :is(.teamA, .teamB)>div {
    display: flex;
    padding: 5px 2px;
}

#playoffs .teamA,
#cup .teamA {
    border-bottom: 1px solid var(--card-bg);
}

#playoffs .score,
#cup .score {
    flex: 0 0 40%;
    display: flex;
    justify-content: center;
    font-weight: 600;
}

#playoffs .teamname,
#cup .teamname {
    flex: 0 0 60%;
    display: flex;
    justify-content: center;
    color: var(--neutral-white);
    background-color: var(--neutral400);
}

#playoffs .teamname:empty::before,
#cup .teamname:empty::before {
    content: "TBD";
}

#playoffs .matchup>div:first-child .teamname,
#cup .matchup>div:first-child .teamname {
    border-radius: var(--radius-first);
}

#playoffs .matchup>div:last-child .teamname,
#cup .matchup>div:last-child .teamname {
    border-radius: var(--radius-last);
}

/*
-------------------------------------------------------------------
TODAY
-------------------------------------------------------------------
*/

#today {
    gap: 20px;
}

#today .game-label {
    background-color: var(--progress-background);
    flex: 0 0 100%;
    text-align: center;
    padding: 2px 0;
    border-radius: 0 0 var(--card-corners) var(--card-corners);
    font-size: 0.9rem;
}

#today .visiting-team+.home-team {
    border-left: 1px solid var(--card-bg);
}

#today .home-team,
#today .visiting-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 40%;
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: var(--neutral-white);
    font-weight: 500;
    text-transform: uppercase;
    background-color: var(--team-color, var(--neutral400));
    padding-block: 5px;
    padding-inline: 8px;
    gap: 5px;
}

#today .home-team:empty,
#today .visiting-team:empty {
    height: 10vw;
    max-height: 80px;
    background: linear-gradient(90deg, var(--neutral200), var(--neutral300));
    background-size: 400% 400%;
    animation: pulse 3s linear infinite;
}

#today .home-team {
    border-radius: 0 var(--card-corners) var(--card-corners) 0;
    direction: rtl;
}

#today .card:has(.game-label:not(:empty)) .home-team {
    border-radius: 0 var(--card-corners) 0 0;
}

#today .wl {
    text-align: right;
    font-weight: normal;
    white-space: nowrap;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

#today .score {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
}

#today .name {
    flex-grow: 1;
}

@keyframes pulse {
    0% {
        background-position: 0% 20%
    }

    50% {
        background-position: 100% 20%
    }

    100% {
        background-position: 0% 20%
    }
}

#today .date {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: 500;
    padding: 0 5px;
    flex: 1 0 18%;
    /* 2% room to make space for long team names */
    border-radius: var(--card-corners) 0 0 var(--card-corners);
}

@keyframes blink-border {
    0% {
        border-left: 3px solid var(--live-color);
    }

    50% {
        border-left: 3px solid transparent;
    }

    100% {
        border-left: 3px solid var(--live-color);
    }
}

#today .live {
    animation: blink-border 2s infinite;
}

#today .card:has(.game-label:not(:empty)) .date.live {
    border-radius: var(--card-corners) 0 0 0;
}

#today .card img {
    width: 10vw;
    height: 10vw;
    max-height: 80px;
    max-width: 80px;
}

/*
-------------------------------------------------------------------
JUMP LINK
-------------------------------------------------------------------
*/

.jump-link {
    display: none;
    justify-content: center;
    margin-bottom: 20px;
}

#more .jump-link {
    display: flex;
    margin-top: 30px;
}

.jump-link a {
    font-size: clamp(0.8rem, 2vw, 1rem);
    padding: 6px 10px;
    color: var(--text-color);
    border: 1px solid var(--text-color);
    border-radius: var(--card-corners);
    text-decoration: none;
    transition: all var(--transition-duration) ease;
    text-transform: uppercase;
}

.jump-link a:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
    cursor: pointer;
}

/*
-------------------------------------------------------------------
MORE
-------------------------------------------------------------------
*/

#more {
    gap: 15px;
}

#more .card {
    justify-content: flex-start;
    padding: 10px;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

#more :is(.home-team, .visiting-team) {
    flex: 1 0 40%;
    display: flex;
    justify-content: left;
    align-items: center;
    gap: 8px;
}

#more .date {
    flex: 0 0 20%;
}

#more .wl {
    opacity: 0.5;
    white-space: nowrap;
}

#more .score {
    font-size: 1.4rem;
    font-weight: 700;
}

#more .color {
    width: 4px;
    height: 100%;
    background-color: var(--team-color, var(--neutral400));
}

#more .game-label {
    flex: 0 0 100%;
    background-color: light-dark(hsla(0, 0%, 0%, 0.05), hsla(0, 0%, 0%, 0.15));
    text-align: center;
    border-radius: var(--card-corners);
    font-size: 0.9rem;
    margin-top: 10px;
    color: light-dark(var(--neutral700), var(--neutral300));
}

.options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

select {
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    flex: 0 0 auto;
    border: none;
    box-shadow: var(--card-shadow);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: inherit;
    font: inherit;
    padding: 10px 50px 10px 10px;
    border-radius: var(--card-corners);
    background-image: linear-gradient(45deg, transparent 50%, var(--text-color) 50%),
        linear-gradient(135deg, var(--text-color) 50%, transparent 50%),
        linear-gradient(to right, var(--text-color), var(--text-color));
    background-position: calc(100% - 20px) calc(1em + 2px),
        calc(100% - 15px) calc(1em + 2px),
        calc(100% - 2.5em) 0.5em;
    background-size: 5px 5px,
        5px 5px,
        1px 1.5em;
    background-repeat: no-repeat;
}

label {
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding: 0 0 0 2em;
}

input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 1.5em;
    width: 1.5em;
    background-color: var(--card-bg);
    border-radius: 5px;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

label input:checked~.checkmark:after {
    display: block;
}

label .checkmark:after {
    left: 0.5em;
    top: 0.15em;
    width: 0.5em;
    height: 1em;
    border: solid var(--text-color);
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

/*
-------------------------------------------------------------------
ASIDE
-------------------------------------------------------------------
*/

aside>div {
    margin-bottom: 30px;
}

aside div {
    width: calc(91vw - 800px);
    min-width: 200px;
    max-width: 400px;
}


#east,
#west {
    margin: 10px 0;
    padding: 10px;
    background-color: var(--card-bg);
    box-shadow: var(--card-shadow);
    border-radius: var(--card-corners);
    width: 100%;
    container-type: inline-size;
}

table {
    border-collapse: collapse;
    width: 100%;
    border-spacing: 30px;
}

@container (max-width: 220px) {

    td:nth-of-type(5),
    th:nth-of-type(5) {
        display: none;
    }
}

@container (max-width: 330px) {

    td:nth-of-type(6),
    th:nth-of-type(6),
    td:nth-of-type(7),
    th:nth-of-type(7) {
        display: none;
    }
}

table tr td:empty:after {
    content: "---";
    display: inline-block;
    vertical-align: top;
    min-height: 26px;
    color: var(--text-muted);
}

tr {
    transition: background-color var(--transition-duration);
}

tr:has(td):hover {
    background-color: var(--team-color, var(--neutral400));
    color: var(--neutral-white);
}

th,
td {
    text-align: center;
    padding: 5px 0;
    white-space: nowrap;
}

.standings td:first-of-type {
    text-align: right;
    width: 8%;
    padding-right: 10px;
}

tr:where(:nth-of-type(7), :nth-of-type(11)) {
    border-bottom: 1px solid var(--divider-color);
}

/*
-------------------------------------------------------------------
FOOTER
-------------------------------------------------------------------
*/

footer {
    width: 100vw;
    max-width: 100%;
    background-color: var(--progress-background);
    box-shadow: var(--progress-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    margin-bottom: 20px;
    color: var(--footer-color);
}

footer img {
    margin: 0 0 0 10px;
    filter: invert(65%);
}

footer img:hover {
    filter: invert(45%);
}

/*
-------------------------------------------------------------------
GAME OVERLAY
-------------------------------------------------------------------
*/

#backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

#game-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 94vw;
    max-width: 800px;
    height: 80vh;
    padding: 15px;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: var(--card-bg);
    border-radius: var(--card-corners);
    box-shadow: var(--card-shadow);
    z-index: 2000;
}

#game-overlay .close {
    position: absolute;
    top: 0px;
    right: 0px;
    padding: 10px;
    cursor: pointer;
}

#game-overlay .close img {
    width: 32px;
    height: auto;
}

#game-overlay h3 img {
    width: 3rem;
    height: auto;
    vertical-align: middle;
    margin-right: 8px;
}

#game-overlay #game-overlay-content {
    margin-top: 35px;
}

#game-excitement {
    margin: 0 0 15px 0;
    color: var(--text-color);
}

#game-excitement-bar {
    height: 16px;
    margin-top: 4px;
}

#game-excitement-label {
    margin: 6px 0 0 0;
}

#game-overlay #periods,
#game-overlay #team-stats {
    margin-bottom: 30px;
}

#game-overlay .players-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
}

.players-wrapper+.players-wrapper {
    margin-top: 20px;
}

#game-overlay .players-wrapper table {
    min-width: 600px;
}

#game-overlay .player-cell {
    display: flex;
    align-items: baseline;
    width: clamp(120px, 20vw, 190px);
}

#game-overlay .player-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 1 auto;
}

#game-overlay .player-pos {
    margin-left: 10px;
    font-size: 0.9rem;
    flex: 0 0 auto;
}

#game-overlay td:first-of-type {
    width: 25%;
}

#game-overlay tr {
    border-bottom: 1px solid var(--divider-color);
}

.players-table th:first-of-type {
    text-align: left;
}

body:has(#game-overlay:not(.hidden)) {
    overflow: hidden;
}

#game-overlay #teams:empty::before {
    content: "Boxscore wird geladen …";
    display: block;
    text-align: center;
}

#game-overlay .stat {
    display: flex;
    gap: 5px;
    align-items: center;
}

#game-overlay .stat .bar {
    padding: 0 10px;
    height: 1.5rem;
    background-color: var(--team-color, var(--neutral500));
    border-radius: 10px;
    width: 50%;
    color: var(--neutral-white);
    min-width: fit-content;
    text-align: center;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

#game-overlay .tabs {
    display: flex;
    border: 1px solid var(--text-color);
    border-radius: var(--card-corners);
    margin: 10px auto 0 auto;
    max-width: 400px;
}

#game-overlay .tab {
    flex: 0 0 50%;
    padding: 6px 10px;
    background-color: transparent;
    border: none;
    color: var(--text-color);
    font: inherit;
    font-size: 1rem;
    text-transform: uppercase;
    cursor: pointer;
    text-align: center;
}

#game-overlay .tab+.tab {
    border-left: 1px solid var(--text-color);
}

#game-overlay .tab.is-active {
    background-color: var(--text-color);
    color: var(--bg-color);
}

#game-overlay .panel {
    margin-top: 16px;
}

#game-overlay .panel:not(.is-active) {
    display: none;
}

#game-overlay label {
    margin-bottom: 30px;
}

#game-overlay .checkmark {
    background-color: var(--progress-background);
}

#playbyplay {
    display: flex;
    flex-direction: column-reverse;
    gap: 15px;
}

#playbyplay .item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

#playbyplay .line {
    width: 8px;
    align-self: stretch;
    background-color: var(--team-color, var(--neutral400));
}

#playbyplay .body {
    flex: 1;
    padding: 0 0 10px 0;
    border-bottom: 1px solid var(--divider-color);
    display: flex;
    gap: 10px;
    align-items: baseline;
}

#playbyplay .time {
    font-weight: 500;
    letter-spacing: 1px;
    min-width: 8ch;
}

#playbyplay .description {
    text-wrap: balance;
    flex: 1;
}

#playbyplay .score {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

#playbyplay .score .made {
    font-weight: 600;
}

/*
-------------------------------------------------------------------
MEDIA QUERIES
-------------------------------------------------------------------
*/

@media (prefers-color-scheme: dark) {
    footer img:hover {
        filter: invert(85%);
    }

    #game-overlay .close img {
        filter: invert(85%);
    }
}

@media (max-width: 1024px) {
    body>div {
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
    }

    .jump-link {
        display: flex;
    }

    aside {
        width: 100%;
        max-width: 800px;
        display: flex;
        gap: 10%;
        margin-bottom: 30px;
    }

    aside div {
        flex: 1 0 45%;
        max-width: unset;
    }

    aside div+div {
        margin-top: inherit;
    }

    footer {
        padding: 5px 3vw;
    }
}

@media (max-width: 800px) {

    .card .name {
        display: none;
    }

    .card .abbr {
        display: inline;
        font-size: clamp(1.2rem, 4vw, 1.5rem);
    }

    #more :is(.home-team, .visiting-team) {
        flex: 1 0 35%;
    }

    #more .date {
        flex: 0 0 30%;
    }

    #playbyplay .body {
        display: block;
    }
}

@media (max-width: 480px) {
    aside {
        flex-wrap: wrap;
    }

    aside div {
        flex: 1 0 100%;
    }
}