body {
    font-family: 'Georgia', 'Times New Roman', serif;
    margin: 0;
    padding: 0;
    background-color: #f8f6f2;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    color: #5a4a3a;
}

a {
    transition: color 0.3s ease;
}

header {
    background-color: #4f3d27;
    color: #f8f6f2;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

header h1 {
    color: #ffffff;
    margin: 0 0 0.75rem 0;
    font-size: 1.8rem;
    text-align: center;
}

@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
}

nav a {
    color: #f8f6f2;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 4px;
}

nav a:hover {
    background-color: rgba(255,255,255,0.1);
    color: #ffffff;
}

@media (max-width: 768px) {
    nav {
        gap: 0.5rem;
        font-size: 1.05rem;
    }
    
    nav a {
        padding: 0.5rem 0.75rem;
    }
}

main {
    padding: 2rem;
    text-align: center;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    main {
        padding: 1rem;
    }
}

.competitor-item {
    background-color: #ffffff;
    border: 1px solid #c9b8a0;
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

@media (max-width: 768px) {
    .competitor-item {
        flex-direction: column;
        gap: 0.5rem;
    }
}

.competitor-item span {
    flex-grow: 1;
}

.competitor-edit {
    background-color: #faf9f7;
    border: 1px solid #c9b8a0;
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
}

.competitor-edit form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.competitor-edit label {
    margin-right: 0.5rem;
}

.competitor-edit input {
    padding: 0.5rem;
    border: 1px solid #c9b8a0;
    border-radius: 6px;
    background-color: #ffffff;
}

.btn-danger {
    background-color: #c1665a;
    color: #ffffff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-danger:hover {
    background-color: #a85548;
}

.search-form {
    margin-bottom: 2rem;
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .search-form {
        flex-direction: column;
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
    }
}

.search-input {
    padding: 0.75rem;
    border: 1px solid #c9b8a0;
    border-radius: 8px;
    flex-grow: 1;
    min-width: 200px;
    background-color: #ffffff;
    font-family: 'Georgia', serif;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .search-input {
        width: 100%;
        min-width: unset;
    }
}

.search-button {
    padding: 0.75rem 1.5rem;
    background-color: #7a9b7f;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 1rem;
}

.search-button:hover {
    background-color: #6a8b6f;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

@media (max-width: 768px) {
    .search-button {
        width: 100%;
    }
}

.clear-search {
    color: #7a9b7f;
    text-decoration: none;
    padding: 0.5rem;
    font-weight: 500;
}

.clear-search:hover {
    text-decoration: underline;
    color: #6a8b6f;
}

@media (max-width: 768px) {
    .clear-search {
        display: block;
        text-align: center;
        width: 100%;
    }
}

.competitions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .competitions-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.competition-card {
    border: 1px solid #c9b8a0;
    border-radius: 12px;
    padding: 1.5rem;
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: left;
}

.competition-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.competition-card h3 {
    margin-top: 0;
    color: #5a4a3a;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .competition-card {
        padding: 1.25rem;
    }
}

.competition-details p {
    margin: 0.5rem 0;
    color: #6a5a4a;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .competition-details p {
        font-size: 0.9rem;
    }
}

.view-competition {
    display: block;
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #7a9b7f 0%, #6a8b6f 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    margin-top: 1rem;
    font-weight: 600;
    font-size: 1.05rem;
    font-family: 'Georgia', serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(122, 155, 127, 0.3);
    text-transform: none;
    letter-spacing: 0.3px;
}

.view-competition:hover {
    background: linear-gradient(135deg, #6a8b6f 0%, #5a7b5f 100%);
    box-shadow: 0 5px 15px rgba(122, 155, 127, 0.4);
    transform: translateY(-2px);
}

.view-competition:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(122, 155, 127, 0.3);
}

.view-competition:focus {
    outline: 3px solid rgba(122, 155, 127, 0.5);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .view-competition {
        padding: 1.1rem 1.5rem;
        font-size: 1.1rem;
        border-radius: 12px;
    }
}

.no-competitions {
    text-align: center;
    padding: 2rem;
    color: #6a5a4a;
    background-color: #faf9f7;
    border-radius: 12px;
    border: 1px solid #c9b8a0;
}

@media (max-width: 768px) {
    .no-competitions {
        padding: 1.5rem;
    }
}

.competition-header {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
    text-align: left;
}

.competition-info h2 {
    margin-top: 0;
    color: #5a4a3a;
    border-bottom: 2px solid #c9b8a0;
    padding-bottom: 0.75rem;
}

@media (max-width: 768px) {
    .competition-header {
        padding: 1.25rem;
    }
    
    .competition-info h2 {
        font-size: 1.5rem;
    }
}

.routes-section {
    margin-bottom: 2rem;
}

.routes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .routes-grid {
        grid-template-columns: 1fr;
    }
}

.route-card {
    border: 1px solid #c9b8a0;
    border-radius: 8px;
    padding: 1rem;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.route-card h4 {
    margin-top: 0;
    color: #5a4a3a;
}

.competitors-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .competitors-list {
        grid-template-columns: 1fr;
    }
}

.competitor-card {
    border: 1px solid #c9b8a0;
    border-radius: 8px;
    padding: 1rem;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.competitor-card h3 {
    margin-top: 0;
    color: #5a4a3a;
}

.enter-competition {
    text-align: center;
    margin-top: 2rem;
    padding: 2rem;
    background-color: #faf9f7;
    border-radius: 12px;
    border: 1px solid #c9b8a0;
}

@media (max-width: 768px) {
    .enter-competition {
        padding: 1.5rem;
    }
}

.enter-button {
    display: inline-block;
    padding: 1rem 2rem;
    background-color: #7a9b7f;
    color: #ffffff;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    font-family: 'Georgia', serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.enter-button:hover {
    background-color: #6a8b6f;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

@media (max-width: 768px) {
    .enter-button {
        width: 100%;
        padding: 1.25rem;
    }
}

.competitor-info {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
    text-align: left;
}

.competitor-info h2 {
    margin-top: 0;
    color: #5a4a3a;
    border-bottom: 2px solid #c9b8a0;
    padding-bottom: 0.75rem;
}

@media (max-width: 768px) {
    .competitor-info {
        padding: 1.25rem;
    }
}

.form-row {
    margin-bottom: 1rem;
}

.form-row label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #5a4a3a;
    font-family: 'Georgia', serif;
}

.form-row input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #c9b8a0;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #ffffff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.form-row input:focus {
    outline: none;
    border-color: #7a9b7f;
    box-shadow: 0 0 0 3px rgba(122,155,127,0.1);
}

@media (max-width: 768px) {
    .form-row input {
        font-size: 16px;
    }
}

.scoring-section {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
    text-align: left;
}

.scoring-section h2 {
    margin-top: 0;
    color: #5a4a3a;
    border-bottom: 2px solid #c9b8a0;
    padding-bottom: 0.75rem;
}

.scoring-section > p {
    color: #6a5a4a;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .scoring-section {
        padding: 1.25rem;
    }
    
    .scoring-section h2 {
        font-size: 1.4rem;
    }
}

.route-scoring {
    border: 1px solid #c9b8a0;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background-color: #faf9f7;
}

.route-scoring h4 {
    margin-top: 0;
    color: #5a4a3a;
    border-bottom: 1px solid #c9b8a0;
    padding-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .route-scoring {
        padding: 1rem;
    }
}

.score-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.score-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: #fefdfb;
    border-radius: 8px;
    border: 2px solid #d4a574;
    cursor: pointer;
    transition: all 0.3s ease;
}

.score-option:hover {
    background: linear-gradient(135deg, #f9f6f0 0%, #e8dcc8 50%);
    border-color: #8b5a3c;
    box-shadow: 0 2px 6px rgba(107,68,35,0.15);
}

.score-option input[type="radio"],
.score-option input[type="checkbox"] {
    margin: 0;
    accent-color: #7a9b6f;
}

.score-option span {
    font-weight: 500;
    color: #6b4423;
}

.form-actions {
    text-align: center;
    padding: 2rem;
}

.submit-button {
    padding: 1rem 3rem;
    background-color: #7a9b7f;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    font-family: 'Georgia', serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-button:hover {
    background-color: #6a8b6f;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

@media (max-width: 768px) {
    .submit-button {
        width: 100%;
        padding: 1.25rem;
    }
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 1.25rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #7a9b7f;
    text-align: center;
    font-weight: 500;
}

@media (max-width: 768px) {
    .success-message {
        padding: 1rem;
        font-size: 0.95rem;
    }
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1.25rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #c1665a;
    text-align: center;
    font-weight: 500;
}

@media (max-width: 768px) {
    .error-message {
        padding: 1rem;
        font-size: 0.95rem;
    }
}

.routes-summary {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
    text-align: left;
}

.routes-summary p {
    margin: 0.5rem 0;
    font-size: 1.05rem;
    color: #5a4a3a;
}

@media (max-width: 768px) {
    .routes-summary {
        padding: 1.25rem;
    }
}

.leaderboard {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .leaderboard {
        padding: 1rem;
        border-radius: 8px;
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
    }
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 600px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 0.875rem;
    text-align: center;
    border-bottom: 1px solid #e8e5e0;
    white-space: nowrap;
}

.leaderboard-table th {
    background-color: #7a9b7f;
    font-weight: 600;
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
}

@media (max-width: 768px) {
    .leaderboard-table {
        font-size: 0.8rem;
        min-width: 500px;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.75rem 0.5rem;
    }
}

.leaderboard-table .position {
    font-weight: 600;
    font-size: 1.05em;
    text-align: center;
    width: 50px;
    min-width: 50px;
}

.leaderboard-table .name {
    font-weight: 500;
    min-width: 120px;
    text-align: left;
    padding-left: 1rem !important;
}

.leaderboard-table .phone {
    font-family: monospace;
    color: #6a5a4a;
    font-size: 0.85em;
    min-width: 100px;
}

.leaderboard-table .total-points {
    font-weight: 600;
    font-size: 1.1em;
    color: #7a9b7f;
    min-width: 80px;
}

@media (max-width: 768px) {
    .leaderboard-table .name {
        min-width: 100px;
        padding-left: 0.5rem !important;
    }
    
    .leaderboard-table .phone {
        min-width: 90px;
        font-size: 0.75em;
    }
}

.first-place {
    background-color: #fff8e1 !important;
    border-left: 4px solid #d4a574;
}

.second-place {
    background-color: #f5f5f5 !important;
    border-left: 4px solid #9e9e9e;
}

.third-place {
    background-color: #fbe9e7 !important;
    border-left: 4px solid #b87a5f;
}

.leaderboard-table tbody tr:hover {
    background-color: #faf9f7;
}

/* Authentication Styles */
.auth-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
}

@media (max-width: 768px) {
    .auth-container {
        margin: 1rem;
        padding: 1.5rem;
    }
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    color: #6a5a4a;
}

.auth-link a {
    color: #7a9b7f;
    font-weight: 500;
    text-decoration: none;
}

.auth-link a:hover {
    color: #6a8b6f;
    text-decoration: underline;
}

.user-info {
    color: #f8f6f2;
    font-weight: 400;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}

@media (max-width: 768px) {
    .user-info {
        display: none;
    }
}

.logout-btn {
    background: none;
    border: 1px solid #f8f6f2;
    color: #f8f6f2;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    font-family: 'Georgia', serif;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background-color: #f8f6f2;
    color: #5a4a3a;
}

@media (max-width: 768px) {
    .logout-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* Admin Users Management */
.users-table-container {
    overflow-x: auto;
    margin-top: 2rem;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
}

.users-table th,
.users-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e8e5e0;
}

.users-table th {
    background-color: #7a9b7f;
    font-weight: 600;
    color: #ffffff;
}

@media (max-width: 768px) {
    .users-table {
        font-size: 0.85rem;
    }
    
    .users-table th,
    .users-table td {
        padding: 0.5rem;
    }
}

.role-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.role-admin {
    background-color: #c1665a;
    color: #ffffff;
}

.role-judge {
    background-color: #d4a574;
    color: #3e2723;
}

.role-user {
    background-color: #7a9b7f;
    color: #ffffff;
}

.role-form {
    margin: 0;
}

.role-select {
    padding: 0.5rem;
    border: 1px solid #c9b8a0;
    border-radius: 6px;
    background-color: #ffffff;
    font-family: 'Georgia', serif;
}

.no-users {
    text-align: center;
    padding: 2rem;
    color: #6a5a4a;
    font-style: italic;
}

.search-section {
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Scoresheet Styles */
.scoresheet-card {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #c9b8a0;
}

.scoresheet-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #5a4a3a;
    border-bottom: 2px solid #c9b8a0;
    padding-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .scoresheet-card {
        padding: 1rem;
    }
}

.scoresheet-details {
    margin-top: 1rem;
}

.scoresheet-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background-color: #f9f6f0;
    border-radius: 8px;
    overflow: hidden;
}

.scoresheet-table th,
.scoresheet-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 2px solid #e8dcc8;
}

.scoresheet-table th {
    background: linear-gradient(135deg, #d4a574 0%, #c4965f 100%);
    font-weight: bold;
    color: #f5f1e8;
}

.scoresheet-table tbody tr:hover {
    background-color: #f5f1e8;
}

.scoresheet-total {
    text-align: right;
    font-size: 1.1rem;
    font-weight: bold;
    color: #7a9b6f;
    padding: 1rem;
    background-color: #f9f6f0;
    border-radius: 8px;
    margin-top: 1rem;
    border: 2px solid #d4a574;
}