/* =================================================================
   Mundial 2026 - Tournament Aesthetic
   Dark, premium, dramatic - inspired by sports broadcast graphics
   ================================================================= */

:root {
    /* Color palette - tournament navy with gold accents */
    --c-bg:           #0a0e1a;
    --c-surface:      #131829;
    --c-surface-2:    #1c2236;
    --c-border:       #2a3050;
    --c-text:         #e8ebf5;
    --c-text-muted:   #8b94b3;
    --c-text-dim:     #5d6685;

    --c-accent:       #d4af37;   /* tournament gold */
    --c-accent-hot:   #f1c548;
    --c-accent-dim:   #8a7228;

    --c-success:      #22c55e;
    --c-danger:       #ef4444;
    --c-warning:      #f59e0b;
    --c-info:         #3b82f6;

    /* Tier colors */
    --tier-1: #d4af37;   /* gold */
    --tier-2: #94a3b8;   /* silver */
    --tier-3: #c97a3a;   /* bronze */
    --tier-4: #5b7c99;
    --tier-5: #4a5568;

    /* Typography */
    --font-display: 'Rubik Mono One', 'Heebo', sans-serif;
    --font-body: 'Heebo', system-ui, sans-serif;

    /* Layout */
    --container: 1200px;
    --radius: 4px;
    --radius-lg: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,.4);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--c-bg);
    background-image:
        radial-gradient(at 80% 0%, rgba(212, 175, 55, .08) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(59, 130, 246, .05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--c-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--c-accent);
    text-decoration: none;
    transition: color .15s;
}
a:hover { color: var(--c-accent-hot); }

/* =================================================================
   Header
   ================================================================= */
.site-header {
    background: linear-gradient(to bottom, rgba(0,0,0,.4), transparent);
    border-bottom: 1px solid var(--c-border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--c-text) !important;
}
.brand-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(212, 175, 55, .4));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: .02em;
    color: var(--c-accent);
}
.brand-subtitle {
    font-size: .75rem;
    color: var(--c-text-muted);
    letter-spacing: .15em;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.main-nav a {
    color: var(--c-text-muted);
    font-weight: 500;
    font-size: .95rem;
    position: relative;
}
.main-nav a:hover { color: var(--c-text); }
.main-nav a.nav-admin {
    color: var(--c-text);
    border: 1px solid var(--c-border);
    padding: .35rem .8rem;
    border-radius: var(--radius);
}
.main-nav a.nav-admin:hover {
    border-color: var(--c-accent);
    color: var(--c-accent);
}

/* =================================================================
   Main + Footer
   ================================================================= */
.site-main {
    flex: 1;
    max-width: var(--container);
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}
.site-footer {
    text-align: center;
    color: var(--c-text-dim);
    padding: 2rem 1.5rem;
    font-size: .85rem;
    border-top: 1px solid var(--c-border);
}

/* =================================================================
   Headings, hero
   ================================================================= */
.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    color: var(--c-text);
    margin-bottom: .5rem;
    letter-spacing: .02em;
}
.page-subtitle {
    color: var(--c-text-muted);
    margin-bottom: 2.5rem;
    font-size: 1.05rem;
}

h2 {
    font-family: var(--font-display);
    color: var(--c-text);
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    letter-spacing: .01em;
}
h3 {
    color: var(--c-text);
    font-size: 1.1rem;
    margin: 1.5rem 0 .75rem;
    font-weight: 700;
}
h2:first-child, h3:first-child { margin-top: 0; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

/* =================================================================
   Flash messages
   ================================================================= */
.flash-container {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.flash {
    padding: .8rem 1rem;
    border-radius: var(--radius);
    border-right: 4px solid;
    background: var(--c-surface);
    font-weight: 500;
}
.flash-success { border-color: var(--c-success); }
.flash-error   { border-color: var(--c-danger); }
.flash-info    { border-color: var(--c-info); }
.flash-warning { border-color: var(--c-warning); }

/* =================================================================
   Cards / surfaces
   ================================================================= */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.5rem; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* =================================================================
   Buttons
   ================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1.25rem;
    border-radius: var(--radius);
    background: var(--c-surface-2);
    color: var(--c-text);
    border: 1px solid var(--c-border);
    cursor: pointer;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 500;
    transition: all .15s;
    text-decoration: none;
}
.btn:hover {
    background: var(--c-border);
    border-color: var(--c-accent);
    color: var(--c-text);
}
.btn-primary {
    background: var(--c-accent);
    color: #0a0e1a;
    border-color: var(--c-accent);
    font-weight: 700;
}
.btn-primary:hover {
    background: var(--c-accent-hot);
    color: #0a0e1a;
}
.btn-danger {
    background: transparent;
    border-color: var(--c-danger);
    color: var(--c-danger);
}
.btn-danger:hover {
    background: var(--c-danger);
    color: white;
}
.btn-sm {
    padding: .35rem .75rem;
    font-size: .85rem;
}

/* =================================================================
   Leaderboard
   ================================================================= */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.lb-row {
    display: grid;
    grid-template-columns: 60px 1fr auto auto;
    gap: 1rem;
    align-items: center;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    transition: all .2s;
    text-decoration: none;
    color: var(--c-text);
}
.lb-row:hover {
    border-color: var(--c-accent);
    transform: translateX(4px);
}
.lb-row .rank {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--c-text-dim);
    text-align: center;
    line-height: 1;
}
.lb-row.rank-1 .rank { color: var(--c-accent); }
.lb-row.rank-2 .rank { color: #c0c0c0; }
.lb-row.rank-3 .rank { color: #cd7f32; }
.lb-row.rank-1 {
    border-color: var(--c-accent);
    background: linear-gradient(135deg, rgba(212, 175, 55, .08), var(--c-surface));
}
.lb-row .name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--c-text);
}
.lb-row .meta {
    font-size: .85rem;
    color: var(--c-text-muted);
    margin-top: .2rem;
}
.lb-row .points {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--c-accent);
    text-align: center;
    line-height: 1;
}
.lb-row .points-label {
    display: block;
    font-family: var(--font-body);
    font-size: .7rem;
    color: var(--c-text-dim);
    letter-spacing: .15em;
    margin-top: .3rem;
}
.lb-row .arrow {
    color: var(--c-text-dim);
    font-size: 1.5rem;
}

/* =================================================================
   Tables
   ================================================================= */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
th, td {
    padding: .75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--c-border);
}
th {
    background: var(--c-surface-2);
    font-size: .8rem;
    color: var(--c-text-muted);
    letter-spacing: .1em;
    font-weight: 700;
    text-transform: uppercase;
}
tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(255, 255, 255, .02); }

/* =================================================================
   Tier badges
   ================================================================= */
.tier-badge {
    display: inline-block;
    padding: .2rem .5rem;
    font-size: .75rem;
    font-weight: 700;
    border-radius: 999px;
    letter-spacing: .05em;
}
.tier-1 { background: rgba(212, 175, 55, .15); color: var(--tier-1); border: 1px solid var(--tier-1); }
.tier-2 { background: rgba(148, 163, 184, .15); color: var(--tier-2); border: 1px solid var(--tier-2); }
.tier-3 { background: rgba(201, 122, 58, .15); color: var(--tier-3); border: 1px solid var(--tier-3); }
.tier-4 { background: rgba(91, 124, 153, .15); color: var(--tier-4); border: 1px solid var(--tier-4); }
.tier-5 { background: rgba(74, 85, 104, .25); color: #94a3b8; border: 1px solid var(--tier-5); }

/* =================================================================
   Participant breakdown
   ================================================================= */
.participant-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--c-border);
}
.participant-header h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    color: var(--c-text);
}
.participant-total {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--c-accent);
    margin-right: auto;
}
.participant-total-label {
    font-family: var(--font-body);
    font-size: .8rem;
    color: var(--c-text-dim);
    letter-spacing: .2em;
    display: block;
    text-align: left;
}

.team-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
}
.team-card-head {
    padding: 1rem 1.25rem;
    background: var(--c-surface-2);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.team-card-head .team-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--c-text);
}
.team-card-head .team-points {
    margin-right: auto;
    font-family: var(--font-display);
    color: var(--c-accent);
    font-size: 1.4rem;
}
.team-events { padding: .5rem 1rem; }
.team-event {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 0;
    border-bottom: 1px dashed var(--c-border);
    font-size: .9rem;
}
.team-event:last-child { border-bottom: none; }
.team-event-desc { color: var(--c-text-muted); }
.team-event-points {
    font-family: var(--font-display);
    color: var(--c-accent-hot);
    font-size: 1rem;
}
.team-event.upset {
    background: rgba(212, 175, 55, .04);
    margin: 0 -1rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
}
.team-event.champion {
    background: rgba(212, 175, 55, .12);
    margin: 0 -1rem;
    padding: .6rem 1rem;
    border-radius: var(--radius);
}
.team-event.champion .team-event-desc {
    color: var(--c-accent);
    font-weight: 700;
}

/* =================================================================
   Selections picker (admin)
   ================================================================= */
.tier-group {
    margin-bottom: 1.5rem;
}
.tier-group-title {
    font-size: 1rem;
    color: var(--c-text-muted);
    margin-bottom: .75rem;
    padding-bottom: .25rem;
    border-bottom: 1px solid var(--c-border);
    letter-spacing: .05em;
}
.team-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .6rem;
}
.team-pick {
    position: relative;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: .65rem .9rem;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .92rem;
}
.team-pick input { display: none; }
.team-pick:hover { border-color: var(--c-accent-dim); }
.team-pick.selected {
    background: rgba(212, 175, 55, .1);
    border-color: var(--c-accent);
    color: var(--c-text);
}
.team-pick.taken {
    opacity: .4;
    cursor: not-allowed;
    background: var(--c-surface-2);
}
.team-pick .team-rank {
    font-size: .7rem;
    color: var(--c-text-dim);
    margin-right: auto;
}
.taken-label {
    font-size: .7rem;
    color: var(--c-text-dim);
    margin-right: auto;
}

.selections-summary {
    position: sticky;
    bottom: 1rem;
    background: var(--c-surface-2);
    border: 1px solid var(--c-accent);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    z-index: 50;
    box-shadow: 0 -8px 24px rgba(0,0,0,.6);
}
.selections-count {
    font-family: var(--font-display);
    font-size: 1.5rem;
}
.selections-count.valid { color: var(--c-success); }
.selections-count.invalid { color: var(--c-warning); }

/* =================================================================
   Forms
   ================================================================= */
.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    margin-bottom: .35rem;
    font-size: .9rem;
    color: var(--c-text-muted);
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: .65rem .85rem;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    color: var(--c-text);
    font-family: inherit;
    font-size: 1rem;
}
.form-control:focus {
    outline: none;
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, .15);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

/* =================================================================
   Admin dashboard
   ================================================================= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}
.stat-label {
    font-size: .8rem;
    color: var(--c-text-muted);
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: .5rem;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--c-accent);
    line-height: 1;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.action-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.action-card h3 {
    margin: 0;
    color: var(--c-text);
    font-size: 1rem;
}
.action-card p {
    color: var(--c-text-muted);
    font-size: .85rem;
    flex: 1;
}

/* =================================================================
   Matches list
   ================================================================= */
.match-row {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    margin-bottom: .5rem;
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto auto;
    align-items: center;
    gap: 1rem;
}
.match-stage {
    font-size: .7rem;
    color: var(--c-text-muted);
    letter-spacing: .1em;
    text-transform: uppercase;
    background: var(--c-surface-2);
    padding: .2rem .5rem;
    border-radius: 2px;
    white-space: nowrap;
}
.match-team {
    font-weight: 600;
    color: var(--c-text);
    font-size: .95rem;
}
.match-team.away { text-align: left; }
.match-score {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--c-accent);
    background: var(--c-surface-2);
    padding: .3rem .8rem;
    border-radius: var(--radius);
    min-width: 60px;
    text-align: center;
}
.match-score.pending {
    color: var(--c-text-dim);
    font-family: var(--font-body);
    font-size: .85rem;
}
.match-time {
    font-size: .8rem;
    color: var(--c-text-muted);
    white-space: nowrap;
}

@media (max-width: 700px) {
    .match-row {
        grid-template-columns: 1fr;
        gap: .5rem;
    }
    .match-team, .match-team.away {
        text-align: center;
    }
}

/* =================================================================
   Rules page
   ================================================================= */
.rules-content {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
}
.rules-content h2 {
    color: var(--c-accent);
    border-bottom: 1px solid var(--c-border);
    padding-bottom: .5rem;
    margin-top: 2rem;
}
.rules-content h2:first-child { margin-top: 0; }
.rules-content ul, .rules-content ol {
    padding-right: 1.5rem;
    margin-bottom: 1rem;
}
.rules-content li { margin-bottom: .35rem; }
.rules-content code {
    background: var(--c-surface-2);
    padding: .1rem .35rem;
    border-radius: 3px;
    font-size: .9em;
    color: var(--c-accent);
}

.rules-table { margin-bottom: 1rem; }
.rules-table th, .rules-table td {
    padding: .5rem .75rem;
    font-size: .9rem;
}

/* =================================================================
   Login
   ================================================================= */
.login-wrap {
    max-width: 400px;
    margin: 4rem auto;
}
.login-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* =================================================================
   Utilities
   ================================================================= */
.text-muted { color: var(--c-text-muted); }
.text-dim { color: var(--c-text-dim); }
.text-accent { color: var(--c-accent); }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 1rem; }
.empty-state {
    text-align: center;
    color: var(--c-text-muted);
    padding: 3rem 1rem;
    background: var(--c-surface);
    border: 1px dashed var(--c-border);
    border-radius: var(--radius-lg);
}
.empty-state p:first-child {
    font-size: 1.2rem;
    color: var(--c-text);
    margin-bottom: .5rem;
}

.inline-form { display: inline; }
.button-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Status pill */
.status-pill {
    display: inline-block;
    font-size: .7rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.status-scheduled { background: var(--c-surface-2); color: var(--c-text-muted); }
.status-in_play   { background: rgba(34, 197, 94, .15); color: var(--c-success); }
.status-finished  { background: rgba(59, 130, 246, .15); color: var(--c-info); }

/* =================================================================
   Mobile responsiveness
   ================================================================= */

/* Table scroll wrapper — apply to any container holding a wide table */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    /* Header: shrink brand text and stack nav below brand */
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
        padding: .75rem 1rem;
    }
    .main-nav {
        gap: 1rem;
        font-size: .9rem;
        width: 100%;
    }
    .brand-title { font-size: .95rem; }

    /* Leaderboard: stack rank+name on one side, points on the other */
    .lb-row {
        grid-template-columns: 44px 1fr auto;
        grid-template-rows: auto auto;
        row-gap: .1rem;
        padding: .85rem 1rem;
    }
    .lb-row .rank {
        font-size: 1.5rem;
        grid-row: 1 / 3;
    }
    .lb-row .name { font-size: 1rem; }
    .lb-row .meta { font-size: .78rem; }
    .lb-row .points {
        font-size: 1.4rem;
        grid-row: 1 / 3;
        align-self: center;
    }
    .lb-row .arrow { display: none; }

    /* Tables: allow horizontal scroll */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Rules content: less padding */
    .rules-content {
        padding: 1.25rem 1rem;
    }

    /* Participant header: stack vertically */
    .participant-header {
        flex-direction: column;
        gap: .5rem;
    }
    .participant-total {
        font-size: 2.2rem;
        margin-right: 0;
    }

    /* Page title smaller on very small screens */
    .page-title { font-size: 1.4rem; }

    /* Stat grid: 2 columns on mobile */
    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }
    .stat-value { font-size: 1.5rem; }

    /* Action grid: single column */
    .action-grid {
        grid-template-columns: 1fr;
    }

    /* Match row already has breakpoint at 700px */

    /* Selections summary: stack */
    .selections-summary {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        bottom: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}
