:root {
    --primary: #FFD700;
    /* Gold */
    --accent: #00B4D8;
    /* Electric Blue */
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(30, 41, 59, 0.7);
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
}

/* NAVBAR */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-card);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-btn:hover,
.nav-btn.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
    border-bottom: 2px solid var(--primary);
}

.container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* TABS */
.tab-content {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* HERO SECTION */
.hero-section {
    text-align: center;
    margin-bottom: 3rem;
}

.hero-title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.hero-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
}

.hero-logo-full {
    width: 60%;
    max-width: 350px;
    height: auto;
    margin: 0 auto 2rem auto;
    display: block;
}

@media (max-width: 768px) {
    .hero-logo-full {
        width: 70%;
        max-width: none;
        padding: 0 1rem;
    }
}

.hero-section h1 {
    font-size: 3rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1rem 2rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card h3 {
    color: var(--accent);
    font-size: 1.5rem;
}

/* CARDS & GRID */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    cursor: pointer;
}

.card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.schedule-list {
    list-style: none;
    margin-top: 1rem;
}

.schedule-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.schedule-list span {
    color: var(--primary);
    font-weight: 600;
}

/* TABLE */
.standings-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.standings-table th,
.standings-table td {
    padding: 1rem;
    text-align: left;
}

.standings-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--accent);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.standings-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.controls select {
    background: var(--bg-card);
    color: white;
    border: 1px solid var(--text-muted);
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* ADMIN FORM */
.score-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 1rem 0;
}

.score-input-group input {
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
}

.save-btn {
    background: var(--primary);
    color: black;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    margin-top: 1rem;
    transition: background 0.2s;
}

.save-btn:hover {
    filter: brightness(1.1);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .hero-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .score-input-group {
        flex-direction: column;
    }
}

/* --- NEW FEATURES CSS --- */

/* Group Grid (Cards) */
.group-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.group-card {
    background: linear-gradient(145deg, var(--card-bg), #2a2a2a);
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s, border-color 0.2s;
}

.group-card:active {
    transform: scale(0.98);
}

.group-card:hover {
    border-color: var(--primary);
}

.group-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.group-card span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Quick Result Form */
.quick-result-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.compact-select {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text);
}

.score-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.score-box {
    width: 60px;
    text-align: center;
    font-size: 1.2rem;
    padding: 0.5rem;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    border-radius: 6px;
}

.small-btn {
    padding: 0.8rem;
    font-size: 1rem;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

/* Teams Management */
.team-form input,
.team-form select {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    border-radius: 6px;
}

.team-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--accent);
    margin-bottom: 0.5rem;
}

.team-info {
    display: flex;
    flex-direction: column;
}

.team-item strong {
    color: var(--text-main);
    font-size: 1.1rem;
}

.team-item span {
    color: var(--primary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: var(--danger);
    color: white;
}

/* Inline Match Editing */
.score-input-match {
    width: 60px;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    padding: 0.4rem;
    border-radius: 6px;
    text-align: center;
    font-size: 1.1rem;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-dark);
    padding: 5px 10px;
    border-radius: 8px;
}

.edit-btn,
.delete-btn-match {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 5px;
    transition: color 0.2s;
}

.edit-btn {
    color: var(--accent);
}

.delete-btn-match {
    color: var(--danger);
}

.status-badge {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-card.played {
    border-left: 4px solid #10b981;
}

.match-card.pending {
    border-left: 3px solid var(--primary);
}

/* HIDE NUMBER INPUT ARROWS */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* MOBILE RESPONSIVE NAV */
@media screen and (max-width: 600px) {
    .navbar {
        padding: 0.8rem 1rem;
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav-links {
        width: 100%;
        justify-content: space-around;
        gap: 2px;
    }

    .nav-btn {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .nav-btn i {
        font-size: 1rem;
        margin-bottom: 0;
    }

    .container {
        padding: 0.75rem;
    }

    .match-main span {
        font-size: 0.8rem;
    }

    .score-display strong {
        font-size: 1rem;
        margin: 0 0.2rem;
    }

    .status-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }
}

/* MOBILE RESPONSIVE NAV */
@media screen and (max-width: 600px) {
    .navbar {
        padding: 0.8rem 1rem;
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav-links {
        width: 100%;
        justify-content: space-around;
        gap: 2px;
    }

    .nav-btn {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .nav-btn i {
        font-size: 1rem;
        margin-bottom: 0;
    }

    .container {
        padding: 0.75rem;
    }

    .match-main span {
        font-size: 0.8rem;
    }

    .score-display strong {
        font-size: 1rem;
        margin: 0 0.2rem;
    }

    .status-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }
}



.winner {
    color: var(--primary);
    font-weight: 700;
}

/* Slots Grid for Team Management */
.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.group-slots {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.2rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.group-slots h4 {
    margin-bottom: 1rem;
    color: var(--primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
    font-size: 0.95rem;
}

.slot-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.slot-row span {
    font-weight: bold;
    color: var(--accent);
    width: 25px;
    font-size: 0.85rem;
}

.slot-row select {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* CELEBRATION MODAL */
.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeInModal 0.5s ease forwards;
}

.celebration-content {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 24px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    border: 2px solid var(--primary);
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.3);
    animation: popContent 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.trophy-container {
    font-size: 5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    animation: trophyBounce 2s infinite;
}

.celebration-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.celebration-content h2 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.mythical-phrase {
    font-style: italic;
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popContent {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes trophyBounce {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-20px) rotate(5deg);
    }
}

/* Redesigned Match Card Internal Layout (Update) */
.match-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.match-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-main span {
    flex: 1;
    font-weight: 500;
}

.match-main span:last-child {
    text-align: right;
}

.match-entry {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.entry-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.entry-row span {
    font-size: 0.95rem;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 10px;
}

/* Final Phase Selector */
.final-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.team-name-input {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.round-header {
    background: rgba(255, 215, 0, 0.1);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin: 1.5rem 0 1rem 0;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
    border-left: 3px solid var(--primary);
}

/* --- ROBUST BRACKET TREE STYLES --- */
.bracket-wrapper {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto;
    padding: 4rem 1rem;
    gap: 0;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    border-radius: 20px;
    margin: 2rem 0;
    min-height: 550px;
}

.bracket-column {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 0 2rem;
    position: relative;
    flex: 0 0 260px;
}

.bracket-round-label {
    position: absolute;
    top: -2.5rem;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

.bracket-pair {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    position: relative;
    padding: 2rem 0;
}

/* Vertical line connecting a pair */
.bracket-pair::after {
    content: "";
    position: absolute;
    right: -2rem;
    top: 25%;
    bottom: 25%;
    width: 2px;
    background: rgba(255, 255, 255, 0.2);
}

/* Horizontal line from the midpoint of the vertical line to the next round */
.bracket-pair::before {
    content: "";
    position: absolute;
    right: -4rem;
    top: 50%;
    width: 2rem;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
}

/* Horizontal lines coming out of each match in a pair */
.bracket-match-container {
    position: relative;
    z-index: 10;
}

.bracket-match-container::after {
    content: "";
    position: absolute;
    right: -2rem;
    top: 50%;
    width: 2rem;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
}

/* The "In" line for the receiving match */
.bracket-column:not(:first-child) .bracket-match-container::before {
    content: "";
    position: absolute;
    left: -2rem;
    top: 50%;
    width: 2rem;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
}

/* Match Box */
.bracket-match {
    background: #1e293b;
    width: 220px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.bracket-team {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.bracket-team.winner {
    background: rgba(0, 180, 216, 0.15);
    color: var(--primary);
}

.bracket-team .score {
    font-weight: 700;
    color: var(--accent);
}

.bracket-team.winner .score {
    color: var(--primary);
}

/* Special Case: Finals Column (no outgoing line) */
.bracket-column:last-child .bracket-match-container::after,
.bracket-column:last-child .bracket-pair::after,
.bracket-column:last-child .bracket-pair::before {
    display: none;
}