* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    margin-bottom: 20px;
}

h1 {
    color: #333;
    margin-bottom: 8px;
    font-size: 24px;
}

.subtitle {
    color: #666;
    margin-bottom: 25px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

input[type="url"],
input[type="text"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: #667eea;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading {
    display: none;
    text-align: center;
    padding: 30px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    display: none;
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 14px;
    border: 1px solid #f5c6cb;
}

.error.show {
    display: block;
}

.results {
    display: none;
}

.results.show {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-card.secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card.tertiary {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-label {
    font-size: 11px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 5px;
}

.metadata {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.metadata h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 16px;
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    font-size: 14px;
}

.metadata-item {
    display: flex;
    gap: 8px;
}

.metadata-item strong {
    color: #667eea;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    background: #f8f9fa;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #ddd;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover {
    background: #e9ecef;
}

th.sortable {
    cursor: pointer;
    transition: background-color 0.2s;
}

th.sortable:hover {
    background: #e2e6ea;
}

th.sortable.active {
    background: #dee2e6;
    color: #667eea;
}

th.sortable.reset {
    color: #666;
}

th.sortable.reset.has-sort {
    color: #dc3545;
}

th.sortable.reset.has-sort:hover {
    background: #f8d7da;
}

td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

tr:hover {
    background: #f8f9fa;
}

.player-name {
    color: #667eea;
    font-weight: 600;
}

.elo-value {
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.elo-change {
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    display: inline-block;
    min-width: 50px;
    text-align: center;
}

.positive {
    background: #d4edda;
    color: #155724;
}

.negative {
    background: #f8d7da;
    color: #721c24;
}

.neutral {
    background: #e2e3e5;
    color: #383d41;
}

.export-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.export-btn {
    padding: 8px 16px;
    background: #28a745;
    width: auto;
    flex: 0;
}

.export-btn:hover {
    background: #218838;
}

.search-filter {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.search-filter input {
    flex: 1;
    min-width: 200px;
}

.api-url-display {
    background: #e9ecef;
    padding: 10px 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    margin-top: 15px;
    word-break: break-all;
    display: none;
}

.api-url-display.show {
    display: block;
}

.api-url-display strong {
    color: #667eea;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: none;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.detail-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.detail-value {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    font-family: 'Courier New', monospace;
}

.detail-value.positive {
    color: #155724;
}

.detail-value.negative {
    color: #721c24;
}

.detail-value.neutral {
    color: #383d41;
}

.games-list {
    margin-top: 15px;
}

.games-list h4 {
    font-size: 14px;
    color: #333;
    margin-bottom: 10px;
}

.game-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
}

.game-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.round-number {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
}

.opponent-name {
    font-weight: 600;
    color: #333;
}

.opponent-rating {
    color: #666;
    font-size: 12px;
}

.color-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
}

.color-badge.white {
    background: #fff;
    color: #333;
    border: 2px solid #333;
}

.color-badge.black {
    background: #333;
    color: #fff;
    border: 2px solid #333;
}

.game-result {
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    min-width: 45px;
    text-align: center;
}

.game-result.win,
.game-result.positive {
    background: #d4edda;
    color: #155724;
}

.game-result.loss,
.game-result.negative {
    background: #f8d7da;
    color: #721c24;
}

.game-result.draw,
.game-result.neutral {
    background: #fff3cd;
    color: #856404;
}

.player-name {
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.player-name:hover {
    color: #764ba2;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    table {
        font-size: 12px;
    }

    td,
    th {
        padding: 8px 6px;
    }

    .modal {
        width: 95%;
        max-height: 90vh;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}
