body {
    font-family: "Roboto", sans-serif;
    background-color: #f4f4f4;
    color: #333;
}

a {
    text-decoration: none;
    color: cadetblue;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img {
    max-height: 30px;
}

h1,
h2 a {
    color: #333;
}

table {
    width: 100%;
    margin: 20px auto;
    border-collapse: collapse;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
}

th,
td {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid #ccc;
}

th {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: normal;
    padding: 14px 20px;
    background-color: #4caf50;
    color: white;
}

td {
    padding: 8px 20px;
}

.totals td {
    background-color: #f3f3f3;
}

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

button {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

button:hover {
    background-color: #45a049;
}

h2 {
    margin-top: 0px;
}

td.percentage {
    color: #999;
    font-size: 12px;
    text-align: left;
    font-style: italic;
    padding-left: 1px;
}
td.score {
    text-align: right;
    padding-right: 1px;
}

td.time {
    white-space: nowrap;
}

.stats {
    padding: 10px 20px;
}

.stats + .stats {
    margin-top: 16px;
}

.table:has(tbody:empty) {
    display: none;
}

.modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content tr {
    cursor: pointer;
}

.modal-content {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    width: 80%;
    max-width: 600px;
    max-height: 80%;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    padding: 10px;
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 1;
}

.modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 10px 10px 10px;
}

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

.close:hover {
    color: #000;
}

.modal h2 {
    margin: 0;
}

@font-face {
    font-family: "Chess V3";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(chessglyph-v3.woff2) format("woff2");
}

span.chess-icon {
    font-family: Chess V3;
    font-size: x-large;
}
span.chess-icon-draw:before {
    color: #ccc;
}
span.chess-icon-won:before {
    color: #4caf50;
}
span.chess-icon-lost:before {
    color: #f00;
}
span.chess-icon-checkmated:before {
    content: "\1F92";
}
span.chess-icon-timeout:before {
    content: "\1F8A";
}
span.chess-icon-resigned:before {
    content: "\1F78";
}
span.chess-icon-abandoned:before {
    content: "\00D7";
}
span.chess-icon-agreed:before {
    content: "\1F88";
}
span.chess-icon-stalemate:before {
    content: "\222B";
}
span.chess-icon-insufficient:before {
    content: "\1F76";
}
span.chess-icon-50move:before {
    content: "\1F90";
}
span.chess-icon-timevsinsufficient:before {
    content: "\1F8A";
}
span.chess-icon-repetition:before {
    content: "\004C";
}
span.chess-icon-unknown:before {
    content: "\1F0D";
}
.red {
    color: red;
}

.yellow {
    color: #cbcb0d;
}

.green {
    color: green;
}

.blue {
    color: blue;
}

/* Layout */
.container {
    max-width: 1000px;
    margin: 0 auto;
}

.panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.date-controls {
    display: flex;
    gap: 8px;
}

.date-controls button {
    color: #666;
    background: #fff;
    border: 1px solid #ddd;
}

.date-controls button.active {
    color: #fff;
    background: #4caf50;
}

.rating-before {
    font-size: xx-small;
    color: #666;
}
.rating-climb {
    color: #4caf50;
}
.rating-fall {
    color: red;
}
.player-noname {
    opacity: 0.5;
}
.modal__move-count {
    padding: 0px;
    font-size: small;
}
.modal__player-black {
    text-align: left;
    padding: 0px 5px 0px 5px;
}
.modal__player-white {
    text-align: right;
    padding: 0px 5px 0px 5px;
}

.checkbox {
    font-size: small;
    font-weight: normal;
    float: right;
    margin-right: 20px;
}

@keyframes rock {
    0% {
        transform: translateX(-5px);
    }
    50% {
        transform: translateX(5px);
    }
    100% {
        transform: translateX(-5px);
    }
}

.rocking-span {
    font-size: 45px;
    animation: rock 1s ease-in-out infinite;
    display: inline-block;
}

canvas#ratingChart {
    width: 100%;
    max-height: 300px;
    margin-bottom: 20px;
}

/* Responsive styles */
@media screen and (max-width: 700px) {
    .panel {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .desktop {
        display: none;
    }

    .date-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .date-controls button {
        flex: 1 1 40%;
        min-width: 0;
        padding: 8px;
        font-size: 14px;
    }
}

@media screen and (max-width: 600px) {
    .stats {
        width: 100%;
        margin: 10px 0;
        padding: 20px 10px 0px 10px;
    }

    table {
        font-size: 12px;
    }

    th,
    td {
        padding: 3px 1px;
    }

    h2 {
        margin-left: 10px;
    }

    .modal-content {
        width: 95%;
        padding: 0px;
    }
}
/* Additional leaderboard styles */
.leaderboard-section {
    margin-bottom: 30px;
}

.leaderboard-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

.leaderboard-section table td {
    vertical-align: middle;
}

.leaderboard-section th {
    background-color: #e4ba31;
}

.leaderboard-section + .leaderboard-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

button.leaderboard {
    background-color: #e4ba31;
}

/* Make the table scrollable on mobile */
@media screen and (max-width: 600px) {
    .leaderboard-section {
        overflow-x: auto;
    }

    .leaderboard-section table {
        min-width: 500px;
    }
}

/* Username Input Form Styles */
.username-input-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f4f4f4;
    padding: 20px;
}

.username-input-form {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.username-input-form h1 {
    color: #4caf50;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.username-input-form p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.username-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

.username-input:focus {
    outline: none;
    border-color: #4caf50;
}

.username-submit-btn {
    background-color: #4caf50;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
}

.username-submit-btn:hover {
    background-color: #45a049;
}

.username-submit-btn:active {
    transform: translateY(1px);
}

/* Mobile responsiveness for username input */
@media screen and (max-width: 600px) {
    .username-input-form {
        padding: 20px;
        margin: 10px;
    }
    
    .username-input-form h1 {
        font-size: 2em;
    }
}

/* Username Tags Styles */
.username-tags-container {
    background: white;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.username-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.username-tag {
    display: inline-flex;
    align-items: center;
    background-color: #4caf50;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    gap: 8px;
    transition: all 0.2s ease;
}

.username-tag:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

.tag-close {
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.tag-close:hover {
    opacity: 1;
}

.add-user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e0e0e0;
    border: 2px dashed #999;
    color: #666;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: bold;
    min-width: 36px;
    height: 28px;
}

.add-user-btn:hover {
    background-color: #4caf50;
    border-color: #4caf50;
    color: white;
    transform: scale(1.1);
}

.plus-icon {
    line-height: 1;
}

/* Add User Modal Styles */
.add-user-modal {
    max-width: 400px;
    width: 90%;
}

.add-user-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    margin-bottom: 20px;
    transition: border-color 0.3s ease;
}

.add-user-input:focus {
    outline: none;
    border-color: #4caf50;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.cancel-btn {
    background-color: #f5f5f5;
    color: #666;
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.cancel-btn:hover {
    background-color: #e0e0e0;
}

.add-btn {
    background-color: #4caf50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.add-btn:hover {
    background-color: #45a049;
}

/* Mobile responsiveness for username tags */
@media screen and (max-width: 600px) {
    .username-tags-container {
        padding: 10px 15px;
        margin-bottom: 15px;
    }
    
    .username-tag {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .add-user-btn {
        padding: 4px 8px;
        font-size: 14px;
        min-width: 32px;
        height: 24px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .cancel-btn,
    .add-btn {
        width: 100%;
    }
}

/* Empty State Styles */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    border-radius: 10px;
    color: white;
    margin: 20px auto;
    max-width: 600px;
}

.empty-state-content h3 {
    margin: 15px 0;
    font-size: 24px;
    color: white;
}

.empty-state p {
    margin: 10px 0;
    font-size: 16px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.empty-state-tip {
    background: rgba(255, 255, 255, 0.15);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    font-style: italic;
}

.empty-state strong {
    color: #fffccc;
}
