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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a5f2a 0%, #2d8a3e 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

header .subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

main {
    padding: 30px;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #444;
}

input[type="number"],
input[type="text"] {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="number"]:focus,
input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: #2d8a3e;
    box-shadow: 0 0 0 3px rgba(45, 138, 62, 0.1);
}

input[type="number"] {
    width: 100px;
}

select {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus {
    outline: none;
    border-color: #2d8a3e;
    box-shadow: 0 0 0 3px rgba(45, 138, 62, 0.1);
}

.field-description {
    margin-top: 6px;
    color: #666;
    font-size: 0.85rem;
}

.add-player-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.add-player-form input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.teams-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    min-height: 50px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #e0e0e0;
}

.team-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #2d8a3e 0%, #1a5f2a 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.team-tag .team-number {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.team-tag .remove-team {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: background 0.2s;
}

.team-tag .remove-team:hover {
    background: rgba(255, 255, 255, 0.4);
}

.add-team-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.add-team-form input {
    flex: 1;
    min-width: 150px;
}

.quick-add {
    margin-bottom: 24px;
}

.quick-add label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #444;
}

.quick-add textarea {
    width: 100%;
    height: 100px;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 10px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 16px;
    font-size: 1.1rem;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
}

.setup-section .btn-primary {
    width: 100%;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

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

/* Manual Setup Section */
.assigned-badge {
    background: #2d8a3e;
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.schedule-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #f0f0f0;
}

.schedule-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

.round {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid transparent;
}

.round.has-assignments {
    border-color: #2d8a3e;
}

.round-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.round h3 {
    color: #2d8a3e;
    font-size: 1.2rem;
}

.round-header .bye-info {
    color: #666;
    font-style: italic;
    font-size: 0.9rem;
}

.bye-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bye-selector label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.bye-selector select {
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    min-width: 140px;
}

.bye-selector select:focus {
    outline: none;
    border-color: #2d8a3e;
}

.round.has-assignments .bye-selector select {
    border-color: #2d8a3e;
    background: #e8f5e9;
}

.bye-print-text {
    display: none;
}

.matches {
    display: grid;
    gap: 12px;
}

.match {
    background: white;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.match:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.match.match-assigned {
    border-color: #2d8a3e;
    background: #f0fff4;
}

/* Round selector dropdown */
.round-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 12px;
}

.round-selector label {
    font-size: 0.8rem;
    color: #666;
    font-weight: 500;
}

.round-selector select {
    padding: 6px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    min-width: 60px;
}

.round-selector select:focus {
    outline: none;
    border-color: #2d8a3e;
}

.match.match-assigned .round-selector select {
    border-color: #2d8a3e;
    background: #e8f5e9;
}

.court-badge {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-right: 16px;
    min-width: 70px;
    text-align: center;
}

.match-teams {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.team-name {
    font-weight: 500;
    color: #333;
    min-width: 150px;
}

.vs {
    color: #999;
    font-weight: 600;
    font-size: 0.9rem;
}

.summary-section {
    margin-top: 30px;
}

.summary-section h3 {
    color: #333;
    margin-bottom: 16px;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.summary-table th,
.summary-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.summary-table th {
    background: #2d8a3e;
    color: white;
    font-weight: 600;
}

.summary-table tr:hover {
    background: #f8f9fa;
}

.summary-table tr:last-child td {
    border-bottom: none;
}

footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

/* Checkbox styling */
.checkbox-group {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #2d8a3e;
}

.checkbox-description {
    margin-top: 6px;
    margin-left: 30px;
    color: #666;
    font-size: 0.9rem;
}

/* Score input styling */
.score-input {
    width: 60px !important;
    padding: 6px 4px !important;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
}

.score-input:focus {
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.match-scored {
    background: #f0fff4 !important;
    border-color: #2d8a3e !important;
}

.match-scored .score-input {
    border-color: #2d8a3e;
    background: #e8f5e9;
}

/* Standings section */
.standings-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #f0f0f0;
}

.standings-section h3 {
    color: #333;
    margin-bottom: 16px;
}

.standings-progress {
    color: #666;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.standings-table th,
.standings-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.standings-table th {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    font-weight: 600;
}

.standings-table tr:hover {
    background: #f8f9fa;
}

.standings-table tr:last-child td {
    border-bottom: none;
}

.standings-table tr.leader {
    background: #fff8e1;
}

.standings-table tr.leader:hover {
    background: #fff3cd;
}

.standings-table .rank {
    font-weight: 700;
    color: #ff6b35;
    width: 50px;
}

.standings-table .team-name-cell {
    font-weight: 500;
}

.standings-table .record {
    font-weight: 600;
    color: #333;
}

.standings-table .margin {
    font-weight: 500;
}

.standings-table .margin.positive {
    color: #2d8a3e;
}

.standings-table .margin.negative {
    color: #dc3545;
}

.standings-note {
    margin-top: 12px;
    color: #888;
    font-size: 0.85rem;
    font-style: italic;
}

/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        box-shadow: none;
    }

    .setup-section,
    .schedule-controls,
    .round-selector,
    .bye-selector,
    footer {
        display: none;
    }

    .bye-print-text {
        display: inline !important;
        color: #666;
        font-style: italic;
        font-size: 0.9rem;
    }

    .schedule-section {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    .hidden {
        display: block !important;
    }

    .round {
        break-inside: avoid;
    }

    .score-input {
        border: 1px solid #ccc;
        background: white;
        -webkit-appearance: none;
        -moz-appearance: textfield;
    }

    .standings-section {
        break-before: page;
    }

    .standings-note {
        display: none;
    }
}

/* Responsive styles */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.5rem;
    }

    .match {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }

    .round-selector {
        margin-right: 8px;
    }

    .round-selector label {
        font-size: 0.75rem;
    }

    .round-selector select {
        padding: 4px 6px;
        font-size: 0.8rem;
        min-width: 50px;
    }

    .court-badge {
        margin-right: 0;
        padding: 4px 8px;
        font-size: 0.75rem;
        min-width: auto;
    }

    .match-teams {
        flex: 1;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-start;
    }

    .team-name {
        min-width: auto;
        font-size: 0.9rem;
    }

    .vs {
        font-size: 0.8rem;
    }

    .score-input {
        width: 45px !important;
        padding: 4px 2px !important;
        font-size: 0.85rem;
    }

    .schedule-controls {
        flex-direction: column;
    }

    .schedule-controls .btn {
        width: 100%;
    }

    .mixed-columns {
        flex-direction: column;
    }

    .mixed-column {
        min-width: 100%;
    }

    .mixed-standings,
    .mixed-summary {
        flex-direction: column;
    }
}

/* Mixed Doubles Styles */
.mixed-columns {
    display: flex;
    gap: 24px;
}

.mixed-column {
    flex: 1;
    min-width: 250px;
}

.mixed-column label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #444;
}

.mixed-column h4 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1rem;
}

/* Gender-specific tag colors */
.male-tag {
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%) !important;
}

.female-tag {
    background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%) !important;
}

/* Mixed Standings */
.mixed-standings {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.standings-group {
    flex: 1;
    min-width: 300px;
    overflow-x: auto;
}

.standings-group h4 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.male-standings h4 {
    color: #1565C0;
}

.female-standings h4 {
    color: #C2185B;
}

/* Compact table styles for mixed standings */
.mixed-standings .standings-table th,
.mixed-standings .standings-table td {
    padding: 8px 10px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.mixed-standings .standings-table th {
    font-size: 0.8rem;
}

.mixed-standings .standings-table .rank {
    width: 40px;
}

.mixed-standings .standings-table .team-name-cell {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mixed Summary */
.mixed-summary {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.summary-column {
    flex: 1;
    min-width: 250px;
}

.summary-column h4 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1rem;
}
