:root {
    --bg-top: #09111f;
    --bg-mid: #081423;
    --bg-bottom: #03070f;
    --panel: rgba(9, 16, 31, 0.76);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text: #f6f8ff;
    --muted: rgba(220, 230, 255, 0.74);
    --accent: #7ae8ff;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
    --board-width: 240px;
    --board-height: 480px;
    --board-gap: 22px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow: hidden;
    font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(81, 150, 255, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(122, 232, 255, 0.14), transparent 24%),
        radial-gradient(circle at bottom center, rgba(255, 136, 90, 0.12), transparent 30%),
        linear-gradient(180deg, var(--bg-top), var(--bg-mid) 48%, var(--bg-bottom));
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    border-radius: 50%;
    filter: blur(18px);
    pointer-events: none;
    opacity: 0.45;
}

body::before {
    width: 34vw;
    height: 34vw;
    left: -8vw;
    top: -10vw;
    background: radial-gradient(circle, rgba(99, 166, 255, 0.22), rgba(99, 166, 255, 0));
}

body::after {
    width: 30vw;
    height: 30vw;
    right: -6vw;
    bottom: -8vw;
    background: radial-gradient(circle, rgba(255, 128, 90, 0.18), rgba(255, 128, 90, 0));
}

.app-shell {
    position: relative;
    min-height: 100vh;
    padding: 18px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.topbar {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 18px;
}

.scores-card,
.board-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.brand-card {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    padding: 2px 4px 0;
    border-radius: 14px;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    cursor: pointer;
    user-select: none;
    transition: transform 180ms ease, background-color 180ms ease, color 180ms ease;
}

.brand-card:hover,
.brand-card:focus-visible {
    background: rgba(255, 255, 255, 0.03);
}

.brand-card:active {
    transform: translateY(1px) scale(0.995);
}

.brand-card:focus-visible {
    outline: none;
}

.eyebrow,
.scores-title,
.board-chip,
.join-caption,
.join-url {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 11px;
}

.board-chip:empty {
    display: none;
}

.eyebrow,
.scores-title,
.board-chip,
.join-caption {
    color: var(--accent);
}

.brand-card h1 {
    margin: 3px 0 0;
    font-size: clamp(24px, 3.2vw, 40px);
    line-height: 0.96;
    letter-spacing: -0.04em;
    text-shadow: 0 0 24px rgba(122, 232, 255, 0.08);
}

.brand-card .eyebrow {
    color: rgba(122, 232, 255, 0.72);
    letter-spacing: 0.18em;
}

.scores-card {
    flex: 0 0 min(31vw, 320px);
    min-width: min(27vw, 280px);
    max-width: min(31vw, 320px);
    padding: 9px 13px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scores-card[hidden],
.idle-hall[hidden] {
    display: none !important;
}

.top-scores {
    display: flex;
    gap: 8px;
    min-height: 50px;
}

.top-scores.expanded {
    flex-direction: column;
    min-height: 0;
    max-height: min(58vh, calc(100vh - 170px));
    overflow: auto;
    padding-right: 2px;
}

.top-scores.expanded .top-score,
.top-scores.expanded .top-score-empty {
    flex: 0 0 auto;
}

.top-score,
.top-score-empty {
    flex: 1 1 0;
    min-width: 0;
    padding: 7px 10px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.top-score.is-podium {
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.top-score.podium-1 {
    background: linear-gradient(180deg, rgba(255, 213, 92, 0.18), rgba(255, 255, 255, 0.05));
    border-color: rgba(255, 213, 92, 0.32);
}

.top-score.podium-2 {
    background: linear-gradient(180deg, rgba(208, 219, 242, 0.16), rgba(255, 255, 255, 0.05));
    border-color: rgba(208, 219, 242, 0.28);
}

.top-score.podium-3 {
    background: linear-gradient(180deg, rgba(232, 164, 106, 0.17), rgba(255, 255, 255, 0.05));
    border-color: rgba(232, 164, 106, 0.28);
}

.top-score-rank {
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.58);
}

.top-score-name {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-score-value {
    margin-top: 1px;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
}

.top-scores.expanded .top-score {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
}

.top-scores.expanded .top-score-rank,
.top-scores.expanded .top-score-name,
.top-scores.expanded .top-score-value {
    margin-top: 0;
}

.top-scores.expanded .top-score-rank {
    min-width: 28px;
}

.top-scores.expanded .top-score-value {
    text-align: right;
}

.top-score-empty {
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.42);
    text-align: center;
}

.stage-shell {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: clamp(20px, 3vw, 36px);
}

.boards {
    flex: 0 1 auto;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--board-gap);
    min-width: 0;
    height: 100%;
}

.idle-hall {
    flex: 0 1 min(36vw, 420px);
    min-width: min(32vw, 320px);
    max-width: min(36vw, 420px);
    height: var(--idle-panel-height, auto);
    min-height: 0;
    display: flex;
    align-items: stretch;
}

.idle-scores-card {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 14px 16px 16px;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(12, 22, 42, 0.92), rgba(8, 14, 28, 0.9)),
        var(--panel);
    box-shadow:
        var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 48px rgba(122, 232, 255, 0.12);
}

.idle-scores-card .top-scores {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
}

.board-card {
    position: relative;
    flex: 0 0 auto;
    width: calc(var(--board-width) + 28px);
    padding: 14px;
    border-radius: 28px;
    transition: transform 320ms ease, opacity 320ms ease, filter 320ms ease;
}

.board-card.is-leaving {
    opacity: 0;
    transform: translateY(18px) scale(0.96);
    filter: saturate(0.6);
}

.board-card.is-demo {
    border-style: dashed;
}

.board-head,
.board-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.board-head {
    margin-bottom: 12px;
}

.board-identity {
    min-width: 0;
}

.board-title {
    margin-top: 6px;
    font-size: 20px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.board-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.board-score {
    font-size: clamp(24px, 2.6vw, 38px);
    font-weight: 900;
    letter-spacing: -0.05em;
    text-shadow: 0 0 26px rgba(255, 255, 255, 0.18);
}

.board-frame {
    position: relative;
    width: var(--board-width);
    height: var(--board-height);
    border-radius: 8px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
        rgba(2, 6, 14, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.board-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.board-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, rgba(3, 6, 12, 0.08), rgba(3, 6, 12, 0.65));
    pointer-events: none;
}

.board-overlay[hidden] {
    display: none !important;
}

.board-overlay-card {
    width: calc(100% - 30px);
    padding: 18px 16px;
    border-radius: 22px;
    text-align: center;
    background: rgba(9, 16, 31, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

.board-overlay-title {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.board-overlay-copy {
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
}

.join-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: none;
}

.join-panel {
    width: 100%;
    max-width: 200px;
    padding: 10px;
    border-radius: 22px;
    text-align: center;
    background: rgba(8, 14, 28, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
}

.join-caption {
    margin-bottom: 10px;
}

.join-qr {
    display: inline-block;
    width: 100%;
    max-width: 156px;
    padding: 8px;
    background: white;
    border-radius: 18px;
}

.join-qr img,
.join-qr canvas {
    display: block;
    width: 100%;
    height: auto;
}

.join-url {
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.14em;
}

.board-foot {
    margin-top: 12px;
    gap: 10px;
}

.board-stat {
    flex: 1 1 0;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.board-stat-label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.54);
}

.board-stat-value {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 800;
}

@media (max-width: 960px) {
    .topbar {
        gap: 12px;
    }

    .brand-card {
        padding: 1px 2px 0;
        border-radius: 12px;
    }

    .brand-card h1 {
        font-size: clamp(22px, 3vw, 34px);
    }

    .scores-card {
        flex-basis: min(34vw, 290px);
        min-width: min(30vw, 248px);
        max-width: min(34vw, 290px);
        padding: 8px 10px;
        border-radius: 18px;
    }

    .top-scores {
        gap: 6px;
    }

    .top-score,
    .top-score-empty {
        padding: 6px 8px;
    }

    .top-score-name {
        font-size: 13px;
    }

    .top-score-value {
        font-size: 11px;
    }
}

@media (max-width: 600px) {
    .topbar {
        flex-direction: column;
    }

    .brand-card,
    .scores-card {
        max-width: none;
        min-width: 0;
    }

    .stage-shell {
        flex-direction: column;
        align-items: center;
    }

    .idle-hall {
        width: min(100%, 720px);
        max-width: 100%;
        min-width: 0;
        height: auto;
        max-height: min(34vh, 360px);
    }
}

@media (max-width: 900px) {
    .app-shell {
        padding: 14px;
        gap: 14px;
    }

    .brand-card {
        padding: 2px 2px 0;
        border-radius: 12px;
    }

    .scores-card {
        padding: 10px 12px;
        border-radius: 18px;
    }

    .top-scores {
        gap: 6px;
    }

    .top-score,
    .top-score-empty {
        padding: 7px 9px;
    }
}

@media (max-height: 600px) {
    .app-shell {
        padding: 10px 12px 12px;
        gap: 10px;
    }

    .topbar {
        gap: 10px;
    }

    .brand-card {
        padding: 1px 2px 0;
        border-radius: 10px;
    }

    .eyebrow,
    .scores-title,
    .board-chip,
    .join-caption,
    .join-url,
    .board-stat-label,
    .top-score-rank {
        font-size: 9px;
        letter-spacing: 0.14em;
    }

    .brand-card h1 {
        margin-top: 4px;
        font-size: clamp(18px, 2.4vw, 26px);
    }

    .scores-card {
        padding: 7px 10px;
        border-radius: 16px;
        gap: 5px;
    }

    .top-scores {
        min-height: 40px;
        gap: 5px;
    }

    .top-score,
    .top-score-empty {
        padding: 5px 7px;
        border-radius: 12px;
    }

    .top-score-name {
        margin-top: 2px;
        font-size: 12px;
    }

    .top-score-value {
        margin-top: 0;
        font-size: 10px;
    }

    .idle-scores-card {
        padding: 10px 12px 12px;
        border-radius: 20px;
    }

    .board-card {
        padding: 10px;
        border-radius: 22px;
    }

    .board-head {
        margin-bottom: 8px;
    }

    .board-title {
        margin-top: 4px;
        font-size: 16px;
    }

    .board-subtitle {
        margin-top: 2px;
        font-size: 11px;
    }

    .board-score {
        font-size: clamp(19px, 2.2vw, 28px);
    }

    .join-panel {
        max-width: 176px;
        padding: 8px;
        border-radius: 18px;
    }

    .join-caption {
        margin-bottom: 8px;
    }

    .join-qr {
        max-width: 132px;
        padding: 6px;
        border-radius: 14px;
    }

    .board-foot {
        margin-top: 8px;
        gap: 8px;
    }

    .board-stat {
        padding: 8px 9px;
        border-radius: 12px;
    }

    .board-stat-value {
        margin-top: 4px;
        font-size: 15px;
    }

    .board-overlay-card {
        width: calc(100% - 20px);
        padding: 14px 12px;
        border-radius: 16px;
    }

    .board-overlay-title {
        font-size: 20px;
    }

    .board-overlay-copy {
        margin-top: 6px;
        font-size: 11px;
    }
}
