/**
 * Multiplayer CSS Styles
 */

/* Multiplayer Menu */
.mp-menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    height: calc(100% - 80px);
}

.mp-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.mp-menu-buttons .menu-btn {
    min-width: 250px;
}

.mp-info {
    color: #888;
    text-align: center;
    font-family: 'Rajdhani', sans-serif;
}

.multiplayer-btn {
    background: linear-gradient(135deg, #6e48aa 0%, #9d50bb 100%);
}

.multiplayer-btn:hover {
    background: linear-gradient(135deg, #9d50bb 0%, #6e48aa 100%);
}

/* Mobile Multiplayer Menu - ensure buttons are clickable */
@media (pointer: coarse), (hover: none), (max-width: 900px) {
    #multiplayer-menu {
        overflow-y: auto !important;
    }

    #multiplayer-menu .mp-menu-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 20px !important;
        height: auto !important;
        min-height: calc(100% - 60px) !important;
    }

    #multiplayer-menu .mp-menu-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
        max-width: 350px !important;
        pointer-events: auto !important;
    }

    #multiplayer-menu .mp-menu-buttons .menu-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: 200px !important;
        padding: 15px 25px !important;
        font-size: 1rem !important;
        pointer-events: auto !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }

    #multiplayer-menu .mp-info {
        margin-top: 20px !important;
        padding: 0 20px !important;
    }
}

/* Multiplayer Lobby */
.mp-lobby-content {
    display: flex;
    flex-direction: column;
    height: calc(100% - 80px);
    padding: 20px;
}

.mp-room-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    margin-bottom: 20px;
}

.mp-room-code-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mp-code-label {
    color: #888;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
}

.mp-room-code {
    font-family: 'Orbitron', monospace;
    font-size: 28px;
    font-weight: bold;
    color: #00ff88;
    letter-spacing: 4px;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.mp-copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #00ff88;
    color: #00ff88;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    transition: all 0.2s;
}

.mp-copy-btn:hover {
    background: rgba(0, 255, 136, 0.2);
}

.mp-connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mp-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
}

.mp-status-dot.connected {
    background: #00ff88;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.mp-status-dot.disconnected {
    background: #ff4444;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

.mp-status-text {
    color: #888;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
}

/* Lobby Main Section */
.mp-lobby-main {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.mp-players-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
}

.mp-players-section h3,
.mp-chat-section h3 {
    color: #00ff88;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.mp-player-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mp-player-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mp-player-item.local {
    border-color: rgba(0, 255, 136, 0.3);
    background: rgba(0, 255, 136, 0.1);
}

.mp-player-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mp-player-name {
    flex: 1;
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    font-weight: 600;
}

.mp-player-badges {
    display: flex;
    gap: 6px;
}

.mp-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: bold;
}

.mp-badge.host {
    background: rgba(255, 170, 0, 0.2);
    color: #ffaa00;
    border: 1px solid rgba(255, 170, 0, 0.5);
}

.mp-badge.ready {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.5);
}

/* Chat Section */
.mp-chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
}

.mp-chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
    padding-right: 10px;
}

.mp-chat-message {
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
}

.mp-chat-message .name {
    font-weight: 600;
}

.mp-chat-message .text {
    color: #ccc;
}

.mp-chat-input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    padding: 10px 15px;
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
}

.mp-chat-input:focus {
    outline: none;
    border-color: #00ff88;
}

.mp-chat-input::placeholder {
    color: #666;
}

/* Settings Panel */
.mp-settings-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    margin-top: 20px;
}

.mp-settings-panel h3 {
    color: #ffaa00;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    margin-bottom: 15px;
}

.mp-setting {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mp-setting label {
    color: #888;
    font-family: 'Rajdhani', sans-serif;
}

.mp-setting select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    padding: 8px 15px;
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
}

/* Map Selector */
.mp-map-selector {
    margin-bottom: 20px;
}

.mp-section-label {
    display: block;
    color: #00ff88;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.mp-map-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.mp-map-option {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 14px;
    color: #aaa;
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.mp-map-option:hover {
    border-color: rgba(0, 255, 136, 0.5);
    color: #fff;
}

.mp-map-option.selected {
    background: rgba(0, 255, 136, 0.2);
    border-color: #00ff88;
    color: #00ff88;
    font-weight: bold;
}

.mp-map-preview {
    display: flex;
    gap: 15px;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 12px;
}

#mp-map-preview-canvas {
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.mp-map-info {
    flex: 1;
}

.mp-map-name {
    color: #00ff88;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
}

.mp-map-desc {
    color: #888;
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    margin-bottom: 8px;
}

.mp-map-size {
    color: #ffaa00;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
}

/* Lobby Actions */
.mp-lobby-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.mp-lobby-actions .menu-btn {
    min-width: 150px;
}

#mp-ready-btn.ready {
    background: rgba(0, 255, 136, 0.3);
    border-color: #00ff88;
}

/* Join Modal */
.mp-join-content {
    text-align: center;
}

.mp-join-form {
    margin: 20px 0;
}

.mp-join-form label {
    display: block;
    color: #888;
    font-family: 'Rajdhani', sans-serif;
    margin-bottom: 10px;
}

.mp-code-input {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 255, 136, 0.5);
    border-radius: 10px;
    padding: 15px 20px;
    color: #00ff88;
    font-family: 'Orbitron', monospace;
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 8px;
    width: 200px;
    text-transform: uppercase;
}

.mp-code-input:focus {
    outline: none;
    border-color: #00ff88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.mp-code-input::placeholder {
    color: #444;
}

/* Multiplayer Overlays */
.mp-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Countdown */
.mp-countdown-content {
    text-align: center;
}

.mp-countdown-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 150px;
    font-weight: 900;
    color: #00ff88;
    text-shadow: 0 0 50px rgba(0, 255, 136, 0.5);
}

.mp-countdown-value.pulse {
    animation: countdownPulse 0.5s ease-out;
}

@keyframes countdownPulse {
    0% {
        transform: scale(1.5);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

/* Game Over */
.mp-gameover-content {
    text-align: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    border: 2px solid #00ff88;
    max-width: 500px;
    width: 90%;
}

.mp-winner-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    color: #ffaa00;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(255, 170, 0, 0.5);
}

.mp-winner-name.local-win {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.mp-scoreboard {
    margin-bottom: 30px;
}

.mp-score-row {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-family: 'Rajdhani', sans-serif;
}

.mp-score-row.winner {
    background: rgba(255, 170, 0, 0.2);
    border: 1px solid rgba(255, 170, 0, 0.5);
}

.mp-score-row.local {
    border: 1px solid rgba(0, 255, 136, 0.5);
}

.mp-score-row .rank {
    width: 40px;
    color: #888;
    font-weight: bold;
}

.mp-score-row .name {
    flex: 1;
    color: #fff;
    font-weight: 600;
}

.mp-score-row .score {
    width: 80px;
    color: #00ff88;
    font-weight: bold;
    text-align: right;
}

.mp-score-row .kills {
    width: 80px;
    color: #ff4488;
    font-size: 12px;
    text-align: right;
}

.mp-gameover-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.mp-gameover-buttons .menu-btn {
    min-width: 100px;
}

/* Kill Feed */
.mp-kill-feed {
    position: fixed;
    top: 100px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 100;
    pointer-events: none;
}

.mp-kill-entry {
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border-radius: 5px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: killFeedIn 0.3s ease-out;
}

.mp-kill-entry.fade-out {
    animation: killFeedOut 0.5s ease-out forwards;
}

@keyframes killFeedIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes killFeedOut {
    to {
        transform: translateX(100px);
        opacity: 0;
    }
}

.killed-icon {
    font-size: 16px;
}

.died-text {
    color: #888;
}

/* In-Game HUD */
.mp-game-hud {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 50;
}

.mp-scores-list {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 10px 15px;
    min-width: 150px;
}

.mp-score-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
}

.mp-score-item .color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.mp-score-item .player-name {
    flex: 1;
    color: #fff;
}

.mp-score-item .player-score {
    color: #00ff88;
    font-weight: bold;
}

.mp-score-item.dead {
    opacity: 0.5;
}

.mp-score-item.dead .player-name {
    text-decoration: line-through;
}

/* Loading Overlay */
#mp-loading-overlay {
    background: rgba(0, 0, 0, 0.9);
}

.mp-loading-content {
    text-align: center;
}

.mp-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 255, 136, 0.2);
    border-top-color: #00ff88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.mp-loading-text {
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
}

/* Responsive */
@media (max-width: 768px) {
    .mp-lobby-main {
        flex-direction: column;
    }

    .mp-room-code {
        font-size: 20px;
    }

    .mp-code-input {
        font-size: 20px;
        width: 160px;
    }

    .mp-countdown-value {
        font-size: 100px;
    }

    .mp-gameover-content {
        padding: 20px;
    }

    .mp-winner-name {
        font-size: 24px;
    }

    .mp-gameover-buttons {
        gap: 10px;
    }

    .mp-gameover-buttons .menu-btn {
        padding: 10px 20px;
        font-size: 13px;
        min-width: 80px;
    }
}

/* ============================================
   Mobile Lobby - Complete Redesign
   ============================================ */

/* Mobile detection - any screen under 600px height OR under 800px width */
@media screen and (max-height: 600px), screen and (max-width: 800px) {
    /* Force lobby to use full viewport and be scrollable */
    #multiplayer-lobby {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Header - just LEAVE button, no LOBBY title */
    #multiplayer-lobby .screen-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        background: #0a0f19 !important;
        padding: 10px 15px !important;
        min-height: auto !important;
        flex-shrink: 0 !important;
        border-bottom: none !important;
    }

    #multiplayer-lobby .screen-header h2 {
        display: none !important;
    }

    /* Lobby content - flex column, full height */
    #multiplayer-lobby .mp-lobby-content {
        height: auto !important;
        flex: 1 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
    }

    /* Room info bar - horizontal with bottom border */
    #multiplayer-lobby .mp-room-info {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 15px 20px !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
        background: transparent !important;
        border-bottom: 2px solid var(--accent-secondary) !important;
    }

    #multiplayer-lobby .mp-room-info-left {
        display: flex !important;
        align-items: center !important;
        gap: 15px !important;
    }

    #multiplayer-lobby .mp-code-label {
        font-size: 11px !important;
        color: #888 !important;
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
    }

    #multiplayer-lobby .mp-room-code {
        font-size: 22px !important;
        letter-spacing: 4px !important;
        color: var(--accent-secondary) !important;
        font-weight: bold !important;
    }

    #multiplayer-lobby .mp-copy-btn {
        padding: 8px 15px !important;
        font-size: 12px !important;
        background: transparent !important;
        border: 1px solid var(--accent-secondary) !important;
        color: var(--accent-secondary) !important;
    }

    /* Connection status on right */
    #multiplayer-lobby .mp-connection-status {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        color: var(--accent-primary) !important;
        font-size: 14px !important;
    }

    #multiplayer-lobby .mp-connection-status::before {
        content: '' !important;
        width: 10px !important;
        height: 10px !important;
        background: var(--accent-primary) !important;
        border-radius: 50% !important;
    }

    /* Main content - two columns */
    #multiplayer-lobby .mp-lobby-main {
        display: flex !important;
        flex-direction: row !important;
        gap: 0 !important;
        flex: 1 !important;
        min-height: 0 !important;
        padding: 15px 20px !important;
    }

    /* Players section - left column ~40% */
    #multiplayer-lobby .mp-players-section {
        display: flex !important;
        flex-direction: column !important;
        flex: 0 0 40% !important;
        min-width: 0 !important;
        padding: 0 !important;
        padding-right: 20px !important;
        background: transparent !important;
        border: none !important;
    }

    #multiplayer-lobby .mp-players-section h3 {
        display: block !important;
        font-size: 13px !important;
        margin-bottom: 12px !important;
        color: var(--accent-primary) !important;
        text-transform: uppercase !important;
        letter-spacing: 2px !important;
        font-weight: bold !important;
    }

    #multiplayer-lobby .mp-player-list {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        flex: 1 !important;
        overflow-y: auto !important;
    }

    #multiplayer-lobby .mp-player-item {
        display: flex !important;
        align-items: center !important;
        padding: 12px 15px !important;
        background: rgba(0, 255, 136, 0.05) !important;
        border: 1px solid rgba(0, 255, 136, 0.3) !important;
        border-radius: 4px !important;
    }

    #multiplayer-lobby .mp-player-color {
        width: 12px !important;
        height: 12px !important;
        border-radius: 50% !important;
        margin-right: 12px !important;
    }

    #multiplayer-lobby .mp-player-name {
        font-size: 15px !important;
        flex: 1 !important;
    }

    #multiplayer-lobby .mp-badge {
        font-size: 10px !important;
        padding: 4px 10px !important;
        background: var(--accent-warning) !important;
        color: #000 !important;
        border-radius: 3px !important;
        font-weight: bold !important;
    }

    /* Chat section - right column ~60% */
    #multiplayer-lobby .mp-chat-section {
        display: flex !important;
        flex-direction: column !important;
        flex: 0 0 60% !important;
        min-width: 0 !important;
        padding: 0 !important;
        padding-left: 20px !important;
        background: transparent !important;
        border: none !important;
    }

    #multiplayer-lobby .mp-chat-section h3 {
        display: block !important;
        font-size: 13px !important;
        margin-bottom: 12px !important;
        color: var(--accent-primary) !important;
        text-transform: uppercase !important;
        letter-spacing: 2px !important;
        font-weight: bold !important;
    }

    #multiplayer-lobby .mp-chat-messages {
        flex: 1 !important;
        min-height: 80px !important;
        background: transparent !important;
        border: none !important;
    }

    #multiplayer-lobby .mp-chat-input {
        padding: 12px 15px !important;
        font-size: 14px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 4px !important;
        color: #fff !important;
        margin-top: auto !important;
    }

    #multiplayer-lobby .mp-chat-input::placeholder {
        color: rgba(255, 255, 255, 0.4) !important;
    }

    /* Settings panel - hide on mobile */
    #multiplayer-lobby .mp-settings-panel {
        display: none !important;
    }

    /* Actions - bottom bar with cyan bordered buttons */
    #multiplayer-lobby .mp-lobby-actions {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: linear-gradient(0deg,
            rgba(10, 15, 30, 1) 0%,
            rgba(10, 15, 30, 0.98) 80%,
            transparent 100%) !important;
        padding: 25px 20px 20px !important;
        gap: 20px !important;
        z-index: 50 !important;
        flex-shrink: 0 !important;
    }

    #multiplayer-lobby .mp-lobby-actions .menu-btn {
        min-width: 150px !important;
        padding: 15px 35px !important;
        font-size: 15px !important;
        font-weight: bold !important;
        text-transform: uppercase !important;
        letter-spacing: 2px !important;
        background: transparent !important;
        border: 2px solid var(--accent-tertiary) !important;
        color: #fff !important;
    }

    #multiplayer-lobby .mp-lobby-actions .menu-btn:hover {
        background: rgba(0, 255, 255, 0.1) !important;
    }

    #multiplayer-lobby .mp-lobby-actions .menu-btn.primary {
        background: transparent !important;
        border-color: var(--accent-tertiary) !important;
    }
}

/* Landscape specific adjustments */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #multiplayer-lobby .mp-lobby-content {
        padding: 10px !important;
        gap: 10px !important;
    }

    #multiplayer-lobby .mp-room-info {
        padding: 8px 12px !important;
    }

    #multiplayer-lobby .mp-room-code {
        font-size: 16px !important;
    }

    #multiplayer-lobby .mp-lobby-main {
        min-height: 100px !important;
    }

    #multiplayer-lobby .mp-players-section,
    #multiplayer-lobby .mp-chat-section {
        padding: 8px !important;
    }

    #multiplayer-lobby .mp-players-section h3,
    #multiplayer-lobby .mp-chat-section h3 {
        font-size: 10px !important;
        margin-bottom: 5px !important;
    }

    #multiplayer-lobby .mp-player-item {
        padding: 8px 10px !important;
    }

    #multiplayer-lobby .mp-player-name {
        font-size: 13px !important;
    }

    #multiplayer-lobby .mp-lobby-actions {
        padding: 15px 10px 10px !important;
        margin: 0 -10px -10px -10px !important;
    }

    #multiplayer-lobby .mp-lobby-actions .menu-btn {
        padding: 10px 20px !important;
        font-size: 13px !important;
    }
}

/* Very small screens */
@media screen and (max-height: 400px) {
    #multiplayer-lobby .screen-header h2 {
        font-size: 12px !important;
    }

    #multiplayer-lobby .mp-chat-messages {
        max-height: 40px !important;
    }

    #multiplayer-lobby .mp-player-list {
        max-height: 70px !important;
    }
}

/* Portrait mobile */
@media screen and (max-width: 500px) and (orientation: portrait) {
    #multiplayer-lobby .mp-lobby-main {
        flex-direction: column !important;
    }

    #multiplayer-lobby .mp-players-section,
    #multiplayer-lobby .mp-chat-section {
        flex: none !important;
        max-height: 200px !important;
    }

    #multiplayer-lobby .mp-lobby-actions {
        flex-direction: column !important;
    }

    #multiplayer-lobby .mp-lobby-actions .menu-btn {
        width: 100% !important;
    }
}

/* ============================================
   Mobile Keyboard Handling
   ============================================ */

:root {
    --keyboard-height: 0px;
}

/* When keyboard is about to open */
.keyboard-preparing .screen-header,
.keyboard-preparing .mp-info,
.keyboard-preparing .version-info {
    transition: opacity 0.15s ease-out;
}

/* When keyboard is open - hide non-essential elements */
.keyboard-open .screen-header h2,
.keyboard-open .mp-menu-content > .mp-info,
.keyboard-open .modal-subtitle {
    display: none !important;
}

/* Reduce header size */
.keyboard-open .screen-header {
    padding: 5px 10px;
    min-height: auto;
}

.keyboard-open .back-btn {
    padding: 5px 10px;
    font-size: 12px;
}

/* Compact modal when keyboard is open */
.keyboard-open .modal {
    align-items: flex-start;
    padding-top: 10px;
}

.keyboard-open .modal-content {
    padding: 15px;
    margin: 0;
    max-height: calc(100vh - var(--keyboard-height) - 20px);
    overflow-y: auto;
    transition: transform 0.2s ease-out;
}

.keyboard-open .modal-content h2 {
    font-size: 18px;
    margin-bottom: 10px;
}

/* Join modal specific */
.keyboard-open .mp-join-content {
    padding: 10px 15px;
}

.keyboard-open .mp-join-form {
    margin: 10px 0;
}

.keyboard-open .mp-join-form label {
    font-size: 12px;
    margin-bottom: 5px;
}

.keyboard-open .mp-code-input {
    font-size: 20px;
    padding: 10px 15px;
    letter-spacing: 5px;
}

.keyboard-open .modal-buttons {
    margin-top: 10px;
    gap: 10px;
}

.keyboard-open .modal-buttons .menu-btn {
    padding: 10px 20px;
    font-size: 14px;
}

/* Player name input modal */
.keyboard-open #name-input-modal .modal-content {
    padding: 15px;
}

.keyboard-open #player-name-input {
    padding: 10px 15px;
    font-size: 16px;
}

/* Lobby screen with keyboard */
.keyboard-open .mp-lobby-content {
    padding: 10px;
}

.keyboard-open .mp-room-info {
    padding: 8px 12px;
    margin-bottom: 10px;
}

.keyboard-open .mp-room-code {
    font-size: 18px;
    letter-spacing: 2px;
}

.keyboard-open .mp-lobby-main {
    gap: 10px;
}

.keyboard-open .mp-chat-section {
    /* Prioritize chat when typing */
    flex: 2;
}

.keyboard-open .mp-players-section {
    flex: 0 0 auto;
    max-height: 80px;
    overflow: hidden;
}

.keyboard-open .mp-players-section h3,
.keyboard-open .mp-chat-section h3 {
    display: none;
}

.keyboard-open .mp-chat-input {
    padding: 8px 12px;
}

.keyboard-open .mp-lobby-actions {
    display: none;
}

/* Adjust transformed elements */
.keyboard-adjusted {
    transition: transform 0.2s ease-out;
}

/* Multiplayer menu with keyboard */
.keyboard-open #multiplayer-menu .mp-menu-content {
    padding: 10px;
    justify-content: flex-start;
}

.keyboard-open .mp-menu-buttons {
    gap: 10px;
    margin-bottom: 15px;
}

.keyboard-open .mp-menu-buttons .menu-btn {
    min-width: 200px;
    padding: 12px 20px;
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .keyboard-open .modal-content,
    .keyboard-open .screen {
        /* Prevent iOS bounce scroll issues */
        -webkit-overflow-scrolling: touch;
    }
}

/* Landscape mobile with keyboard - extra compact */
@media (max-height: 500px) and (orientation: landscape) {
    .keyboard-open .modal-content {
        padding: 10px;
    }

    .keyboard-open .modal-content h2 {
        font-size: 16px;
        margin-bottom: 5px;
    }

    .keyboard-open .mp-code-input {
        font-size: 18px;
        padding: 8px 12px;
        width: 140px;
    }

    .keyboard-open .mp-join-form {
        margin: 5px 0;
    }

    .keyboard-open .mp-join-form label {
        display: none;
    }

    .keyboard-open .modal-buttons {
        flex-direction: row;
        gap: 8px;
    }

    .keyboard-open .modal-buttons .menu-btn {
        padding: 8px 16px;
        font-size: 12px;
        min-width: auto;
    }

    /* Hide even more in extreme cases */
    .keyboard-open .mp-players-section {
        display: none;
    }

    .keyboard-open .mp-chat-messages {
        max-height: 60px;
    }
}
