body {
            margin: 0;
            overflow: hidden;
            background: #89cff0;
            font-family: 'Poppins', sans-serif;
            font-weight: 300;
            user-select: none;
            -webkit-user-select: none;
            cursor: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOSIgaGVpZ2h0PSIxOSIgdmlld0JveD0iLTEgLTEgMTYgMTYiPjxwYXRoIGQ9Ik0xMy43NDggNC45NzNjMCAtMC4yNTYgLTAuMTQzIC0wLjQ1NiAtMC4yNDQgLTAuNTcyYTIuNjI1IDIuNjI1IDAgMCAwIC0wLjQyOCAtMC4zOGMtMC4zMyAtMC4yNDQgLTAuNzg2IC0wLjUxIC0xLjMxNSAtMC43OCAtMS4wNjEgLTAuNTQzIC0yLjQ4IC0xLjE0IC0zLjkzNiAtMS42NTVDNi4zNyAxLjA3MiA0Ljg1OCAwLjYzMiAzLjYxIDAuNDA4IDIuOTkgMC4yOTcgMi40MTIgMC4yMzYgMS45MzIgMC4yNTMgMS40ODMgMC4yNyAwLjk5IDAuMzU4IDAuNjczIDAuNjc0Yy0wLjMxOCAwLjMxOCAtMC40MDQgMC44MTMgLTAuNDE5IDEuMjYgLTAuMDE1IDAuNDggMC4wNDkgMS4wNTcgMC4xNjMgMS42NzkgMC4yMjkgMS4yNDcgMC42NzYgMi43NiAxLjE5NyA0LjIxNCAwLjUyMiAxLjQ1NiAxLjEyNSAyLjg3NiAxLjY3MiAzLjkzNyAwLjI3MyAwLjUyOSAwLjU0IDAuOTg1IDAuNzg0IDEuMzE1IDAuMTIgMC4xNjMgMC4yNDkgMC4zMTMgMC4zOCAwLjQyNyAwLjExNiAwLjEgMC4zMTUgMC4yNDQgMC41NzIgMC4yNDQgMC4zMzIgMCAwLjYwMyAtMC4xNiAwLjgwNiAtMC4zNSAwLjIgLTAuMTkgMC4zNjggLTAuNDM4IDAuNTExIC0wLjcwMSAwLjI4NiAtMC41MjggMC41MjUgLTEuMjE4IDAuNzI1IC0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zAuMDc4IC0wLjM0IDAuMTQxIC0wLjYxNiAwLjE5MiAtMC44MTMgMC4xOTQgLTAuMDUgMC40NjUgLTAuMTE1IDAuOCAtMC4xOTRsMC4yIC0wLjA0N2MwLjU5IC0wLjE0IDEuMzA1IC0wLjMxMyAxLjk5NiAtMC41MiAwLjY4NCAtMC4yMDQgMS4zNzQgLTAuNDQ4IDEuOTAxIC0wLjczOSAwLjI2MyAtMC4xNDUgMC41MTEgLTAuMzE1IDAuNjk5IC0wLjUxNyAwLjE5IC0wLjIwMyAwLjM0OSAtMC40NzUgMC4zNDkgLTAuODA3WiIgZmlsbD0iI2ZmZTI4YSIgc3Ryb2tlPSIjMTExMTExIiBzdHJva2Utd2lkdGg9IjAuOSIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PC9zdmc+') 2 2, pointer;
    }
    input, textarea {
        cursor: text;
    }
    input:hover, textarea:hover {
        outline: 2px solid rgba(255, 255, 255, 0.6);
        outline-offset: 1px;
    }

        #game-topbar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 40px;
            background: rgba(20, 20, 22, 0.75);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 14px;
            box-sizing: border-box;
            z-index: 500;
        }
        #game-topbar .topbar-left {
            display: flex;
            align-items: center;
            gap: 14px;
        }
        #game-topbar .topbar-icon-btn {
            background: none;
            border: none;
            padding: 0;
            margin: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            position: relative;
            opacity: 0.9;
            transition: opacity 0.15s;
        }
        #game-topbar .topbar-icon-btn:hover { opacity: 1; }
        #game-topbar .topbar-icon-btn:active { transform: scale(0.94); }
        #game-topbar .topbar-icon-btn svg { display: block; }
        #chat-toggle-btn .chat-unread-dot {
            display: none;
            position: absolute;
            top: -2px;
            right: -3px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #ff4d4d;
            border: 1px solid #130000;
        }
        #chat-toggle-btn.has-unread .chat-unread-dot {
            display: block;
        }
        #topbar-username {
            font-family: 'Poppins', sans-serif;
            font-size: 14px;
            font-weight: 400;
            color: rgba(255, 255, 255, 0.75);
            letter-spacing: 0.01em;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
        }

        #chat-panel {
            display: none;
            position: absolute;
            top: 40px;
            left: 0;
            width: 340px;
            background: rgba(20, 20, 22, 0.75);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 0;
            box-shadow: 0 4px 6px rgba(0,0,0,0.15);
            z-index: 300;
            overflow: hidden;
            font-family: 'Poppins', sans-serif;
            flex-direction: column;
        }
        #chat-panel.open {
            display: flex;
        }
        #chat-header {
            padding: 8px 12px;
            color: #ffffff;
            font-size: 12px;
            font-weight: 500;
            letter-spacing: 0.03em;
            border-bottom: 1px solid rgba(255, 255, 255, 0.15);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        #chat-close-btn {
            display: none;
            background: none;
            border: none;
            color: rgba(255, 255, 255, 0.7);
            font-size: 16px;
            line-height: 1;
            padding: 4px;
            margin: -4px;
            cursor: pointer;
        }
        #chat-messages {
            padding: 8px 12px;
            display: flex;
            flex-direction: column;
            gap: 6px;
            height: 160px;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }
        .chat-message {
            font-size: 12.5px;
            line-height: 1.35;
            color: #f0f0f0;
            word-wrap: break-word;
        }
        .chat-message .chat-name {
            font-weight: 500;
        }
        .chat-message.chat-system {
            color: #b8b8bd;
            font-style: italic;
        }
        /* Whole message is replaced with a ####### tag (not just the cuss
           word) when it contains profanity; tapping the row reveals the
           real text, tapping again re-hides it. */
        .chat-message.hexi-censored {
            cursor: pointer;
        }
        .chat-message.hexi-censored .chat-text {
            letter-spacing: 1px;
            opacity: 0.75;
        }
        .chat-message.hexi-censored.hexi-revealed .chat-text {
            letter-spacing: normal;
            opacity: 1;
        }
        /* Same ####### tag treatment, but for messages caught by spam
           (rate) detection rather than a bad word. */
        .chat-message.hexi-spam .chat-name {
            opacity: 0.85;
        }
        #chat-input-row {
            display: flex;
            align-items: stretch;
            gap: 0;
            margin: 0;
            border: none;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.06);
        }
        #chat-input {
            flex: 1;
            min-width: 0;
            background: transparent;
            border: none;
            border-radius: 0;
            color: #ffffff;
            font-family: 'Poppins', sans-serif;
            font-size: 12.5px;
            font-weight: 400;
            padding: 8px 10px;
            outline: none;
        }
        #chat-input::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }
        #chat-send-btn {
            background: transparent;
            border: none;
            border-left: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 0;
            color: #ffffff;
            width: 38px;
            flex: none;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            cursor: pointer;
            transition: background 0.15s;
        }
        #chat-send-btn svg { display: block; }
        #chat-send-btn:hover {
            background: rgba(255, 255, 255, 0.15);
        }
        /* --- Speech bubbles that float above a player's head when they chat --- */
        #speech-bubbles-layer {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 30;
        }
        .speech-bubble {
            position: absolute;
            transform: translate(-50%, -100%);
            max-width: 200px;
            padding: 7px 12px;
            background: #ffffff;
            color: #1a1a1a;
            font-family: 'Poppins', sans-serif;
            font-size: 13px;
            font-weight: 500;
            line-height: 1.3;
            text-align: center;
            border-radius: 12px;
            border: none;
            word-wrap: break-word;
            overflow-wrap: break-word;
            opacity: 0;
            transition: opacity 0.15s ease;
            pointer-events: none;
            will-change: left, top;
        }
        .speech-bubble.visible {
            opacity: 1;
        }
        .speech-bubble.offscreen {
            opacity: 0 !important;
        }
        /* The little pointer sticking out of the bottom of the bubble */
        .speech-bubble::after {
            content: '';
            position: absolute;
            left: 50%;
            top: 100%;
            transform: translateX(-50%);
            border-width: 7px 6px 0 6px;
            border-style: solid;
            border-color: #ffffff transparent transparent transparent;
        }

        /* A player's stack of speech bubbles: newest at the bottom, right
           above the head (with the pointer); older ones sit above it. */
        .speech-stack {
            position: absolute;
            transform: translate(-50%, -100%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
            pointer-events: none;
            will-change: left, top;
        }
        .speech-stack.offscreen { opacity: 0; }
        .speech-stack .speech-bubble {
            position: relative;
            transform: none;
            left: auto;
            top: auto;
        }
        .speech-stack .speech-bubble { transition: opacity 0.2s ease, transform 0.2s ease, translate 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2); transform-origin: 50% 100%; }
        /* New bubble pops in from just below while the old one slides up */
        .speech-stack .speech-bubble.entering { animation: speechBubbleIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
        @keyframes speechBubbleIn {
            from { transform: translateY(10px) scale(0.85); }
            to { transform: translateY(0) scale(1); }
        }
        /* When two are stacked, the older (upper) one is a bit faded and smaller */
        .speech-stack .speech-bubble.visible:first-child:not(:last-child) {
            opacity: 0.55;
            transform: scale(0.94);
        }
        .speech-stack .speech-bubble::after { display: none; }
        .speech-stack .speech-bubble:last-child::after { display: block; }

        #leaderboard {
            position: absolute;
            top: 44px;
            right: 8px;
            width: 150px;
            background: transparent;
            border: none;
            border-radius: 8px;
            box-shadow: none;
            overflow: hidden;
            z-index: 300;
            font-family: 'Poppins', sans-serif;
            pointer-events: auto;
        }
        #leaderboard-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 6px 9px;
            background: #505a69;
        }
        #leaderboard-title {
            color: rgba(255, 255, 255, 0.6);
            font-size: 9px;
            font-weight: 700;
            letter-spacing: 1.2px;
            text-transform: uppercase;
        }
        #leaderboard-close-btn {
            background: none;
            border: none;
            padding: 0;
            margin: 0;
            color: rgba(255, 255, 255, 0.6);
            font-size: 14px;
            line-height: 1;
            cursor: pointer;
        }
        #leaderboard-close-btn:hover {
            color: rgba(255, 255, 255, 0.9);
        }
        #leaderboard-body {
            padding: 6px 9px 7px;
            display: flex;
            flex-direction: column;
            background: rgba(109, 131, 149, 0.55);
        }
        #leaderboard-self-card {
            display: flex;
            align-items: center;
            padding: 5px 2px;
            box-sizing: border-box;
        }
        #lb-self-avatar {
            display: none;
        }
        #lb-self-avatar canvas {
            width: 100%;
            height: 100%;
            display: block;
        }
        #lb-self-info {
            flex: 1 1 auto;
            min-width: 0;
        }
        #lb-self-name {
            color: #ffffff;
            font-size: 12px;
            font-weight: 400;
            line-height: 1.3;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #lb-health-bar {
            display: none;
        }
        #lb-health-fill {
            height: 100%;
            width: 100%;
            background: #4fc631;
            border-radius: 4px;
            transition: width 0.25s ease-out;
        }
        #leaderboard-list {
            padding: 0;
            display: flex;
            flex-direction: column;
            max-height: 200px;
            overflow-y: auto;
        }
        .leaderboard-entry {
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: #ffffff;
            font-size: 12px;
            font-weight: 400;
            padding: 5px 2px;
            background: transparent;
            border-radius: 5px;
            box-sizing: border-box;
        }
        .leaderboard-entry .leaderboard-name {
            display: flex;
            align-items: center;
            gap: 6px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #zoom-controls {
            position: absolute;
            bottom: 25px;
            right: 25px;
            display: flex;
            flex-direction: column;
            gap: 6px;
            z-index: 10;
        }
        .zoom-btn {
            background: rgba(20, 20, 22, 0.75);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.08);
            width: 28px;
            height: 28px;
            border-radius: 0;
            font-size: 14px;
            font-weight: 300;
            font-family: 'Poppins', sans-serif;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 6px rgba(0,0,0,0.15);
            transition: background 0.15s, transform 0.1s, border-color 0.15s;
        }
        .zoom-btn:hover {
            background: rgba(255, 255, 255, 0.16);
            border-color: rgba(255, 255, 255, 0.2);
        }
        .zoom-btn:active { 
            transform: scale(0.92); 
        }

        /* --- Bottom-middle HUD: a pointer triangle (the exact asset from
           the client asset export) above a single 4-way divided item-slot
           bar, with a pill-shaped health bar underneath. Decorative only
           for now (no inventory logic yet). --- */
        #hud-bottom {
            position: fixed;
            bottom: 22px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0;
            z-index: 25;
            pointer-events: none;
        }
        #hud-pointer {
            width: 24px;
            height: auto;
            margin-bottom: 9px;
            display: block;
        }
        #hud-slots {
            display: flex;
            gap: 7px;
            width: 231px;
            background: none;
            margin-bottom: 9px;
        }
        .hud-slot {
            flex: 1 1 0;
            height: 52px;
            background: rgba(54, 53, 65, 0.55);
            border-radius: 3px;
            box-sizing: border-box;
        }
        #hud-health-bar {
            width: 231px;
            height: 12px;
            background: rgba(30, 32, 30, 0.55);
            border: 2px solid #4d484d;
            border-radius: 999px;
            box-sizing: border-box;
            overflow: hidden;
        }
        #hud-health-fill {
            height: 100%;
            width: 100%;
            background: #6dff7e;
            border-radius: 999px;
            transition: width 0.25s ease-out;
        }

        #mobile-controls {
            display: none;
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 20;
        }
        #joystick-base {
            position: absolute;
            bottom: 40px;
            left: 40px;
            width: 120px;
            height: 120px;
            background: rgba(255, 255, 255, 0.15);
            border: 2px solid rgba(255, 255, 255, 0.4);
            border-radius: 50%;
            pointer-events: auto;
            touch-action: none;
        }
        #joystick-stick {
            position: absolute;
            top: 30px;
            left: 30px;
            width: 60px;
            height: 60px;
            background: rgba(255, 255, 255, 0.5);
            border: 2px solid rgba(255, 255, 255, 0.8);
            border-radius: 50%;
            pointer-events: none;
            transform: translate(0px, 0px);
        }
        #jump-btn {
            position: absolute;
            bottom: 50px;
            right: 40px;
            width: 85px;
            height: 85px;
            background: rgba(0, 0, 0, 0.25);
            border: 3px solid rgba(255, 255, 255, 0.6);
            border-radius: 50%;
            color: white;
            font-size: 15px;
            font-weight: 300;
            font-family: 'Poppins', sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: auto;
            box-shadow: 0 4px 10px rgba(0,0,0,0.2);
            touch-action: none;
            transition: background 0.2s;
        }
        #jump-btn:active { background: rgba(255, 255, 255, 0.3); }

        #add-part-btn {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: 60px;
            height: 60px;
            border-radius: 0;
            border: none;
            background: rgba(30, 30, 34, 0.4);
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            cursor: pointer;
            z-index: 30;
            display: flex;
            align-items: center;
            justify-content: center;
            touch-action: none;
            user-select: none;
            -webkit-user-select: none;
            transition: box-shadow 0.15s, background 0.15s;
        }
        #add-part-btn span {
            font-family: 'Poppins', sans-serif;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.04em;
            color: #ffffff;
            text-align: center;
            text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 4px rgba(0,0,0,0.6);
            pointer-events: none;
        }
        #add-part-btn:hover {
            background: rgba(90, 90, 98, 0.55);
        }
        #add-part-btn:active {
            background: rgba(60, 60, 68, 0.55);
            box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35), 0 4px 16px rgba(0,0,0,0.4);
        }
        #add-part-btn-number {
            position: fixed;
            bottom: calc(20px + 60px - 20px);
            left: calc(50% - 30px + 6px);
            color: #ffffff;
            font-family: 'Poppins', sans-serif;
            font-size: 12px;
            font-weight: 700;
            text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
            z-index: 31;
            pointer-events: none;
        }


        canvas { 
            display: block; 
            background: transparent; 
        }

        #shift-lock-crosshair {
            display: none;
            position: absolute;
            top: 50%;
            left: 50%;
            width: 8px;
            height: 8px;
            aspect-ratio: 1 / 1;
            box-sizing: border-box;
            background: rgba(255, 255, 255, 0.95);
            border: 1px solid rgba(0, 0, 0, 0.5);
            border-radius: 50%;
            box-shadow: 0 0 3px rgba(0,0,0,0.5);
            transform: translate(-50%, -50%);
            pointer-events: none;
            z-index: 50;
        }
        #loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 10000;
            background: radial-gradient(circle at 85% 8%, #4a4a52 0%, #2c2c30 35%, #1a1a1c 75%);
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 1;
            transition: opacity 0.4s ease;
        }

        #loading-screen.fade-out {
            opacity: 0;
            pointer-events: none;
        }

        .loading-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
        }

        .loading-preview {
            width: 340px;
            height: 224px;
            position: relative;
            overflow: hidden;
            border-radius: 8px;
            background: #8a8a8f;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .no-thumbnail-text {
            color: #56565b;
            font-size: 16px;
            font-weight: 400;
        }

        .loading-title {
            margin-top: 14px;
            font-size: 26px;
            font-weight: 500;
            color: #ffffff;
            line-height: 1.15;
        }

        .loading-subtitle {
            margin-top: 2px;
            font-size: 14px;
            font-weight: 400;
            color: #b8b8bd;
        }

        #loading-logo {
            position: fixed;
            left: 28px;
            bottom: 24px;
            height: 90px;
            width: auto;
            z-index: 10001;
        }

        #afk-kick-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 20000;
            background: rgba(10, 10, 12, 0.45);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            align-items: center;
            justify-content: center;
        }
        #afk-kick-overlay.show {
            display: flex;
        }
        #afk-kick-box {
            background: rgba(28, 28, 32, 0.92);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.35);
            padding: 32px 36px;
            max-width: 360px;
            width: calc(100% - 48px);
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
        }
        #afk-kick-message {
            color: #ffffff;
            font-size: 17px;
            font-weight: 400;
            line-height: 1.45;
        }
        #afk-kick-leave-btn {
            margin-top: 22px;
            background: rgba(255, 255, 255, 0.95);
            border: none;
            color: #1a1a1c;
            font-family: 'Poppins', sans-serif;
            font-size: 14px;
            font-weight: 500;
            padding: 10px 28px;
            border-radius: 10px;
            cursor: pointer;
            transition: background 0.15s, transform 0.1s;
        }
        #afk-kick-leave-btn:hover {
            background: #ffffff;
        }
        #afk-kick-leave-btn:active {
            transform: scale(0.96);
        }
        /* Mobile: a noticeably smaller UI overall, so controls and panels take
           up less of a small screen. Chat input stays at 16px font — going
           smaller than that makes iOS Safari auto-zoom the whole page on focus. */
        @media (max-width: 640px), (pointer: coarse) {
            #game-topbar { height: 36px; padding: 0 10px; }
            #game-topbar .topbar-left { gap: 10px; }
            #leave-btn svg { width: 21px; height: 21px; }
            #chat-toggle-btn svg { width: 20px; height: 20px; }
            #topbar-username { font-size: 12.5px; max-width: 120px; }

            #leaderboard {
                top: 40px;
                right: 6px;
                width: 120px;
                border-radius: 7px;
            }
            #leaderboard-header { padding: 5px 8px; }
            #leaderboard-title { font-size: 8px; letter-spacing: 1px; }
            #leaderboard-close-btn { font-size: 12px; }
            #leaderboard-body { padding: 5px 8px 6px; }
            #leaderboard-self-card { padding: 4px 2px; }
            #lb-self-name { font-size: 10.5px; }
            #leaderboard-list {
                padding: 0;
                max-height: 150px;
            }
            .leaderboard-entry { font-size: 10.5px; padding: 4px 2px; border-radius: 4px; }

            #chat-panel {
                top: 40px;
                left: 14px;
                width: min(210px, calc(100vw - 24px));
                border-radius: 0;
            }
            #chat-header {
                padding: 6px 9px;
                font-size: 10px;
            }
            #chat-close-btn {
                display: block;
                font-size: 14px;
            }
            #chat-messages {
                height: 100px;
                max-height: 100px;
                padding: 6px 9px;
                gap: 4px;
            }
            .chat-message { font-size: 10.5px; }
            #chat-input-row { margin: 0; }
            #chat-input {
                font-size: 16px; /* keep — prevents iOS auto-zoom */
                padding: 6px 8px;
                border-radius: 0;
            }
            #chat-send-btn { width: 34px; border-radius: 0; }

            #hud-bottom {
                bottom: 14px;
            }
            #hud-pointer {
                width: 19px;
                margin-bottom: 7px;
            }
            #hud-slots {
                width: 176px;
                gap: 5px;
                margin-bottom: 7px;
            }
            .hud-slot {
                height: 40px;
            }
            #hud-health-bar {
                width: 176px;
                height: 10px;
            }

            #joystick-base {
                bottom: 26px;
                left: 26px;
                width: 88px;
                height: 88px;
            }
            #joystick-stick {
                top: 22px;
                left: 22px;
                width: 44px;
                height: 44px;
            }
            #jump-btn {
                bottom: 34px;
                right: 24px;
                width: 60px;
                height: 60px;
                border-width: 2px;
                font-size: 11px;
            }
        }

        /* --- Test game: simplified UI overrides ---
           This game only shows the chat box (top-left) and the player
           leaderboard (top-right). No topbar, zoom buttons, or mobile
           joystick/jump controls. The underlying elements are left in the
           DOM (just hidden) so the existing game script that references
           them by id keeps working without errors. */
        #game-topbar,
        #zoom-controls {
            display: none !important;
        }
        #chat-panel {
            display: flex !important;
            top: 0 !important;
            left: 0 !important;
            background: transparent !important;
            border-radius: 0 !important;
            box-shadow: none !important;
            border: none !important;
        }
        #chat-messages {
            background: transparent !important;
        }
        #chat-input-row {
            background: transparent !important;
            border-top: none !important;
        }
        #chat-input {
            color: #ffffff !important;
        }
        #chat-panel {
            text-shadow:
                -1px -1px 0 #000,
                1px -1px 0 #000,
                -1px 1px 0 #000,
                1px 1px 0 #000,
                0 0 3px rgba(0,0,0,0.6) !important;
        }
        #chat-input::placeholder {
            color: rgba(255, 255, 255, 0.85) !important;
            text-shadow:
                -1px -1px 0 #000,
                1px -1px 0 #000,
                -1px 1px 0 #000,
                1px 1px 0 #000,
                0 0 3px rgba(0,0,0,0.6) !important;
        }
        #chat-send-btn {
            display: none !important;
        }
        #leaderboard {
            top: 5px !important;
            right: 5px !important;
            background: transparent !important;
            border-radius: 0 !important;
            box-shadow: none !important;
        }
        #leaderboard-list {
            background: transparent !important;
        }
        .leaderboard-value {
            color: #ffffff !important;
        }
        .leaderboard-entry {
            color: #ffffff !important;
        }

        /* --- Friends: side panel + request modal + toast ---
           Click a name on the leaderboard to open the side panel; hitting
           "Friend?" sends a request that pops up the confirm modal on that
           player's own screen. Accepting saves the friendship in Supabase,
           so it still shows up back on the Home page after leaving. */
        .leaderboard-entry-clickable {
            cursor: pointer;
        }
        .leaderboard-entry-clickable:hover .leaderboard-name {
            text-decoration: underline;
        }
        #friend-side-panel {
            display: none;
            position: absolute;
            top: 44px;
            right: 164px;
            width: 176px;
            background: rgba(27, 29, 34, 0.7);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 10px;
            box-shadow: none;
            overflow: hidden;
            z-index: 310;
            font-family: 'Poppins', sans-serif;
            flex-direction: column;
            pointer-events: auto;
        }
        #player-card-close-btn {
            position: absolute;
            top: 4px;
            right: 7px;
            background: none;
            border: none;
            padding: 0;
            color: rgba(255, 255, 255, 0.45);
            font-size: 15px;
            line-height: 1;
            cursor: pointer;
        }
        #player-card-close-btn:hover { color: rgba(255, 255, 255, 0.9); }
        #player-card-top {
            display: flex;
            align-items: center;
            gap: 9px;
            padding: 11px 22px 10px 11px;
            min-width: 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }
        #player-card-avatar {
            flex: 0 0 36px;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            overflow: hidden;
            background: #3a3d45;
        }
        #player-card-avatar canvas { width: 100%; height: 100%; display: block; }
        #player-card-names { flex: 1 1 auto; min-width: 0; }
        #friend-side-panel-name {
            color: #ffffff;
            font-size: 13px;
            font-weight: 700;
            line-height: 1.25;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #player-card-handle {
            color: rgba(255, 255, 255, 0.5);
            font-size: 11px;
            line-height: 1.25;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #player-card-actions, #player-card-report {
            display: flex;
            flex-direction: column;
            padding: 3px 0;
        }
        #player-card-report-label {
            color: rgba(255, 255, 255, 0.6);
            font-size: 10.5px;
            padding: 6px 12px 3px;
        }
        .pc-row {
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            background: transparent;
            color: #ffffff;
            border: none;
            padding: 9px 12px;
            font-family: 'Poppins', sans-serif;
            font-size: 12.5px;
            font-weight: 600;
            text-align: left;
            cursor: pointer;
        }
        .pc-row + .pc-row { border-top: 1px solid rgba(255, 255, 255, 0.06); }
        .pc-row:hover { background: rgba(255, 255, 255, 0.09); }
        .pc-ico { flex: 0 0 16px; }
        .pc-row-danger, .pc-row.pc-friend-remove { color: #ff4d4d; }
        .pc-row:disabled { color: rgba(255, 255, 255, 0.45); cursor: default; background: transparent; }
        .pc-row.pc-active .pc-ico { color: #ff5a7a; }
        #friend-request-modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.55);
            z-index: 500;
            align-items: center;
            justify-content: center;
        }
        #friend-request-modal {
            background: #ffffff;
            color: #222;
            border-radius: 6px;
            padding: 22px 24px;
            width: min(300px, calc(100vw - 40px));
            box-shadow: 0 8px 24px rgba(0,0,0,0.3);
            font-family: 'Poppins', sans-serif;
            text-align: center;
        }
        #friend-request-modal-text {
            margin: 0 0 16px 0;
            font-size: 15px;
            font-weight: 500;
        }
        #friend-request-modal-btns {
            display: flex;
            gap: 10px;
            justify-content: center;
        }
        #friend-request-yes-btn, #friend-request-no-btn {
            flex: 1;
            padding: 8px 0;
            border: none;
            border-radius: 4px;
            font-family: 'Poppins', sans-serif;
            font-size: 13.5px;
            font-weight: 600;
            cursor: pointer;
        }
        #friend-request-yes-btn {
            background: #4caf50;
            color: #ffffff;
        }
        #friend-request-no-btn {
            background: #e2e5e9;
            color: #333;
        }
        #friend-request-yes-btn:hover, #friend-request-no-btn:hover {
            opacity: 0.88;
        }
        #friend-toast {
            position: fixed;
            left: 50%;
            bottom: 26px;
            transform: translateX(-50%) translateY(12px);
            background: rgba(20, 20, 22, 0.92);
            color: #ffffff;
            padding: 10px 18px;
            border-radius: 5px;
            font-family: 'Poppins', sans-serif;
            font-size: 13px;
            z-index: 510;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s, transform 0.2s;
        }
        #friend-toast.visible {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
        @media (max-width: 640px), (pointer: coarse) {
            #friend-side-panel {
                top: 40px;
                right: 156px;
                width: 156px;
            }
            .pc-row { font-size: 11.5px; padding: 8px 10px; }
        }
