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

:root {
    --bg: #050914;
    --panel: rgba(8, 14, 24, 0.94);
    --panel-soft: rgba(11, 18, 30, 0.9);
    --line: #1f6f95;
    --line-soft: #244556;
    --line-bright: #25c7ff;
    --text: #f8fbff;
    --text-soft: #c7d2df;
    --muted: #8795a6;
    --green: #39ff88;
    --green-soft: rgba(57, 255, 136, 0.14);
    --red: #d90429;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Orbitron', sans-serif;
    overflow: hidden;
}

.youtube-board {
    width: 100vw;
    height: 100vh;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 23vw, 430px);
    grid-template-rows:
        clamp(82px, 13vh, 142px)
        minmax(0, 1fr)
        clamp(132px, 21vh, 230px)
        clamp(48px, 7vh, 78px);
    grid-template-areas:
        "header header"
        "match rail"
        "other rail"
        "ticker ticker";
    gap: clamp(10px, 1.6vh, 20px) clamp(14px, 1.6vw, 28px);
    padding: clamp(12px, 2.2vh, 32px) clamp(16px, 2.3vw, 44px) clamp(10px, 1.8vh, 24px);
    background:
        radial-gradient(circle at 44% 28%, rgba(37, 199, 255, 0.16), transparent 36%),
        radial-gradient(circle at 62% 56%, rgba(57, 255, 136, 0.08), transparent 32%),
        linear-gradient(180deg, #0c1422 0%, #050914 56%, #070b13 100%);
    border: clamp(4px, 0.6vw, 8px) solid #1f2e3d;
    overflow: hidden;
}

.youtube-main {
    display: contents;
}

.youtube-header {
    grid-area: header;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(12px, 2vw, 28px);
    border-bottom: clamp(2px, 0.35vw, 4px) solid var(--line-soft);
    padding-bottom: clamp(8px, 1.5vh, 18px);
    overflow: hidden;
}

.eyebrow,
.section-label {
    color: var(--text-soft);
    font-size: clamp(13px, 1.25vw, 22px);
    line-height: 1.1;
    letter-spacing: clamp(2px, 0.22vw, 4px);
}

h1 {
    margin: clamp(4px, 0.8vh, 10px) 0 0;
    color: var(--text);
    font-size: clamp(30px, 3.35vw, 64px);
    line-height: 0.96;
    letter-spacing: 0;
    font-weight: 900;
    text-shadow: 0 0 28px rgba(37, 199, 255, 0.14);
    white-space: nowrap;
}

.header-meta {
    flex: 0 0 auto;
    text-align: right;
}

.clock {
    color: var(--green);
    font-size: clamp(22px, 2.25vw, 42px);
    line-height: 1;
    font-weight: 700;
    text-shadow: 0 0 18px rgba(57, 255, 136, 0.26);
}

.last-updated {
    color: var(--text-soft);
    font-size: clamp(10px, 0.95vw, 18px);
    margin-top: clamp(5px, 0.9vh, 10px);
    opacity: 0.86;
    white-space: nowrap;
}

.match-stage,
.countdown-card,
.rotating-panel,
.other-section {
    min-width: 0;
    min-height: 0;
    border: clamp(2px, 0.25vw, 3px) solid var(--line-soft);
    background: var(--panel);
    box-shadow:
        0 0 20px rgba(0, 0, 0, 0.36),
        inset 0 0 34px rgba(37, 199, 255, 0.035);
    overflow: hidden;
}

.match-stage {
    grid-area: match;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(18px, 3vh, 36px) clamp(20px, 2.2vw, 42px);
    border-color: color-mix(in srgb, var(--line-bright) 54%, #243447);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.045), rgba(8, 14, 24, 0.92) 46%, rgba(37, 199, 255, 0.055)),
        var(--panel);
    box-shadow:
        0 0 34px rgba(37, 199, 255, 0.16),
        inset 0 0 48px rgba(57, 255, 136, 0.035);
}

.youtube-board[data-mode="live"] .match-stage {
    border-color: var(--red);
    box-shadow:
        0 0 34px rgba(217, 4, 41, 0.34),
        inset 0 0 46px rgba(217, 4, 41, 0.08);
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(10px, 1.2vw, 22px);
    margin-top: clamp(10px, 1.8vh, 22px);
}

.status-badge {
    display: inline-block;
    max-width: 100%;
    padding: clamp(7px, 1vh, 12px) clamp(14px, 1.5vw, 24px);
    border-radius: 999px;
    color: var(--text);
    font-size: clamp(15px, 1.35vw, 26px);
    font-weight: 900;
    letter-spacing: clamp(1.5px, 0.18vw, 3px);
    white-space: nowrap;
}

.status-badge.is-live {
    background: var(--red);
    color: #fff;
    box-shadow:
        0 0 12px var(--red),
        0 0 28px rgba(217, 4, 41, 0.82);
    animation: pulseLive 2s infinite;
}

.status-badge.is-upcoming {
    background: linear-gradient(90deg, rgba(37, 199, 255, 0.16), var(--green-soft));
    border: 2px solid var(--green);
    color: #eafff2;
    box-shadow: 0 0 18px rgba(57, 255, 136, 0.2);
}

.status-badge.is-final,
.status-badge.is-neutral {
    background: #121a25;
    border: 2px solid #627184;
    color: #e1e8f0;
}

@keyframes pulseLive {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.06);
        opacity: 0.86;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.match-minute {
    color: var(--green);
    font-size: clamp(18px, 1.7vw, 32px);
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
}

.youtube-board[data-mode="live"] .match-minute {
    color: #fff;
    font-size: clamp(24px, 2.1vw, 40px);
    text-shadow: 0 0 18px rgba(217, 4, 41, 0.55);
}

.teams-row {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, clamp(150px, 16vw, 310px)) minmax(0, 1fr);
    align-items: center;
    gap: clamp(10px, 1.4vw, 26px);
    margin-top: clamp(14px, 3vh, 38px);
}

.team-block {
    min-width: 0;
    text-align: center;
}

.team-flag {
    min-height: clamp(42px, 5.4vw, 104px);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.flag-image-wrap {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    font-weight: 900;
    line-height: 1;
}

.flag-icon {
    display: block;
    width: clamp(56px, 5.8vw, 118px);
    height: clamp(38px, 4vw, 78px);
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(37, 199, 255, 0.12));
}

.flag-fallback-text {
    display: none;
    font-size: 0.72em;
}

.flag-load-failed .flag-fallback-text {
    display: inline;
}

.team-name {
    margin-top: clamp(8px, 1.5vh, 18px);
    color: var(--text);
    font-size: clamp(26px, 2.9vw, 54px);
    line-height: 1.02;
    font-weight: 900;
    overflow-wrap: anywhere;
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.08);
}

.team-code {
    margin-top: clamp(5px, 1vh, 10px);
    color: var(--text-soft);
    font-size: clamp(16px, 1.55vw, 30px);
    line-height: 1;
    font-weight: 700;
}

.score-block {
    min-width: 0;
    text-align: center;
}

.score {
    color: var(--green);
    font-size: clamp(42px, 4.8vw, 90px);
    font-weight: 900;
    line-height: 0.95;
    text-shadow: 0 0 28px rgba(57, 255, 136, 0.34);
    white-space: nowrap;
}

.score-hint {
    color: var(--text-soft);
    font-size: clamp(12px, 1.05vw, 20px);
    line-height: 1.15;
    margin-top: clamp(8px, 1.7vh, 20px);
    opacity: 0.86;
}

.info-rail {
    grid-area: rail;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: clamp(10px, 1.6vh, 22px);
}

.countdown-card,
.rotating-panel {
    min-width: 0;
    min-height: 0;
    padding: clamp(14px, 2vh, 28px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.countdown {
    color: var(--green);
    font-size: clamp(30px, 2.8vw, 50px);
    line-height: 0.95;
    margin-top: clamp(10px, 1.6vh, 18px);
    font-weight: 900;
    text-shadow: 0 0 20px rgba(57, 255, 136, 0.26);
    white-space: nowrap;
}

.countdown-match {
    color: var(--text);
    font-size: clamp(17px, 1.6vw, 30px);
    line-height: 1.05;
    margin-top: clamp(9px, 1.4vh, 16px);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.countdown-time,
.panel-sub {
    color: var(--green);
    font-size: clamp(12px, 1.15vw, 22px);
    line-height: 1.2;
    margin-top: clamp(6px, 1vh, 10px);
}

.panel-main {
    color: var(--text);
    font-size: clamp(22px, 2.1vw, 40px);
    line-height: 1.05;
    margin-top: clamp(8px, 1.5vh, 18px);
    font-weight: 900;
    overflow-wrap: anywhere;
}

.panel-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(6px, 1vh, 10px) clamp(8px, 1vw, 14px);
    margin-top: clamp(8px, 1.5vh, 18px);
}

.panel-detail {
    border-left: clamp(2px, 0.25vw, 3px) solid var(--line);
    color: var(--text-soft);
    font-size: clamp(10px, 0.95vw, 18px);
    line-height: 1.12;
    padding-left: clamp(6px, 0.6vw, 10px);
}

.standings-table {
    display: grid;
    grid-template-rows: repeat(5, minmax(0, auto));
    gap: clamp(7px, 0.9vh, 13px);
    margin-top: clamp(10px, 1.6vh, 18px);
}

.standings-row {
    min-width: 0;
    display: grid;
    grid-template-columns:
        minmax(28px, 0.7fr)
        minmax(22px, 0.55fr)
        minmax(52px, 1.45fr)
        repeat(4, minmax(24px, 0.7fr))
        minmax(34px, 0.82fr);
    align-items: center;
    gap: clamp(4px, 0.45vw, 8px);
    color: var(--text-soft);
    font-size: clamp(11px, 0.88vw, 17px);
    line-height: 1;
}

.standings-header {
    color: var(--muted);
    font-size: clamp(8px, 0.68vw, 13px);
    letter-spacing: 0;
    text-transform: uppercase;
}

.standings-header .standings-cell:nth-child(1) {
    grid-column: 1;
}

.standings-header .standings-cell:nth-child(2) {
    grid-column: 2;
    visibility: hidden;
}

.standings-header .standings-cell:nth-child(3) {
    grid-column: 2 / 4;
}

.standings-header .standings-cell:nth-child(4) {
    grid-column: 4;
}

.standings-header .standings-cell:nth-child(5) {
    grid-column: 5;
}

.standings-header .standings-cell:nth-child(6) {
    grid-column: 6;
}

.standings-header .standings-cell:nth-child(7) {
    grid-column: 7;
}

.standings-header .standings-cell:nth-child(8) {
    grid-column: 8;
}

.standings-cell {
    min-width: 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.standings-cell.flag {
    display: flex;
    align-items: center;
    justify-content: center;
}

.standings-cell.flag .flag-icon {
    width: clamp(18px, 1.1vw, 24px);
    height: clamp(12px, 0.8vw, 16px);
}

.standings-cell.flag .flag-fallback-text {
    font-size: clamp(8px, 0.68vw, 12px);
}

.standings-cell.team {
    color: var(--text);
    font-weight: 900;
    text-align: left;
    letter-spacing: 0;
}

.standings-cell.points {
    color: var(--green);
    font-weight: 900;
    text-shadow: 0 0 12px rgba(57, 255, 136, 0.28);
}

.standings-message {
    color: var(--text-soft);
    font-size: clamp(13px, 1.1vw, 20px);
    line-height: 1.28;
    margin-top: clamp(8px, 1.4vh, 16px);
}

.rotating-panel-content {
    width: 100%;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.fade-out {
    opacity: 0;
    transform: translateY(10px);
}

.other-section {
    grid-area: other;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: clamp(7px, 1.1vh, 14px);
    padding: clamp(12px, 1.9vh, 22px) clamp(14px, 1.4vw, 26px);
}

.other-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(10px, 1.1vw, 18px);
}

.other-card {
    min-width: 0;
    min-height: 0;
    border: 2px solid #1f3444;
    background: var(--panel-soft);
    padding: clamp(10px, 1.5vh, 18px) clamp(12px, 1.2vw, 22px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.other-matchup {
    color: var(--text);
    font-size: clamp(18px, 1.6vw, 30px);
    font-weight: 900;
    line-height: 1.12;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 0.8vw, 14px);
}

.matchup-team {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: clamp(5px, 0.45vw, 8px);
}

.matchup-separator {
    color: var(--text);
}

.other-matchup .flag-icon {
    width: clamp(22px, 1.7vw, 34px);
    height: clamp(15px, 1.15vw, 23px);
}

.other-matchup .flag-fallback-text {
    font-size: 0.72em;
}

.other-time {
    color: var(--green);
    font-size: clamp(14px, 1.35vw, 25px);
    line-height: 1.1;
    margin-top: clamp(7px, 1.2vh, 16px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.other-status {
    color: var(--text-soft);
    font-size: clamp(10px, 1vw, 18px);
    line-height: 1;
    margin-top: clamp(5px, 0.9vh, 8px);
    letter-spacing: clamp(1px, 0.14vw, 2px);
}

.youtube-ticker-wrap {
    grid-area: ticker;
    min-width: 0;
    min-height: 0;
    border-top: clamp(2px, 0.35vw, 4px) solid var(--line-soft);
    overflow: hidden;
    display: flex;
    align-items: center;
}

.youtube-ticker {
    white-space: nowrap;
    color: var(--green);
    font-size: clamp(20px, 1.8vw, 34px);
    line-height: 1;
    font-weight: 700;
    text-shadow: 0 0 16px rgba(57, 255, 136, 0.24);
    animation: scrollTicker var(--ticker-duration, 80s) linear infinite;
    will-change: transform;
}

.youtube-legal {
    display: none;
}

@keyframes scrollTicker {
    0% {
        transform: translateX(100vw);
    }

    88% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(-100%);
    }
}

@media (max-aspect-ratio: 16 / 10) {
    .youtube-board {
        grid-template-columns: minmax(0, 1fr) clamp(260px, 24vw, 350px);
        grid-template-rows:
            clamp(70px, 12vh, 108px)
            minmax(0, 1fr)
            clamp(110px, 20vh, 170px)
            clamp(42px, 7vh, 64px);
        gap: clamp(8px, 1.3vh, 14px) clamp(10px, 1.3vw, 18px);
    }

    .teams-row {
        grid-template-columns: minmax(0, 1fr) minmax(112px, 18vw) minmax(0, 1fr);
    }
}

@media (max-width: 820px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .youtube-board {
        width: 100%;
        min-height: 100svh;
        height: auto;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        grid-template-areas:
            "header"
            "match"
            "countdown"
            "ticker"
            "standings"
            "other";
        gap: 14px;
        padding: 16px 12px calc(18px + env(safe-area-inset-bottom));
        border-width: 0;
        overflow: visible;
    }

    .youtube-header {
        align-items: flex-start;
        gap: 12px;
        padding-bottom: 14px;
        overflow: visible;
    }

    h1 {
        margin-top: 0;
        font-size: clamp(28px, 8.3vw, 46px);
        line-height: 0.98;
        white-space: normal;
    }

    .header-meta {
        padding-top: 2px;
    }

    .clock {
        font-size: clamp(20px, 5.5vw, 30px);
    }

    .last-updated {
        max-width: 34vw;
        font-size: clamp(9px, 2.5vw, 13px);
        line-height: 1.25;
        white-space: normal;
    }

    .match-stage,
    .countdown-card,
    .rotating-panel,
    .other-section {
        overflow: visible;
    }

    .match-stage {
        min-height: 0;
        padding: 20px 14px 22px;
    }

    .section-label {
        font-size: clamp(12px, 3.2vw, 16px);
        line-height: 1.18;
    }

    .status-row {
        flex-wrap: wrap;
        align-items: center;
        margin-top: 14px;
    }

    .status-badge {
        font-size: clamp(13px, 3.6vw, 18px);
        padding: 8px 14px;
    }

    .match-minute {
        font-size: clamp(16px, 4vw, 22px);
    }

    .teams-row {
        grid-template-columns: minmax(0, 1fr) clamp(104px, 28vw, 126px) minmax(0, 1fr);
        gap: clamp(6px, 2vw, 10px);
        margin-top: 18px;
    }

    .team-block {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .team-flag {
        min-height: clamp(32px, 8.8vw, 52px);
    }

    .team-flag .flag-icon {
        width: clamp(42px, 11vw, 62px);
        height: clamp(28px, 7.2vw, 42px);
    }

    .team-name {
        max-width: 100%;
        margin-top: 8px;
        font-size: clamp(18px, 5.2vw, 30px);
        line-height: 1.05;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
    }

    .team-code {
        font-size: clamp(14px, 3.7vw, 20px);
    }

    .score-block {
        width: 100%;
        max-width: clamp(104px, 28vw, 126px);
        justify-self: center;
        overflow: hidden;
    }

    .score {
        font-size: clamp(30px, 8.5vw, 52px);
    }

    .score-hint {
        max-width: 100%;
        font-size: clamp(12px, 3.2vw, 16px);
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .info-rail {
        display: contents;
    }

    .countdown-card {
        grid-area: countdown;
    }

    .rotating-panel {
        grid-area: standings;
    }

    .countdown-card,
    .rotating-panel {
        padding: 17px 14px;
    }

    .countdown {
        font-size: clamp(32px, 9.5vw, 52px);
        white-space: normal;
    }

    .countdown-match {
        font-size: clamp(17px, 5vw, 25px);
        line-height: 1.12;
    }

    .countdown-time,
    .panel-sub {
        font-size: clamp(12px, 3.5vw, 17px);
        line-height: 1.25;
    }

    .panel-main {
        font-size: clamp(24px, 7vw, 36px);
        line-height: 1.08;
    }

    .panel-details {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .panel-detail {
        font-size: clamp(12px, 3.2vw, 16px);
        line-height: 1.25;
    }

    .standings-table {
        width: 100%;
        min-width: 0;
        gap: 9px;
    }

    .standings-row {
        width: 100%;
        min-width: 0;
        grid-template-columns:
            minmax(22px, 0.45fr)
            minmax(18px, 0.32fr)
            minmax(42px, 1fr)
            repeat(4, minmax(20px, 0.4fr))
            minmax(30px, 0.55fr);
        gap: clamp(2px, 0.9vw, 4px);
        font-size: clamp(10px, 2.7vw, 14px);
    }

    .standings-header {
        font-size: clamp(7px, 2.2vw, 10px);
    }

    .standings-cell.flag .flag-icon {
        width: clamp(15px, 4.2vw, 20px);
        height: clamp(10px, 2.8vw, 14px);
    }

    .standings-cell.flag .flag-fallback-text {
        font-size: clamp(7px, 2vw, 9px);
    }

    .standings-message {
        font-size: clamp(14px, 3.8vw, 18px);
    }

    .other-section {
        grid-template-rows: auto auto;
        padding: 16px 14px;
    }

    .other-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .other-card {
        min-height: 94px;
        padding: 14px;
    }

    .other-matchup {
        font-size: clamp(19px, 5.5vw, 28px);
        line-height: 1.18;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        gap: 8px;
    }

    .other-matchup .flag-icon {
        width: clamp(22px, 7vw, 30px);
        height: clamp(15px, 4.8vw, 20px);
    }

    .other-time {
        font-size: clamp(14px, 4.2vw, 21px);
        line-height: 1.2;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .other-status {
        font-size: clamp(11px, 3vw, 14px);
    }

    .youtube-ticker-wrap {
        min-height: 54px;
        padding: 0;
        border-top-width: 2px;
        background: rgba(5, 9, 20, 0.98);
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.3);
    }

    .youtube-ticker {
        font-size: clamp(18px, 5.3vw, 24px);
    }

    .youtube-legal {
        display: block;
        padding: 4px 12px calc(18px + env(safe-area-inset-bottom));
        color: var(--muted);
        font-family: Arial, sans-serif;
        font-size: 12px;
        line-height: 1.45;
    }

    .youtube-legal p {
        margin: 0 0 8px;
    }

    .youtube-legal nav {
        display: flex;
        flex-wrap: wrap;
        gap: 14px;
    }

    .youtube-legal a {
        color: var(--green);
        text-decoration: none;
    }

    .youtube-legal a:hover {
        color: var(--text);
    }
}

@media (max-width: 430px) {
    .youtube-header {
        flex-direction: column;
    }

    .header-meta {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 12px;
        text-align: right;
    }

    .last-updated {
        max-width: 48vw;
        text-align: right;
    }
}

@media (max-width: 380px) {
    .youtube-board {
        padding-right: 10px;
        padding-left: 10px;
    }

    .youtube-header {
        gap: 10px;
    }

    .match-stage {
        padding-right: 12px;
        padding-left: 12px;
    }

    .teams-row {
        gap: 6px;
    }

    .team-name {
        font-size: clamp(17px, 5vw, 24px);
    }

    .score {
        font-size: clamp(29px, 8vw, 38px);
    }

    .standings-table {
        gap: 7px;
    }

    .standings-row {
        grid-template-columns:
            minmax(20px, 0.42fr)
            minmax(16px, 0.3fr)
            minmax(38px, 1fr)
            repeat(4, minmax(18px, 0.38fr))
            minmax(28px, 0.52fr);
        gap: 2px;
        font-size: clamp(9px, 2.75vw, 12px);
    }

    .standings-header {
        font-size: clamp(6px, 2vw, 9px);
    }
}
