body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.card {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.table th {
    background-color: #343a40;
    color: white;
    text-align: center;
    vertical-align: middle;
}

.table td {
    vertical-align: middle;
    text-align: center;
}

.score-input {
    width: 70px;
    text-align: center;
}

.table td.text-start {
    text-align: left;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.payout-projection {
    font-size: 0.9em;
    color: #28a745;
    font-weight: bold;
}

#floatingScrollBtns {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

#floatingScrollBtns button {
    opacity: 0.7;
    transition: opacity 0.2s;
    width: 80px;
}

#floatingScrollBtns button:hover {
    opacity: 1;
}

/* Prevent text wrapping and fix widths to make sticky positioning consistent */
#scoresTable th,
#scoresTable td,
#leaderboardTable th,
#leaderboardTable td {
    white-space: nowrap;
}

#scoresTable td.text-start,
#leaderboardTable td.text-start {
    min-width: 120px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-rank { min-width: 45px; max-width: 45px; text-align: center; }
.col-select { min-width: 45px; max-width: 45px; }
.col-sel-mobile { min-width: 45px; max-width: 45px; }
.col-last-name { min-width: 120px; max-width: 120px; }
.col-first-name { min-width: 120px; max-width: 120px; }
.col-name-mobile { min-width: 150px; max-width: 150px; }
.col-asg { min-width: 70px; max-width: 70px; }
.col-avg { min-width: 50px; max-width: 50px; }
.col-hcp { min-width: 50px; max-width: 50px; }

/* Tablet and mobile overrides */
@media (max-width: 991.98px) {
    body {
        padding-top: 70px; /* Offset for fixed navbar */
    }

    .navbar {
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 1030; /* Keep above standard content */
    }

    #tournamentSelector {
        margin-top: 10px;
    }

    /* Freeze pane */
    #scoresTable th.col-sel-mobile,
    #scoresTable td.col-sel-mobile {
        position: sticky;
        left: 0;
        z-index: 2;
        background-color: #fff; /* Match table striped background base */
    }

    #scoresTable th.col-name-mobile,
    #scoresTable td.col-name-mobile {
        position: sticky;
        left: 45px;
        z-index: 2;
        background-color: #fff;
        border-right: 2px solid #dee2e6; /* Give a visual divider */
    }

    /* Leaderboard Public View (Rank is first, Name is second) */
    #leaderboardTable th.col-rank,
    #leaderboardTable td.col-rank {
        position: sticky;
        left: 0;
        z-index: 2;
        background-color: #fff;
    }

    #leaderboardTable th.col-name-mobile,
    #leaderboardTable td.col-name-mobile {
        position: sticky;
        left: 45px;
        z-index: 2;
        background-color: #fff;
        border-right: 2px solid #dee2e6;
    }

    /* Ensure odd rows retain their striped appearance even while frozen.
       Must use solid opaque color so underlying scroll text doesn't bleed through. */
    #scoresTable tbody tr:nth-of-type(odd) td.col-sel-mobile,
    #scoresTable tbody tr:nth-of-type(odd) td.col-name-mobile,
    #leaderboardTable tbody tr:nth-of-type(odd) td.col-rank,
    #leaderboardTable tbody tr:nth-of-type(odd) td.col-name-mobile {
        background-color: #f2f2f2;
    }

    /* Ensure table headers sit above table cells */
    #scoresTable th.col-sel-mobile,
    #scoresTable th.col-name-mobile,
    #leaderboardTable th.col-rank,
    #leaderboardTable th.col-name-mobile {
        z-index: 3;
        background-color: #343a40; /* Match dark header */
    }
}

/* Specific Mobile overrides (max-width: 575.98px) */
@media (max-width: 575.98px) {
    /* Add bottom margin to action buttons on mobile to prevent stacking overlap */
    #deleteTournamentBtn,
    #editTournamentBtn,
    #forceSaveBtn,
    button[data-bs-target="#newTournamentModal"],
    #deletePlayerBtn,
    #editPlayerBtn,
    button[data-bs-target="#addPlayerModal"] {
        margin-bottom: 5px;
    }
}

/* Footer updates */
.footer-spaced {
    margin-top: 60px;
}

.contact-link {
    text-decoration: none;
}
.contact-link:hover {
    text-decoration: underline;
}
