* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a1a;
    color: white;
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

/* Login Screen */
.login-container, .menu-container, .connecting-container, .gameover-container {
    text-align: center;
    padding: 40px 20px;
    max-width: 400px;
    width: 100%;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #4FC3F7, #81D4FA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.subtitle {
    color: #666;
    margin-bottom: 40px;
}

.welcome {
    color: #888;
    margin-bottom: 32px;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    padding: 16px;
    border: 1px solid #333;
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    color: white;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: #4FC3F7;
}

.error {
    color: #E53935;
    font-size: 14px;
    min-height: 20px;
}

.register-hint {
    margin-top: 24px;
    color: #666;
    font-size: 14px;
}

.register-hint a {
    color: #4FC3F7;
    text-decoration: none;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.1s, opacity 0.2s;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    padding: 20px 32px;
    background: linear-gradient(135deg, #4FC3F7, #2196F3);
    color: white;
    border-radius: 12px;
    width: 100%;
    min-height: 56px;
}

.btn-primary:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    padding: 16px 32px;
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-text {
    background: none;
    border: none;
    color: #666;
    padding: 12px;
    cursor: pointer;
}

.btn-text:hover {
    color: #4FC3F7;
}

/* Menu */
.menu-container {
    max-width: 320px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
}

.join-room {
    display: flex;
    gap: 8px;
}

.join-room input {
    flex: 1;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 2px;
    font-size: 14px;
    padding: 14px;
}

.join-room button {
    flex-shrink: 0;
    padding: 14px 20px;
}

/* Game Mode Picker */
.mode-picker {
    margin-bottom: 20px;
    width: 100%;
}

.mode-label {
    display: block;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.mode-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: linear-gradient(135deg, #4FC3F7, #2196F3);
    color: white;
}

.mode-btn:not(.active):hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.controls-hint {
    font-size: 12px;
    color: #666;
    margin-bottom: 16px;
}

/* Connecting */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #333;
    border-top-color: #4FC3F7;
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 1s linear infinite;
}

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

/* Game Canvas */
#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Top bar */
.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px;
    padding-top: env(safe-area-inset-top, 16px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.time-display {
    font-size: 1.3rem;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 16px;
    border-radius: 8px;
}

.room-code-display {
    position: absolute;
    right: 60px;
    top: 16px;
    font-size: 0.9rem;
    color: #666;
    font-family: monospace;
}

.map-name {
    position: absolute;
    left: 90px;
    top: 16px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 10px;
    border-radius: 6px;
}

.trophy-btn {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    font-size: 18px;
    cursor: pointer;
    pointer-events: auto;
}

.trophy-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.exit-btn {
    position: absolute;
    left: 16px;
    top: 16px;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    font-size: 14px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    pointer-events: auto;
}

.exit-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Bottom center score (iOS-style) */
.bottom-score {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 24px;
    border-radius: 12px;
}

.score-column {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 50px;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.red-score, .blue-score {
    font-size: 2.2rem;
    font-weight: bold;
}

.red-score { color: #E53935; }
.blue-score { color: #2196F3; }
.separator { color: #666; font-size: 1.8rem; font-weight: bold; }

.red-flag-indicator, .blue-flag-indicator {
    font-size: 14px;
    height: 18px;
}

.red-flag-indicator {
    color: #FFD700;
}

.blue-flag-indicator {
    color: #FFD700;
}

/* Countdown overlay */
#countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

#countdown-overlay.hidden {
    display: none;
}

.countdown-content {
    text-align: center;
}

.countdown-number {
    font-size: 120px;
    font-weight: bold;
    color: #4FC3F7;
    text-shadow: 0 0 30px rgba(79, 195, 247, 0.5);
    margin-bottom: 30px;
}

.countdown-players {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.countdown-team {
    text-align: center;
}

.countdown-team-label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.countdown-team-label.red { color: #E53935; }
.countdown-team-label.blue { color: #2196F3; }

.countdown-player {
    padding: 4px 0;
    color: #ccc;
    font-size: 14px;
}

.countdown-player.you {
    color: #fff;
    font-weight: bold;
}

/* Stats Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-backdrop.hidden {
    display: none;
}

.stats-modal-content {
    background: rgba(10, 10, 26, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 24px;
    min-width: 300px;
    max-width: 90vw;
}

.stats-modal-content h3 {
    text-align: center;
    margin-bottom: 16px;
    color: #4FC3F7;
}

.stats-modal-content table {
    border-collapse: collapse;
    width: 100%;
}

.stats-modal-content th, .stats-modal-content td {
    padding: 8px;
}

.stats-modal-content th {
    color: #888;
    font-weight: normal;
}

.stats-modal-content button {
    margin-top: 16px;
    width: 100%;
}

/* Virtual Joystick */
#joystick-zone {
    position: fixed;
    left: 20px;
    bottom: 20px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    touch-action: none;
}

#joystick-base {
    width: 150px;
    height: 150px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#joystick-stick {
    width: 60px;
    height: 60px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    position: absolute;
    transition: none;
}

/* Action Buttons - hidden on mobile, shown on desktop */
#action-buttons {
    position: fixed;
    right: 20px;
    bottom: 20px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    display: none;
    gap: 12px;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid rgba(255,255,255,0.3);
}

.action-btn:active {
    background: rgba(255,255,255,0.3);
}

/* Game Over */
.gameover-container h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

#final-score {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #888;
}

#gameover-stats {
    margin-bottom: 24px;
    max-height: 300px;
    overflow-y: auto;
}

.gameover-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.gameover-stats-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid #444;
    color: #aaa;
}

.gameover-stats-table td {
    padding: 6px 12px;
}

.gameover-buttons {
    margin-top: 16px;
}

.gameover-container button {
    margin-bottom: 12px;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    #joystick-zone {
        left: 40px;
        bottom: 40px;
    }

    #joystick-base {
        width: 180px;
        height: 180px;
    }

    #joystick-stick {
        width: 70px;
        height: 70px;
    }

    #action-buttons {
        display: flex;
        right: 40px;
        bottom: 40px;
    }

    .action-btn {
        width: 80px;
        height: 80px;
        font-size: 14px;
    }

    .gameover-container {
        max-width: 800px;
    }

    #gameover-stats {
        max-height: none;
        overflow-y: visible;
    }

    .gameover-stats-table {
        font-size: 16px;
    }

    .gameover-stats-table th,
    .gameover-stats-table td {
        padding: 10px 16px;
    }
}

/* Leaderboard */
#leaderboard {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 16px;
    padding: 24px;
    min-width: 280px;
    z-index: 100;
}

#leaderboard.hidden {
    display: none;
}

#leaderboard h3 {
    text-align: center;
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: #4FC3F7;
}

#leaderboard-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-team {
    margin-bottom: 12px;
}

.leaderboard-team-header {
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.leaderboard-team-header.red {
    background: rgba(230, 74, 74, 0.3);
    color: #E53935;
}

.leaderboard-team-header.blue {
    background: rgba(74, 128, 230, 0.3);
    color: #4a80e6;
}

.leaderboard-player {
    padding: 4px 12px;
    font-size: 0.9rem;
    color: #ccc;
}

.leaderboard-player.local {
    color: white;
    font-weight: bold;
}

#leaderboard .hint {
    text-align: center;
    color: #666;
    font-size: 0.8rem;
    margin-top: 16px;
}

/* Chat */
#chat-container {
    position: fixed;
    bottom: 100px;
    left: 20px;
    width: 300px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 8px;
    z-index: 100;
}

#chat-container.hidden {
    display: none;
}

#chat-messages {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 8px;
    font-size: 13px;
}

.chat-message {
    padding: 2px 0;
    word-wrap: break-word;
}

.chat-message.team {
    color: #88ff88;
}

.chat-message .name {
    font-weight: bold;
}

.chat-message .name.red {
    color: #E53935;
}

.chat-message .name.blue {
    color: #2196F3;
}

#chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-prefix {
    font-size: 12px;
    color: #888;
    flex-shrink: 0;
}

#chat-prefix.team {
    color: #88ff88;
}

#chat-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #444;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    outline: none;
}

#chat-input:focus {
    border-color: #4FC3F7;
}

/* Room Lobby Screen */
.room-lobby-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    padding: 16px;
    padding-top: env(safe-area-inset-top, 16px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.lobby-header h2 {
    color: #4FC3F7;
    font-size: 1.3rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.2);
}

.btn-icon-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    color: #888;
    font-size: 14px;
}

/* Profile Card */
.profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    margin-bottom: 16px;
}

.profile-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(79, 195, 247, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
}

.profile-info {
    flex: 1;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

#profile-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.profile-stats-row {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #888;
    font-size: 0.9rem;
}

.level-badge {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Stats Panel */
.stats-panel {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.stats-section {
    margin-bottom: 16px;
}

.stats-section:last-child {
    margin-bottom: 0;
}

.stats-section h4 {
    color: #888;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    font-size: 0.85rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-weight: 600;
    color: white;
}

.stat-label {
    color: #666;
    font-size: 0.7rem;
}

/* Lobby Actions */
.lobby-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mode-chips {
    display: flex;
    gap: 8px;
}

.mode-chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    color: #888;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
}

.mode-chip.active {
    background: linear-gradient(135deg, #4FC3F7, #2196F3);
    color: white;
}

.lobby-actions .btn-primary {
    flex: 1;
    padding: 12px 16px;
    min-height: auto;
}

/* Games List */
.games-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: #888;
    font-size: 0.9rem;
}

#games-count {
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.games-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.no-games {
    color: #666;
    text-align: center;
    padding: 40px;
}

/* Game Card */
.game-card {
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 16px;
}

.game-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.mode-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.mode-badge.ctf {
    background: rgba(255, 152, 0, 0.2);
    color: #FF9800;
}

.mode-badge.nf {
    background: rgba(156, 39, 176, 0.2);
    color: #9C27B0;
}

.phase-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.phase-badge.waiting {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.phase-badge.countdown {
    background: rgba(255, 193, 7, 0.2);
    color: #FFC107;
}

.phase-badge.playing {
    background: rgba(33, 150, 243, 0.2);
    color: #2196F3;
}

.phase-badge.finished {
    background: rgba(158, 158, 158, 0.2);
    color: #9E9E9E;
}

.phase-badge.forming {
    background: rgba(255, 152, 0, 0.2);
    color: #FF9800;
    animation: pulse-forming 1.5s ease-in-out infinite;
}

@keyframes pulse-forming {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.game-card.forming {
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.game-card .slots-info {
    font-size: 0.85rem;
    color: #aaa;
}

.game-time {
    margin-left: auto;
    color: #888;
    font-size: 0.9rem;
}

.game-card-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}

.game-card-score .red {
    font-size: 1.8rem;
    font-weight: bold;
    color: #E53935;
}

.game-card-score .blue {
    font-size: 1.8rem;
    font-weight: bold;
    color: #2196F3;
}

.game-card-score .sep {
    color: #666;
    font-size: 1.4rem;
}

.game-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-count {
    color: #888;
    font-size: 0.85rem;
}

.game-card-actions {
    display: flex;
    gap: 8px;
}

.game-card-actions button {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.btn-spectate {
    background: rgba(255,255,255,0.1);
    color: #888;
}

.btn-join {
    background: linear-gradient(135deg, #4FC3F7, #2196F3);
    color: white;
}

/* Lobby overlay improvements */
.lobby-code-display {
    font-family: monospace;
    font-size: 1.5rem;
    color: #4FC3F7;
    margin-bottom: 8px;
    letter-spacing: 4px;
}

.lobby-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.lobby-buttons .btn-primary {
    max-width: 200px;
    margin: 0 auto;
}

.lobby-player-ready {
    color: #4CAF50;
    margin-left: auto;
}

.lobby-player.ready {
    background: rgba(76, 175, 80, 0.1);
}

/* ==================== Create Room Modal ==================== */
.create-room-modal-content {
    background: rgba(10, 10, 26, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 24px;
    width: 90vw;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    margin: 0;
    color: #4FC3F7;
}

.create-room-form .form-group {
    margin-bottom: 20px;
}

.create-room-form label {
    display: block;
    margin-bottom: 8px;
    color: #aaa;
    font-size: 0.9rem;
}

.create-room-form select {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
}

.players-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.players-btn {
    flex: 1;
    min-width: 50px;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: #888;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.players-btn.active {
    background: linear-gradient(135deg, #4FC3F7, #2196F3);
    color: white;
    border-color: transparent;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
}

.seat-config {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.seat-config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
}

.seat-config-row.red { border-left: 3px solid #E53935; }
.seat-config-row.blue { border-left: 3px solid #1E88E5; }

.seat-config-row .seat-num {
    width: 24px;
    color: #666;
    font-size: 0.8rem;
}

.seat-config-row select {
    flex: 1;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: white;
    font-size: 0.85rem;
}

.btn-full {
    width: 100%;
}

/* ==================== Profile Modal ==================== */
.profile-modal-content {
    background: rgba(10, 10, 26, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 24px;
    width: 90vw;
    max-width: 360px;
}

.profile-form .form-group {
    margin-bottom: 20px;
}

.profile-form label {
    display: block;
    margin-bottom: 8px;
    color: #aaa;
    font-size: 0.9rem;
}

.profile-form input[type="text"] {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
}

.flair-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.flair-option {
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
}

.flair-option.selected {
    background: rgba(79, 195, 247, 0.2);
    border-color: #4FC3F7;
}

.no-flairs {
    color: #666;
    font-style: italic;
}

/* ==================== Invite Code Modal ==================== */
.invite-code-modal-content {
    background: rgba(10, 10, 26, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 24px;
    width: 90vw;
    max-width: 320px;
}

.invite-code-modal-content input {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 4px;
}

/* ==================== Transfer Leadership Modal ==================== */
.transfer-leader-modal-content {
    background: rgba(10, 10, 26, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 24px;
    width: 90vw;
    max-width: 320px;
}

.transfer-player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.transfer-player-btn {
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.transfer-player-btn:hover {
    background: rgba(79, 195, 247, 0.2);
}

.transfer-player-btn.red {
    border-left: 3px solid #E53935;
}

.transfer-player-btn.blue {
    border-left: 3px solid #1E88E5;
}

/* ==================== Auto-join Toggle ==================== */
.lobby-action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.auto-join-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #888;
    font-size: 0.9rem;
}

.auto-join-toggle input {
    width: 18px;
    height: 18px;
}

#create-room-lobby-btn {
    flex: 1;
    transition: all 0.3s;
}

#create-room-lobby-btn.disabled {
    background: #444;
    color: #666;
    pointer-events: none;
}

/* ==================== Seat Lobby Screen ==================== */
.seat-lobby-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    padding-top: env(safe-area-inset-top, 16px);
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

.seat-lobby-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.room-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.room-code {
    font-family: monospace;
    font-size: 1.2rem;
    color: #4FC3F7;
    letter-spacing: 2px;
}

.map-name {
    font-size: 0.85rem;
    color: #888;
}

.teams-container {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.team-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.team-header {
    text-align: center;
    padding: 8px;
    border-radius: 8px 8px 0 0;
    margin: 0;
    font-size: 1rem;
}

.team-header.red { background: rgba(229, 57, 53, 0.3); color: #ff6b6b; }
.team-header.blue { background: rgba(30, 136, 229, 0.3); color: #64b5f6; }

.seats-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: rgba(255,255,255,0.03);
    border-radius: 0 0 8px 8px;
    overflow-y: auto;
}

.seat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.seat-item:hover {
    background: rgba(255,255,255,0.1);
}

.seat-item.occupied {
    cursor: default;
}

.seat-item.my-seat {
    background: rgba(79, 195, 247, 0.2);
    border: 1px solid rgba(79, 195, 247, 0.4);
}

.seat-item.ready {
    background: rgba(76, 175, 80, 0.2);
}

.seat-item.bot {
    opacity: 0.6;
}

.seat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.seat-avatar.red { background: #E53935; }
.seat-avatar.blue { background: #1E88E5; }
.seat-avatar.empty { background: rgba(255,255,255,0.1); color: #666; }

.seat-name {
    flex: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.seat-name.empty {
    color: #666;
    font-style: italic;
}

.seat-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: #888;
}

.seat-badge.ready {
    background: rgba(76, 175, 80, 0.3);
    color: #4CAF50;
}

.seat-badge.host {
    background: rgba(255, 193, 7, 0.3);
    color: #FFC107;
}

.seat-kick {
    padding: 4px 8px;
    font-size: 1rem;
    background: rgba(229, 57, 53, 0.2);
    color: #ff6b6b;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.seat-kick:hover {
    background: rgba(229, 57, 53, 0.4);
}

#seat-lobby-start:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vs-divider {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    color: #444;
    font-weight: bold;
}

.invite-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    margin: 12px 0;
}

.invite-code {
    font-family: monospace;
    font-size: 1.2rem;
    color: #4FC3F7;
    letter-spacing: 2px;
}

/* Lobby Chat */
.seat-lobby-chat {
    margin: 12px 0;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    overflow: hidden;
}

.seat-lobby-chat .chat-messages {
    height: 120px;
    overflow-y: auto;
    padding: 8px;
}

.seat-lobby-chat .chat-msg {
    padding: 4px 0;
    font-size: 0.85rem;
}

.seat-lobby-chat .chat-msg .sender {
    font-weight: bold;
    margin-right: 8px;
}

.seat-lobby-chat .chat-msg .sender.red { color: #ff6b6b; }
.seat-lobby-chat .chat-msg .sender.blue { color: #64b5f6; }

.seat-lobby-chat .chat-input-row {
    display: flex;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.seat-lobby-chat input {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.9rem;
}

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

.seat-lobby-chat button {
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: #4FC3F7;
    font-size: 1.1rem;
    cursor: pointer;
}

.seat-lobby-actions {
    display: flex;
    gap: 12px;
    padding-top: 12px;
}

.seat-lobby-actions button {
    flex: 1;
}

/* Desktop adjustments for seat lobby */
@media (min-width: 768px) {
    .seat-lobby-container {
        max-width: 800px;
        margin: 0 auto;
    }

    .seat-lobby-chat .chat-messages {
        height: 150px;
    }

    .teams-container {
        gap: 24px;
    }
}

/* ==================== Enhanced Game Cards ==================== */
.game-card {
    background: rgba(20, 20, 40, 0.9);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.game-card-preview {
    position: relative;
    height: 100px;
}

.map-preview {
    width: 100%;
    height: 100%;
}

.map-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.map-name-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #aaa;
}

.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    padding: 8px;
    pointer-events: none;
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 45%;
}

.player-list .player-name {
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.blue-list .player-name {
    color: #64b5f6;
    border-left: 2px solid #1E88E5;
}

.red-list .player-name {
    color: #ff6b6b;
    border-right: 2px solid #E53935;
    text-align: right;
}

.score-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    gap: 8px;
}

.score-overlay .red { color: #ff6b6b; }
.score-overlay .blue { color: #64b5f6; }
.score-overlay .sep { color: #666; }

.game-card-info {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-card-info .game-card-actions {
    display: flex;
    gap: 8px;
}

.game-card-info .btn-spectate {
    padding: 6px 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    font-size: 0.9rem;
}

.game-card-info .btn-join {
    padding: 6px 14px;
    background: linear-gradient(135deg, #4FC3F7, #2196F3);
    border-radius: 6px;
    font-size: 0.85rem;
}

/* ==================== Discharge RB Button ==================== */
.discharge-rb-btn {
    position: fixed;
    bottom: 100px;
    right: 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #ff4444, #cc0000);
    border: 2px solid #ff6666;
    border-radius: 50px;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
    z-index: 150;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: scale(1);
    animation: pulse-rb 1.5s infinite;
}

.discharge-rb-btn:active {
    transform: scale(0.95);
}

.discharge-rb-btn.hidden {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}


@keyframes pulse-rb {
    0%, 100% { box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(255, 0, 0, 0.7); }
}

@media (min-width: 768px) {
    .discharge-rb-btn {
        bottom: 120px;
        right: 40px;
        padding: 14px 24px;
    }
}
