/* Lobby Styles - Based on v1 design */

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --success: #48bb78;
    --success-dark: #38a169;
    --danger: #f56565;
    --danger-dark: #e53e3e;
    --warning: #ed8936;
    --warning-dark: #dd6b20;
    --bg-primary: #f7fafc;
    --bg-secondary: #edf2f7;
    --bg-card: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 16px;
    color: var(--text-primary);
    line-height: 1.6;
}

#lobby-container {
    max-width: 420px;
    margin: 0 auto;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-header {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.card-content {
    padding: 24px;
}

.header-top {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 0;
}

.lobby-title {
    font-size: 20px;
    font-weight: 600;
    color: white;
    text-align: center;
    margin-bottom: 12px;
}

.lobby-id {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.game-type {
    font-size: 13px;
    opacity: 0.8;
}

#auth-status {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.loader {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.user-info {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.user-name {
    font-weight: 500;
    font-size: 16px;
}

.stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
}

.stat {
    text-align: center;
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.divider {
    width: 1px;
    height: 40px;
    background: var(--border);
    margin: 0 16px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

#players-list {
    list-style: none;
    margin-bottom: 24px;
}

.player-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.player-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.player-card.player-ready {
    border-color: var(--success);
    background: rgba(72, 187, 120, 0.1);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: white;
    position: relative;
    overflow: hidden;
}

.player-avatar.has-image {
    background: #f0f0f0;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.host-crown {
    position: absolute;
    top: -2px;
    right: -2px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 2px solid #FFD700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.player-details {
    flex: 1;
}

.player-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
}

.player-role {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.player-status {
    font-size: 20px;
    transition: all 0.3s ease;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn {
    border: none;
    border-radius: var(--radius);
    padding: 14px 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.fullscreen-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    color: white;
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, var(--warning-dark) 100%);
    color: white;
}

.btn-warning:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-full {
    grid-column: span 2;
}

/* Lobby Settings Styles */
.settings-toggle {
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.settings-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.settings-toggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* === БЛОК НАСТРОЕК === */
.lobby-settings {
    margin-bottom: 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
}

.lobby-settings.collapsed {
    max-height: 0;
    border: 1px solid transparent;
    margin-bottom: 0;
    opacity: 0;
    transform: scaleY(0);
}

.lobby-settings:not(.collapsed) {
    max-height: 400px;
    transform: scaleY(1);
}

.settings-content {
    padding: 24px;
    display: grid;
    gap: 20px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.setting-item label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

/* === СЕЛЕКТЫ В СТИЛЕ ОСНОВНОГО ДИЗАЙНА === */
.setting-input {
    width: 100%;
    padding: 14px 40px 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    
    /* Стрелка в соответствии с цветовой схемой */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%234a5568' viewBox='0 0 16 16'%3e%3cpath d='M8 11L3 6h10l-5 5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    
    box-shadow: var(--shadow);
}

.setting-input:hover {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
}

.setting-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-input option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 500;
}

/* Custom select arrow now handled via background-image in .setting-input */

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    animation: slideInRight 0.3s ease-out;
    max-width: 320px;
    font-size: 14px;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animations */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.glow {
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

.bounce {
    animation: bounce 0.6s ease-out;
}

@keyframes bounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ====== V1 COMPATIBILITY STYLES ====== */

/* User info block with purple borders */
.user-info {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary);
    border-right: 4px solid var(--primary);
    text-align: center;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}

/* Players list improvements */
#players-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

/* Player ready state with shimmer effect */
.player-card.player-ready {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%) !important;
    color: white !important;
    border-color: var(--success);
}

/* Ensure text is readable in ready state */
.player-card.player-ready .player-name {
    color: white !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.player-card.player-ready .player-role {
    color: rgba(255, 255, 255, 0.9) !important;
    opacity: 1 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.player-card.player-ready .player-status {
    color: white !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.player-card.player-ready::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Player info layout */
.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-avatar.has-image {
    background: none;
    overflow: hidden;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.host-crown {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 12px;
}

.player-details {
    flex: 1;
}

.player-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

.player-role {
    font-size: 12px;
    opacity: 0.8;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Player status animations */
.player-status {
    transition: all 0.3s ease;
}

.ready-changing {
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.ready-changing .player-status {
    transition: all 0.15s ease;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .card-content {
        padding: 16px;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }

    .toast {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .stats-bar {
        padding: 12px;
    }

    .player-card {
        padding: 12px;
    }

    .player-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}