/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #2d5016 0%, #3c4043 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
}

/* Tournament selector removed - simplified single tournament interface */

.tournament-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.9rem;
    color: #666;
    flex-wrap: wrap;
    gap: 1rem;
}

.tournament-details {
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.current-tournament {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tournament status removed - unnecessary UI element */

/* Tournament Management Section */
/* Tournament management section removed - simplified interface */

/* Main Content */
.main {
    padding: 2rem 0 4rem;
    min-height: calc(100vh - 200px);
}

/* Setup Phase */
.setup-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.setup-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.setup-card p {
    color: #666;
    margin-bottom: 1.5rem;
}

.racer-input-section {
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.input-group input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: #1B5E1F;
}

/* Car Number Input */
.car-number-input {
    max-width: 100px !important;
    text-align: center;
    font-weight: 600;
}

/* Age Group Select */
.age-group-select {
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    min-width: 180px;
    transition: border-color 0.2s;
}

.age-group-select:focus {
    outline: none;
    border-color: #1B5E1F;
}

/* Bulk Actions */
.bulk-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Racers List Header */
.racers-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.age-group-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.age-group-filter {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Age Group Stats */
.age-group-stats {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #0369a1;
}

.age-group-stats-content {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Filter Status */
.filter-status {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: #92400e;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #1B5E1F;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2E8B57;
    transform: translateY(-1px);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-1px);
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-outline {
    background: transparent;
    color: #1B5E1F;
    border: 2px solid #1B5E1F;
}

.btn-outline:hover {
    background: #1B5E1F;
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Racers List */
.racers-list h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.racers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.racer-card {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    position: relative;
    transition: all 0.2s;
    padding-top: 1rem;
    padding-right: 2.5rem;
}

.racer-card:hover {
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.racer-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
}

.racer-name {
    font-weight: 500;
    color: #2d3748;
}

.racer-age-group {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #e2e8f0;
    color: #4a5568;
    font-weight: 500;
    display: inline-block;
    max-width: fit-content;
}

.racer-age-group.no-age {
    background: #fed7d7;
    color: #c53030;
}

/* Age Group Specific Colors */
.age-group-tigers .racer-age-group { background: #fbb6ce; color: #97266d; }
.age-group-wolves .racer-age-group { background: #c6f6d5; color: #22543d; }
.age-group-bears .racer-age-group { background: #fbd38d; color: #7b341e; }
.age-group-webelos .racer-age-group { background: #bee3f8; color: #2a69ac; }
.age-group-arrow-of-light .racer-age-group { background: #d6f5d6; color: #276749; }
.age-group-scouts-bsa .racer-age-group { background: #e9d8fd; color: #553c9a; }
.age-group-adults .racer-age-group { background: #fed7e2; color: #97266d; }
.age-group-open .racer-age-group { background: #fbb6ce; color: #97266d; }

.remove-racer-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #fee2e2;
    color: #dc2626;
    border: 2px solid #fecaca;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.remove-racer-btn:hover {
    background: #dc2626;
    color: white;
    border-color: #b91c1c;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.3);
}

.setup-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Tournament Phase */
.tournament-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.round-info {
    text-align: center;
    flex: 1;
}

.current-round {
    font-weight: 600;
    color: #2d3748;
    font-size: 1.1rem;
}

.round-name {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Bracket */
.bracket-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    overflow-x: auto;
    min-height: 400px;
}

.bracket {
    display: flex;
    gap: 3rem;
    min-width: fit-content;
    align-items: center;
    justify-content: center;
}

.round {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 200px;
}

.round-title {
    text-align: center;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f7fafc;
    border-radius: 8px;
    font-size: 0.9rem;
}

.match {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.match:hover {
    border-color: #cbd5e0;
    transform: scale(1.02);
}

.match.completed {
    border-color: #48bb78;
    background: #f0fff4;
}

.match-participants {
    margin-bottom: 0.75rem;
}

.participant {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 6px;
    background: #f7fafc;
    transition: all 0.2s;
    cursor: pointer;
}

.participant:last-child {
    margin-bottom: 0;
}

.participant:hover {
    background: #edf2f7;
}

.participant.winner {
    background: #c6f6d5;
    font-weight: 600;
    color: #22543d;
}

.participant.bye {
    background: #fed7e2;
    color: #702459;
    font-style: italic;
}

.participant-name {
    font-weight: 500;
}

.participant-score {
    background: #2E8B57;
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    min-width: 30px;
    text-align: center;
}

.match-winner {
    text-align: center;
    padding: 0.5rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: #666;
}

/* Winner Announcement */
.winner-announcement {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.winner-card {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    animation: confettiDrop 0.6s ease-out;
}

.winner-card h2 {
    margin-bottom: 1rem;
    color: #2d3748;
    font-size: 2rem;
}

.winner-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #48bb78;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f0fff4;
    border-radius: 12px;
}

.confetti {
    font-size: 1.5rem;
    margin: 1rem 0;
    animation: bounce 1s infinite;
}

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Drag and Drop */
.participant.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.match.drag-over {
    border-color: #1B5E1F;
    background: #edf2f7;
}

/* Button Styles */
.btn-accent {
    background: linear-gradient(135deg, #3c4043, #2c3e50);
    color: white;
    border: none;
    font-weight: 600;
}

.btn-accent:hover {
    background: linear-gradient(135deg, #2c3e50, #3c4043);
    transform: translateY(-1px);
}

.btn-accent:disabled {
    background: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

/* Race day mode removed - simplified interface */

/* Enhanced Tournament Display */
@media (max-width: 768px) {
    .header-main {
        flex-direction: column;
        text-align: center;
    }
    
    .tournament-details {
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    text-align: center;
    padding: 1.5rem 0;
    color: rgba(255, 255, 255, 0.8);
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .title {
        font-size: 1.4rem;
    }

    .tournament-info {
        font-size: 0.8rem;
    }

    .setup-card {
        padding: 1.5rem;
    }

    .input-group {
        flex-direction: column;
    }

    .racers-grid {
        grid-template-columns: 1fr;
    }

    .tournament-controls {
        flex-direction: column;
        text-align: center;
    }

    .bracket {
        gap: 1.5rem;
    }

    .round {
        min-width: 180px;
    }

    .bracket-container {
        padding: 1rem;
    }

    .winner-card {
        margin: 1rem;
        padding: 2rem;
    }

    .setup-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .header .container {
        flex-direction: column;
        text-align: center;
    }

    .match {
        font-size: 0.9rem;
    }

    .participant {
        padding: 0.4rem 0.6rem;
    }

    .btn {
        font-size: 0.9rem;
        padding: 0.6rem 1.2rem;
    }

    .racers-list-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .age-group-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .age-group-stats-content {
        justify-content: center;
        text-align: center;
    }

    .racer-info {
        min-width: 0;
    }

    .racer-age-group {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }

    .bulk-actions {
        justify-content: center;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .header, .footer, .tournament-controls {
        display: none;
    }
    
    .bracket-container {
        background: white;
        box-shadow: none;
    }
}