:root {
    --green-dark: #1a4d2e;
    --green-primary: #2d7a4f;
    --green-light: #4caf6f;
    --green-accent: #7ed957;
    --cream: #faf8f3;
    --sand: #e8dcc4;
    --gold: #d4af37;
    --text-dark: #1a1a1a;
    --text-light: #666;
    --white: #ffffff;
    --shadow: rgba(26, 77, 46, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--cream) 0%, var(--sand) 100%);
    color: var(--text-dark);
    min-height: 100vh;
    position: relative;
}

.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
    opacity: 0.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 2;
}

/* Header */
.header {
    background: var(--green-dark);
    color: var(--white);
    padding: 32px 0;
    box-shadow: 0 8px 32px var(--shadow);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(125, 217, 87, 0.1) 100%);
    pointer-events: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
}

.logo-link {
    text-decoration: none;
    color: inherit;
}

.logo {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 0.85;
}

.logo-main {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 64px;
    font-weight: 400;
    letter-spacing: 8px;
    color: #e8dcc8;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.logo-sub {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 48px;
    font-weight: 400;
    letter-spacing: 12px;
    color: var(--white);
    margin-left: 4px;
}

.tournament-info {
    text-align: right;
}

.tournament-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--white);
}

.last-update {
    font-size: 14px;
    font-weight: 300;
    color: rgba(255,255,255,0.7);
}

/* Controls */
.controls {
    margin: 40px 0 32px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    font-family: 'Outfit', sans-serif;
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--green-primary);
    color: var(--white);
    box-shadow: 0 4px 16px rgba(45, 122, 79, 0.3);
}

.btn-primary:hover {
    background: var(--green-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(45, 122, 79, 0.4);
}

.btn-icon {
    font-size: 20px;
    display: inline-block;
    transition: transform 0.3s ease;
}

.btn-primary:hover .btn-icon {
    transform: rotate(180deg);
}

.search-box {
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Outfit', sans-serif;
    background: var(--white);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.search-input:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 4px 16px rgba(45, 122, 79, 0.2);
}

/* Status Messages */
.status-message {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    display: none;
}

.status-message.show {
    display: block;
    animation: slideDown 0.3s ease;
}

.status-message.error {
    background: #fee;
    color: #c33;
    border-left: 4px solid #c33;
}

.status-message.success {
    background: #efe;
    color: #2d7a4f;
    border-left: 4px solid var(--green-primary);
}

/* Leaderboard */
.leaderboard-container {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--shadow);
    margin-bottom: 60px;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 60px 80px 1fr 160px;
    gap: 16px;
    padding: 20px 24px;
    background: var(--green-dark);
    color: var(--white);
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    align-items: center;
}

.leaderboard-header > div {
    text-align: center;
}

.leaderboard-header > div:nth-child(3) {
    text-align: left;
}

.leaderboard-body {
    min-height: 400px;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 20px;
    color: var(--text-light);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--sand);
    border-top-color: var(--green-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.team-row {
    display: grid;
    grid-template-columns: 60px 80px 1fr 160px;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--sand);
    transition: all 0.3s ease;
    cursor: pointer;
    animation: fadeIn 0.5s ease;
    animation-fill-mode: both;
    align-items: center;
}

.team-row:hover {
    background: var(--cream);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rank {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 32px;
    color: var(--green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rank.top3 {
    color: var(--green-dark);
}

.team-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.team-number-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    text-align: center;
}

.roster {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: stretch;
    overflow: hidden;
}

.roster::-webkit-scrollbar {
    display: none;
}

.player-chip {
    background: var(--cream);
    padding: 6px 6px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dark);
    border: 1px solid var(--sand);
    transition: all 0.2s ease;
    width: 128px;
    min-width: 128px;
    max-width: 128px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
}

.player-chip.not-in-field {
    opacity: 0.45;
}

.player-chip:hover {
    background: var(--green-primary);
    color: var(--white);
    border-color: var(--green-primary);
}

.player-chip:hover .player-earnings {
    color: rgba(255, 255, 255, 0.8);
}

.player-chip.earning {
    background: var(--green-light);
    color: var(--white);
    border-color: var(--green-light);
}

.player-chip.earning .player-earnings {
    color: rgba(255, 255, 255, 0.85);
}

.player-name {
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.player-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.player-position {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
    line-height: 1;
    text-align: left;
}

.player-earnings {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
    line-height: 1;
    text-align: right;
}

.player-chip.earning .player-position {
    color: rgba(255, 255, 255, 0.85);
}

.player-chip:hover .player-position {
    color: rgba(255, 255, 255, 0.8);
}

.earnings {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 26px;
    color: var(--green-dark);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.show {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 77, 46, 0.8);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-light);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--text-dark);
    transform: rotate(90deg);
}

.modal-team-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 42px;
    color: var(--green-dark);
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.modal-player-list {
    list-style: none;
}

.modal-player-item {
    padding: 16px;
    border-bottom: 1px solid var(--sand);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-player-item:last-child {
    border-bottom: none;
}

.modal-player-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.modal-player-earnings {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 24px;
    color: var(--green-primary);
}

.modal-total {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px solid var(--green-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-total-label {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

.modal-total-amount {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 36px;
    color: var(--green-dark);
}

/* Cumulative Season Standings */
.cumulative-header {
    display: grid;
    grid-template-columns: 60px 70px repeat(5, 1fr) 140px;
    gap: 8px;
    padding: 16px 24px;
    background: var(--green-dark);
    color: var(--white);
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.cumulative-header .sortable {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s ease;
}

.cumulative-header .sortable:hover {
    opacity: 0.8;
}

.cumulative-header .sortable.active {
    color: var(--white);
}

.cumulative-row {
    display: grid;
    grid-template-columns: 60px 70px repeat(5, 1fr) 140px;
    gap: 8px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--sand);
    align-items: center;
    animation: fadeIn 0.4s ease;
    animation-fill-mode: both;
    transition: background 0.2s ease;
}

.cumulative-row:hover {
    background: var(--cream);
}

.c-rank {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    color: var(--green-dark);
    text-align: center;
}

.c-rank.top3 {
    color: var(--green-dark);
    font-weight: 700;
}

.c-team-num {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
}

.c-tourney-val {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dark);
    text-align: center;
}

.c-total-val {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    color: var(--green-dark);
    text-align: center;
    font-weight: 700;
}

.no-result {
    color: var(--text-light);
    opacity: 0.4;
}

/* Page Navigation */
.page-nav {
    display: flex;
    gap: 4px;
    margin: 32px 0 24px;
    background: var(--white);
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 2px 8px var(--shadow);
    width: fit-content;
}

.nav-link {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-dark);
    background: var(--cream);
}

.nav-link.active {
    background: var(--green-primary);
    color: var(--white);
}

/* Tournament Leaderboard */
.tournament-leaderboard-header {
    display: grid;
    grid-template-columns: 70px 1fr 80px 70px 80px 70px 140px;
    gap: 12px;
    padding: 16px 24px;
    background: var(--green-dark);
    color: var(--white);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.tournament-leaderboard-header > div:nth-child(2) {
    text-align: left;
}

.tournament-player-row {
    display: grid;
    grid-template-columns: 70px 1fr 80px 70px 80px 70px 140px;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--sand);
    align-items: center;
    animation: fadeIn 0.4s ease;
    animation-fill-mode: both;
    transition: background 0.2s ease;
}

.tournament-player-row:hover {
    background: var(--cream);
}

.tournament-player-row.top3 .t-pos {
    color: var(--green-dark);
    font-weight: 700;
}

.t-pos {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    color: var(--green-dark);
    text-align: center;
}

.t-player {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

.t-score {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    color: var(--green-dark);
    text-align: center;
}

.t-thru {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    text-align: center;
}

.t-round {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    text-align: center;
}

.t-earnings {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px;
    color: var(--green-dark);
    text-align: center;
}

.t-rosters {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
}

/* Player chip name row with roster count */
.player-name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.player-name-row .player-name {
    text-align: right;
    flex: 1;
    min-width: 0;
}

.player-roster-count {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-light);
    background: rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.player-chip.earning .player-roster-count {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.player-chip:hover .player-roster-count {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

/* Responsive */
@media (max-width: 968px) {
    .leaderboard-header,
    .team-row {
        grid-template-columns: 50px 70px 1fr 120px;
        gap: 10px;
        padding: 14px 16px;
    }
    
    .roster {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    
    .player-chip {
        width: 100px;
        min-width: 100px;
        max-width: 100px;
        padding: 5px 4px;
    }
    
    .player-name {
        font-size: 10px;
    }
    
    .player-earnings,
    .player-position {
        font-size: 9px;
    }

    .player-roster-count {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }

    .logo-main {
        font-size: 48px;
    }
    
    .logo-sub {
        font-size: 36px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .tournament-info {
        text-align: center;
    }

    .tournament-leaderboard-header,
    .tournament-player-row {
        grid-template-columns: 60px 1fr 70px 60px 70px 60px 120px;
        gap: 8px;
        padding: 12px 16px;
    }

    .cumulative-header,
    .cumulative-row {
        grid-template-columns: 50px 60px repeat(5, 1fr) 120px;
        gap: 6px;
        padding: 12px 16px;
    }

    .cumulative-header {
        font-size: 11px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 12px;
    }

    .leaderboard-header {
        display: none;
    }

    .team-row {
        display: grid;
        grid-template-columns: 44px 1fr auto;
        grid-template-rows: auto auto;
        gap: 4px 10px;
        padding: 14px 16px;
        position: relative;
    }

    /* Row 1: rank + team # + earnings side by side */
    .team-row .rank {
        grid-column: 1;
        grid-row: 1;
        font-size: 26px;
        position: static;
    }

    .team-info {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
    }

    .team-number-label {
        font-size: 16px;
        font-weight: 700;
    }

    .earnings {
        grid-column: 3;
        grid-row: 1;
        font-size: 22px;
        justify-content: flex-end;
        color: var(--green-primary);
    }

    /* Row 2: roster spans full width, scrollable */
    .roster {
        grid-column: 1 / -1;
        grid-row: 2;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        padding: 4px 0 2px;
        scrollbar-width: thin;
    }

    .player-chip {
        min-width: 120px;
        max-width: 120px;
        width: 120px;
        flex-shrink: 0;
        padding: 8px 6px;
    }

    .player-name {
        font-size: 11px;
    }

    .player-earnings,
    .player-position {
        font-size: 10px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: 100%;
    }

    .page-nav {
        width: 100%;
    }

    .nav-link {
        flex: 1;
        text-align: center;
        padding: 10px 12px;
        font-size: 13px;
    }

    .tournament-leaderboard-header {
        grid-template-columns: 50px 1fr 60px 50px 60px 50px;
        gap: 6px;
        padding: 12px 12px;
        font-size: 11px;
    }

    .tournament-leaderboard-header > div:last-child {
        display: none;
    }

    .tournament-player-row {
        grid-template-columns: 50px 1fr 60px 50px 60px 50px;
        gap: 6px;
        padding: 10px 12px;
    }

    .t-earnings {
        display: none;
    }

    .t-pos {
        font-size: 18px;
    }

    .t-player {
        font-size: 13px;
    }

    .t-score {
        font-size: 18px;
    }

    .t-thru, .t-round {
        font-size: 12px;
    }

    .cumulative-header {
        grid-template-columns: 40px 50px repeat(5, 1fr);
        gap: 4px;
        padding: 12px 10px;
        font-size: 10px;
    }

    .cumulative-header > div:last-child {
        display: none;
    }

    .cumulative-row {
        grid-template-columns: 40px 50px repeat(5, 1fr);
        gap: 4px;
        padding: 10px 10px;
    }

    .c-total-val {
        display: none;
    }

    .c-rank {
        font-size: 16px;
    }

    .c-team-num {
        font-size: 12px;
    }

    .c-tourney-val {
        font-size: 11px;
    }
}
