* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

nav a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
}

nav a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

nav a.active {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Main */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    color: var(--text);
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.card h3 {
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover {
    background: var(--bg);
}

/* Clickable rows */
tr.clickable {
    cursor: pointer;
}

tr.clickable:hover {
    background: #e0f2fe;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary {
    background: #dbeafe;
    color: var(--primary);
}

.badge-success {
    background: #dcfce7;
    color: #16a34a;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
}

.badge-silver {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: white;
}

.badge-bronze {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

/* Player Name Display */
.player-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-name .alias {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Placement Display */
.placement {
    font-weight: 600;
    min-width: 2.5rem;
    display: inline-block;
}

.placement-1 { color: #fbbf24; }
.placement-2 { color: #94a3b8; }
.placement-3 { color: #d97706; }

/* Grid layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

/* Back button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    text-decoration: none;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.back-btn:hover {
    text-decoration: underline;
}

/* Search */
.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Select */
select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Hole scores grid */
.holes-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.hole-score {
    text-align: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
}

.hole-score .hole-num {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.7rem;
}

.hole-score .score {
    font-size: 1.1rem;
    font-weight: 600;
}

.score-under { background: #dcfce7; color: #16a34a; }
.score-par { background: var(--bg); }
.score-over { background: #fee2e2; color: #dc2626; }
.score-double { background: #fecaca; color: #b91c1c; }

/* Leaderboard specific */
.rank-cell {
    font-weight: 700;
    font-size: 1.1rem;
}

.rank-1 { color: #fbbf24; }
.rank-2 { color: #94a3b8; }
.rank-3 { color: #d97706; }

/* Footer */
footer {
    background: var(--text);
    color: rgba(255,255,255,0.6);
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.85rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 1rem auto;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Scorecard table */
.scorecard-table {
    overflow-x: auto;
}

.scorecard-table table {
    min-width: 900px;
}

.scorecard-table .sticky-col {
    position: sticky;
    left: 0;
    background: var(--card-bg);
    z-index: 1;
    width: 40px;
    text-align: center;
}

.scorecard-table .sticky-col2 {
    position: sticky;
    left: 40px;
    background: var(--card-bg);
    z-index: 1;
    min-width: 100px;
}

.scorecard-table .hole-col {
    text-align: center;
    min-width: 32px;
    width: 32px;
    font-size: 0.85rem;
}

.scorecard-table .subtotal-col {
    text-align: center;
    font-weight: 600;
    background: var(--bg);
    min-width: 40px;
}

.scorecard-table .total-col {
    text-align: center;
    font-weight: 700;
    background: var(--primary);
    color: white;
    min-width: 45px;
}

.scorecard-table .par-row {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Score colors */
.score-eagle {
    background: #fbbf24 !important;
    color: #92400e;
    font-weight: 700;
}

.score-birdie {
    background: #bbf7d0 !important;
    color: #166534;
    font-weight: 600;
}

.score-par {
    background: transparent;
}

.score-bogey {
    background: #fee2e2 !important;
    color: #991b1b;
}

.score-double {
    background: #fca5a5 !important;
    color: #7f1d1d;
    font-weight: 600;
}

/* Contact links */
#contactsTable a {
    color: var(--primary);
    text-decoration: none;
}

#contactsTable a:hover {
    text-decoration: underline;
}

/* Scorecard styles */
.scorecard-table {
    border-collapse: collapse;
    min-width: 100%;
}

.scorecard-table th,
.scorecard-table td {
    border: 1px solid var(--border);
    padding: 0.25rem 0.4rem;
    text-align: center;
    min-width: 28px;
}

.scorecard-table th {
    background: var(--bg);
    font-weight: 600;
}

.score-eagle {
    background: #fbbf24 !important;
    color: #000 !important;
    font-weight: bold;
}

.score-birdie {
    background: #22c55e !important;
    color: white !important;
}

.score-par {
    background: #e0e0e0;
}

.score-bogey {
    background: #f97316 !important;
    color: white !important;
}

.score-double {
    background: #ef4444 !important;
    color: white !important;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    nav {
        justify-content: center;
    }
    
    main {
        padding: 1rem;
    }
    
    .grid-2 {
        grid-template-columns: 1fr;
    }
    
    .holes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
