:root {
    --bg-0: #050913;
    --bg-1: #08101f;
    --bg-2: rgba(10, 18, 34, 0.86);
    --panel-border: rgba(130, 179, 255, 0.2);
    --text: #eef5ff;
    --muted: #95a8cb;
    --accent: #ffde59;
    --cyan: #62ddff;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(70, 129, 255, 0.24), transparent 30%),
        radial-gradient(circle at bottom left, rgba(255, 222, 89, 0.08), transparent 28%),
        linear-gradient(180deg, var(--bg-1), var(--bg-0));
    color: var(--text);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
    position: relative;
}

#mazeCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
}

.hud-shell {
    position: fixed;
    top: 22px;
    left: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: min(360px, calc(100vw - 44px));
    z-index: 2;
    transform-origin: top left;
}

.brand-card,
.scoreboard,
.message-card,
.qr-shell,
.room-pill,
.footer-ribbon {
    border: 1px solid var(--panel-border);
    background: var(--bg-2);
    backdrop-filter: blur(16px);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.hud-shell,
.qr-shell,
.room-pill,
.footer-ribbon,
.brand-card,
.scoreboard {
    transition: transform 220ms ease, opacity 220ms ease, filter 220ms ease;
}

.brand-card,
.message-card,
.scoreboard {
    border-radius: 24px;
}

.brand-card {
    padding: 18px 18px 16px;
}

.eyebrow {
    color: var(--cyan);
    font-size: 0.74rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.brand-card h1 {
    margin: 8px 0 10px;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    line-height: 0.95;
}

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

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

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #d6e5ff;
    font-size: 0.84rem;
}

.legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.dot-dot {
    background: #ffd76a;
}

.power-dot {
    background: #7af7ff;
    box-shadow: 0 0 16px rgba(122, 247, 255, 0.75);
}

.scoreboard {
    max-height: min(46vh, 420px);
    overflow: auto;
    padding: 12px;
}

.score-empty {
    padding: 12px 10px;
}

.score-card {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 18px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.04);
}

.score-card:last-child {
    margin-bottom: 0;
}

.score-avatar {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #0a1220;
    background: hsl(var(--hue), 90%, 68%);
    box-shadow: 0 12px 22px hsla(var(--hue), 90%, 60%, 0.28);
}

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

.score-name {
    font-size: 1rem;
    font-weight: 700;
}

.score-meta {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.84rem;
}

.score-points {
    text-align: right;
}

.score-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
}

.score-label {
    color: var(--muted);
    font-size: 0.8rem;
}

.center-message {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    pointer-events: none;
    z-index: 2;
}

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

.message-card {
    max-width: 540px;
    padding: 24px 28px;
    text-align: center;
}

.message-title {
    margin: 10px 0 10px;
    font-size: clamp(2rem, 6vw, 3.2rem);
    line-height: 0.95;
}

.qr-shell {
    position: fixed;
    right: 22px;
    top: 22px;
    width: 180px;
    padding: 14px;
    border-radius: 26px;
    text-decoration: none;
    color: inherit;
    text-align: center;
    z-index: 2;
}

.qr-caption,
.qr-copy,
.room-pill,
.footer-ribbon {
    color: var(--muted);
}

.qr-caption {
    margin-bottom: 10px;
    font-size: 0.82rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

#qrCode {
    display: flex;
    justify-content: center;
    min-height: 126px;
}

#qrCode img,
#qrCode canvas {
    width: 126px !important;
    height: 126px !important;
    padding: 10px;
    border-radius: 18px;
    background: #fff;
}

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

.room-pill,
.footer-ribbon {
    position: fixed;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    z-index: 2;
}

.room-pill {
    left: 22px;
    bottom: 22px;
}

.footer-ribbon {
    right: 22px;
    bottom: 22px;
}

.room-pill span,
.footer-ribbon span {
    color: var(--text);
    font-weight: 700;
}

body.compact-panels .hud-shell {
    transform: scale(0.84);
    opacity: 0.72;
}

body.compact-panels .qr-shell {
    transform: scale(0.84);
    transform-origin: top right;
    opacity: 0.66;
}

body.compact-panels .room-pill,
body.compact-panels .footer-ribbon {
    transform: scale(0.9);
    opacity: 0.68;
}

@media (max-width: 900px) {
    .hud-shell {
        width: calc(100vw - 32px);
        top: 16px;
        left: 16px;
    }

    .qr-shell {
        top: auto;
        right: 16px;
        bottom: 78px;
        width: 160px;
    }

    .room-pill {
        left: 16px;
        bottom: 16px;
    }

    .footer-ribbon {
        right: 16px;
        bottom: 16px;
    }
}

@media (max-width: 640px) {
    .hud-shell {
        gap: 12px;
    }

    .brand-card p {
        font-size: 0.92rem;
    }

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

    #qrCode img,
    #qrCode canvas {
        width: 102px !important;
        height: 102px !important;
    }

    .scoreboard {
        max-height: 30vh;
    }

    .message-card {
        padding: 18px 20px;
    }
}
