:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #ecf0f1;
    --accent: #3498db;
    --header-height: 60px;
}

body {
    margin: 0; padding: 0;
    font-family: 'Roboto', -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; 
    height: 100vh;
}

/* --- HEADER --- */
header {
    height: var(--header-height);
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 15px; box-sizing: border-box;
    position: fixed; top: 0; left: 0; width: 100%; z-index: 100;
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 18px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.action-btn {
    background: var(--accent); color: white; border: none; padding: 8px 16px;
    border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px;
}
.action-btn:disabled { background: #555; cursor: not-allowed; }
.btn-settings { background: #444; }

/* --- WORKSPACE --- */
.workspace {
    position: absolute;
    top: var(--header-height);
    left: 0; right: 0; bottom: 0;
    background: var(--bg-color);
    overflow: hidden;
    display: flex; flex-direction: column;
}

.results-container {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.save-panel {
    padding: 10px;
    background: #1a1a1a;
    border-top: 1px solid #444;
    z-index: 200;
}

/* --- TABLE --- */
.chess-table {
    border-collapse: separate; 
    border-spacing: 0;
    width: max-content; 
    min-width: 100%;
    color: #fff; font-size: 14px;
}

.chess-table th, .chess-table td {
    border: 1px solid #444;
    padding: 8px 5px;
    text-align: center;
    vertical-align: middle;
    background: var(--bg-color);
    max-width: 120px;
    overflow: hidden; text-overflow: ellipsis;
}

/* Прилипающая шапка */
.chess-table thead th {
    position: sticky; top: 0;
    background: #2c3e50;
    z-index: 20;
    border-bottom: 2px solid #555;
    font-size: 12px;
}

/* >>> НОВОЕ: Стили для сортируемых заголовков <<< */
.sortable-header {
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    text-decoration: underline dotted #aaa;
}
.sortable-header:hover {
    background: #34495e !important;
    color: #f1c40f;
}
.sort-active {
    background: #34495e !important;
    color: #f1c40f;
    border-bottom: 3px solid #f1c40f !important;
}

/* Прилипающий первый столбец */
.chess-table th.col-name, .chess-table td.col-name {
    position: sticky; left: 0;
    background: #1a1a1a;
    z-index: 15;
    border-right: 2px solid #555;
    text-align: left;
    min-width: 180px; max-width: 200px;
    white-space: nowrap;
}

.chess-table thead th.col-name {
    z-index: 30;
    background: #2c3e50;
}

.user-mini-ava { width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; margin-right: 8px; }

.cell-win { background-color: rgba(46, 204, 113, 0.2) !important; color: #2ecc71; font-weight: bold; }
.cell-loss { background-color: rgba(231, 76, 60, 0.2) !important; color: #e74c3c; opacity: 0.8; }
.cell-neutral { color: #555; }
.score-match { font-weight: bold; color: #f1c40f; background: #222 !important; }
.score-total { font-weight: bold; color: #3498db; background: #222 !important; }

/* --- MODAL --- */
#setupModal { display: flex; position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.95); z-index: 2000; justify-content: center; align-items: center; flex-direction: column; }
#wizardContainer { display: none; position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.95); z-index: 2000; justify-content: center; align-items: center; flex-direction: column; }

.modal-content, .wizard-card {
    background: #1e1e1e; padding: 25px; border-radius: 12px; border: 1px solid #444;
    width: 90%; max-width: 450px; text-align: center;
}
.form-group { margin-bottom: 12px; text-align: left; }
.form-group label { display: block; font-size: 12px; margin-bottom: 4px; color: #aaa; }
input[type="text"], input[type="number"] {
    width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #444;
    background: #252525; color: white; box-sizing: border-box;
}
.wizard-input-text { font-size: 16px; text-align: center; color: #f1c40f !important; font-weight: bold; border-color: #f1c40f !important; }

.start-btn { width: 100%; padding: 12px; background: #27ae60; color: white; border:none; border-radius:6px; margin-top:15px; cursor:pointer; font-weight:bold; }
.checkbox-container { text-align: left; margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.checkbox-group { display: flex; align-items: center; gap: 10px; cursor: pointer; background: #252525; padding: 8px; border-radius: 6px; }
.checkbox-title { font-weight: bold; font-size: 13px; }

.wizard-option-text { font-size: 14px; color: #888; margin-bottom: 10px; min-height: 30px; display: flex; align-items: center; justify-content: center; font-style: italic; }
.wizard-controls { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.wizard-input { width: 80px !important; text-align: center; font-size: 18px; }
.btn-bool { flex: 1; padding: 12px; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; transition: 0.2s; opacity: 0.4; }
.btn-bool.selected { opacity: 1; transform: scale(1.05); box-shadow: 0 0 10px currentColor; }
.btn-yes { background: #27ae60; color: white; }
.btn-no { background: #c0392b; color: white; }