body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: #f5f5f5;
}

header {
    background-color: #1a1a1a;
    color: white;
    padding: 1rem 2rem;
    text-align: center;
}

header h1 {
    margin-bottom: 0.5rem;
}

.update-info {
    margin-top: 0.5rem;
}

.update-info p {
    margin: 0.25rem 0;
    font-style: italic;
    font-size: 0.9rem;
    opacity: 0.9;
}

.tabs {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.tab-button {
    background-color: #e0e0e0;
    border: none;
    padding: 10px 20px;
    margin: 0 5px;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 5px 5px 0 0;
    transition: background-color 0.3s;
}

.tab-button.active {
    background-color: #007bff;
    color: white;
}

.tab-button:hover:not(.active) {
    background-color: #cccccc;
}

.tab-content {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.tab-content.active {
    display: block;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

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

th {
    background-color: #007bff;
    color: white;
    position: sticky;
    top: 0;
}

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

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

.loading {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #777;
}

footer {
    padding: 1.5rem;
    background-color: #1a1a1a;
    color: white;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}

.footer-item {
    margin: 0 10px;
    text-align: center;
}

.footer-divider {
    margin: 0 5px;
    color: #555;
}

.copyright {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

footer a {
    color: #4da9ff;
    text-decoration: none;
    transition: color 0.3s;
}

footer a:hover {
    color: #99ccff;
    text-decoration: underline;
}

@media (max-width: 768px) {

    th,
    td {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .tab-button {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .footer-row {
        flex-direction: column;
    }

    .footer-item {
        margin: 0.5rem 0;
    }

    .footer-divider {
        display: none;
    }
}

nav {
    margin-top: 0.5rem;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 5px 15px;
    border-radius: 3px;
    transition: background-color 0.3s;
}

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

.player-info {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.player-details {
    display: flex;
    flex-wrap: wrap;
}

#player-data {
    flex: 1;
    min-width: 300px;
}

.rating-history h3 {
    margin-top: 0;
    color: #333;
}

.chart-container {
    height: 300px;
    margin-bottom: 2rem;
}

#history-table {
    width: 100%;
}

@media (max-width: 768px) {
    .player-container {
        padding: 15px;
    }

    .chart-container {
        height: 250px;
    }
}

.player-link {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s;
}

.player-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Responsive tables for mobile */
@media (max-width: 767px) {

    /* First, ensure tables take full width of their container */
    #men-table,
    #women-table,
    #history-table {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* For rankings tables on index page */
    #men-table tr,
    #women-table tr,
    #history-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        background-color: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        width: 100%;
    }

    /* Hide table headers visually but maintain for screen readers */
    #men-table thead tr,
    #women-table thead tr,
    #history-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    #men-table td,
    #women-table td,
    #history-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
        text-align: left;
        padding: 8px 8px 8px 45% !important;
        /* Adjusted padding */
        position: relative;
        border-bottom: 1px solid #eee;
        min-height: 40px;
        /* Ensure enough height for content */
    }

    /* Ensure cells take full width */
    #men-table td:before,
    #women-table td:before,
    #history-table td:before {
        position: absolute;
        top: 8px;
        left: 8px;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        content: attr(data-label);
    }

    /* Handle better alignment */
    #men-table td,
    #women-table td,
    #history-table td {
        word-break: break-word;
    }

    .player-link {
        word-break: break-word;
    }

    /* Ensure tab content containers use full width */
    .tab-content {
        width: 100%;
        padding: 15px 10px;
        box-sizing: border-box;
    }

    /* Ensure player container uses full width */
    .player-container {
        width: 100%;
        box-sizing: border-box;
        padding: 15px 10px;
    }
}

/* Improve overall container widths for mobile */
@media (max-width: 767px) {
    .tabs {
        width: 100%;
        box-sizing: border-box;
        padding: 0 10px;
    }

    .tab-button {
        flex: 1;
        min-width: 0;
        padding: 8px 5px;
        font-size: 0.9rem;
    }

    header {
        padding: 1rem;
    }

    .update-info p {
        font-size: 0.8rem;
    }
}

/* Page view counter styling */
.page-views {
    margin-top: 10px;
    font-size: 0.9rem;
    opacity: 0.9;
}

@media (max-width: 767px) {
    .page-views {
        margin-top: 5px;
        font-size: 0.8rem;
    }
}

/* Column toggle styles */
.column-toggles {
    margin-bottom: 15px;
    display: none;
    /* Hidden by default on desktop */
}

.column-toggles p {
    margin: 0 0 5px 0;
    font-size: 0.9rem;
    color: #555;
}

.toggle-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.toggle-button {
    padding: 5px 10px;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-button.active {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
}

@media (max-width: 767px) {
    .column-toggles {
        display: block;
    }
}

/* Navigation bar in header - UPDATED */
.main-nav {
    margin: 0.5rem 0;
}

.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
}

.main-nav ul li {
    margin: 0;
    display: flex;
    align-items: center;
}

/* Add separator between nav items */
.main-nav ul li:not(:last-child):after {
    content: "|";
    margin: 0 1rem;
    color: #aaa;
}

.main-nav ul li a {
    color: white;
    text-decoration: none;
    padding: 5px 10px;
    transition: all 0.3s;
}

.main-nav ul li a:hover {
    color: #99ccff;
}

/* Active navigation link style - bold and underlined but not italic */
.active-nav {
    font-weight: bold !important;
    text-decoration: underline !important;
}

/* Responsive styles for the navigation */
@media (max-width: 768px) {
    .main-nav ul {
        flex-direction: column;
        align-items: center;
    }

    .main-nav ul li {
        margin: 0.25rem 0;
    }

    /* Remove separator for vertical layout */
    .main-nav ul li:not(:last-child):after {
        content: none;
    }
}

/* History table styles */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    table-layout: fixed;
    /* Fixed layout for consistent column widths */
}

/* Player cell layout */
.player-cell {
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    line-height: 1.3;
}

/* Player name style */
.player-name {
    font-size: 0.95rem;
    max-width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Player rating style */
.player-rating {
    font-size: 0.85rem;
    color: #555;
    margin-top: 2px;
}

.history-table th:first-child,
.history-table td:first-child {
    width: 15%;
    /* Slightly wider date column */
    min-width: 110px;
}

.history-table th:not(:first-child),
.history-table td:not(:first-child) {
    width: 17%;
    /* Player columns width (5 columns at 17% each = 85%, plus 15% for date = 100%) */
    min-width: 90px;
    padding: 8px 4px;
}


.date-link {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s;
}

.date-link:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Snapshot page styles */
.snapshot-header {
    max-width: 1200px;
    margin: 1rem auto;
    text-align: center;
}

.snapshot-header h2 {
    margin-bottom: 0.5rem;
}

.snapshot-header p {
    margin-top: 0.25rem;
}

.snapshot-header a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s;
}

.snapshot-header a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Loader styles */
.loader {
    text-align: center;
    padding: 20px;
    color: #777;
    font-style: italic;
}

/* Responsive styles for the navigation */
@media (max-width: 768px) {
    .main-nav ul {
        flex-direction: column;
        align-items: center;
    }

    .main-nav ul li {
        margin: 0.25rem 0;
    }
}

/* Responsive styles for history table on mobile */
@media (max-width: 767px) {

    .history-table th:not(:first-child),
    .history-table td:not(:first-child) {
        display: none;
        /* Hide all player columns initially */
    }

    /* Show only the top 3 players on mobile */
    .history-table th:nth-child(2),
    .history-table td:nth-child(2),
    .history-table th:nth-child(3),
    .history-table td:nth-child(3),
    .history-table th:nth-child(4),
    .history-table td:nth-child(4) {
        display: table-cell;
        width: 28.33%;
        /* Evenly distribute the remaining 85% among 3 columns */
    }

    /* Style for the date column */
    .history-table th:first-child,
    .history-table td:first-child {
        width: 15%;
    }

    /* Make player name font smaller on mobile */
    .player-name {
        font-size: 0.85rem;
    }

    /* Make player rating font smaller on mobile */
    .player-rating {
        font-size: 0.75rem;
    }
}

/* Active navigation link style */
.active-nav {
    font-weight: bold;
}

/* Styles for the update info container */
.update-info-container {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 20px;
    text-align: center;
}

.update-info {
    background-color: #f8f8f8;
    border-radius: 5px;
    padding: 10px 15px;
    margin-bottom: 1rem;
    display: inline-block;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.update-info p {
    margin: 0.25rem 0;
    font-style: italic;
    font-size: 0.9rem;
    color: #555;
}

/* Responsive styles */
@media (max-width: 768px) {
    .update-info-container {
        padding: 0 10px;
    }

    .update-info {
        padding: 8px 10px;
        width: 100%;
    }

    .update-info p {
        font-size: 0.8rem;
    }
}

/* Scroll buttons styles */
.scroll-buttons-container {
    position: fixed;
    right: 20px;
    top: 50%;
    /* Position at middle-right */
    transform: translateY(-50%);
    /* Center vertically */
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.scroll-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(100, 100, 100, 0.7);
    /* More gray-ish color with transparency */
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s, background-color 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Custom arrow icons with just the arrowhead */
.scroll-top-button::before {
    content: '▲';
    /* Triangle up arrowhead */
    font-size: 14px;
}

.scroll-bottom-button::before {
    content: '▼';
    /* Triangle down arrowhead */
    font-size: 14px;
}

.scroll-button:hover {
    background-color: rgba(80, 80, 80, 0.9);
}

.scroll-button.visible {
    opacity: 0.8;
}

.scroll-button.visible:hover {
    opacity: 1;
}

/* Responsive styles for smaller screens */
@media (max-width: 768px) {
    .scroll-buttons-container {
        right: 15px;
    }

    .scroll-button {
        width: 35px;
        height: 35px;
    }

    .scroll-top-button::before,
    .scroll-bottom-button::before {
        font-size: 12px;
    }
}

/* Adjust position for very small screens */
@media (max-width: 480px) {
    .scroll-buttons-container {
        right: 10px;
    }
}

/* Player photo styles */
.player-info {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
}

.player-info h2 {
    width: 100%;
    margin-top: 0;
}

.player-photo-container {
    flex: 0 0 200px;
    height: 250px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    overflow: hidden;
}

.player-photo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.player-details {
    flex: 1;
    min-width: 300px;
}

.no-photo,
.photo-loading {
    color: #777;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .player-info {
        flex-direction: column;
    }

    .player-photo-container {
        width: 100%;
        flex: 0 0 auto;
        max-width: 200px;
        align-self: center;
    }
}

/* Center-align player name */
.player-info h2 {
    width: 100%;
    margin-top: 0;
    text-align: center;
    /* Center align the player name */
    margin-bottom: 20px;
    /* Add some space below the name */
}

/* Ensure center alignment in responsive view too */
@media (max-width: 768px) {
    .player-info h2 {
        text-align: center;
    }
}