* {
    box-sizing: border-box;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background: #1a1a2e;
    color: #eee;
}
h1 {
    text-align: center;
    color: #fff;
    margin-bottom: 10px;
}
.stats-summary {
    display: flex;
    gap: 30px;
    justify-content: center;
    margin-bottom: 20px;
}
.stat-item {
    text-align: center;
}
.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #e94560;
}
.stat-label {
    font-size: 12px;
    color: #888;
}
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Table Styles */
.table-container {
    background: #16213e;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.filter-group label {
    font-size: 12px;
    color: #888;
}
.filter-group input, .filter-group select {
    background: #0f3460;
    border: 1px solid #1a4d7a;
    color: #fff;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
}
.filter-group input:focus, .filter-group select:focus {
    outline: none;
    border-color: #e94560;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #0f3460;
}
th {
    background: #0f3460;
    cursor: pointer;
    user-select: none;
    position: relative;
}
th:hover {
    background: #1a4d7a;
}
th .sort-icon {
    margin-left: 5px;
    opacity: 0.5;
}
th.sorted .sort-icon {
    opacity: 1;
}
tr:hover {
    background: #0f3460;
}
tr.selected {
    background: #1a4d7a;
}
tbody tr {
    cursor: pointer;
}
.sequence-cell {
    font-family: monospace;
    font-size: 13px;
}
.color-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
}
.color-white {
    background: #fff;
    color: #000;
}
.color-black {
    background: #333;
    color: #fff;
}
.occurrences-value {
    font-weight: bold;
}
.impact-badge {
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 13px;
}
.impact-medium {
    background: #4a4a27;
    color: #cfcf63;
}
.impact-high {
    background: #5a3a27;
    color: #cf9f63;
}
.impact-critical {
    background: #5a2727;
    color: #cf6363;
}

/* Detail Panel - Slide from right */
.detail-panel {
    position: fixed;
    top: 0;
    right: -670px;
    width: 650px;
    height: 100vh;
    background: #16213e;
    padding: 25px;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
    transition: right 0.3s ease;
    overflow-y: auto;
    z-index: 1000;
}
.detail-panel.open {
    right: 0;
}
.detail-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    pointer-events: none;
}
.detail-overlay.open {
    display: block;
}
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.detail-header h2 {
    margin: 0;
    font-size: 22px;
}
.close-btn {
    background: transparent;
    border: none;
    color: #888;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.close-btn:hover {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}
.detail-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.board-section {
    background: #0f3460;
    padding: 20px;
    border-radius: 10px;
}
#board {
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}
.controls {
    margin-top: 15px;
    text-align: center;
}
.controls button {
    background: #1a4d7a;
    color: #fff;
    border: none;
    padding: 12px 24px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}
.controls button:hover:not(:disabled) {
    background: #e94560;
}
.controls button:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}
.best-move-btn {
    background: #2d5a27 !important;
}
.best-move-btn:hover {
    background: #3d7a37 !important;
}
.highlight-best {
    box-shadow: inset 0 0 3px 3px #4caf50 !important;
}
.highlight-mistake {
    box-shadow: inset 0 0 3px 3px #e94560 !important;
}
.move-display {
    margin-top: 15px;
    padding: 15px;
    background: #16213e;
    border-radius: 5px;
    font-family: monospace;
    font-size: 16px;
}
.move-display span {
    padding: 2px 4px;
    margin: 2px;
    display: inline-block;
}
.move-display .current {
    background: #e94560;
    border-radius: 3px;
}
.move-display .mistake {
    color: #ff6b6b;
    font-weight: bold;
}

/* Games List */
.games-list {
    max-height: 500px;
    overflow-y: auto;
}
.games-list h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
}
.game-item {
    background: #0f3460;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    cursor: pointer;
    border-left: 4px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}
.game-item:hover {
    background: #1a4d7a;
}
.game-item.game-win {
    border-left-color: #4caf50;
}
.game-item.game-draw {
    border-left-color: #888;
}
.game-item.game-loss {
    border-left-color: #e94560;
}
.game-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
}
.game-time-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.game-time-icon svg {
    width: 24px;
    height: 24px;
}
.game-time-icon .blitz-icon {
    fill: #f7c631;
}
.game-time-icon .rapid-icon {
    fill: #7cb342;
}
.time-control-text {
    font-size: 12px;
    color: #888;
}
.game-players {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.game-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    font-size: 15px;
}
.game-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    color: #aaa;
}
.game-eval {
    color: #ff6b6b;
    font-weight: bold;
}
.game-date {
    color: #888;
    font-size: 13px;
}
.player-row {
    display: flex;
    align-items: center;
    gap: 5px;
}
.color-icon {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}
.color-icon-white {
    background: #fff;
    border: 1px solid #666;
}
.color-icon-black {
    background: #333;
    border: 1px solid #666;
}
.player-name {
    color: #ddd;
}
.player-rating {
    color: #888;
}
.game-result {
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
}
.result-win {
    background: #2d5a27;
    color: #6bcf63;
}
.result-loss {
    background: #5a2727;
    color: #cf6363;
}
.result-draw {
    background: #4a4a27;
    color: #cfcf63;
}

.loading {
    text-align: center;
    padding: 50px;
    color: #888;
}
.no-results {
    text-align: center;
    padding: 30px;
    color: #888;
}

/* Setup Screen */
.setup-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.setup-box {
    background: #16213e;
    border-radius: 15px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    text-align: center;
}
.setup-box h1 {
    margin: 0 0 10px 0;
    font-size: 28px;
}
.setup-box p {
    color: #888;
    margin-bottom: 30px;
}
.setup-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.setup-input {
    background: #0f3460;
    border: 2px solid #1a4d7a;
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
}
.setup-input:focus {
    outline: none;
    border-color: #e94560;
}
.setup-input::placeholder {
    color: #666;
}
.setup-btn {
    background: #e94560;
    color: #fff;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.setup-btn:hover {
    background: #d63850;
}
.setup-btn:disabled {
    background: #666;
    cursor: not-allowed;
}
.setup-error {
    background: rgba(233, 69, 96, 0.2);
    border: 1px solid #e94560;
    color: #ff6b6b;
    padding: 12px;
    border-radius: 5px;
    font-size: 14px;
    display: none;
}
.setup-note {
    margin-top: 20px;
    font-size: 12px;
    color: #666;
}

/* Header with config button */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.header h1 {
    margin: 0;
    flex: 1;
    text-align: center;
}
.header-spacer {
    width: 40px;
}
.config-btn {
    background: transparent;
    border: 1px solid #1a4d7a;
    color: #888;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.config-btn:hover {
    background: #1a4d7a;
    color: #fff;
}

/* Config Menu */
.config-menu {
    position: fixed;
    top: 70px;
    right: 20px;
    background: #16213e;
    border-radius: 10px;
    padding: 20px;
    min-width: 280px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    display: none;
}
.config-menu.open {
    display: block;
}
.config-menu h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #888;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 10px;
}
.config-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}
.config-stat {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}
.config-stat-label {
    color: #888;
}
.config-stat-value {
    color: #fff;
    font-weight: bold;
}
.config-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.config-action-btn {
    background: #0f3460;
    border: 1px solid #1a4d7a;
    color: #fff;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: all 0.2s;
}
.config-action-btn:hover {
    background: #1a4d7a;
}
.config-action-btn.danger {
    border-color: #5a2727;
}
.config-action-btn.danger:hover {
    background: #5a2727;
}

/* Progress Overlay */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}
.progress-overlay.visible {
    opacity: 1;
    visibility: visible;
}
.progress-modal {
    background: #16213e;
    border-radius: 15px;
    padding: 30px;
    max-width: 450px;
    width: 90%;
}
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.progress-header h2 {
    margin: 0;
    font-size: 20px;
}
.progress-cancel-btn {
    background: transparent;
    border: 1px solid #5a2727;
    color: #cf6363;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}
.progress-cancel-btn:hover {
    background: #5a2727;
}
.progress-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.progress-message {
    font-size: 14px;
    color: #aaa;
    min-height: 20px;
}
.progress-bar-container {
    background: #0f3460;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
}
.progress-bar {
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}
.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #888;
}
.progress-details {
    font-size: 12px;
    color: #666;
    min-height: 16px;
}
