* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(90deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.2rem;
    margin-bottom: 5px;
    font-weight: 600;
    letter-spacing: 1px;
}

.header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

.bracket-container {
    width: 100%;
    height: 80vh;
    min-height: 600px;
    overflow: hidden;
    position: relative;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

svg {
    display: block;
    transition: transform 0.3s ease;
    cursor: grab;
    width: 100%;
    height: 100%;
}

svg:active {
    cursor: grabbing;
}

.controls {
    padding: 20px 30px;
    background: #f8fafc;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.btn {
    padding: 10px 20px;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn#setTeam {
    background: #27ae60;
}

.btn#simulate {
    background: #f39c12;
}

.btn#reset {
    background: #e74c3c;
}

.team-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.team-selector input, .team-selector select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 120px;
}

.status {
    margin-left: auto;
    padding: 8px 15px;
    background: #edf2f7;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.legend {
    padding: 20px 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    background: white;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* SVG styles */
.round-label {
    font-size: 16px;
    font-weight: bold;
    fill: #2d3748;
    text-anchor: middle;
}

.team-text, .semifinal-text, .final-text {
    font-size: 14px;
    font-weight: 600;
    fill: #2d3748;
    text-anchor: middle;
    pointer-events: none;
    transition: fill 0.3s ease;
}

.semifinal-text {
    fill: #1a4a7a;
}

.final-text {
    fill: #8b6500;
    font-weight: 700;
}

/* Team highlighting styles - multi-color support */
.highlighted-team-1 {
    fill: #e3f2fd !important;
    stroke: #1976d2 !important;
    stroke-width: 3 !important;
    transition: all 0.3s ease;
}

.highlighted-team-2 {
    fill: #fce4ec !important;
    stroke: #c2185b !important;
    stroke-width: 3 !important;
    transition: all 0.3s ease;
}

.highlighted-team-3 {
    fill: #f3e5f5 !important;
    stroke: #7b1fa2 !important;
    stroke-width: 3 !important;
    transition: all 0.3s ease;
}

.highlighted-team-4 {
    fill: #e8f5e8 !important;
    stroke: #388e3c !important;
    stroke-width: 3 !important;
    transition: all 0.3s ease;
}

.highlighted-team-5 {
    fill: #fff3e0 !important;
    stroke: #f57c00 !important;
    stroke-width: 3 !important;
    transition: all 0.3s ease;
}

.highlighted-text-1 {
    fill: #0d47a1 !important;
    font-weight: bold !important;
}

.highlighted-text-2 {
    fill: #880e4f !important;
    font-weight: bold !important;
}

.highlighted-text-3 {
    fill: #4a148c !important;
    font-weight: bold !important;
}

.highlighted-text-4 {
    fill: #1b5e20 !important;
    font-weight: bold !important;
}

.highlighted-text-5 {
    fill: #e65100 !important;
    font-weight: bold !important;
}

.highlighted-connector-1 {
    stroke: #1976d2 !important;
    stroke-width: 3 !important;
    stroke-dasharray: none !important;
    transition: all 0.3s ease;
}

.highlighted-connector-2 {
    stroke: #c2185b !important;
    stroke-width: 3 !important;
    stroke-dasharray: none !important;
    transition: all 0.3s ease;
}

.highlighted-connector-3 {
    stroke: #7b1fa2 !important;
    stroke-width: 3 !important;
    stroke-dasharray: none !important;
    transition: all 0.3s ease;
}

.highlighted-connector-4 {
    stroke: #388e3c !important;
    stroke-width: 3 !important;
    stroke-dasharray: none !important;
    transition: all 0.3s ease;
}

.highlighted-connector-5 {
    stroke: #f57c00 !important;
    stroke-width: 3 !important;
    stroke-dasharray: none !important;
    transition: all 0.3s ease;
}

.connector {
    stroke: #666;
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 5,5;
    transition: all 0.3s ease;
}

.team {
    fill: white;
    stroke: #333;
    stroke-width: 2;
    transition: all 0.3s ease;
    cursor: pointer;
}

.team:hover {
    fill: #f0f8ff;
    stroke: #4a90e2;
    stroke-width: 3;
}

.semifinal-team {
    fill: white;
    stroke: #333;
    stroke-width: 2;
}

.final-team {
    fill: white;
    stroke: #333;
    stroke-width: 2;
}

/* Advanced team style */
.advanced-team {
    fill: #4caf50 !important;
    stroke: #2e7d32 !important;
    stroke-width: 2 !important;
}

.advanced-text {
    fill: #1b5e20 !important;
    font-weight: bold !important;
}

/* Teams list style */
.teams-list {
    padding: 20px 30px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.teams-list h3 {
    margin-bottom: 10px;
    color: #2d3748;
    font-size: 1.1rem;
}

.teams-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.team-tag {
    padding: 6px 12px;
    background: white;
    border-radius: 20px;
    border: 2px solid #4a90e2;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.team-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.team-tag button {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.team-tag button:hover {
    background: #ffeaea;
}

/* Responsive design */
@media (max-width: 1200px) {
    .bracket-container {
        height: 70vh;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .bracket-container {
        height: 60vh;
        min-height: 400px;
    }
    
    .controls {
        padding: 15px 20px;
        justify-content: center;
    }
    
    .status {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    .legend {
        padding: 15px 20px;
        justify-content: center;
    }
    
    .teams-list {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .legend {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .team-selector {
        width: 100%;
        justify-content: center;
    }
    
    .teams-container {
        justify-content: center;
    }
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Matchup dialog */
.matchup-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.matchup-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.matchup-content h3 {
    margin-bottom: 20px;
    color: #2d3748;
    text-align: center;
}

.matchup-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.matchup-option {
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.matchup-option:hover {
    background: #f7fafc;
    border-color: #4a90e2;
}

.matchup-option.selected {
    background: #e3f2fd;
    border-color: #1976d2;
}

.matchup-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.matchup-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Team selector dialog */
.team-selector-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.team-selector-content {
    background: white;
    border-radius: 12px;
    padding: 25px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.team-selector-content h3 {
    margin-bottom: 10px;
    color: #2d3748;
    text-align: center;
    font-size: 1.4rem;
}

#teamSelectorDescription {
    margin-bottom: 20px;
    color: #4a5568;
    text-align: center;
}

.group-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.group-tab {
    padding: 8px 16px;
    background: #edf2f7;
    border: 2px solid #cbd5e0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 40px;
    text-align: center;
}

.group-tab:hover {
    background: #e2e8f0;
    border-color: #a0aec0;
}

.group-tab.active {
    background: #4a90e2;
    color: white;
    border-color: #2c5282;
}

.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.team-option {
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.team-option:hover {
    background: #f7fafc;
    border-color: #4a90e2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.team-option.selected {
    background: #e3f2fd;
    border-color: #1976d2;
}

.team-flag {
    width: 60px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.team-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.team-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.2;
}

.team-selector-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}