* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #061521;
    color: #f8fbff;
    font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
    touch-action: none;
    user-select: none;
}

.app-shell {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 10%, rgba(20, 177, 255, 0.24), transparent 28rem),
        radial-gradient(circle at 80% 80%, rgba(255, 70, 205, 0.18), transparent 32rem),
        #061521;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: crosshair;
}

.top-left-panel,
.leaderboard-panel,
.stats-panel,
.center-banner {
    position: absolute;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(5, 15, 27, 0.72);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}

.top-left-panel {
    top: 14px;
    left: 14px;
    min-width: 154px;
    padding: 10px 12px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-transform: lowercase;
}

.brand-mark {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #5cff5c, #27e9ff, #ff48d5, #ffe342, #5cff5c);
    box-shadow: 0 0 18px rgba(92, 255, 92, 0.68);
}

.status-line,
.room-line,
.host-line,
.panel-heading,
.stat-label {
    color: rgba(248, 251, 255, 0.74);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.25;
    text-transform: uppercase;
}

.status-line {
    margin-top: 8px;
}

.room-line {
    margin-top: 3px;
}

.host-line {
    margin-top: 3px;
    max-width: 190px;
    overflow: hidden;
    color: rgba(125, 245, 255, 0.88);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qr-button {
    margin-top: 8px;
    padding: 7px 9px;
    border: 1px solid rgba(125, 245, 255, 0.46);
    border-radius: 6px;
    color: #ffffff;
    background: rgba(12, 55, 78, 0.72);
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    pointer-events: auto;
}

.qr-button:active {
    transform: translateY(1px);
}

.leaderboard-panel {
    top: 14px;
    right: 14px;
    width: min(310px, calc(100vw - 188px));
    max-height: min(52vh, 360px);
    padding: 10px 10px 8px;
}

.leaderboard-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.name-button {
    padding: 5px 8px;
    border: 1px solid rgba(125, 245, 255, 0.42);
    border-radius: 6px;
    color: #ffffff;
    background: rgba(12, 55, 78, 0.72);
    font: inherit;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    pointer-events: auto;
}

.leaderboard-columns {
    display: grid;
    grid-template-columns: 24px 10px minmax(64px, 1fr) 52px 52px;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: rgba(248, 251, 255, 0.54);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.05em;
    line-height: 1;
    text-align: right;
    text-transform: uppercase;
}

.leaderboard {
    display: grid;
    gap: 4px;
    margin: 5px 0 0;
    padding: 0;
    list-style: none;
}

.leaderboard li {
    display: grid;
    grid-template-columns: 24px 10px minmax(64px, 1fr) 52px 52px;
    align-items: center;
    gap: 8px;
    min-height: 22px;
    color: rgba(248, 251, 255, 0.9);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.leader-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leader-score {
    color: #ccf6ff;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.leader-current-score {
    color: #fff45f;
}

.leader-max-score {
    color: #ccf6ff;
}

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

.stats-panel {
    right: 14px;
    bottom: 14px;
    display: grid;
    grid-template-columns: auto auto;
    gap: 14px;
    padding: 10px 12px;
    text-align: right;
}

.stats-panel strong {
    display: block;
    margin-top: 2px;
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.center-banner {
    left: 50%;
    top: 50%;
    min-width: 220px;
    padding: 16px 18px;
    text-align: center;
    transform: translate(-50%, -50%);
}

.center-banner strong,
.center-banner span {
    display: block;
}

.center-banner strong {
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
}

.center-banner span {
    margin-top: 6px;
    color: rgba(248, 251, 255, 0.78);
    font-size: 13px;
    font-weight: 800;
}

.qr-modal,
.name-modal {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(2, 8, 15, 0.62);
    pointer-events: auto;
}

.qr-modal[hidden],
.name-modal[hidden] {
    display: none;
}

.qr-dialog,
.name-dialog {
    width: min(360px, calc(100vw - 28px));
    padding: 16px 18px 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(5, 15, 27, 0.94);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.56);
    text-align: center;
}

.qr-dialog {
    min-height: 350px;
}

.qr-title {
    margin: 6px 0 14px;
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
}

.qr-close {
    display: block;
    margin-left: auto;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 6px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.name-title {
    margin: 4px 0 18px;
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
}

.name-label {
    display: block;
    margin-bottom: 8px;
    color: rgba(248, 251, 255, 0.74);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
}

.name-input {
    display: block;
    width: 100%;
    padding: 12px 13px;
    border: 1px solid rgba(125, 245, 255, 0.38);
    border-radius: 7px;
    color: #ffffff;
    background: rgba(2, 8, 15, 0.62);
    font: inherit;
    font-size: 18px;
    font-weight: 800;
}

.name-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.name-action {
    padding: 9px 12px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    color: #ffffff;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.name-action.primary {
    border-color: rgba(125, 245, 255, 0.54);
    background: rgba(12, 55, 78, 0.88);
}

.name-action.secondary {
    background: rgba(255, 255, 255, 0.1);
}

.qr-code-slot {
    min-height: 224px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rcRoomQrCodeLink,
.rcRoomQrCodeLink * {
    box-sizing: content-box;
}

.rcRoomQrCodeLink {
    display: block;
    width: 150px;
    margin-left: auto;
    margin-right: auto;
    border: solid 8px #fff;
    border-radius: 8px;
    color: #fff;
    background-color: #fff;
    box-shadow: 0 0 0 1px #fff;
    text-align: center;
    text-decoration: none;
}

.rcTechLabel {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    margin: 0 0 8px 0;
    padding: 4px;
    letter-spacing: 0.2em;
    border-radius: 8px 8px 0 0;
}

.rcRoomQrCode {
    width: 150px;
    height: 150px;
}

.rcRoomId {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 16px;
    padding: 4px;
    margin: 8px 0 0 0;
    letter-spacing: 0.25em;
    border-radius: 0 0 8px 8px;
}

.fallback-link {
    color: #9df7ff;
    font-size: 13px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.touch-stick {
    position: absolute;
    z-index: 3;
    width: 116px;
    height: 116px;
    margin: -58px 0 0 -58px;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-radius: 50%;
    background: rgba(5, 15, 27, 0.28);
    box-shadow: 0 0 0 1px rgba(5, 15, 27, 0.28), 0 0 34px rgba(39, 233, 255, 0.18);
    pointer-events: none;
}

.touch-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 22px rgba(255, 255, 255, 0.72);
}

.lean-paint .app-shell {
    background: #061521;
}

.lean-paint .top-left-panel,
.lean-paint .leaderboard-panel,
.lean-paint .stats-panel,
.lean-paint .center-banner,
.lean-paint .touch-stick,
.lean-paint .touch-knob,
.lean-paint .brand-mark,
.lean-paint .leader-dot {
    box-shadow: none;
    filter: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

@media (max-width: 700px) {
    .top-left-panel {
        top: 10px;
        left: 10px;
        min-width: 128px;
        padding: 8px 9px;
    }

    .brand-row {
        font-size: 18px;
    }

    .leaderboard-panel {
        top: 10px;
        right: 10px;
        width: min(245px, calc(100vw - 156px));
        padding: 8px;
    }

    .leaderboard-columns {
        grid-template-columns: 20px 8px minmax(44px, 1fr) 42px 42px;
        gap: 5px;
        font-size: 8px;
    }

    .leaderboard li {
        grid-template-columns: 20px 8px minmax(44px, 1fr) 42px 42px;
        gap: 5px;
        min-height: 19px;
        font-size: 10px;
    }

    .leader-dot {
        width: 8px;
        height: 8px;
    }

    .stats-panel {
        right: 10px;
        bottom: 10px;
        gap: 10px;
        padding: 8px 9px;
    }

    .stats-panel strong {
        font-size: 19px;
    }
}

@media (max-width: 460px) {
    .leaderboard-panel {
        max-height: 210px;
    }

    .leaderboard li:nth-child(n + 7) {
        display: none;
    }

    .status-line,
    .room-line,
    .host-line,
    .panel-heading,
    .stat-label {
        font-size: 9px;
    }

    .qr-button {
        padding: 6px 7px;
        font-size: 9px;
    }

    .name-button {
        padding: 4px 6px;
        font-size: 8px;
    }
}
