:root {
    --bg: #06080d;
    --panel: #101622;
    --line: #243047;
    --text: #f8fafc;
    --muted: #94a3b8;
    --home: #f97316;
    --away: #38bdf8;
    --clock: #fef08a;
    --poss: #4ade80;
}

* {
    box-sizing: border-box;
    margin: 0;
}

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, sans-serif;
}

.board {
    --u: min(1.45vh, 1.45vw);
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100svh;
    max-height: 100svh;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: calc(var(--u) * 0.15);
    padding: calc(var(--u) * 0.25) calc(var(--u) * 0.35);
    transition: background 0.2s ease;
}

.board.buzzer {
    animation: buzz 0.25s ease-in-out 4;
}

@keyframes buzz {
    50% { background: #450a0a; }
}

.top-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: calc(var(--u) * 0.35);
    min-height: 0;
}

.label {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: calc(var(--u) * 1.1);
    color: var(--muted);
    margin-bottom: calc(var(--u) * 0.05);
}

.period {
    font-size: min(8vh, calc(var(--u) * 5.5));
    font-weight: 800;
    line-height: 1;
}

.clock-block {
    text-align: center;
}

.clock {
    display: block;
    font-size: min(16vh, 14vw, calc(var(--u) * 12));
    font-weight: 900;
    line-height: 0.95;
    color: var(--clock);
    font-variant-numeric: tabular-nums;
}

.clock.running {
    color: #fff;
}

.clock.expired {
    color: #f87171;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    50% { opacity: 0.55; }
}

.meta-block {
    justify-self: end;
}

.fs-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: calc(var(--u) * 0.5);
    padding: calc(var(--u) * 0.3) calc(var(--u) * 0.65);
    font: inherit;
    font-size: calc(var(--u) * 1.1);
    cursor: pointer;
}

.score-area {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: calc(var(--u) * 0.2);
}

.team {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: calc(var(--u) * 0.8);
    padding: calc(var(--u) * 0.25) calc(var(--u) * 0.3);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(var(--u) * 0.15);
    position: relative;
    transition: border-color 0.2s ease;
}

.team.home { border-top: calc(var(--u) * 0.35) solid var(--home); }
.team.away { border-top: calc(var(--u) * 0.35) solid var(--away); }

.team.has-possession {
    border-color: var(--poss);
    outline: 2px solid rgba(74, 222, 128, 0.45);
}

.logo-wrap {
    width: calc(var(--u) * 5);
    height: calc(var(--u) * 5);
    flex: 0 0 auto;
}

.logo-wrap[hidden] {
    display: none !important;
}

.team-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.95);
    border-radius: calc(var(--u) * 0.6);
    padding: calc(var(--u) * 0.2);
}

.possession {
    position: absolute;
    top: calc(var(--u) * 0.2);
    left: 50%;
    transform: translateX(-50%);
    background: var(--poss);
    color: #052e16;
    font-weight: 900;
    letter-spacing: 0.08em;
    padding: calc(var(--u) * 0.15) calc(var(--u) * 0.55);
    border-radius: 999px;
    font-size: calc(var(--u) * 1.35);
    white-space: nowrap;
}

.possession[hidden] {
    display: none !important;
}

.team-name {
    width: 100%;
    flex: 0 0 auto;
    font-size: min(4.5vh, calc(var(--u) * 3.4));
    line-height: 1.2;
    padding: calc(var(--u) * 0.2) calc(var(--u) * 0.15);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    word-break: break-word;
}

.score {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    font-size: min(38vh, 30vw, calc(var(--u) * 18));
    font-weight: 900;
    line-height: 0.82;
    font-variant-numeric: tabular-nums;
}

.home .score { color: var(--home); }
.away .score { color: var(--away); }

.fouls {
    flex: 0 0 auto;
    font-size: min(4vh, calc(var(--u) * 3));
    color: var(--muted);
    line-height: 1;
}

.fouls span {
    color: #fff;
    font-weight: 800;
}

.divider {
    align-self: stretch;
    width: calc(var(--u) * 0.3);
    border-radius: 999px;
    background: linear-gradient(var(--home), var(--away));
}

.hometime-ad {
    min-height: 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.hometime-ad a {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--u) * 0.45);
    padding: calc(var(--u) * 0.2) calc(var(--u) * 0.55);
    border-radius: calc(var(--u) * 0.5);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
    text-decoration: none;
    max-width: 100%;
    min-width: 0;
}

.hometime-logo {
    flex: 0 0 auto;
    width: calc(var(--u) * 2.8);
    height: calc(var(--u) * 2.8);
    border-radius: 50%;
}

.hometime-copy {
    display: flex;
    flex-direction: column;
    gap: 0;
    text-align: left;
    min-width: 0;
}

.hometime-copy strong {
    font-size: calc(var(--u) * 1.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hometime-copy small {
    color: var(--muted);
    font-size: calc(var(--u) * 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 900px) {
    .score-area {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .divider {
        width: min(50%, 10rem);
        height: calc(var(--u) * 0.25);
    }

    .top-bar {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "clock clock"
            "period meta";
    }

    .clock-block { grid-area: clock; }
    .period-block { grid-area: period; text-align: left; }
    .meta-block { grid-area: meta; justify-self: end; }

    .score {
        font-size: min(28vh, 24vw, calc(var(--u) * 14));
    }

    .clock {
        font-size: min(12vh, 10vw, calc(var(--u) * 9));
    }
}

@media (max-height: 520px) {
    .hometime-copy small {
        display: none;
    }
}
