/* FIFA Colors and Global Styles */
:root {
    --fifa-blue: #004B93;
    --fifa-light-blue: #3B82C4;
    --fifa-gold: #FFD700;
    --fifa-red: #E60026;
    --fifa-green: #00A651;
    --fifa-dark: #1a1a1a;
    --fifa-gray: #f8f9fa;
    --fifa-white: #ffffff;
    --fifa-shadow: rgba(0, 75, 147, 0.15);
    --fifa-border: rgba(0, 75, 147, 0.2);
}

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, var(--fifa-blue) 0%, var(--fifa-light-blue) 100%);
    color: var(--fifa-dark);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px;
}

/* Header */
.header {
    text-align: center;
    background: var(--fifa-white);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 12px;
}

.header h1 {
    color: var(--fifa-blue);
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 6px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.header h2 {
    color: var(--fifa-red);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.draw-button, .playoff-button {
    border: none;
    padding: 16px 32px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.draw-button {
    background: linear-gradient(45deg, var(--fifa-gold), #FFA500);
    color: var(--fifa-dark);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.draw-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.draw-button:disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    box-shadow: none;
}

.playoff-button {
    background: linear-gradient(45deg, var(--fifa-red), #c71e39);
    color: var(--fifa-white);
    box-shadow: 0 4px 15px rgba(230, 0, 38, 0.3);
}

.playoff-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(230, 0, 38, 0.4);
}

/* Sections */
.pots-section, .groups-section, .matches-section, .playoffs-section {
    background: var(--fifa-white);
    margin: 12px 0;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.pots-section h3, .groups-section h3, .matches-section h3, .playoffs-section h3 {
    color: var(--fifa-blue);
    font-size: 1rem;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--fifa-gold);
    padding-bottom: 4px;
}

/* Pots Header */
.pots-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.pots-header h3 {
    margin-bottom: 0;
}

.toggle-pots {
    background: var(--fifa-light-blue);
    color: var(--fifa-white);
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.6rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.toggle-pots:hover {
    background: var(--fifa-blue);
    transform: translateY(-1px);
}

/* Pots Container */
.pots-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.pots-container.hidden {
    display: none;
}

.pot {
    background: linear-gradient(135deg, var(--fifa-gray) 0%, #e8e8e8 100%);
    border-radius: 4px;
    padding: 4px;
    border: 1px solid var(--fifa-blue);
}

.pot-header {
    background: var(--fifa-blue);
    color: var(--fifa-white);
    padding: 2px;
    border-radius: 3px;
    text-align: center;
    font-weight: bold;
    font-size: 0.6rem;
    margin-bottom: 3px;
}

.pot-team {
    display: flex;
    align-items: center;
    padding: 2px 3px;
    margin: 1px 0;
    background: var(--fifa-white);
    border-radius: 2px;
    border-left: 2px solid var(--fifa-green);
    transition: transform 0.2s ease;
}

.pot-team:hover {
    transform: translateX(5px);
}

.team-flag {
    font-size: 0.7rem;
    margin-right: 3px;
    min-width: 12px;
}

.team-info {
    flex: 1;
}

.team-name {
    font-weight: bold;
    font-size: 0.5rem;
    color: var(--fifa-dark);
    line-height: 1.0;
}

.team-confederation {
    font-size: 0.4rem;
    color: #666;
    display: inline-flex;
    align-items: center;
    gap: 1px;
    background: var(--fifa-gray);
    padding: 0px 1px;
    border-radius: 1px;
    margin-top: 1px;
    font-weight: 500;
}

.team-points {
    font-size: 0.4rem;
    color: var(--fifa-blue);
    font-weight: 600;
    margin-top: 1px;
}

/* Groups Container */
.groups-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.group {
    background: linear-gradient(135deg, var(--fifa-white) 0%, var(--fifa-gray) 100%);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid var(--fifa-blue);
    transition: transform 0.3s ease;
}

.group:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 75, 147, 0.2);
}

.group-header {
    background: var(--fifa-blue);
    color: var(--fifa-white);
    padding: 6px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 6px;
}

.group-team {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    margin: 3px 0;
    background: var(--fifa-white);
    border-radius: 3px;
    border-left: 2px solid var(--fifa-gold);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.group-team:nth-child(even) {
    border-left-color: var(--fifa-red);
}

.group-team .team-flag {
    font-size: 1rem;
    margin-right: 6px;
    min-width: 18px;
}

.group-team .team-name {
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--fifa-dark);
    line-height: 1.1;
}

.group-team .team-confederation {
    margin-left: 4px;
    background: var(--fifa-blue);
    color: var(--fifa-white);
    padding: 1px 3px;
    border-radius: 2px;
    font-size: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Matches Container */
.matches-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}

.group-matches {
    background: var(--fifa-gray);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid var(--fifa-blue);
}

.group-matches-header {
    background: var(--fifa-red);
    color: var(--fifa-white);
    padding: 4px;
    border-radius: 3px;
    text-align: center;
    font-weight: bold;
    font-size: 0.7rem;
    margin-bottom: 6px;
}

.match {
    background: var(--fifa-white);
    padding: 6px;
    margin: 4px 0;
    border-radius: 3px;
    border-left: 2px solid var(--fifa-green);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.match-number {
    background: var(--fifa-blue);
    color: var(--fifa-white);
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: bold;
    font-size: 0.55rem;
}

.match-date {
    color: var(--fifa-red);
    font-weight: bold;
    font-size: 0.55rem;
}

.match-teams {
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--fifa-dark);
    margin: 3px 0;
    text-align: center;
    line-height: 1.2;
}

.match-venue {
    font-size: 0.55rem;
    color: #666;
    text-align: center;
    font-style: italic;
    margin-top: 2px;
}

.team-with-flag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.vs-text {
    margin: 0 6px;
    font-weight: normal;
    color: var(--fifa-red);
}

/* Match View Toggle */
.matches-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.view-toggle {
    display: flex;
    gap: 4px;
}

.toggle-view-btn {
    background: var(--fifa-gray);
    color: var(--fifa-dark);
    border: 1px solid var(--fifa-blue);
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.6rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.toggle-view-btn:hover {
    background: var(--fifa-light-blue);
    color: var(--fifa-white);
}

.toggle-view-btn.active {
    background: var(--fifa-blue);
    color: var(--fifa-white);
}

/* City View Specific Styling */
.city-matches {
    background: var(--fifa-gray);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid var(--fifa-blue);
}

.city-matches-header {
    background: var(--fifa-blue);
    color: var(--fifa-white);
    padding: 4px;
    border-radius: 3px;
    text-align: center;
    font-weight: bold;
    font-size: 0.7rem;
    margin-bottom: 6px;
}

.city-match {
    background: var(--fifa-white);
    padding: 4px;
    margin: 3px 0;
    border-radius: 3px;
    border-left: 2px solid var(--fifa-green);
    font-size: 0.55rem;
}

.city-match-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.city-match-teams {
    font-weight: bold;
    line-height: 1.2;
}

.city-match-details {
    font-size: 0.5rem;
    color: #666;
}

/* Stage Indicator */
.stage-indicator {
    font-size: 0.6rem;
    color: var(--fifa-red);
    font-weight: normal;
    font-style: italic;
}

/* Calendar View */
.calendar-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 10px;
}

.calendar-day {
    background: var(--fifa-gray);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid var(--fifa-blue);
}

.calendar-day-header {
    background: var(--fifa-blue);
    color: var(--fifa-white);
    padding: 4px;
    border-radius: 3px;
    text-align: center;
    font-weight: bold;
    font-size: 0.7rem;
    margin-bottom: 6px;
}

.calendar-match {
    background: var(--fifa-white);
    padding: 4px;
    margin: 3px 0;
    border-radius: 3px;
    border-left: 2px solid var(--fifa-green);
    font-size: 0.55rem;
}

.calendar-match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.calendar-match-teams {
    font-weight: bold;
    line-height: 1.2;
    margin: 2px 0;
}

.calendar-match-venue {
    font-size: 0.5rem;
    color: #666;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .pots-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 6px;
    }
    
    .header {
        padding: 8px;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header h2 {
        font-size: 0.8rem;
    }
    
    .pots-section h3, .groups-section h3, .matches-section h3, .playoffs-section h3 {
        font-size: 0.9rem;
    }
    
    .pots-container {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .groups-container,
    .matches-container {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .pot, .group, .group-matches {
        margin-bottom: 8px;
        padding: 6px;
    }
    
    .team-flag {
        font-size: 0.8rem;
    }
    
    .group-team .team-flag {
        font-size: 0.9rem;
    }
    
    .team-name {
        font-size: 0.55rem;
    }
    
    .group-team .team-name {
        font-size: 0.6rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--fifa-white);
    animation: spin 1s ease-in-out infinite;
}

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

/* Team status styling */
.qualified-team {
    border-left-color: var(--fifa-green) !important;
}

.projected-team {
    border-left-color: var(--fifa-light-blue) !important;
    opacity: 0.9;
}

.projected-team .team-name::after {
    content: " (Projected)";
    font-size: 0.7rem;
    color: var(--fifa-light-blue);
    font-weight: normal;
}

.playoff-winner-team {
    border-left-color: var(--fifa-red) !important;
    background: linear-gradient(90deg, #ffe6e6 0%, var(--fifa-white) 100%) !important;
}

.playoff-winner-team .team-name {
    font-weight: bold;
    color: var(--fifa-red);
}

.placeholder-team {
    opacity: 0.7;
    font-style: italic;
    border-left-color: #ccc !important;
}

.placeholder-team .team-name {
    color: #888;
}

.placeholder-team .team-confederation {
    background: #ccc !important;
}

.placeholder-points {
    color: #888 !important;
    font-style: italic;
    font-size: 0.45rem !important;
}

/* Team Status Labels */
.team-host-status {
    color: var(--fifa-gold) !important;
    font-weight: bold;
}

.team-qualified-status {
    color: var(--fifa-green) !important;
}

.team-projected-status {
    color: var(--fifa-blue) !important;
}

.team-playoff-status {
    color: var(--fifa-red) !important;
    font-weight: bold;
}

/* Host team styling */
.host-team {
    border-left-color: var(--fifa-gold) !important;
    background: linear-gradient(90deg, #fff9e6 0%, var(--fifa-white) 100%) !important;
}

.host-team .team-confederation::after {
    content: " (Host)";
    font-weight: bold;
    color: var(--fifa-gold);
    margin-left: 5px;
}

/* Confederation colors for team info */
.team-confederation.AFC { background: #FF6B35; }
.team-confederation.CAF { background: #F4D03F; color: #333; }
.team-confederation.CONCACAF { background: #85C1E9; }
.team-confederation.CONMEBOL { background: #82E0AA; color: #333; }
.team-confederation.OFC { background: #D7BDE2; }
.team-confederation.UEFA { background: #F8C471; color: #333; }
.team-confederation.PLAYOFF { background: #BDC3C7; }

/* Playoff Results Styling - ULTRA COMPACT */
.playoffs-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 8px;
}

.playoff-section {
    background: var(--fifa-gray);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid var(--fifa-red);
}

.playoff-header {
    background: var(--fifa-red);
    color: var(--fifa-white);
    padding: 4px;
    border-radius: 3px;
    text-align: center;
    font-weight: bold;
    font-size: 0.7rem;
    margin-bottom: 6px;
}

.playoff-path {
    margin: 6px 0;
    padding: 6px;
    background: var(--fifa-white);
    border-radius: 3px;
    border-left: 2px solid var(--fifa-blue);
}

.playoff-path-header {
    font-weight: bold;
    font-size: 0.6rem;
    color: var(--fifa-blue);
    margin-bottom: 4px;
}

.playoff-match {
    margin: 3px 0;
    padding: 4px;
    background: var(--fifa-gray);
    border-radius: 2px;
    border-left: 2px solid var(--fifa-green);
    font-size: 0.55rem;
    line-height: 1.2;
}

.playoff-match.semifinal {
    border-left-color: var(--fifa-light-blue);
}

.playoff-match.final {
    border-left-color: var(--fifa-gold);
    font-weight: bold;
}

.playoff-winner {
    background: linear-gradient(135deg, var(--fifa-gold), #FFA500);
    color: var(--fifa-dark);
    padding: 4px;
    border-radius: 3px;
    text-align: center;
    font-weight: bold;
    font-size: 0.6rem;
    margin-top: 4px;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

.playoff-winner .team-flag {
    font-size: 0.8rem;
    margin-right: 3px;
}

.match-probability {
    font-size: 0.5rem;
    color: #666;
    font-style: italic;
    margin-top: 1px;
}

/* Playoff Toggle Functionality */
.playoffs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.toggle-playoffs {
    background: var(--fifa-light-blue);
    color: var(--fifa-white);
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.6rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.toggle-playoffs:hover {
    background: var(--fifa-blue);
    transform: translateY(-1px);
}

.playoffs-container.collapsed {
    display: none;
}

.playoffs-container:not(.collapsed) {
    display: grid;
}

/* Simulation Log Styling */
.simulation-log-section {
    background: var(--fifa-white);
    margin: 12px 0;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

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

.log-header h3 {
    color: var(--fifa-blue);
    font-size: 1rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--fifa-gold);
    padding-bottom: 4px;
}

.toggle-log {
    background: var(--fifa-light-blue);
    color: var(--fifa-white);
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.6rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.toggle-log:hover {
    background: var(--fifa-blue);
    transform: translateY(-1px);
}

.simulation-log {
    max-height: 400px;
    overflow-y: auto;
    background: var(--fifa-gray);
    border-radius: 6px;
    padding: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    line-height: 1.4;
    border: 1px solid var(--fifa-border);
}

.simulation-log.collapsed {
    display: none;
}

.log-entry {
    margin: 4px 0;
    padding: 2px 0;
}

.log-entry.pot-start {
    color: var(--fifa-blue);
    font-weight: bold;
    border-top: 1px solid var(--fifa-border);
    padding-top: 6px;
    margin-top: 8px;
}

.log-entry.team-drawn {
    color: var(--fifa-dark);
    margin-left: 10px;
}

.log-entry.constraint {
    color: var(--fifa-red);
    margin-left: 20px;
    font-style: italic;
}

.log-entry.success {
    color: var(--fifa-green);
    margin-left: 10px;
}

.log-entry.error {
    color: var(--fifa-red);
    font-weight: bold;
}

.log-entry.validation {
    color: var(--fifa-gold);
    font-weight: bold;
    border-top: 1px solid var(--fifa-gold);
    padding-top: 6px;
    margin-top: 8px;
}

/* Playoff Notes - Cosmetic Only */
.playoff-note {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 1px solid var(--fifa-gold);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 10px;
    text-align: center;
}

.playoff-note-content {
    font-size: 0.7rem;
    font-weight: bold;
    color: #856404;
    line-height: 1.3;
}

.playoff-note-details {
    font-size: 0.6rem;
    font-weight: normal;
    color: #6c5701;
    display: block;
    margin-top: 2px;
}

.playoff-reminder {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 1px solid var(--fifa-light-blue);
    border-radius: 6px;
    padding: 6px;
    margin-top: 10px;
    text-align: center;
}

.playoff-reminder-content {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--fifa-blue);
    font-style: italic;
}