@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Open+Sans:wght@400;600;700&display=swap');

:root {
    --font-sans: "Open Sans", "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "Menlo", monospace;

    --color-bg: #ffffff;
    --color-text: #2C2D34;
    --color-muted: #8f939d;
    --color-surface: #F7F7F7;
    --color-surface-strong: #EBEEF4;
    --color-border: #E1E4EB;
    --color-shadow: rgba(17, 19, 22, 0.08);

    --color-blue: #0156FF;
    --color-blue-dark: #0044D4;
    --color-orange: #FF6B00;
    --color-orange-light: #FB832C;
    --color-green: #1DBF73;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
}

header.scoreboard-header {
    padding: 2.5rem 3.5rem 2rem;
    background: linear-gradient(135deg, var(--color-blue) 0%, var(--color-blue-dark) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.scoreboard-header__title {
    margin: 0;
    font-family: var(--font-mono);
    font-size: clamp(2rem, 3vw, 2.75rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.scoreboard-header__meta {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.scoreboard-header__meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.scoreboard-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 1rem;
    padding: 0.65rem 1.2rem;
    border-radius: 999px;
    line-height: 1;
}

.scoreboard-chip--orange {
    background: var(--color-orange);
    color: #ffffff;
    border: 1px solid rgba(255, 107, 0, 0.85);
    box-shadow: 0 12px 25px rgba(255, 107, 0, 0.25);
}

.scoreboard-chip--neutral {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

#scoreboard-countdown[data-status="reconnecting"] {
    background: linear-gradient(135deg, #FF6B00 0%, #FB832C 100%);
    border-color: rgba(255, 107, 0, 0.95);
}

.scoreboard-division-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0 3.5rem 1.2rem;
}

.scoreboard-division-link {
    font-family: var(--font-mono);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    transition: all 0.2s ease;
}

.scoreboard-division-link:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.55);
}

.scoreboard-division-link--active {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 18px rgba(1, 86, 255, 0.2);
}

.queue-toggle {
    background: rgba(255, 107, 0, 0.12);
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 0.45rem 1.45rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: none;
}

.queue-toggle:hover {
    background: rgba(255, 107, 0, 0.22);
    transform: none;
}

.queue-toggle[data-open="0"] {
    background: rgba(1, 86, 255, 0.12);
    color: #ffffff;
    border: none;
}

.queue-toggle--panel {
    display: inline-flex;
    margin-left: auto;
}

.queue-toggle--header {
    display: none;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 0.5rem 1.3rem;
}

.queue-toggle--header:hover {
    background: rgba(255, 255, 255, 0.2);
}

body.queue-hidden .queue-toggle--header {
    display: inline-flex;
    background: var(--color-brand-orange);
    border: 1px solid rgba(255, 107, 0, 0.7);
}

body.queue-hidden .queue-toggle--panel {
    display: none;
}

.scoreboard-main {
    flex: 1;
    background: var(--color-surface);
    padding: 2.5rem 3.5rem 3rem;
}

.scoreboard-layout {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    max-width: 1800px;
    margin: 0 auto;
}

.scoreboard-layout--full {
    max-width: 1800px;
}

.scoreboard-layout--queue-hidden {
    gap: 0;
}

.scoreboard-content {
    flex: 1 1 auto;
    display: flex;
}

.scoreboard-layout--queue-hidden .scoreboard-content {
    flex: 1 1 100%;
}

.scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 45px var(--color-shadow);
}

.scoreboard-table thead {
    background: var(--color-surface);
}

.scoreboard-table th,
.scoreboard-table td {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--color-border);
    text-align: center;
}

.scoreboard-table th {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-muted);
}

.scoreboard-table tbody tr {
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.scoreboard-table tbody tr:nth-child(even) {
    background: #fafbff;
}

.scoreboard-table tbody tr:hover {
    background: rgba(1, 86, 255, 0.08);
}

.scoreboard-table tbody tr.is-active {
    background: rgba(1, 86, 255, 0.12);
    box-shadow: inset 4px 0 0 var(--color-blue);
}

.scoreboard-table tbody tr.row-animating {
    will-change: transform;
    position: relative;
    z-index: 1;
}

.scoreboard-table tbody tr.row-auto-focus {
    box-shadow: inset 4px 0 0 var(--color-orange);
}

.col-rank {
    width: 80px;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.col-team {
    text-align: left;
    min-width: 320px;
}

.team-name {
    font-size: 1.35rem;
    font-weight: 600;
}

.team-division {
    margin-top: 0.3rem;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-muted);
    font-family: var(--font-mono);
}

.team-slug {
    display: block;
    font-size: 0.95rem;
    color: var(--color-muted);
    margin-top: 0.2rem;
}

.col-total {
    width: 160px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-orange);
    font-family: var(--font-mono);
}

.col-task {
    min-width: 160px;
    position: relative;
}

.col-task .score {
    font-size: 1.25rem;
    font-weight: 600;
}

.freeze-flag {
    font-size: 0.9rem;
    display: inline-block;
    margin-left: 0.35rem;
    color: #1d4ed8;
}

.col-task .time {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin-top: 0.3rem;
}

.col-task--running {
    border: 2px solid rgba(1, 86, 255, 0.35);
    background: rgba(1, 86, 255, 0.08);
    animation: taskPulse 1.6s ease-in-out infinite;
}

@keyframes taskPulse {
    0%, 100% {
        background: rgba(1, 86, 255, 0.08);
    }
    50% {
        background: rgba(255, 107, 0, 0.16);
    }
}

.scoreboard-empty {
    padding: 2.5rem 0;
    font-size: 1.25rem;
    color: var(--color-muted);
}

/* Queue */
.queue-panel {
    flex: 0 0 30%;
    max-width: 520px;
    background: linear-gradient(165deg, rgba(31, 35, 41, 0.95) 0%, rgba(17, 19, 22, 0.92) 100%);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 45px rgba(10, 12, 16, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.queue-panel--hidden {
    opacity: 0;
    transform: translateX(40px);
    pointer-events: none;
    flex: 0 0 0;
    max-width: 0;
    width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.queue-panel__summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.2rem 1.6rem;
    color: #ffffff;
}

.queue-panel__summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.queue-panel__summary-item .label {
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.66);
    font-family: var(--font-mono);
}

.queue-panel__summary-item .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-orange);
    font-family: var(--font-mono);
}

.queue-panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 1.4rem 1.6rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.queue-empty {
    margin: 0;
    text-align: center;
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.55);
}

.queue-group {
    background: rgba(12, 15, 20, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    overflow: hidden;
}

.queue-group__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    background: rgba(28, 32, 40, 0.65);
    font-weight: 600;
    color: #ffffff;
}

.queue-group__title {
    font-family: var(--font-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.75);
}

.queue-group__count {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-orange);
}

.queue-entries {
    list-style: none;
    margin: 0;
    padding: 0.7rem 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.queue-entry {
    display: grid;
    grid-template-columns: 2rem 1fr auto auto;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.82);
}

.queue-entry__index {
    text-align: right;
    font-family: var(--font-mono);
    color: rgba(255, 255, 255, 0.5);
}

.queue-entry__team {
    font-weight: 600;
}

.queue-entry__status {
    text-transform: lowercase;
    font-family: var(--font-mono);
    color: var(--color-orange);
}

.queue-entry__time {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: right;
}

.queue-entry--empty {
    font-style: italic;
    color: rgba(255, 255, 255, 0.5);
}

/* Responsive */
@media (max-width: 1280px) {
    header.scoreboard-header {
        padding: 2.2rem 2.5rem 1.8rem;
    }

    .scoreboard-main {
        padding: 2rem 2.5rem;
    }
}

@media (max-width: 1024px) {
    .scoreboard-layout {
        flex-direction: column;
    }

    .queue-panel {
        width: 100%;
        max-width: 100%;
        transform: translateY(0);
    }

    .queue-panel--hidden {
        transform: translateY(20px);
    }
}

@media (max-width: 768px) {
    header.scoreboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        padding: 2rem 1.5rem;
    }

    .scoreboard-header__meta {
        flex-wrap: wrap;
        gap: 0.8rem;
    }

    .scoreboard-main {
        padding: 1.5rem;
    }

    .scoreboard-table th,
    .scoreboard-table td {
        padding: 0.85rem 0.9rem;
    }

    .col-team {
        min-width: 220px;
    }
}

@media (max-width: 600px) {
    .scoreboard-header__title {
        font-size: 1.75rem;
    }

    .scoreboard-header__subtitle {
        letter-spacing: 0.16em;
    }

    .scoreboard-layout {
        gap: 1.5rem;
    }

    .queue-panel__summary {
        flex-wrap: wrap;
    }

    .queue-entry {
        grid-template-columns: 1.5rem 1fr auto;
    }

    .queue-entry__time {
        display: none;
    }
}
