/* ============================================================
   RESET & БАЗОВЫЕ НАСТРОЙКИ
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, system-ui, sans-serif;
}

/* ============================================================
   ПЕРЕМЕННЫЕ (Тёмная тема по умолчанию)
   ============================================================ */
:root {
    --bg-body: #0b171c;
    --bg-container: rgba(20, 40, 46, 0.95);
    --bg-card: #0d1e24;
    --bg-input: #0b171c;
    --bg-result: #14282e;
    --bg-tab: #1b343d;
    --bg-tab-active: #2d5866;
    --border-color: #1d3a42;
    --border-light: #2b4f5a;
    --text-primary: #e0f0f5;
    --text-secondary: #7a9ca8;
    --text-muted: #4a6b77;
    --gold: #f5c542;
    --green: #4cd9a0;
    --blue: #5ab0d9;
    --red: #e07a7a;
    --shadow: rgba(0, 0, 0, 0.8);
    --scrollbar-track: #0b171c;
    --scrollbar-thumb: #2b4f5a;
}

/* ============================================================
   СВЕТЛАЯ ТЕМА
   ============================================================ */
body.light-mode {
    --bg-body: #e8f0f5;
    --bg-container: rgba(255, 255, 255, 0.95);
    --bg-card: #f0f5f8;
    --bg-input: #ffffff;
    --bg-result: #eaf0f4;
    --bg-tab: #dce4e9;
    --bg-tab-active: #b0c8d4;
    --border-color: #c0d0d8;
    --border-light: #b0c0c8;
    --text-primary: #1a2f36;
    --text-secondary: #4a6b77;
    --text-muted: #8a9ca8;
    --shadow: rgba(0, 0, 0, 0.15);
    --scrollbar-track: #dce4e9;
    --scrollbar-thumb: #b0c0c8;
}

/* ============================================================
   БАЗОВЫЕ СТИЛИ
   ============================================================ */
body {
    background: var(--bg-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1000px;
    width: 100%;
    background: var(--bg-container);
    backdrop-filter: blur(4px);
    border-radius: 40px;
    padding: 30px 25px;
    box-shadow: 0 25px 50px var(--shadow);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.hidden {
    display: none !important;
}

/* ============================================================
   ШАПКА
   ============================================================ */
.header {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 15px;
}

.logo {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 0 10px rgba(245, 197, 66, 0.3));
}

.header h1 {
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(245, 197, 66, 0.15);
    font-size: 2rem;
    margin-right: auto;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-theme {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--gold);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.btn-theme:hover {
    transform: scale(1.1);
    background: var(--bg-tab-active);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    background: var(--bg-card);
    padding: 6px 18px;
    border-radius: 30px;
    border: 1px solid var(--border-light);
}

/* ============================================================
   БАНКРОЛЛ
   ============================================================ */
.bankroll-section {
    background: var(--bg-card);
    padding: 15px 18px;
    border-radius: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
}

.bankroll-info {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 0.95rem;
}
.bankroll-info i {
    color: var(--gold);
    margin-right: 4px;
}
.bankroll-info strong {
    color: var(--gold);
}

.bet-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.bet-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}
.bet-controls input {
    width: 70px;
    padding: 6px 10px;
    border-radius: 30px;
    border: 1px solid var(--border-light);
    background: var(--bg-input);
    color: var(--text-primary);
    text-align: center;
}
.bet-controls input:focus {
    outline: 2px solid var(--gold);
}

.btn-auto,
.btn-stop {
    padding: 8px 20px;
    border: none;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    color: white;
}
.btn-auto {
    background: #2d7a5e;
}
.btn-auto:hover {
    background: #3a9a78;
    transform: translateY(-2px);
}
.btn-stop {
    background: #7a3d4a;
}
.btn-stop:hover {
    background: #a04d5e;
    transform: translateY(-2px);
}

/* ============================================================
   СТАТУС КОЛОДЫ
   ============================================================ */
.deck-status {
    background: var(--bg-card);
    padding: 18px 15px;
    border-radius: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.deck-status h3 {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 12px;
}
.deck-status h3 i {
    margin-right: 8px;
    color: var(--gold);
}

.card-count-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.card-badge {
    background: var(--bg-tab);
    border-radius: 30px;
    padding: 6px 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    transition: 0.2s;
}
.card-badge span {
    color: var(--gold);
    margin-left: 6px;
    font-weight: 700;
}
.card-badge:hover {
    transform: scale(1.05);
    background: var(--bg-tab-active);
}

/* ============================================================
   ВВОД КАРТ
   ============================================================ */
.input-section {
    background: var(--bg-card);
    padding: 20px 15px;
    border-radius: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.input-section label {
    display: block;
    margin-bottom: 12px;
    font-weight: 300;
    color: var(--text-secondary);
}
.input-section label i {
    margin-right: 6px;
    color: var(--gold);
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.btn-card {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    border: none;
    background: var(--bg-tab);
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-card:hover {
    background: var(--bg-tab-active);
    transform: translateY(-3px);
}
.btn-card:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.btn-card.btn-danger {
    background: #632c3a;
    box-shadow: 0 4px 0 #3d1b23;
}
.btn-card.btn-danger:hover {
    background: #8a3d4f;
}

.played-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    background: var(--bg-input);
    padding: 8px 14px;
    border-radius: 30px;
    margin-top: 8px;
}
.played-list .placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.played-chip {
    background: var(--bg-tab);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.95rem;
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.played-chip .del {
    cursor: pointer;
    color: var(--red);
    font-weight: bold;
    transition: 0.2s;
}
.played-chip .del:hover {
    color: #ff9999;
    transform: scale(1.2);
}

/* ============================================================
   БЫСТРЫЙ ВВОД РЕЗУЛЬТАТОВ
   ============================================================ */
.quick-input-section {
    background: var(--bg-card);
    padding: 15px 18px;
    border-radius: 20px;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.quick-input-section label {
    display: block;
    margin-bottom: 12px;
    font-weight: 300;
    color: var(--text-secondary);
}
.quick-input-section label i {
    color: var(--gold);
    margin-right: 6px;
}

.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.quick-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    flex: 1;
    min-width: 80px;
    justify-content: center;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.quick-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
}
.quick-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.quick-btn.player {
    background: linear-gradient(135deg, #2d7a5e, #1a4a3a);
}
.quick-btn.player:hover {
    background: linear-gradient(135deg, #3a9a78, #2d7a5e);
}

.quick-btn.banker {
    background: linear-gradient(135deg, #2d5866, #1a3a42);
}
.quick-btn.banker:hover {
    background: linear-gradient(135deg, #3a6a7a, #2d5866);
}

.quick-btn.tie {
    background: linear-gradient(135deg, #b8882a, #7a5a1a);
}
.quick-btn.tie:hover {
    background: linear-gradient(135deg, #d4a033, #b8882a);
}

.quick-btn.random {
    background: linear-gradient(135deg, #6d4c8a, #4a2a5a);
}
.quick-btn.random:hover {
    background: linear-gradient(135deg, #8c63af, #6d4c8a);
}

.quick-info {
    margin-top: 12px;
    padding: 8px 14px;
    background: var(--bg-input);
    border-radius: 30px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border: 1px solid var(--border-light);
}
.quick-info i {
    margin-right: 6px;
    color: var(--gold);
}

/* ============================================================
   АНИМАЦИЯ
   ============================================================ */
@keyframes flashGreen {
    0% { background: transparent; }
    50% { background: rgba(76, 217, 160, 0.3); }
    100% { background: transparent; }
}

.quick-flash {
    animation: flashGreen 0.6s ease;
}

/* ============================================================
   КНОПКИ ДЕЙСТВИЙ
   ============================================================ */
.action-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.action-row button {
    flex: 1;
    padding: 14px 12px;
    border: none;
    border-radius: 40px;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 120px;
}
.action-row button:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background: #2d7a5e;
}
.btn-primary:hover {
    background: #3a9a78;
    transform: translateY(-2px);
}

.btn-ai {
    background: #6d4c8a;
}
.btn-ai:hover {
    background: #8c63af;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #354f58;
}
.btn-secondary:hover {
    background: #4a6b77;
    transform: translateY(-2px);
}

.training-status {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--bg-input);
    border-radius: 30px;
    text-align: center;
    color: var(--gold);
    font-size: 0.9rem;
    border: 1px solid var(--border-light);
}
.training-status i {
    margin-right: 6px;
}

/* ============================================================
   ГРАФИК
   ============================================================ */
.chart-section {
    background: var(--bg-card);
    padding: 15px 18px;
    border-radius: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
.chart-section h4 {
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.chart-section h4 i {
    color: var(--gold);
    margin-right: 6px;
}
.chart-section canvas {
    max-height: 150px;
}

/* ============================================================
   РЕЗУЛЬТАТЫ
   ============================================================ */
.results {
    margin-top: 20px;
    background: var(--bg-card);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.method-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.method-tabs button {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-tab);
    border: none;
    border-radius: 30px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 100px;
}
.method-tabs button.active {
    background: var(--bg-tab-active);
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(45, 88, 102, 0.3);
}
.method-tabs button i {
    font-size: 1.1rem;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 18px;
}
.result-item {
    background: var(--bg-result);
    padding: 14px 8px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: 0.2s;
}
.result-item:hover {
    transform: translateY(-2px);
}
.result-item .label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}
.result-item .label i {
    margin-right: 4px;
}
.result-item .value {
    font-size: 1.8rem;
    font-weight: 700;
}
.value.green {
    color: var(--green);
}
.value.blue {
    color: var(--blue);
}
.value.gold {
    color: var(--gold);
}

.ev-box {
    background: var(--bg-input);
    padding: 14px 12px;
    border-radius: 16px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.ev-item {
    text-align: center;
}
.ev-item .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: block;
}
.ev-item .number {
    font-weight: 700;
    font-size: 1.2rem;
}

.recommendation {
    text-align: center;
    padding: 16px 12px;
    border-radius: 40px;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
    background: var(--bg-result);
    color: var(--text-secondary);
    transition: 0.3s;
}
.recommendation i {
    margin-right: 8px;
}
.recommendation.positive {
    background: #1e4a3c;
    color: var(--green);
    border: 1px solid #2d7a5e;
}
.recommendation.negative {
    background: #4a2e33;
    color: var(--red);
    border: 1px solid #7a3d4a;
}

.footer-note {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 16px;
}

/* ============================================================
   ИСТОРИЯ
   ============================================================ */
.history-section {
    margin-top: 20px;
    background: var(--bg-card);
    border-radius: 20px;
    padding: 18px;
    border: 1px solid var(--border-color);
}
.history-section h4 {
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.history-section h4 i {
    color: var(--gold);
    margin-right: 6px;
}

.history-controls {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.btn-small {
    padding: 6px 16px;
    background: var(--bg-tab);
    border: 1px solid var(--border-light);
    border-radius: 30px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
}
.btn-small:hover {
    background: var(--bg-tab-active);
}
.btn-small.btn-danger {
    background: #632c3a;
    color: white;
    border-color: #7a3d4a;
}
.btn-small.btn-danger:hover {
    background: #8a3d4f;
}

.table-wrapper {
    max-height: 200px;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}
.table-wrapper::-webkit-scrollbar {
    width: 6px;
}
.table-wrapper::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 10px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

#historyTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
#historyTable th {
    background: var(--bg-tab);
    color: var(--text-secondary);
    padding: 10px 12px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}
#historyTable td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}
#historyTable tr:hover td {
    background: var(--bg-result);
}
#historyTable .win {
    color: var(--green);
}
#historyTable .loss {
    color: var(--red);
}
#historyTable .tie {
    color: var(--gold);
}

/* ============================================================
   АДАПТИВ (Mobile First)
   ============================================================ */
@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }
    
    .header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .header h1 {
        margin-right: 0;
        font-size: 1.6rem;
    }
    .logo {
        width: 50px;
        height: 50px;
    }
    
    .bankroll-section {
        flex-direction: column;
        align-items: stretch;
    }
    .bankroll-info {
        justify-content: center;
    }
    .bet-controls {
        justify-content: center;
    }
    
    .btn-card {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    
    .result-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .action-row button {
        min-width: 100px;
        padding: 12px 10px;
        font-size: 0.9rem;
    }
    
    .method-tabs button {
        font-size: 0.85rem;
        padding: 8px 10px;
        min-width: 80px;
    }
    
    .quick-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
        min-width: 60px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px 10px;
        border-radius: 24px;
    }
    
    .btn-card {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    
    .card-badge {
        padding: 4px 10px;
        font-size: 0.8rem;
    }
    
    .result-item .value {
        font-size: 1.4rem;
    }
    
    .ev-item .number {
        font-size: 1rem;
    }
    
    .recommendation {
        font-size: 1rem;
        padding: 12px 10px;
    }
    
    .table-wrapper {
        max-height: 150px;
    }
    #historyTable {
        font-size: 0.75rem;
    }
    #historyTable th,
    #historyTable td {
        padding: 6px 8px;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .quick-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: 50px;
    }
}