/* --- TOTALIZATOR: SPORTSBOOK PERFECT (V3.1 + FIXES) --- */

/* 1. Глобальные настройки */
#main_view {
    color: #2c3e50;
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: #f4f7f9;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #dce1e6;
    width: 100%;
    box-sizing: border-box;
}

/* Ссылки (КРОМЕ КНОПОК) */
#main_view a:not(.chelsea-btn-action):not(.chelsea-btn-small), 
.chelsea-tote-nav a {
    color: #034694 !important;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

#main_view a:not(.chelsea-btn-action):not(.chelsea-btn-small):hover, 
.chelsea-tote-nav a:hover {
    color: # !important;
    text-decoration: underline;
}

/* Админ панель */
#main_view a:not(.chelsea-btn-action):not(.chelsea-btn-small), 
.admin-links a {
    color: #034694 !important;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

#main_view a:not(.chelsea-btn-action):not(.chelsea-btn-small):hover, 
.admin-links a:hover {
    color: # !important;
    text-decoration: underline;
}

/* --- 2. Навигация --- */
.chelsea-tote-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    background: #fff;
    padding: 5px;
    border-radius: 6px;
    margin-bottom: 25px;
    border: 1px solid #dce1e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.tote-tab {
    color: #555 !important;
    background: #;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    flex-grow: 1;
    text-align: center;
}

.tote-tab:hover {
    background: #;
    color: #034694 !important;
}

.tote-tab.active {
    background: #034694;
    color: #fff !important;
    box-shadow: 0 2px 4px rgba(3, 70, 148, 0.2);
}

/* --- 3. Правила (Аккордеон) --- */
.chelsea-rules-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.chelsea-rule-card {
    background: #ffffff;
    border: 1px solid #e1e4e8;
    border-top: 3px solid #034694;
    border-radius: 4px;
    padding: 0;
    overflow: hidden;
}

.rule-header {
    font-size: 15px;
    font-weight: 700;
    color: #2c3e50;
    padding: 15px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    transition: background 0.2s;
}
.rule-header:hover { background: #f8f9fa; color: #034694; }
.active-header { background: #f1f3f5; border-bottom: 1px solid #e1e4e8; }

.plus-icon { font-size: 18px; font-weight: bold; color: #034694; }

/* Скрытый контент */
.rule-content {
    display: none; 
    padding: 15px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.rule-list { padding-left: 15px; margin: 0; color: #555; font-size: 13px; }
.point-badge { background: #034694; color: #fff; padding: 3px 6px; border-radius: 3px; font-weight: bold; font-family: monospace; }
.important-rule { color: #d9534f; font-weight: 600; }


/* --- 4. Карточки Матчей --- */
.tote-matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.tote-match-card {
    background: #ffffff;
    border: 1px solid #dce1e6;
    border-radius: 4px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.tote-card-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #7f8c8d;
    background: #f8f9fa;
    padding: 8px 12px;
    border-bottom: 1px solid #ebebeb;
    font-weight: 600;
    text-transform: uppercase;
}

/* Команды по бокам (Desktop) */
.tote-card-main {
    text-align: center;
    padding: 15px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.tote-team {
    font-weight: 700;
    color: #2c3e50;
    font-size: 14px;
    flex: 1;
    word-wrap: break-word;
}
.team-home { text-align: right; padding-right: 10px; }
.team-away { text-align: left; padding-left: 10px; }

.tote-score-area {
    background: #f0f2f5;
    padding: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    border: 1px solid #dce1e6;
}

/* --- ФИКС АДМИНКИ (чтобы матчи не косились) --- */
.admin-mode .tote-card-main {
    display: block !important;
    text-align: center;
    color: #034694;
    font-weight: bold;
    padding: 20px 10px;
}
.admin-score-edit { background: #fff; padding: 10px; text-align: center; border-top: 1px solid #eee; }
.admin-footer { background: #f8f9fa; padding: 10px; display: flex; justify-content: space-between; }
/* ----------------------------------------------- */

/* Инпуты */
.tote-inputs-wrapper { display: flex; align-items: center; gap: 5px; }

.tote-input {
    background: #fff !important; color: #333 !important; border: 2px solid #dce1e6;
    width: 38px; height: 35px; text-align: center; border-radius: 4px;
    font-weight: bold; font-size: 16px; font-family: monospace;
}
.tote-input:focus { border-color: #034694; outline: none; box-shadow: 0 0 0 3px rgba(3, 70, 148, 0.1); }
.tote-input.input-changed { border-color: #28a745; background-color: #f4fff7 !important; }

.tote-divider { color: #7f8c8d; font-weight: bold; margin: 0 2px; }
.tote-status { display: none; }
.tote-final-score { font-size: 24px; font-weight: 800; color: #2c3e50; font-family: monospace; letter-spacing: 1px; }
.score-wait { font-size: 20px; color: #aaa; }

.tote-card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #7f8c8d;
    background: #fff;
    padding: 8px 12px;
    border-top: 1px solid #ebebeb;
    text-transform: uppercase;
    font-weight: 600;
}
.tote-stat span { color: #2c3e50; font-weight: bold; margin-left: 4px; }

/* Кнопка "Сохранить" - СИНЯЯ */
.mass-save-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
}
.mass-save-btn input {
    background: #034694; /* CHELSEA BLUE */
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(3, 70, 148, 0.4);
    cursor: pointer;
    transition: background 0.2s;
}
.mass-save-btn input:hover { background: #002a5c; }

/* --- 5. Таблицы (ИСПРАВЛЕНЫ ШИРИНЫ И НАЕЗДАНИЕ ТЕКСТА) --- */
.leaderboard-list {
    background: #ffffff; border-radius: 4px; border: 1px solid #dce1e6;
    overflow: hidden; margin-top: 15px;
}

/* Общий рейтинг (Rank | User | Points) */
.leaderboard-header {
    display: grid; 
    grid-template-columns: 40px 1fr 60px; /* Фиксированные края, гибкий центр */
    background: #f1f3f5; color: #495057; padding: 12px 15px;
    font-weight: 700; font-size: 12px; text-transform: uppercase; border-bottom: 2px solid #dce1e6;
}
.leaderboard-row {
    display: grid; 
    grid-template-columns: 40px 1fr 60px; /* То же самое для строк */
    padding: 10px 15px; border-bottom: 1px solid #ebebeb; color: #333; align-items: center; font-size: 13px;
}

/* Рейтинг матча (User | Bet | Points) - отдельная структура */
.bets-list-header {
    display: grid; 
    grid-template-columns: 1fr 100px 60px; /* 100px для счета достаточно */
    background: #f1f3f5; color: #495057; padding: 10px 15px;
    font-weight: 700; font-size: 12px; text-transform: uppercase; border-bottom: 2px solid #dce1e6;
}
.bets-list-row {
    display: grid; 
    grid-template-columns: 1fr 100px 60px;
    padding: 10px 15px; border-bottom: 1px solid #ebebeb; color: #333; align-items: center; font-size: 13px;
}

.leaderboard-row:nth-child(even), .bets-list-row:nth-child(even) { background: #f8f9fa; }
.leaderboard-row:hover, .bets-list-row:hover { background: #eef2f7; }

.lb-rank { font-weight: 700; color: #7f8c8d; text-align: center; }
.rank-top .lb-rank { color: #d1a603; font-size: 1.1em; }
.lb-name a { color: #034694 !important; font-weight: 600; }
.lb-points { font-weight: 700; text-align: center; color: #2c3e50; }

.bet-col, .points-col { font-family: monospace; font-weight: bold; text-align: center; }

/* --- 6. Страница Матча --- */
.tote-single-match-header {
    background: #fff; border: 1px solid #dce1e6; border-top: 4px solid #034694;
    padding: 25px; border-radius: 4px; text-align: center; margin-bottom: 25px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.single-teams { 
    font-size: 26px; font-weight: 800; color: #2c3e50; margin: 15px 0;
    display: flex; align-items: center; justify-content: center; gap: 15px; /* FIX: Разделение команд */
}
.single-result { font-size: 36px; font-weight: 900; color: #034694; margin-top: 10px; }

.points-three { color: #fff; background: #28a745; padding: 2px 8px; border-radius: 4px; }
.points-two { color: #2c3e50; background: #ffc107; padding: 2px 8px; border-radius: 4px; }
.points-one { color: #fff; background: #17a2b8; padding: 2px 8px; border-radius: 4px; }
.points-zero { color: #aaa; }

/* --- 7. Админка и Кнопки (FIX) --- */
.admin-list-container { background: #fff; padding: 20px; border-radius: 4px; border: 1px solid #dce1e6; }
.admin-item-row { background: #fff; border: 1px solid #ebebeb; margin-bottom: 5px; border-radius: 4px; padding: 8px 15px; display: flex; justify-content: space-between; align-items: center; }
.admin-panel-bar { background: #2c3e50; color: #fff; padding: 10px 15px; border-radius: 4px; font-size: 13px; margin-bottom: 20px; }
.admin-panel-bar a { color: #aab8c2 !important; margin: 0 10px; }
.admin-actions-bar { margin-bottom: 20px; text-align: right; }

/* ФИКС КНОПКИ АДМИНКИ: Принудительный белый текст */
.chelsea-btn-action {
    background: #034694; 
    color: #fff !important; 
    border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; 
    font-weight: 700; text-transform: uppercase; font-size: 12px;
    display: inline-block;
}
.chelsea-btn-action:hover { background: #002a5c; color: #fff !important; text-decoration: none !important; }

.chelsea-btn-small { background: #034694; color: #fff !important; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.chelsea-btn-text { background: transparent; color: #777 !important; border: none; cursor: pointer; font-size: 12px; text-transform: uppercase; }
.chelsea-btn-text:hover { color: #d9534f !important; text-decoration: underline; }

/* --- МОБИЛЬНАЯ АДАПТАЦИЯ (v3.1) --- */
@media screen and (max-width: 768px) {
    #main_view { padding: 10px 0; border: none; background: transparent; }
    
    .tote-matches-grid {
        grid-template-columns: 1fr !important; /* Одна колонка */
    }
    
    .tote-match-card {
        margin-bottom: 15px;
    }
    
    /* Уменьшаем шрифты на телефоне */
    .tote-team { font-size: 13px; }
    .tote-card-main { padding: 10px; }
    
    /* Лидерборд сжимаем и предотвращаем наложение текста */
    .leaderboard-row, .leaderboard-header {
        grid-template-columns: 30px 1fr 50px !important; /* Узкий ранк, широкий ник */
        font-size: 11px;
        padding: 8px 5px;
    }
    
    /* Таблица прогнозов (Ник - Ставка - Очки) */
    .bets-list-row, .bets-list-header {
        grid-template-columns: 1fr 70px 30px !important; /* Больше места нику */
        font-size: 11px;
        padding: 8px 5px;
    }
    
    /* Обрезка длинных никнеймов с троеточием */
    .lb-name, .user-col {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        display: block;
    }
    
    .chelsea-tote-nav { background: #fff; padding: 5px; border-radius: 8px; }
}



/* --- СТИЛИ ДЛЯ ВЫБОРА СОСТАВА (LINEUP BUILDER) --- */

.lineup-section {
    margin-top: 30px;
    border-top: 2px solid #e1e4e8;
    padding-top: 20px;
}

.lineup-title {
    font-size: 16px;
    font-weight: 800;
    color: #2c3e50;
    text-transform: uppercase;
    margin-bottom: 15px;
    text-align: center;
}

/* Поле */
.pitch-container {
    position: relative;
    width: 100%;
    max-width: 450px; /* Ограничиваем ширину */
    height: 550px;
    background-color: #2e7d32;
    background-image: repeating-linear-gradient(0deg, transparent, transparent 50px, rgba(0,0,0,0.1) 50px, rgba(0,0,0,0.1) 100px);
    border: 2px solid #fff;
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    margin: 0 auto 20px auto; /* Центрируем */
}

/* Линии поля */
.pitch-lines { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.pitch-lines::before { content: ''; position: absolute; top: 50%; left: 0; width: 100%; height: 2px; background: rgba(255,255,255,0.6); }
.pitch-circle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80px; height: 80px; border: 2px solid rgba(255,255,255,0.6); border-radius: 50%; }
.pitch-box-top { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 180px; height: 80px; border: 2px solid rgba(255,255,255,0.6); border-top: none; }
.pitch-box-bottom { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 180px; height: 80px; border: 2px solid rgba(255,255,255,0.6); border-bottom: none; }

/* Игрок */
.pitch-player {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    width: 70px;
    z-index: 10;
}
.pitch-player:hover .player-kit { transform: scale(1.1); box-shadow: 0 0 10px rgba(255,255,255,0.8); }

.player-kit {
    width: 36px; height: 36px;
    background: #034694;
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 12px; color: #fff;
    box-shadow: 0 4px 5px rgba(0,0,0,0.3);
    margin-bottom: 4px;
    transition: transform 0.2s;
}
.player-kit.empty { background: rgba(0,0,0,0.3); border: 2px dashed rgba(255,255,255,0.5); color: rgba(255,255,255,0.7); }

.player-name-label {
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* Модальное окно списка игроков */
.player-modal {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.modal-content {
    background: #fff;
    width: 90%; max-width: 350px;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex; flex-direction: column; max-height: 80vh;
}
.modal-header { padding: 15px; background: #034694; color: #fff; font-weight: bold; text-align: center; }
.modal-list { overflow-y: auto; flex: 1; padding: 10px; }
.player-option {
    padding: 12px; border-bottom: 1px solid #f0f0f0; cursor: pointer; color: #333; display: flex; justify-content: space-between;
}
.player-option:hover { background: #f4f7f9; color: #034694; }
.modal-close-btn {
    width: 100%; padding: 15px; background: #f8f9fa; border: none; border-top: 1px solid #eee; color: #777; font-weight: bold; cursor: pointer;
}