:root {
    --bg-top: #152128;
    --bg-mid: #0b1115;
    --bg-bottom: #040708;
    --panel: rgba(10, 18, 23, 0.8);
    --panel-border: rgba(255, 255, 255, 0.09);
    --text: #f4f7f8;
    --muted: rgba(223, 231, 231, 0.72);
    --accent: #ffb347;
    --cool: #7ef0d2;
    --hazard: #d8ff61;
    --font-title: Georgia, "Palatino Linotype", "Book Antiqua", serif;
    --font-body: "Trebuchet MS", Verdana, sans-serif;
    --shadow: 0 28px 74px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow: hidden;
    color: var(--text);
    font-family: var(--font-body);
    background:
        radial-gradient(circle at top left, rgba(255, 179, 71, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(126, 240, 210, 0.12), transparent 26%),
        linear-gradient(180deg, var(--bg-top), var(--bg-mid) 52%, var(--bg-bottom));
}

body {
    position: relative;
}

#arenaCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

.hud {
    position: absolute;
    inset: 0 0 auto 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 18px 20px 0;
    pointer-events: none;
}

.brand-card,
.score-row,
.message-card,
.qr-shell,
.room-pill,
.footer-ribbon {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    transition: opacity 220ms ease, transform 220ms ease, width 220ms ease, padding 220ms ease;
}

.brand-card {
    max-width: 480px;
    padding: 18px 20px;
    border-radius: 28px;
    transform-origin: top left;
}

.eyebrow,
.qr-caption {
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 11px;
    color: var(--accent);
}

.brand-card h1 {
    margin: 8px 0 12px;
    font-family: var(--font-title);
    font-size: clamp(38px, 4.8vw, 70px);
    line-height: 0.94;
    transition: font-size 220ms ease;
}

.brand-card p,
.message-copy,
.qr-copy,
.score-row-meta {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.legend-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 13px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 16px currentColor;
}

.live-dot {
    color: var(--accent);
    background: currentColor;
}

.ghost-dot {
    color: var(--hazard);
    background: currentColor;
}

.scoreboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(390px, 35vw);
}

.score-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 18px;
}

.score-row.empty {
    grid-template-columns: 1fr;
    text-align: center;
}

.score-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 18px currentColor;
}

.score-copy {
    min-width: 0;
}

.score-name {
    display: block;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-row-meta {
    font-size: 12px;
}

.score-mode {
    font-family: var(--font-title);
    font-size: 17px;
    color: var(--cool);
    white-space: nowrap;
}

.score-points {
    font-family: var(--font-title);
    font-size: 27px;
    color: #fff0d5;
    white-space: nowrap;
}

.center-message {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    pointer-events: none;
}

.center-message.hidden {
    opacity: 0;
    visibility: hidden;
}

.message-card {
    max-width: 680px;
    padding: 22px 24px;
    border-radius: 32px;
    text-align: center;
    transition: opacity 220ms ease, transform 220ms ease;
}

.message-title {
    margin: 10px 0 8px;
    font-family: var(--font-title);
    font-size: clamp(34px, 4vw, 56px);
    line-height: 0.95;
}

.qr-shell {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 188px;
    padding: 14px;
    border-radius: 28px;
    color: inherit;
    text-decoration: none;
    transform-origin: bottom right;
}

.qr-caption,
.qr-copy {
    text-align: center;
}

.qr-copy {
    margin-top: 10px;
    font-size: 12px;
    word-break: break-word;
}

#qrCode {
    margin: 10px auto 0;
    padding: 10px;
    width: fit-content;
    background: #fff;
    border-radius: 18px;
}

#qrCode img,
#qrCode canvas {
    display: block;
}

.room-pill,
.footer-ribbon {
    position: absolute;
    left: 20px;
    padding: 10px 14px;
    border-radius: 999px;
    color: var(--muted);
}

.room-pill {
    bottom: 20px;
}

.footer-ribbon {
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: flex;
    gap: 14px;
    color: var(--text);
}

.footer-ribbon span + span {
    color: var(--cool);
}

body.live-player .brand-card,
body.live-player .qr-shell,
body.live-player .room-pill,
body.live-player .footer-ribbon,
body.live-player .scoreboard {
    opacity: 0.35;
}

body.live-player .brand-card {
    transform: scale(0.82);
}

body.live-player .brand-card h1 {
    font-size: clamp(28px, 3.8vw, 52px);
}

body.live-player .legend-row,
body.live-player .brand-card p {
    opacity: 0.7;
}

body.live-player .qr-shell {
    transform: scale(0.8);
}

body.live-player .room-pill,
body.live-player .footer-ribbon {
    transform: scale(0.9);
}

body.live-player .footer-ribbon {
    transform: translateX(-50%) scale(0.9);
}

@media (max-width: 980px) {
    .brand-card {
        max-width: min(52vw, 340px);
    }

    .scoreboard {
        width: min(40vw, 290px);
    }
}

@media (max-width: 760px) {
    .hud {
        padding: 12px 12px 0;
        gap: 10px;
    }

    .brand-card {
        max-width: 62vw;
        padding: 14px 16px;
        border-radius: 22px;
    }

    .brand-card h1 {
        font-size: clamp(28px, 6vw, 42px);
    }

    .brand-card p,
    .legend-chip,
    .score-row-meta {
        font-size: 12px;
    }

    .scoreboard {
        width: min(34vw, 220px);
    }

    .score-row {
        grid-template-columns: auto 1fr auto;
    }

    .score-points {
        display: none;
    }

    .qr-shell {
        width: 154px;
        padding: 12px;
    }

    .room-pill,
    .footer-ribbon {
        bottom: 12px;
        font-size: 12px;
    }
}
