/* =========================================
   VARIABLES & SETUP
   ========================================= */
:root {
    /* Color Palette */
    --clr-primary: #1e3a8a;       /* Deep Blue */
    --clr-primary-light: #3b82f6; /* Bright Blue */
    --clr-accent: #10b981;        /* Energetic Green */
    --clr-accent-hover: #059669;  /* Darker Green */
    
    --clr-bg-dark: #0f172a;       /* Slate 900 */
    --clr-bg-card: rgba(30, 41, 59, 0.7);
    --clr-border: rgba(255, 255, 255, 0.1);
    
    --clr-text: #f8fafc;
    --clr-text-muted: #94a3b8;
    
    /* Typography */
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Layout */
    --max-width: 1200px;
    --radius-lg: 16px;
    --radius-md: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--clr-bg-dark);
    color: var(--clr-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }

/* =========================================
   TYPOGRAPHY
   ========================================= */
h1, h2, h3, h4, h5 {
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 4rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); margin-bottom: 0.5rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }

p { font-size: 1rem; margin-bottom: 1rem; color: var(--clr-text-muted); }

/* =========================================
   HERO SECTION
   ========================================= */
.hero {
    position: relative;
    padding: 6rem 1rem 4rem;
    text-align: center;
    background-image: url('https://offertabs.s3.amazonaws.com/offer/pojxdd/site/media/6a1712b1b860d6.65458950.jpg');
    background-size: cover;
    background-position: center;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.4) 0%, rgba(15, 23, 42, 1) 100%);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
}

.hero-tag {
    display: inline-block;
    padding: 0.25rem 1rem;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid var(--clr-accent);
    color: var(--clr-accent);
    border-radius: 99px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero h1 {
    text-shadow: 0 4px 20px rgba(0,0,0,0.5);
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* =========================================
   COUNTDOWN
   ========================================= */
.countdown-timer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.time-block {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid var(--clr-border);
    padding: 1rem;
    border-radius: var(--radius-md);
    min-width: 80px;
}

.time-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--clr-accent);
}

.time-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--clr-text-muted);
    margin-top: 0.25rem;
}

/* =========================================
   MAIN LAYOUT & CARDS
   ========================================= */
.main-content {
    flex: 1;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.view-section {
    width: 100%;
    margin-bottom: 3rem;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.glass-card {
    background: var(--clr-bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.form-card { max-width: 500px; margin: 0 auto; }
.success-card { max-width: 600px; margin: 0 auto; text-align: center; }

/* =========================================
   BANNERS (Errors & Status)
   ========================================= */
.status-banner {
    width: 100%;
    max-width: 800px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--clr-primary-light);
    color: #fff;
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: 2rem;
    font-weight: 500;
}

.error-banner {
    width: 100%;
    max-width: 800px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #fca5a5;
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.btn-icon {
    background: none;
    border: none;
    color: currentColor;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
}
.btn-icon:hover { opacity: 1; }

/* =========================================
   BUTTONS
   ========================================= */
.btn {
    display: inline-block;
    padding: 0.875rem 1.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-align: center;
}

.btn-primary {
    background: var(--clr-accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-primary:hover:not(:disabled) {
    background: var(--clr-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-primary:disabled {
    background: #334155;
    color: #64748b;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid var(--clr-border);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.2);
}

.btn-outline {
    background: transparent;
    color: var(--clr-accent);
    border: 2px solid var(--clr-accent);
}

.btn-outline:hover {
    background: rgba(16, 185, 129, 0.1);
}

.btn-block {
    display: block;
    width: 100%;
}

/* =========================================
   FORMS
   ========================================= */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="email"],
input[type="number"] {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--clr-primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* =========================================
   MODAL (Tie Breaker)
   ========================================= */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--clr-bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 450px;
    border: 1px solid var(--clr-border);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    text-align: center;
}

.tiebreaker-matchup {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
    gap: 1rem;
}

.team-score-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.team-name-label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--clr-text);
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    text-align: center;
}

.team-score-group input {
    width: 80px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0.5rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    color: #fff;
}

.team-score-group input:focus {
    outline: none;
    border-color: var(--clr-accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.vs-label {
    font-weight: 800;
    color: var(--clr-text-muted);
    font-size: 1.25rem;
}


/* =========================================
   SHARE PANEL
   ========================================= */
.share-panel {
    background: rgba(59, 130, 246, 0.05);
    border: 1px dashed var(--clr-primary-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-top: 2rem;
    text-align: left;
}

.share-panel h3 { color: var(--clr-primary-light); margin-bottom: 0.25rem; }

.share-input-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.share-input-group input {
    flex: 1;
    background: rgba(0,0,0,0.3);
}

/* =========================================
   GROUP STAGE UI
   ========================================= */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.group-card {
    background: var(--clr-bg-card);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.group-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--clr-primary-light);
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 700;
}

.group-body {
    display: flex;
    gap: 1rem;
}

.group-ranks {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rank-num {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    width: 24px;
    font-weight: 800;
    color: var(--clr-accent);
    font-size: 1.1rem;
}

.group-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.group-item {
    display: flex;
    align-items: center;
    height: 44px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-md);
    padding: 0 1rem;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}

.group-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
}

.group-item.sortable-ghost {
    opacity: 0.3;
    background: var(--clr-primary-light);
}

.drag-handle {
    margin-right: 0.75rem;
    color: var(--clr-text-muted);
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.5rem;
    margin-left: -0.5rem;
    cursor: grab;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.item-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* =========================================
   WORLD CUP STYLE BRACKET UI
   ========================================= */
.bracket-scroll-area {
    width: 100%;
    overflow-x: auto;
    padding: 1rem 0 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--clr-accent) rgba(255,255,255,0.05);
}
.bracket-scroll-area::-webkit-scrollbar { height: 8px; }
.bracket-scroll-area::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 4px; }
.bracket-scroll-area::-webkit-scrollbar-thumb { background: var(--clr-accent); border-radius: 4px; }

/* Main bracket layout */
.bracket-container {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 1.5rem;
    padding: 1rem 2rem;
    width: max-content;
    margin: 0 auto;
}

/* Bracket Halves */
.bracket-side {
    display: flex;
    gap: 3rem; /* distance between rounds */
}
.side-left { flex-direction: row; }
.side-right { flex-direction: row-reverse; }

.side-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 240px;
}

/* Rounds & Wrappers */
.bracket-round {
    display: flex;
    flex-direction: column;
    width: 200px;
}

.round-title {
    text-align: center;
    font-family: var(--font-heading);
    font-size: 0.875rem;
    color: var(--clr-primary-light);
    margin-bottom: 1rem;
    letter-spacing: 0.1em;
}

.matches-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex-grow: 1;
}

/* Pair Grouping for Connectors */
.match-pair {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    gap: 1.5rem;
    margin: 1rem 0;
    flex-grow: 1;
}

/* Match Cards */
.match-card {
    background: var(--clr-bg-card);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 96px; /* Fixed height for connector alignment */
    display: flex;
    flex-direction: column;
    z-index: 2;
}

.match-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.match-meta {
    position: absolute;
    top: -18px;
    left: -20px;
    right: -20px;
    text-align: center;
    font-size: 0.65rem;
    color: var(--clr-text-muted);
    white-space: nowrap;
    pointer-events: none;
    font-weight: 600;
    z-index: 5;
}

.match-team {
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--clr-border);
    transition: all 0.2s ease;
    flex: 1;
    overflow: hidden;
}
.match-team:last-child {
    border-bottom: none;
}

/* Team Interaction States */
.match-team.interactive:hover {
    background: rgba(255, 255, 255, 0.1);
}
.match-team.selected {
    background: rgba(16, 185, 129, 0.15);
    color: #fff;
    font-weight: 600;
}
/* Left side selection border */
.round-left .match-team.selected { border-left: 4px solid var(--clr-accent); }
/* Right side selection border */
.round-right .match-team.selected { border-right: 4px solid var(--clr-accent); }
/* Center selection border */
.round-center .match-team.selected { border-left: 4px solid var(--clr-accent); }

.match-team.dimmed {
    opacity: 0.4;
    filter: grayscale(100%);
}

.match-team.tbd {
    cursor: default;
    opacity: 0.5;
    font-style: italic;
    color: var(--clr-text-muted);
}

.team-image {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    flex-shrink: 0;
}
.team-image.placeholder {
    background: rgba(255,255,255,0.1);
    border: 1px dashed rgba(255,255,255,0.3);
}

.team-name {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right-aligned text for right side */
.team-right { flex-direction: row-reverse; }
.team-right .team-name { text-align: right; }


/* =========================================
   BRACKET CONNECTORS (CSS Math)
   ========================================= */

/* --- LEFT SIDE CONNECTORS --- */
/* Horizontal line out from every left side card */
.round-left .match-card::after {
    content: '';
    position: absolute;
    right: -1.5rem;
    top: calc(50% - 1px);
    width: 1.5rem;
    height: 2px;
    background: var(--clr-border);
    z-index: -1;
}
/* Vertical line bridging pairs on the left */
.side-left .match-pair::after {
    content: '';
    position: absolute;
    right: -1.5rem;
    top: 48px; /* Midpoint of top card */
    bottom: 48px; /* Midpoint of bottom card */
    width: 2px;
    background: var(--clr-border);
}
/* Horizontal stem pointing to next round from the left pair */
.side-left .match-pair::before {
    content: '';
    position: absolute;
    right: -3rem;
    top: calc(50% - 1px);
    width: 1.5rem;
    height: 2px;
    background: var(--clr-border);
}

/* --- RIGHT SIDE CONNECTORS --- */
/* Horizontal line out from every right side card (points visually left) */
.round-right .match-card::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: calc(50% - 1px);
    width: 1.5rem;
    height: 2px;
    background: var(--clr-border);
    z-index: -1;
}
/* Vertical line bridging pairs on the right */
.side-right .match-pair::after {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 48px;
    bottom: 48px;
    width: 2px;
    background: var(--clr-border);
}
/* Horizontal stem pointing to next round from the right pair */
.side-right .match-pair::before {
    content: '';
    position: absolute;
    left: -3rem;
    top: calc(50% - 1px);
    width: 1.5rem;
    height: 2px;
    background: var(--clr-border);
}


/* =========================================
   CENTER COLUMN STYLING
   ========================================= */
.center-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.round-center .match-card {
    width: 100%; 
}

.champion-connector {
    width: 2px;
    height: 1.5rem;
    background: #fbbf24;
    margin: 0.5rem auto;
}

.champion-card {
    border-color: #fbbf24;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}


/* =========================================
   ACTION BAR
   ========================================= */
.action-bar {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-lg);
    border: 1px solid var(--clr-border);
}

.progress-indicator {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--clr-text);
}

#picks-count {
    color: var(--clr-accent);
}

/* =========================================
   SUCCESS & LEADERBOARD
   ========================================= */
.success-icon {
    width: 80px;
    height: 80px;
    background: rgba(16, 185, 129, 0.2);
    color: var(--clr-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem;
    border: 2px solid var(--clr-accent);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.leaderboard-table th {
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    font-family: var(--font-heading);
    font-size: 0.875rem;
    color: var(--clr-primary-light);
    border-bottom: 2px solid var(--clr-border);
}

.leaderboard-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--clr-border);
    color: #fff;
}

.leaderboard-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

/* =========================================
   SDK ATTRUBTION
   ========================================= */
#wbx-powered-by-slot {
    margin-top: auto;
    padding: 2rem 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* =========================================
   MEDIA QUERIES
   ========================================= */
@media (max-width: 768px) {
    .bracket-container {
        /* On small screens, keep it inline-flex with scrolling */
        gap: 1.5rem;
    }
    .bracket-round {
        width: 160px; /* Slightly tighter on mobile */
    }
    .side-center {
        width: 200px;
    }
    .hero h1 {
        font-size: 2.5rem;
    }
    .action-bar {
        position: sticky;
        bottom: 1rem;
        z-index: 10;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
    }
}
