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

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
    color: #f0f4f8;
    position: relative;
}

/* === TOP BAR === */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(2, 6, 23, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-self: start;
    min-width: 0;
}

.top-bar-center {
    justify-self: center;
}

.top-bar-right {
    justify-self: end;
}

.header-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.compact-title {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, #81e6d9 0%, #63b3ed 50%, #b794f4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.countdown-compact {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    display: flex;
    gap: 6px;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.count-num {
    color: #4fd1c5;
    font-weight: 800;
}

.sync-status {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 16px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.5s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.sync-status.text-hidden .status-text {
    width: 0;
    opacity: 0;
    visibility: hidden;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.sync-status.live {
    background: rgba(79, 209, 197, 0.15);
    color: #4fd1c5;
    border: 1px solid rgba(79, 209, 197, 0.3);
    box-shadow: 0 0 15px rgba(79, 209, 197, 0.1);
}

.sync-status.text-hidden {
    padding: 4px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.sync-status.offline {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

@media (max-width: 600px) {
    .top-bar {
        padding: 0 10px;
        grid-template-columns: 1fr auto 1fr;
        gap: 8px;
    }

    .hero-button {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .compact-title {
        font-size: 0.85rem;
    }

    .countdown-compact {
        font-size: 0.6rem;
    }

    .top-bar-left {
        gap: 6px;
    }

    .sync-status {
        padding: 2px 4px;
    }

    .left-sidebar {
        width: 100%;
        height: auto;
        bottom: auto;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        position: relative;
        top: 0;
    }

    #bubble-chart,
    #bracket-view {
        margin-left: 0;
        margin-top: 0;
    }

    body {
        overflow-y: auto;
    }
}

/* === HERO BUTTON === */
.hero-button {
    background: linear-gradient(135deg, #f6e05e 0%, #f59e0b 100%);
    border: none;
    color: #1a202c;
    font-size: 1.1rem;
    font-weight: 900;
    padding: 14px 32px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow:
        0 10px 30px rgba(246, 224, 94, 0.3),
        0 0 0 2px rgba(246, 224, 94, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.hero-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.hero-button:hover::before {
    left: 100%;
}

.hero-button:hover {
    transform: translateY(-2px);
    box-shadow:
        0 15px 40px rgba(246, 224, 94, 0.4),
        0 0 0 3px rgba(246, 224, 94, 0.3);
}

.hero-button:active {
    transform: translateY(0);
}

/* Spacebar hint tooltip */
.spacebar-hint {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 12px;
    padding: 8px 16px;
    background: rgba(79, 209, 197, 0.15);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(79, 209, 197, 0.3);
    border-radius: 8px;
    color: #4fd1c5;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    animation: fadeInOut 4s ease-in-out forwards;
    z-index: 1000;
}

.spacebar-hint kbd {
    background: rgba(79, 209, 197, 0.2);
    border: 1px solid rgba(79, 209, 197, 0.4);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    margin: 0 4px;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }

    10% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    85% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
        display: none;
    }
}

/* === LEFT SIDEBAR === */
.left-sidebar {
    position: fixed;
    left: 0;
    top: 70px;
    bottom: 0;
    width: 280px;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px;
    overflow-y: auto;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.left-sidebar::-webkit-scrollbar {
    width: 6px;
}

.left-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.left-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* === GROUP GRID === */
.group-grid-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 16px;
}

.section-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

#group-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

#group-grid .group-btn[data-group="all"] {
    grid-column: 1 / -1;
    font-size: 0.9rem;
    /* Make it slightly more prominent */
    letter-spacing: 0.1em;
}

.group-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 8px 4px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.group-btn.active {
    background: linear-gradient(135deg, #4fd1c5, #38b2ac);
    color: #020617;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(79, 209, 197, 0.3);
}

/* === SEARCH BAR === */
.search-container-sidebar {
    width: 100%;
}

.search-container-sidebar input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-container-sidebar input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: #4fd1c5;
    box-shadow: 0 0 20px rgba(79, 209, 197, 0.2);
}

.search-container-sidebar input::placeholder {
    color: #64748b;
}

/* === MODELING OPTIONS DROPDOWN === */
.modeling-options {
    position: relative;
}

.dropdown-toggle {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.dropdown-toggle .arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
}

.dropdown-toggle.active .arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 8px;
}

.dropdown-menu.open {
    max-height: 400px;
}

.option-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    transition: all 0.2s;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
}

.option-icon {
    font-size: 1.1rem;
}

.option-text {
    flex: 1;
    text-align: left;
}

/* === VISUAL SIMULATION CONTROLS === */
.visual-sim-controls {
    background: rgba(79, 209, 197, 0.08);
    border: 1px solid rgba(79, 209, 197, 0.2);
    border-radius: 16px;
    padding: 16px;
    display: none;
    flex-direction: column;
    gap: 12px;
}

.step-indicator {
    font-size: 0.75rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
}

.step-indicator span {
    color: #4fd1c5;
}

.sim-control-btn {
    width: 100%;
    background: linear-gradient(135deg, #4fd1c5, #38b2ac);
    border: none;
    color: #020617;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
}

.sim-control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 209, 197, 0.3);
}

.sim-control-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
    font-size: 0.75rem;
}

.sim-control-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

/* === BUBBLE CHART === */
#bubble-chart {
    margin-left: 280px;
    margin-top: 70px;
    min-height: calc(100vh - 70px);
    position: relative;
    perspective: 1000px;
}

#bracket-view {
    margin-left: 280px;
    margin-top: 70px;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    cursor: pointer;
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid rgba(255, 255, 255, 0.1);
    will-change: transform, left, top, opacity;
    touch-action: none;
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.5s;
}

.bubble.not-qualified {
    box-shadow:
        0 0 0 4px #ef4444,
        0 8px 16px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    border-color: #ef4444;
}

.bubble:active {
    cursor: grabbing;
}

.bubble:hover {
    z-index: 50 !important;
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.6),
        inset 0 0 0 2px rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.bubble.filtered {
    display: none !important;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #475569;
    font-size: 1.2rem;
    font-weight: 500;
}

/* === VISUAL SIMULATION STYLES === */
@keyframes championPulse {
    0% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.5), inset 0 0 0 2px #fbbf24;
        transform: scale(1.2);
    }

    50% {
        box-shadow: 0 0 60px rgba(251, 191, 36, 0.8), inset 0 0 0 4px #fbbf24;
        transform: scale(1.3);
    }

    100% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.5), inset 0 0 0 2px #fbbf24;
        transform: scale(1.2);
    }
}

.bubble.champion {
    border: 4px solid #fbbf24 !important;
    animation: championPulse 2s infinite ease-in-out;
    z-index: 100 !important;
}

.bubble.eliminated {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

.bubble.silver {
    border: 4px solid #cbd5e1 !important;
    box-shadow: 0 0 20px rgba(203, 213, 225, 0.5);
}

.bubble.bronze {
    border: 4px solid #b45309 !important;
    box-shadow: 0 0 20px rgba(180, 83, 9, 0.5);
}

.bubble.side-stage {
    opacity: 0.6 !important;
    filter: grayscale(0.4) brightness(0.7);
    z-index: 10;
}


/* === MODALS === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 28px;
    padding: 32px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.modal-overlay.active .modal-card {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.team-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 28px;
}

.team-flag-large {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.team-title h2 {
    font-size: 2.2rem;
    margin: 0;
    line-height: 1;
    font-weight: 800;
}

.group-badge {
    display: inline-block;
    background: rgba(99, 179, 237, 0.15);
    color: #63b3ed;
    padding: 6px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    margin-top: 8px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.status-alert {
    background: rgba(239, 68, 68, 0.15);
    border-left: 4px solid #ef4444;
    color: #f87171;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 28px;
    font-weight: 700;
    font-size: 0.95rem;
    display: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #4fd1c5;
}

.schedule-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.15em;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.match-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.match-date {
    font-size: 0.85rem;
    color: #94a3b8;
    width: 70px;
}

.match-opponent {
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
    padding: 0 12px;
}

.match-city {
    font-size: 0.75rem;
    color: #475569;
    text-align: right;
}

.match-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
    cursor: default;
}

.match-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(99, 179, 237, 0.3);
    transform: translateX(4px);
}

.match-rank-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
    line-height: 1;
}

.match-rank-badge .rank-label {
    font-size: 0.6rem;
    opacity: 0.8;
    margin-bottom: 2px;
}

.match-rank-badge .rank-val {
    font-size: 1.1rem;
}

.rank-top10 {
    background: linear-gradient(135deg, #f6e05e, #d69e2e);
    color: #1a202c;
    box-shadow: 0 0 20px rgba(246, 224, 94, 0.2);
}

.rank-top25 {
    background: linear-gradient(135deg, #e2e8f0, #a0aec0);
    color: #1a202c;
}

.rank-normal {
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.match-info-main {
    flex: 1;
}

.match-teams-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.match-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: #64748b;
}

.match-flag-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#schedule-list::-webkit-scrollbar,
#mc-results-list::-webkit-scrollbar {
    width: 6px;
}

#schedule-list::-webkit-scrollbar-track,
#mc-results-list::-webkit-scrollbar-track {
    background: transparent;
}

#schedule-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

#mc-results-list::-webkit-scrollbar-thumb {
    background: rgba(246, 135, 179, 0.3);
    border-radius: 10px;
}

/* === MONTE CARLO TABLE === */
.mc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9rem;
}

.mc-table th {
    text-align: left;
    padding: 12px 16px;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mc-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.mc-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.mc-prob-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.mc-prob-fill {
    height: 100%;
    background: linear-gradient(to right, #f687b3, #a78bfa);
}

/* === OLD STYLES FOR BACKWARD COMPATIBILITY === */
.filter-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    padding: 10px 20px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}