* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    margin-bottom: 5px;
    color: #2c3e50;
}

.subtitle {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 20px;
    font-style: italic;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    flex-wrap: wrap;
}

#toggle-btn, #step-btn, #reset-trueskill-btn {
    padding: 8px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

#toggle-btn:hover, #step-btn:hover, #reset-trueskill-btn:hover {
    background-color: #2980b9;
}

#step-btn {
    background-color: #27ae60;
}

#step-btn:hover {
    background-color: #219955;
}

#reset-trueskill-btn {
    background-color: #e67e22;
}

#reset-trueskill-btn:hover {
    background-color: #d35400;
}

#step-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#speed-slider {
    width: 150px;
}

.k-factor-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#k-slider {
    width: 150px;
}

.trueskill-scale-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#trueskill-scale-slider {
    width: 150px;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#sort-select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.stats-display {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: bold;
}

.stats-display span {
    display: inline-block;
    background-color: #ecf0f1;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.game-details {
    margin-bottom: 30px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.game-details h2 {
    margin-bottom: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.game-details-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-details-toggle input {
    margin: 0;
}

.game-details-toggle label {
    margin: 0;
    cursor: pointer;
    font-size: 0.9rem;
}

.game-details-content {
    font-family: 'Courier New', monospace;
    background-color: #ffffff;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
    line-height: 1.4;
}

.detail-section {
    margin-bottom: 10px;
    padding: 8px;
    background-color: #f9f9f9;
    border-left: 3px solid #3498db;
    border-radius: 3px;
}

.detail-section h4 {
    margin: 0 0 5px 0;
    color: #2c3e50;
    font-size: 0.9rem;
    font-weight: bold;
}

.detail-row {
    margin: 3px 0;
    font-size: 0.85rem;
}

.outcome-result {
    font-weight: bold;
    padding: 3px 6px;
    border-radius: 3px;
    margin: 5px 0;
}

.outcome-white-win {
    background-color: #d5f4e6;
    color: #27ae60;
}

.outcome-black-win {
    background-color: #fadbd8;
    color: #e74c3c;
}

.outcome-draw {
    background-color: #f4f6f7;
    color: #5d6d7e;
}

.stats-container {
    display: block;
    width: 100%;
}

.player-stats {
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.2rem;
}

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

th, td {
    padding: 4px; /* Adjust padding for smaller screens */
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f1f1f1;
    font-weight: bold;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #f1f1f1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        gap: 10px;
    }
}

/* Cross-reference chart (matchup grid) */
.matchup-grid-container {
    max-width: 1200px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
    overflow-x: auto;
}

/* ELO rating change indicators */
.positive-change {
    color: #2ecc71;
    font-weight: bold;
}

.negative-change {
    color: #e74c3c;
    font-weight: bold;
}

/* Editable TrueSkill cells */
.trueskill-cell {
    background-color: rgba(52, 152, 219, 0.2);
    cursor: pointer;
    position: relative;
    font-weight: bold;
    border: 1px dashed rgba(52, 152, 219, 0.5);
    padding-right: 20px !important;
}

.trueskill-cell:hover {
    background-color: rgba(52, 152, 219, 0.4);
    box-shadow: inset 0 0 0 1px rgba(52, 152, 219, 0.8);
}

.trueskill-cell::after {
    content: "✏️";
    font-size: 0.8rem;
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    opacity: 0.7;
}

/* Row background colors for rating changes */
.positive-background {
    background-color: rgba(46, 204, 113, 0.1) !important;
}

.negative-background {
    background-color: rgba(231, 76, 60, 0.1) !important;
}

.grid-legend {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 15px;
    height: 15px;
    border-radius: 3px;
}

.legend-color.win {
    background-color: rgba(46, 204, 113, 0.3);
}

.legend-color.draw {
    background-color: rgba(241, 196, 15, 0.3);
}

.legend-color.loss {
    background-color: rgba(231, 76, 60, 0.3);
}

.grid-container {
    display: grid;
    grid-template-columns: 150px repeat(10, minmax(45px, 1fr));
    gap: 1px;
    background-color: #ddd;
    border: 1px solid #ddd;
    font-size: 0.85rem;
}

.grid-header, .grid-cell {
    padding: 4px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.grid-header {
    background-color: #f1f1f1;
    font-weight: bold;
}

.grid-header.player-name {
    justify-content: flex-start;
}

.grid-header.diagonal {
    background-color: #e0e0e0;
}

.grid-cell.win {
    background-color: rgba(46, 204, 113, 0.3);
}

.grid-cell.draw {
    background-color: rgba(241, 196, 15, 0.3);
}

.grid-cell.loss {
    background-color: rgba(231, 76, 60, 0.3);
}

.grid-cell.no-result {
    background-color: white;
}

/* ELO Chart Styles */
.chart-container {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-toggle, .history-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #ecf0f1;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.chart-toggle input, .history-toggle input {
    cursor: pointer;
}

.chart-toggle label, .history-toggle label {
    cursor: pointer;
    user-select: none;
}

#toggle-all-btn {
    padding: 5px 10px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

#toggle-all-btn:hover {
    background-color: #2980b9;
}

.canvas-container {
    height: 400px;
    width: 100%;
    position: relative;
}

@media (max-width: 768px) {
    .canvas-container {
        height: 300px;
    }
}