:root {
    --primary-color: #2ecc71;
    --secondary-color: #3498db;
    --danger-color: #e74c3c;
    --background: #f8f9fa;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #ecf0f1;
    --winner-bg: #d4edda;
    --positive-color: #27ae60;
    --negative-color: #e74c3c;
    --card-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 28px;
    color: var(--text-dark);
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-small {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    font-weight: 500;
    min-height: 44px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #27ae60;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #2980b9;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
    min-height: 32px;
}

/* Rankings Table */
.rankings {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
}

.rankings h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--background);
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-dark);
}

.rank {
    font-weight: bold;
    font-size: 18px;
}

.player-name a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
}

.player-name a:hover {
    color: var(--primary-color);
}

.elo {
    font-weight: bold;
    font-size: 18px;
    color: var(--primary-color);
}

/* Match Cards */
.recent-matches, .matches-history, .player-matches {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
}

.recent-matches h2, .player-matches h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
}

.match-card {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    background: white;
}

.match-card.detailed {
    padding: 20px;
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.match-date {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 10px;
}

.match-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 15px;
    align-items: center;
    margin-bottom: 10px;
}

.team {
    padding: 8px;
    border-radius: 4px;
    transition: background 0.3s;
}

.team.winner {
    background: var(--winner-bg);
    font-weight: bold;
}

.team-players {
    margin-bottom: 5px;
}

.score, .match-score-center {
    text-align: center;
    font-weight: bold;
    font-size: 20px;
}

.sets-score {
    font-size: 24px;
    margin-bottom: 5px;
}

.games-score, .match-score-detail {
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
}

.elo-changes {
    font-size: 14px;
    margin-top: 5px;
}

.elo-change, .positive, .negative {
    font-weight: bold;
}

.positive {
    color: var(--positive-color);
}

.negative {
    color: var(--negative-color);
}

.match-result {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
    margin-right: 10px;
}

.match-result.won {
    background: var(--winner-bg);
    color: var(--positive-color);
}

.match-result.lost {
    background: #f8d7da;
    color: var(--danger-color);
}

/* Forms */
.match-form {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.form-section {
    margin-bottom: 30px;
}

.form-section h2 {
    margin-bottom: 15px;
    color: var(--text-dark);
    font-size: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group input[type="text"],
.form-group input[type="datetime-local"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 16px;
    min-height: 44px;
}

.form-group input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

#score-inputs {
    transition: opacity 0.3s;
}

/* Player Stats */
.player-stats {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
}

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

.stat-card {
    text-align: center;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-light);
    font-size: 14px;
    text-transform: uppercase;
}

/* Messages */
.message {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Utilities */
.no-matches {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 18px;
}

.view-all {
    text-align: center;
    margin-top: 20px;
}

.view-all a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.view-all a:hover {
    text-decoration: underline;
}

/* Autocomplete */
.autocomplete {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--background);
}

.autocomplete-item.new-player {
    color: var(--primary-color);
    font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    .btn-primary, .btn-secondary {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    table {
        font-size: 14px;
    }
    
    th, td {
        padding: 8px;
    }
    
    .match-teams {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .score, .match-score-center {
        margin: 10px 0;
    }
    
    .team {
        text-align: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 20px;
    }
    
    .rankings-table {
        font-size: 14px;
    }
    
    .rank, .elo {
        font-size: 16px;
    }
    
    .match-card {
        padding: 10px;
    }
}