/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative;
}

#about-link {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #3498db;
    text-decoration: none;
    font-weight: bold;
}

#about-link:hover {
    text-decoration: underline;
}

h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

h2 {
    color: #3498db;
    margin-bottom: 15px;
}

h3 {
    color: #2c3e50;
    margin: 15px 0 10px 0;
}

/* Game selector */
.game-selector {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#game-date {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#new-game {
    padding: 8px 15px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#new-game:hover {
    background-color: #219653;
}

/* Player management */
.player-management {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#player-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#player-form input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 1;
    min-width: 150px;
}

#player-form button {
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#player-form button:hover {
    background-color: #2980b9;
}

#players-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.player-tag {
    display: flex;
    align-items: center;
    background-color: #e1f0fa;
    padding: 8px 15px;
    border-radius: 20px;
}

.player-tag span {
    margin-right: 10px;
}

.remove-player {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

/* Statistics table */
.statistics {
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.stats-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

#download-csv {
    padding: 10px 20px;
    background-color: #9b59b6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#download-csv:hover {
    background-color: #8e44ad;
}

#minus-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #e74c3c;
    background-color: white;
    color: #e74c3c;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

#minus-button.active {
    background-color: #e74c3c;
    color: white;
}

#stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#stats-table th,
#stats-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

#stats-table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

#stats-table th:first-child,
#stats-table th:nth-child(2),
#stats-table th:nth-child(3),
#stats-table td:first-child,
#stats-table td:nth-child(2),
#stats-table td:nth-child(3) {
    text-align: left;
}

/* Group headers */
#stats-table th[colspan] {
    text-align: center;
    background-color: #eee;
    border: 1px solid #ddd;
}

/* Position-based row coloring */
.hitter-row {
    background-color: #ffebee; /* Light red */
}

.setter-row {
    background-color: #e8f5e9; /* Light green */
}

.ds-row {
    background-color: #e3f2fd; /* Light blue */
}

/* Playing checkbox */
.playing-checkbox {
    transform: scale(1.3);
    margin: 0;
}

/* Stat cells */
.stat-cell {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.stat-cell:hover {
    background-color: rgba(0,0,0,0.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 30px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-content ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

.modal-content a {
    color: #3498db;
    text-decoration: none;
}

.modal-content a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    #player-form {
        flex-direction: column;
    }
    
    #stats-table {
        display: block;
        overflow-x: auto;
    }
    
    .game-selector {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px;
    }
}