:root {
    --bg-top: #08101d;
    --bg-bottom: #020611;
    --panel: rgba(7, 13, 27, 0.72);
    --panel-border: rgba(255, 255, 255, 0.12);
    --text: #f8fbff;
    --muted: rgba(232, 241, 255, 0.74);
    --accent: #6af6b6;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow: hidden;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(63, 124, 255, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(106, 246, 182, 0.12), transparent 26%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
}

body {
    position: relative;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    touch-action: none;
}

.fruit-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.fruit-emoji {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform;
    transform-origin: center center;
    line-height: 1;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    text-shadow: 0 0 18px rgba(255, 190, 120, 0.28);
}

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

.brand,
.qr-shell,
.message-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    transition: opacity 220ms ease, background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.brand {
    max-width: 420px;
    padding: 16px 18px;
    border-radius: 24px;
}

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

.brand h1 {
    margin: 8px 0;
    font-size: clamp(36px, 4vw, 64px);
    line-height: 0.95;
}

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

.scoreboard {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    max-width: min(34vw, 320px);
}

.score-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.best-score-panel {
    padding: 8px 12px;
    border-radius: 14px;
    background: rgba(7, 13, 27, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
    font-weight: 700;
    backdrop-filter: blur(16px);
    transition: opacity 220ms ease, background-color 220ms ease, border-color 220ms ease;
}

.score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 14px;
    background: rgba(7, 13, 27, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 180px;
    font-size: 14px;
    backdrop-filter: blur(16px);
    transition: opacity 220ms ease, background-color 220ms ease, border-color 220ms ease;
}

.score-row-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.score-row-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 14px currentColor;
    flex: 0 0 auto;
}

.score-row span:last-child {
    font-weight: 700;
}

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

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

.center-message.hidden .message-card {
    opacity: 0;
    transform: translateY(8px);
}

body.hud-dimmed .brand,
body.hud-dimmed .qr-shell,
body.hud-dimmed .message-card,
body.hud-dimmed .best-score-panel,
body.hud-dimmed .score-row {
    opacity: 0.34;
}

body.hud-dimmed .brand,
body.hud-dimmed .qr-shell,
body.hud-dimmed .message-card {
    background: rgba(7, 13, 27, 0.28);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

body.hud-dimmed .score-row {
    background: rgba(7, 13, 27, 0.22);
    border-color: rgba(255, 255, 255, 0.05);
}

body.hud-dimmed .best-score-panel {
    background: rgba(7, 13, 27, 0.22);
    border-color: rgba(255, 255, 255, 0.05);
}

body.start-narrow .qr-shell {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

.qr-shell {
    position: absolute;
    right: 22px;
    bottom: 20px;
    width: 170px;
    padding: 14px;
    border-radius: 28px;
    color: inherit;
    text-decoration: none;
    transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}

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

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

@media (max-width: 980px) {
    .hud {
        align-items: flex-start;
    }
}

@media (max-width: 760px) {
    .brand p {
        display: none;
    }

    .scoreboard {
        max-width: min(44vw, 240px);
    }

    .best-score-panel {
        font-size: 13px;
    }

    .score-row {
        min-width: 0;
        font-size: 13px;
    }
}

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

    .brand {
        max-width: min(56vw, 220px);
        padding: 10px 12px;
        border-radius: 18px;
    }

    .brand h1 {
        margin: 6px 0 0;
        font-size: 24px;
    }

    .eyebrow {
        font-size: 9px;
        letter-spacing: 0.16em;
    }

    .scoreboard {
        max-width: min(46vw, 184px);
        gap: 6px;
    }

    .score-stack {
        position: absolute;
        top: 12px;
        right: 12px;
        gap: 6px;
        max-width: min(46vw, 184px);
    }

    .best-score-panel {
        padding: 6px 8px;
        border-radius: 12px;
        font-size: 11px;
    }

    .score-row {
        padding: 6px 8px;
        border-radius: 12px;
        gap: 8px;
        font-size: 11px;
        min-width: 0;
    }

    .score-swatch {
        width: 8px;
        height: 8px;
    }

    .message-card {
        padding: 18px;
        border-radius: 22px;
    }
}
