: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;
    --left-column-width: 360px;
    --edge-gap: 22px;
}

* {
    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;
}

.screen-warning {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top, rgba(98, 221, 255, 0.14), transparent 30%),
        linear-gradient(180deg, rgba(8, 16, 31, 0.95), rgba(5, 9, 19, 0.98));
    z-index: 50;
}

.screen-warning-card {
    max-width: 320px;
    padding: 20px 22px;
    border-radius: 24px;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
    background: rgba(10, 18, 34, 0.9);
    border: 1px solid rgba(130, 179, 255, 0.2);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.4);
}

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

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

.brand-card,
.scoreboard,
.qr-shell {
    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,
.brand-card,
.scoreboard {
    transition: transform 220ms ease, opacity 220ms ease, filter 220ms ease;
}

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

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

.room-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(130, 179, 255, 0.18);
}

.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,
.score-empty {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

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

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

.info-chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
}

.info-label {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.info-value {
    display: block;
    margin-top: 4px;
    font-size: 1rem;
    font-weight: 700;
}

.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;
}

.qr-shell {
    position: fixed;
    left: var(--edge-gap);
    bottom: var(--edge-gap);
    width: auto;
    padding: 10px 10px 8px;
    border-radius: 26px;
    text-decoration: none;
    color: inherit;
    text-align: center;
    z-index: 2;
}

.qr-caption {
    color: var(--muted);
}

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

#qrCode {
    display: flex;
    justify-content: center;
}

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

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

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

@media (max-width: 900px) {
    :root {
        --left-column-width: 320px;
        --edge-gap: 16px;
    }

    .hud-shell {
        width: min(var(--left-column-width), calc(100vw - (var(--edge-gap) * 2)));
    }
}

@media (max-width: 1000px), (max-height: 600px) {
    :root {
        --left-column-width: 250px;
        --edge-gap: 12px;
    }

    .hud-shell {
        gap: 10px;
    }

    .brand-card {
        padding: 12px 13px 11px;
    }

    .room-badge {
        top: 9px;
        right: 9px;
        padding: 4px 7px;
        font-size: 0.56rem;
    }

    .eyebrow {
        font-size: 0.6rem;
        letter-spacing: 0.18em;
    }

    .brand-card h1 {
        margin: 5px 0 6px;
        font-size: clamp(1.18rem, 3vw, 1.55rem);
    }

    .brand-card p {
        font-size: 0.76rem;
        line-height: 1.28;
    }

    .legend-row {
        gap: 6px;
        margin-top: 10px;
    }

    .info-row {
        gap: 8px;
        margin-top: 10px;
    }

    .info-chip {
        padding: 7px 8px;
        border-radius: 12px;
    }

    .info-label {
        font-size: 0.56rem;
    }

    .info-value {
        margin-top: 3px;
        font-size: 0.74rem;
    }

    .legend-chip {
        padding: 5px 8px;
        font-size: 0.68rem;
    }

    .scoreboard {
        max-height: min(29vh, 156px);
        padding: 8px;
    }

    .score-card {
        grid-template-columns: 34px 1fr auto;
        gap: 8px;
        padding: 8px;
        margin-bottom: 7px;
        border-radius: 14px;
    }

    .score-avatar {
        width: 34px;
        height: 34px;
        border-radius: 11px;
        font-size: 0.95rem;
    }

    .score-name {
        font-size: 0.8rem;
    }

    .score-meta,
    .score-label,
    .score-empty {
        font-size: 0.66rem;
    }

    .score-value {
        font-size: 1rem;
    }

    .qr-shell {
        width: 124px;
        bottom: var(--edge-gap);
        padding: 8px 8px 6px;
        border-radius: 18px;
    }

    .qr-caption {
        margin-bottom: 7px;
        font-size: 0.62rem;
        letter-spacing: 0.12em;
    }

    #qrCode img,
    #qrCode canvas {
        width: 84px !important;
        height: 84px !important;
        padding: 7px;
        border-radius: 12px;
    }

}

@media (max-width: 700px) and (orientation: portrait) {
    .screen-warning {
        display: flex;
    }

    #mazeCanvas,
    .hud-shell,
    .qr-shell {
        visibility: hidden;
    }
}
