        :root {
            --panel: rgba(8,12,18,0.8);
            --accent: #ffd166;
            --danger: #ff6b6b;
        }

        html, body {
            height: 100%;
            margin: 0;
            background: #071226;
            color: #eaf6ff;
            font-family: Inter,Arial,Helvetica,sans-serif;
            overflow: hidden;
        }

        canvas {
            display: block;
        }

        #loginOverlay {
            position: fixed;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 200;
            background: url('../SupGalaxy.jpg') no-repeat center center;
            background-size: cover;
        }

        #loginOverlay::before {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0.8));
            z-index: -1;
        }

        #loginCard {
            width: 360px;
            padding: 18px;
            background: var(--panel);
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.6);
            margin-top: 100px;
        }

            #loginCard input, #loginCard button {
                width: 100%;
                padding: 10px;
                margin-top: 8px;
                border-radius: 8px;
                border: 1px solid rgba(255,255,255,0.06);
                background: #0d1620;
                color: #fff;
                box-sizing: border-box;
            }

            #loginCard button {
                background: var(--accent);
                color: #111;
                border: 0;
                font-weight: 700;
                cursor: pointer;
            }

        .inputContainer {
            display: flex;
            align-items: center;
            gap: 4px;
        }

            .inputContainer input {
                flex-grow: 1;
                min-width: 150px; /* Ensure input doesn't get too small */
            }

        #loginCard .emojiBtn {
            width: 20px;
            height: 20px;
            padding: 0;
            font-size: 12px;
            line-height: 20px; /* Center emoji vertically */
            margin-top: 0;
            flex-shrink: 0;
            background: #0d1620;
            font-weight: normal;
        }

        #emojiModal {
            display: none;
            position: fixed;
            inset: 0;
            align-items: center;
            justify-content: center;
            z-index: 210;
            background: rgba(0,0,0,0.7);
        }

        #emojiGrid {
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 8px;
        }

        .autocomplete {
            position: relative;
        }

        .autocomplete-suggestions {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: #0d1620;
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 8px;
            max-height: 200px;
            overflow-y: auto;
            z-index: 210;
        }

            .autocomplete-suggestions div {
                padding: 8px;
                cursor: pointer;
            }

                .autocomplete-suggestions div:hover {
                    background: #1a2632;
                }

                .autocomplete-suggestions div.greyed {
                    color: grey;
                }

        #hud {
            position: fixed;
            left: 12px;
            top: 12px;
            z-index: 200;
            background: rgba(6,8,12,0.55);
            padding: 10px;
            border-radius: 8px;
            min-width: 220px;
            display: none;
        }

.progress-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) calc(var(--p, 0) * 3.6deg), #444 0deg);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-circle-inner {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--panel);
    position: absolute;
}

.progress-circle-label {
    position: relative;
    z-index: 1;
    font-size: 14px;
    color: #fff;
}

            #hud .row {
                display: flex;
                justify-content: space-between;
                gap: 8px;
                align-items: center;
            }

            #hud button {
                margin-top: 8px;
                padding: 6px 8px;
                background: #0f2a3a;
                border: 1px solid rgba(255,255,255,0.04);
                color: #fff;
                border-radius: 6px;
                cursor: pointer;
            }

        #messages {
            position: fixed;
            left: 12px;
            top: 180px;
            z-index: 30;
            max-width: 360px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .msg {
            background: linear-gradient(180deg, rgba(0,0,0,0.42), rgba(255,255,255,0.02));
            padding: 8px 10px;
            border-radius: 8px;
            font-size: 13px;
            box-shadow: 0 6px 14px rgba(0,0,0,0.5);
        }

        #hotbar {
            position: fixed;
            left: 50%;
            transform: translateX(-50%);
            bottom: 12px;
            z-index: 210;
            display: flex;
            gap: 4px;
            width: 90%;
            max-width: 520px;
            justify-content: center;
        }

            #hotbar::-webkit-scrollbar {
                display: none;
            }

        .hot-slot {
            width: 10%;
            padding-bottom: 10%;
            height: 0;
            border-radius: 10px;
            background: rgba(0,0,0,0.45);
            border: 2px solid rgba(255,255,255,0.06);
            cursor: pointer;
            position: relative;
        }

        .hot-slot-content {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

            .hot-slot.active {
                border-color: var(--accent);
                transform: scale(1.1);
                box-shadow: 0 0 15px var(--accent);
            }

        .hot-label {
            font-size: 12px;
            color: #fff;
            text-align: center;
            user-select: none;
            position: relative; /* Ensure it's positioned correctly within the flex container */
        }

        .hot-count {
            position: absolute;
            bottom: 2px;
            right: 2px;
            background: rgba(0,0,0,0.7);
            border-radius: 4px;
            padding: 2px 4px;
            font-size: 10px;
            color: #fff;
        }

        #rightPanel {
            position: fixed;
            right: 12px;
            top: 12px;
            z-index: 200;
            background: rgba(6,8,12,0.55);
            padding: 10px;
            border-radius: 8px;
            width: 180px;
            height: 240px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        #minimap {
            width: 100%;
            height: 150px;
            border: 1px solid rgba(255,255,255,0.1);
        }

        #versionLabel {
            font-size: 10px;
            color: #eaf6ff;
            opacity: 0.78;
            margin-top: 4px;
            text-align: center;
        }

        #musicPlayer button {
            margin-top: 4px;
            padding: 2px 6px;
            font-size: 10px;
            background: #0f2a3a;
            border: 1px solid rgba(255,255,255,0.04);
            color: #fff;
            border-radius: 4px;
            cursor: pointer;
        }

        #craftModal {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            z-index: 220;
            display: none;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            width: 95%;
            max-width: 500px;
            max-height: 85vh; /* Adjusted for mobile safe areas */
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            overscroll-behavior: contain;
        }

        #craftModal h3 {
            margin: 0 0 8px 0;
            text-align: center;
            flex-shrink: 0;
        }

        #recipeList {
            overflow-y: auto;
            flex-grow: 1;
            padding-right: 5px; /* for scrollbar */
            padding-bottom: 20px; /* Ensure bottom items are visible */
        }

        .recipe-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px;
            border-radius: 6px;
            background: #0d1620;
            margin-bottom: 8px;
        }

        .recipe-preview {
            width: 40px;
            height: 40px;
            border-radius: 4px;
            flex-shrink: 0;
        }

        .recipe-info {
            flex-grow: 1;
        }

        .recipe-name {
            font-weight: bold;
        }

        .recipe-ingredients {
            font-size: 12px;
            opacity: 0.8;
            margin-top: 4px;
        }

        .recipe-status {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
        }

        .recipe-status .status-text {
            font-size: 12px;
            font-weight: bold;
        }

        .status-craftable {
            color: #66ff66;
        }

        .status-not-craftable {
            color: #ff6b6b;
        }

        .recipe-status button {
             padding: 6px 10px;
             border-radius: 4px;
             background: var(--accent);
             color: #111;
             border: 0;
             cursor: pointer;
        }

        #inventoryModal {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            z-index: 220;
            display: none;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            width: 95%;
            max-width: 480px;
            max-height: 85vh;
            overflow-y: auto;
            overscroll-behavior: contain;
            color: #fff;
            box-sizing: border-box;
        }

        #inventoryGrid {
            display: grid;
            grid-template-columns: repeat(9, 50px);
            gap: 4px;
            margin-bottom: 10px;
        }

        #inventoryHotbar {
            display: grid;
            grid-template-columns: repeat(9, 50px);
            gap: 4px;
            border-top: 2px solid rgba(255,255,255,0.1);
            padding-top: 10px;
        }

        .inv-slot {
            width: 50px;
            height: 50px;
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 4px;
            position: relative;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            text-align: center;
            overflow: hidden;
            user-select: none;
        }

        .inv-slot.selected {
            border-color: var(--accent);
            box-shadow: 0 0 8px var(--accent);
        }

        .inv-slot.highlight-craft {
            border: 2px solid var(--accent);
            box-shadow: 0 0 12px var(--accent);
            animation: pulse-craft 1.5s infinite;
        }

        @keyframes pulse-craft {
            0% {
                box-shadow: 0 0 12px var(--accent);
            }

            50% {
                box-shadow: 0 0 20px var(--accent);
            }

            100% {
                box-shadow: 0 0 12px var(--accent);
            }
        }

        .inv-count {
            position: absolute;
            bottom: 2px;
            right: 2px;
            font-size: 10px;
            background: rgba(0,0,0,0.7);
            padding: 1px 3px;
            border-radius: 2px;
        }

        #mobileControls {
            position: fixed;
            left: 20px;
            bottom: 80px;
            z-index: 195;
            display: none;
            gap: 8px;
        }

        .m-btn {
            width: 56px;
            height: 56px;
            border-radius: 12px;
            background: rgba(0,0,0,0.45);
            border: 1px solid rgba(255,255,255,0.04);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            color: #fff;
        }

        #mobileRight {
            position: fixed;
            right: 20px;
            bottom: 80px;
            z-index: 195;
            display: none;
            gap: 8px;
            flex-direction: column;
        }

        @media (max-width:700px) {
            #emojiGrid {
                grid-template-columns: repeat(4, 1fr);
                max-height: 80vh;
                overflow-y: auto;
            }
        }

        .m-action {
            width: 56px;
            height: 56px;
            border-radius: 12px;
            background: rgba(0,0,0,0.45);
            border: 1px solid rgba(255,255,255,0.04);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
        }

        #seedLabel {
            font-size: 12px;
            opacity: 0.9;
            display: block;
            margin-top: 6px;
        }

        #healthBar {
            height: 10px;
            background: #2b2b2b;
            border-radius: 6px;
            margin-top: 6px;
            overflow: hidden;
        }

        #healthBarInner {
            height: 100%;
            background: var(--danger);
            width: 100%;
        }

        #homeIcon {
            cursor: pointer;
            margin-left: 8px;
            display: none;
        }

        #trashConfirm {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            z-index: 230;
            display: none;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            min-width: 200px;
            text-align: center;
        }

            #trashConfirm button {
                padding: 6px 12px;
                margin: 8px 4px;
                background: #0f2a3a;
                border: 1px solid rgba(255,255,255,0.04);
                color: #fff;
                border-radius: 6px;
                cursor: pointer;
            }

            #trashConfirm .danger {
                background: #ff6b6b;
                color: #111;
            }

        #joinScriptModal {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            z-index: 220;
            display: none;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            width: 90%;
            max-width: 360px;
            max-height: 85vh;
            overflow-y: auto;
            overscroll-behavior: contain;
            box-sizing: border-box;
        }

            #joinScriptModal h3 {
                margin: 0 0 8px 0;
            }

            #joinScriptModal textarea {
                width: 100%;
                height: 100px;
                padding: 10px;
                margin-top: 8px;
                border-radius: 8px;
                border: 1px solid rgba(255,255,255,0.06);
                background: #0d1620;
                color: #fff;
            }

        #downloadModal {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            z-index: 220;
            display: none;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            width: 90%;
            max-width: 360px;
            max-height: 85vh;
            overflow-y: auto;
            overscroll-behavior: contain;
            box-sizing: border-box;
        }

            #downloadModal h3 {
                margin: 0 0 8px 0;
            }

            #downloadModal textarea {
                width: 100%;
                height: 100px;
                padding: 10px;
                margin-top: 8px;
                border-radius: 8px;
                border: 1px solid rgba(255,255,255,0.06);
                background: #0d1620;
                color: #fff;
            }

        #teleportModal {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            z-index: 220;
            display: none;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            width: 90%;
            max-width: 360px;
            max-height: 85vh;
            overflow-y: auto;
            overscroll-behavior: contain;
            box-sizing: border-box;
        }

            #teleportModal h3 {
                margin: 0 0 8px 0;
            }

            #teleportModal input {
                width: 100%;
                padding: 10px;
                margin-top: 8px;
                border-radius: 8px;
                border: 1px solid rgba(255,255,255,0.06);
                background: #0d1620;
                color: #fff;
                box-sizing: border-box;
            }

            #teleportModal .row {
                display: flex;
                gap: 8px;
                margin-top: 8px;
            }

            #teleportModal button {
                padding: 6px 12px;
                margin: 8px 4px;
                background: #0f2a3a;
                border: 1px solid rgba(255,255,255,0.04);
                color: #fff;
                border-radius: 6px;
                cursor: pointer;
            }

        #deathScreen {
            position: fixed;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 250;
            background: rgba(139,0,0,0.7);
            flex-direction: column;
            color: #fff;
            text-align: center;
        }

            #deathScreen h1 {
                font-size: 48px;
                margin: 0;
                text-shadow: 0 0 10px rgba(0,0,0,0.8);
            }

            #deathScreen button {
                margin-top: 20px;
                padding: 10px 20px;
                background: var(--accent);
                color: #111;
                border: none;
                border-radius: 8px;
                font-weight: 700;
                cursor: pointer;
            }

        #usersModal {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            z-index: 220;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            width: 90%;
            max-width: 360px;
            max-height: 85vh;
            overflow-y: auto;
            overscroll-behavior: contain;
            display: none;
            box-sizing: border-box;
        }

            #usersModal h3 {
                margin: 0 0 8px 0;
            }

            #usersModal p.warning {
                font-size: 12px;
                opacity: 0.7;
                margin-top: 10px;
                color: #ff6b6b;
            }

        #pendingModal {
            position: fixed;
            right: 12px;
            bottom: 12px;
            z-index: 220;
            background: var(--panel);
            padding: 14px;
            border-radius: 10px;
            width: 90%;
            max-width: 300px;
            max-height: 60vh;
            overflow-y: auto;
            display: none;
            box-sizing: border-box;
        }

            #pendingModal h3 {
                margin: 0 0 8px 0;
            }

        #pendingList .row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 6px;
            padding: 4px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
        }

            #pendingList .row.selected {
                background: #1a2632;
            }

        #pendingModal .actions {
            margin-top: 10px;
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .minimap-small {
            width: 80px !important;
            height: 100px !important;
        }

        .minimap-small #minimap {
            height: 80px !important;
        }

        @media (max-width: 700px) and (orientation: portrait) {
            #mobileControls, #mobileRight {
                display: flex;
            }

            #hud {
                display: none !important;
            }

            #hotbar {
                flex-wrap: wrap;
                justify-content: flex-start;
                max-width: 240px;
            }

            #rightPanel {
                width: 80px;
                height: 100px;
            }

            #minimap {
                height: 80px;
            }

            .hot-slot {
                width: 48px;
                height: 0;
                padding-bottom: 48px; /* Force square aspect ratio */
                flex-shrink: 0; /* Prevent shrinking */
            }

            #inventoryModal {
                width: 95vw;
                min-width: unset;
                padding: 8px;
                max-height: 80vh;
                overflow-y: auto;
            }

            #inventoryGrid, #inventoryHotbar {
                grid-template-columns: repeat(9, 1fr);
                gap: 2px;
            }

            .inv-slot {
                width: auto;
                aspect-ratio: 1/1;
                font-size: 8px;
            }
        }

        #crosshair {
            position: fixed;
            left: 50%;
            top: 50%;
            color: white;
            font-size: 24px;
            transform: translate(-50%,-50%);
            display: none;
            z-index: 200;
            pointer-events: none;
        }

        #usersBtn.hosting {
            box-shadow: 0 0 10px 3px rgba(255, 209, 102, 0.7);
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% {
                box-shadow: 0 0 10px 3px rgba(255, 209, 102, 0.7);
            }

            50% {
                box-shadow: 0 0 14px 7px rgba(255, 209, 102, 0.7);
            }

            100% {
                box-shadow: 0 0 10px 3px rgba(255, 209, 102, 0.7);
            }
        }

/* Update Mobile Controls */
#mobileInterface {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 170; /* Below HUD (180), Hotbar (190), etc. */
}

#mobileJoystickZone {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    pointer-events: auto;
    touch-action: none;
    z-index: 50; /* Above canvas, below everything else */
}

#mobileJoystickKnob {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    border: 2px solid rgba(255, 255, 255, 0.8);
}

#mobileLookZone {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    pointer-events: auto;
    touch-action: none;
    z-index: 50; /* Above canvas, below HUD */
}

#mobileButtonsContainer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    pointer-events: auto;
    z-index: 195;
    align-items: center;
    justify-content: center;
}

/* Re-use old IDs but they are now all in one container at bottom */
#mobileButtonsLeft {
    display: contents; /* Allow children to sit in the flex container */
}

#mobileButtonsRight {
    display: contents;
}

.m-action-btn {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    user-select: none;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: transform 0.1s, background 0.1s;
}

.m-action-btn:active {
    background: rgba(255, 209, 102, 0.5);
    transform: scale(0.95);
    border-color: var(--accent);
    color: #111;
}

#mobileJumpBtn {
    background: rgba(200, 200, 200, 0.3);
}

#mobileSprintBtn {
    background: rgba(200, 200, 200, 0.3);
}

/* Shrink hotbar in mobile mode and move to top */
.mobile-hotbar {
    top: 12px;
    bottom: auto !important; /* Override default bottom positioning */
}

.mobile-hotbar .hot-slot {
    width: 35px; /* Shrunk from 10% or 50px */
    padding-bottom: 35px;
    height: 0;
    border-radius: 6px;
}

.mobile-hotbar .hot-slot-content {
    /* No change needed, absolute pos */
}

.mobile-hotbar .hot-label {
    font-size: 8px; /* Smaller font */
}

.mobile-hotbar .hot-count {
    font-size: 8px;
    bottom: 1px;
    right: 1px;
    padding: 1px 2px;
}

/* Hide old controls if they still exist in CSS but are removed from HTML */
#mobileControls, #mobileRight {
    display: none !important;
}

/* Adjustments for landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #mobileButtonsContainer {
        bottom: 10px;
    }
    /* Force hotbar to top in landscape too */
    #hotbar {
        top: 12px;
        bottom: auto !important;
    }
}

/* Adjustments for landscape mobile / small height screens */
@media (max-height: 600px) {
    #rightPanel {
        width: 130px;
        height: auto;
        min-height: 180px;
        padding: 6px;
    }

    #minimap {
        height: 100px;
    }

    #versionLabel {
        font-size: 9px;
        margin-top: 2px;
    }

    #musicPlayer {
        margin-top: 4px;
        max-width: 95vw;
    }

    #musicPlayer button {
        padding: 2px 4px;
        font-size: 9px;
    }

    #currentTrack {
        font-size: 9px;
    }

    #musicMenuBtn {
        font-size: 9px;
        padding: 2px;
    }
}

#chestModal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 220;
    display: none;
    background: var(--panel);
    padding: 14px;
    border-radius: 10px;
    min-width: 320px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: #fff;
    flex-direction: column;
    padding-bottom: 30px;
}

#chestGrid {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    gap: 4px;
    margin-bottom: 10px;
    justify-content: center;
}

#chestInventoryGrid {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    gap: 4px;
    margin-bottom: 10px;
    justify-content: center;
}

#chestInventoryHotbar {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    gap: 4px;
    border-top: 2px solid rgba(255,255,255,0.1);
    padding-top: 10px;
    justify-content: center;
}

@media (max-width: 700px) and (orientation: portrait) {
    #chestGrid, #chestInventoryGrid, #chestInventoryHotbar {
        grid-template-columns: repeat(9, 1fr);
        gap: 2px;
    }
}

/* Disable interaction with messages in mobile mode to allow joystick usage */
body.is-mobile-mode #messages {
    pointer-events: none;
}

/* Chat System Styles */
#chatButton {
    transition: opacity 0.2s, transform 0.1s;
}

#chatButton:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}

#chatButton:active {
    transform: scale(0.95);
}

/* Mobile Mode Toggle Button Styles */
#mobileModeToggle {
    transition: opacity 0.2s, transform 0.1s;
}

#mobileModeToggle:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}

#mobileModeToggle:active {
    transform: scale(0.95);
}

#chatPanel {
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

#chatHistory {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.2);
}

#chatHistory::-webkit-scrollbar {
    width: 8px;
}

#chatHistory::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

#chatHistory::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

#chatHistory::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.chat-message {
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-username {
    font-weight: bold;
    color: var(--accent);
    margin-right: 4px;
}

.chat-text {
    color: #eaf6ff;
}

/* Mobile responsiveness for chat */
@media (max-width: 700px) and (orientation: portrait) {
    #chatPanel {
        width: 100%;
        max-width: 100%;
        max-height: 80vh;
        padding: 10px;
        border-radius: 8px;
    }

    #chatHistory {
        min-height: 150px;
        max-height: 300px;
    }

    #chatInput {
        font-size: 16px; /* Prevent auto-zoom on iOS */
    }

    #chatButton {
        font-size: 28px; /* Larger hit area on mobile */
        bottom: 80px; /* Move up to avoid hotbar overlap */
        left: 12px; /* Maintain horizontal position from HTML */
    }
    
    #mobileModeToggle {
        font-size: 28px; /* Larger hit area on mobile */
        bottom: 80px; /* Move up to avoid hotbar overlap */
        left: 52px; /* 12px (chatButton left) + 28px (button width) + 12px (spacing) */
    }
}

/* Ensure bottom-left buttons don't overlap with hotbar on mobile */
@media (max-width: 700px) {
    #chatButton {
        bottom: 16px;
        left: 16px;
    }
    
    #mobileModeToggle {
        bottom: 16px;
        left: 56px; /* 16px (chatButton left) + 28px (button width) + 12px (spacing) */
    }
}
