/* Basic page styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    display: flex;
    justify-content: center;
    padding: 20px;
    margin: 0;
}

main {
    position: relative; /* This is the new "anchor" for our dogs */
    overflow: visible !important; /* Lets the dogs peek out */
    width: 100%;
    max-width: 800px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

h1 {
    text-align: center;
    padding: 20px 0;
    margin: 0;
    background-color: #fafafa;
    border-bottom: 1px solid #eee;
    font-size: 1.5em;
    color: #111;
}

.table-container {
    overflow-x: auto; /* Allows horizontal scrolling on small screens */
}

/* Table styling */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

/* Table Header */
thead tr {
    background-color: #f9f9f9;
}

th {
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    font-size: 0.85em;
}

/* Table Body */
tbody tr:nth-child(even) {
    background-color: #fdfdfd; /* Stripe effect */
}

tbody tr:hover {
    background-color: #f1f1f1;
}

td:first-child {
    font-weight: 500;
    color: #000;
}

/* Mimic the image styles */
.total-score {
    font-weight: 700;
    color: #D9534F; /* Red color for totals */
}

.default-score {
    background-color: #ececec !important; /* Gray background for default */
    color: #333;
}

/* Table Footer (for Averages) */
tfoot tr {
    background-color: #fafafa;
    font-weight: 700;
}

.note {
    padding: 15px;
    font-size: 0.9em;
    color: #777;
    background-color: #fdfdfd;
    border-top: 1px solid #eee;

}

/* --- Add these styles for the chart --- */

.chart-container {
    padding: 20px;
    border-top: 1px solid #eee;
    margin-top: 20px;
}

.chart-container h2 {
    text-align: center;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    font-size: 1.25em;
}

/* --- Add these styles for the new chart's toggles --- */

/* This creates a responsive grid for the checkboxes */
#team-toggle-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 250px; /* Makes the box scrollable */
    overflow-y: auto;
    background-color: #fcfcfc;
    border: 1px solid #eee;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

/* Styles for each checkbox item */
#team-toggle-container div {
    display: flex;
    align-items: center;
    gap: 8px;
}

#team-toggle-container label {
    font-size: 0.9em;
    color: #333;
    cursor: pointer;
}

#team-toggle-container input[type="checkbox"] {
    cursor: pointer;
}

/* --- FUNNY DACHSHUND EASTER EGG --- */
/* To remove, just delete this entire block. */

/* Common styles for both dogs */
main#leaderboard::before,
main#leaderboard::after {
    content: '';
    position: absolute;
    top: 0px; /* Sits just below the main white box */
    
    /* Your image is 1343x807. We'll make it 200px wide. */
    /* (807 / 1343) * 200px = 120px */
    width: 200px;
    height: 120px; 
    
    background-image: url('dachs.png');
    background-size: contain;
    background-repeat: no-repeat;
    
    /* Tucks it *behind* the charts just slightly */
    z-index: -1; 
}

/* Dog 1: Peeking from the left */
/* (He's facing right, so he's looking AT the scores) */
main#leaderboard::before {
    left: 0;
    transform: translateX(-50%); /* Hides 65% of his body */
}

/* Dog 2: Peeking from the right */
/* (He's facing right, so he's running OFF the page) */
main#leaderboard::after {
    right: 0;
    transform: translateX(65%); /* Hides 65% of his body */
}
/* --- END OF DACHSHUND --- */


/* Reduce width of the Position column */
th:first-child, td:first-child {
    width: 40px;
    text-align: center;
}

/* --- CALCULATOR STYLES --- */

.calc-container {
    margin-top: 30px;
    padding: 20px 10px; /* Less side padding for mobile space */
    background-color: #f8f9fa;
    border-top: 2px solid #eee;
}

.calc-container h2 {
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.2em;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9em;
    color: #555;
    text-align: center;
}

/* The row container */
.hcp-row {
    display: flex;
    gap: 5px; /* Tight gap to fit 5 columns */
    justify-content: space-between;
}

/* Each player column (Initials on top, Number on bottom) */
.player-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1; /* Distribute space evenly */
    min-width: 0; /* Prevents flex items from overflowing on tiny screens */
}

/* Common input styles */
.player-col input {
    width: 100%;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 0;
    box-sizing: border-box; 
}

/* Initials specific style */
.init-input {
    font-size: 0.75em;
    text-transform: uppercase;
    background-color: #fff;
    color: #777;
}

/* Handicap number specific style */
.hcp-input {
    font-size: 1em;
    padding: 8px 0;
    font-weight: bold;
}

#gross-input {
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    text-align: center;
}

/* Results Box */
.calc-results {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    text-align: center;
    margin-top: 20px;
}

.calc-details {
    font-size: 0.85em;
    color: #777;
    margin-bottom: 5px;
}

.final-net-score {
    font-size: 1.8em;
    font-weight: 800;
    color: #2c3e50;
}

.calc-formula-text {
    font-size: 0.75em;
    color: #aaa;
    margin-top: 5px;
}

/* --- STICKY COLUMNS & SCROLLING --- */

.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 4px;
    border: 1px solid #eee;
}

table {
    border-collapse: separate; 
    border-spacing: 0;
    min-width: 100%;
}

/* Base sticky behavior */
.sticky-col {
    position: sticky;
    background-color: #fff;
    z-index: 10;
}

th.sticky-col {
    z-index: 20;
    background-color: #2c3e50;
    color: white;
}

tfoot .sticky-col {
    background-color: #f8f9fa;
    font-weight: bold;
}

/* --- COLUMN WIDTHS & POSITIONS --- */

/* 1. Position Column (Fixed width, always stuck) */
.col-pos {
    left: 0;
    width: 45px;      /* Reduced from 50px */
    min-width: 45px;
    max-width: 45px;
    border-right: 1px solid #eee;
    padding: 8px 2px !important; /* Tight padding */
}

/* 2. Name Column (Always stuck) */
.col-name {
    left: 45px;       /* Starts after 45px Pos col */
    width: 160px;     /* Reduced from 180px */
    min-width: 160px;
    max-width: 160px;
    border-right: 1px solid #eee;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds "..." if name is too long */
    white-space: nowrap;
}

/* 3. Total Column (Desktop: Stuck / Mobile: Scrolls) */
.col-total {
    width: 70px;
    min-width: 70px;
    text-align: center;
    font-weight: bold;
    color: #2c3e50;
    border-right: 2px solid #ccc;
}

/* --- RESPONSIVE LOGIC --- */

/* DESKTOP (Screens wider than 768px) */
@media (min-width: 768px) {
    .col-total {
        position: sticky;
        left: 205px; /* 45px (Pos) + 160px (Name) */
        z-index: 10;
        background-color: #fff; /* Opaque so scores hide behind it */
    }
    th.col-total {
        z-index: 20;
        background-color: #2c3e50;
        color: white;
    }
    tfoot .col-total {
        background-color: #f8f9fa;
    }
}

/* MOBILE (Screens narrower than 768px) */
@media (max-width: 767px) {
    .col-total {
        position: static; /* Un-stick it! */
        border-right: 1px solid #eee; /* Normal border, not the heavy divider */
        box-shadow: none;
    }
    
    /* On mobile, the "Name" column becomes the edge, so give IT the heavy border */
    .col-name {
        border-right: 2px solid #ccc;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    }
}




