:root {
    --bg: #ffffff;
    --bg-soft: #f4f8fc;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --surface-blue: #eef6ff;
    --text: #0f172a;
    --text-strong: #020617;
    --muted: #5b6b84;
    --line: #dbe5f0;
    --line-strong: #c7d5e8;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --accent: #14b8a6;
    --danger: #dc2626;
    --warning: #ca8a04;
    --success: #15803d;
    --shadow: 0 18px 50px rgba(15, 23, 42, .09);
    --shadow-soft: 0 10px 28px rgba(15, 23, 42, .06);
    --radius: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, .11), transparent 32rem),
        radial-gradient(circle at 90% 4%, rgba(37, 99, 235, .12), transparent 34rem),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(15, 23, 42, .025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, .02) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: linear-gradient(180deg, rgba(0,0,0,.35), transparent 70%);
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 16px 32px;
    backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 950;
    letter-spacing: .2px;
    color: var(--text-strong);
}

.brand-ball {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .18);
}

.nav-links { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav-links a { color: var(--muted); font-weight: 800; }
.nav-links a:hover { color: var(--primary); }
.user-pill { padding: 8px 12px; border-radius: 999px; background: #eef6ff; color: var(--primary-dark); font-size: .9rem; font-weight: 850; border: 1px solid #d9eaff; }

.container { position: relative; width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 28px 0 60px; }
.footer { color: var(--muted); border-top: 1px solid var(--line); text-align: center; padding: 22px; font-size: .9rem; background: rgba(255,255,255,.68); }

.hero { display: grid; grid-template-columns: 1.35fr .85fr; gap: 28px; align-items: center; padding: 48px 0; }
.eyebrow { display: inline-flex; color: #0369a1; background: #e6f6ff; border: 1px solid #d9eaff; border-radius: 999px; text-transform: uppercase; letter-spacing: .12em; font-weight: 950; font-size: .76rem; margin: 0 0 14px; padding: 8px 12px; }
h1 { font-size: clamp(2rem, 5vw, 4.6rem); line-height: .98; margin: 0 0 18px; letter-spacing: -0.05em; color: var(--text-strong); }
h2 { margin: 0; font-size: 1.55rem; color: var(--text-strong); }
h3 { margin: 0; color: var(--text-strong); }
.hero-text { color: var(--muted); font-size: 1.08rem; max-width: 760px; line-height: 1.7; }
.hero-actions, .header-actions, .section-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero-actions, .header-actions { margin-top: 22px; }

.btn {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 15px;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .04);
}
.btn:hover { transform: translateY(-1px); background: var(--surface-soft); border-color: var(--line-strong); box-shadow: var(--shadow-soft); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #ffffff; border: 0; box-shadow: 0 16px 35px rgba(37, 99, 235, .22); }
.btn.primary:hover { background: linear-gradient(135deg, #1d4ed8, #1e3a8a); }
.btn.info { background: #e6f6ff; border-color: #c7e7ff; color: #075985; }
.btn.full { width: 100%; }

.hero-panel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.metric, .card, .group-card, .round-row, .qualification-graphic {
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}
.metric { padding: 24px; min-height: 130px; display: flex; flex-direction: column; justify-content: center; background: linear-gradient(180deg, #ffffff, #f8fbff); }
.metric span { font-size: 3rem; font-weight: 950; color: var(--primary); }
.metric small { color: var(--muted); font-weight: 750; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card { padding: 24px; }
.feature p, .muted { color: var(--muted); line-height: 1.65; }
.center { text-align: center; }

.auth-wrap { min-height: 72vh; display: grid; place-items: center; }
.auth-card { width: min(100%, 460px); }
.form-stack { display: grid; gap: 10px; margin-top: 20px; }
.form-stack label { color: #24324a; font-weight: 850; }
input { width: 100%; background: #ffffff; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; outline: none; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.validation { color: var(--danger); font-size: .9rem; }

.page-header, .section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-header { margin: 18px 0 24px; }
.header-actions, .section-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.section-actions { justify-content: flex-end; }
.page-header h1 { font-size: clamp(2rem, 4vw, 3.5rem); }
.section-title { margin: 24px 0 16px; }
.section-title p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }
.knockout-title { margin-top: 34px; }
.alert { padding: 14px 18px; border-radius: 16px; background: #ecfdf5; border: 1px solid #bbf7d0; margin-bottom: 20px; color: #14532d; font-weight: 750; }
.today-matches-card {
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 24px;
}
.today-matches-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.today-matches-head h2 { margin: 0; }
.today-count {
    background: #eef6ff;
    color: var(--primary-dark);
    border: 1px solid #d9eaff;
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 950;
    white-space: nowrap;
}
.today-match-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}
.today-match-btn {
    width: 100%;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    border-radius: 18px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 6px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .035);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.today-match-btn:hover {
    transform: translateY(-1px);
    background: #f8fbff;
    border-color: var(--primary);
    box-shadow: var(--shadow-soft);
}
.today-time {
    width: fit-content;
    background: #e6f6ff;
    color: #075985;
    border: 1px solid #c7e7ff;
    border-radius: 999px;
    padding: 4px 9px;
    font-weight: 950;
    font-size: .82rem;
}
.today-match-btn strong {
    color: var(--text-strong);
    font-size: 1rem;
    line-height: 1.35;
}
.today-match-btn em {
    color: var(--muted);
    font-style: normal;
    font-weight: 950;
}
.today-match-btn small {
    color: var(--muted);
    font-weight: 750;
}
.empty-today {
    background: #ffffff;
    border: 1px dashed var(--line-strong);
    border-radius: 16px;
    color: var(--muted);
    padding: 16px;
    font-weight: 750;
}
.match-highlight {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .14), var(--shadow) !important;
}


.group-card { padding: 0; margin-bottom: 22px; overflow: hidden; }
.collapsible-summary { list-style: none; cursor: pointer; }
.collapsible-summary::-webkit-details-marker { display: none; }
.collapsible-body { padding: 0 18px 18px; }
.group-head, .round-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #ffffff, #f8fbff); }
.group-head small, .round-head small { display: block; margin-top: 4px; color: var(--muted); font-weight: 650; }
.group-head span, .round-head span { color: var(--muted); }
.summary-meta { display: flex; align-items: center; gap: 12px; }
.collapse-icon { width: 32px; height: 32px; border-radius: 11px; display: grid; place-items: center; background: #eef6ff; border: 1px solid #d9eaff; }
.collapse-icon::before { content: "−"; color: var(--primary); font-weight: 950; font-size: 1.25rem; line-height: 1; }
details:not([open]) .collapse-icon::before { content: "+"; }
details:not([open]) .group-head, details:not([open]) .round-head { border-bottom: 0; }

.match-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; padding-top: 18px; }
.match-card { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; gap: 10px; min-width: 0; box-shadow: 0 8px 18px rgba(15, 23, 42, .035); }
.match-card.locked { opacity: .72; background: #f1f5f9; }
.match-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.match-meta strong { color: var(--text-strong); }
.teams-score { display: grid; grid-template-columns: minmax(0, 1fr) 72px 18px 72px minmax(0, 1fr); gap: 8px; align-items: center; }
.team-name { font-weight: 850; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text-strong); }
.team-name.right { text-align: right; }
.score-input { text-align: center; padding: 10px 8px; font-weight: 900; }
.score-input.mini { max-width: 58px; padding: 8px 6px; }
.dash { text-align: center; color: var(--muted); font-weight: 900; }
.locked-text { grid-column: span 3; }
.match-card small { color: var(--muted); }
.penalty-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: .9rem; }

.table-wrap { overflow-x: auto; border-radius: 16px; border: 1px solid var(--line); background: #ffffff; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: center; color: var(--text); }
th { color: var(--primary-dark); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; background: #f1f7ff; font-weight: 950; }
td.team-cell, th:nth-child(2) { text-align: left; }
tbody tr:hover { background: #f8fbff; }
tr.qualified { background: #ecfdf5; }
tr.third-qualified { background: #fffbeb; }
.tag { padding: 6px 9px; border-radius: 999px; font-weight: 900; font-size: .78rem; display: inline-block; }
.tag.success { background: #dcfce7; color: #166534; }
.tag.warn { background: #fef3c7; color: #92400e; }

.qualification-graphic { padding: 18px; margin-bottom: 24px; background: linear-gradient(180deg, #ffffff, #f8fbff); }
.is-hidden { display: none !important; }
.graphic-header, .bracket-preview-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.graphic-header p { margin-bottom: 0; color: var(--muted); }
.graphic-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.stat-card { background: #ffffff; border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 0 8px 18px rgba(15, 23, 42, .035); }
.stat-card strong { display: block; color: var(--primary); font-size: 1.7rem; }
.stat-card span { color: var(--muted); font-size: .9rem; font-weight: 700; }
.qualification-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.qualifier-card { background: #ffffff; border: 1px solid var(--line); border-radius: 18px; padding: 13px; box-shadow: 0 8px 18px rgba(15, 23, 42, .035); }
.qualifier-card-title { font-weight: 950; color: var(--primary-dark); margin-bottom: 10px; }
.qualifier-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.qualifier-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 4px 8px; align-items: center; padding: 9px; border-radius: 14px; background: var(--surface-soft); border: 1px solid transparent; }
.qualifier-item small { grid-column: 2; color: var(--muted); }
.qualifier-item.direct { border-color: #bbf7d0; background: #ecfdf5; }
.qualifier-item.third { border-color: #fde68a; background: #fffbeb; }
.rank-badge { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 10px; background: #eef6ff; color: var(--primary-dark); font-weight: 950; }
.qualifier-team { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-strong); }
.bracket-preview { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.bracket-preview-head span { color: var(--muted); }
.bracket-preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.mini-bracket-card { background: #ffffff; border: 1px solid var(--line); border-radius: 16px; padding: 12px; box-shadow: 0 8px 18px rgba(15, 23, 42, .035); }
.mini-bracket-card strong { display: block; color: var(--primary-dark); margin-bottom: 8px; }
.mini-bracket-card div { display: grid; gap: 4px; color: var(--text); }
.mini-bracket-card em { color: var(--muted); font-style: normal; font-weight: 900; }
.mini-bracket-card.locked { opacity: .72; background: #f1f5f9; }

.knockout-board { display: grid; gap: 18px; align-items: start; overflow: visible; padding-bottom: 12px; }
.round-row { padding: 0; overflow: hidden; }
.round-head h3 { color: var(--primary-dark); }
.round-match-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; padding-top: 18px; }
.knockout .teams-score { grid-template-columns: minmax(0, 1fr) 58px 14px 58px minmax(0, 1fr); }

@media (max-width: 1180px) {
    .qualification-grid, .bracket-preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .graphic-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
    .hero { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .match-grid { grid-template-columns: 1fr; }
    .qualification-grid, .bracket-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .topbar { padding: 14px 16px; align-items: flex-start; flex-direction: column; }
    .container { width: min(100% - 24px, 1480px); }
    .teams-score, .knockout .teams-score { grid-template-columns: minmax(0, 1fr) 54px 12px 54px minmax(0, 1fr); }
    .hero-panel, .graphic-stats, .qualification-grid, .bracket-preview-grid { grid-template-columns: 1fr; }
    .round-match-grid { grid-template-columns: 1fr; }
    .group-head, .round-head { align-items: flex-start; }
    .summary-meta { width: 100%; justify-content: space-between; }
    .page-header, .section-title { align-items: stretch; }
    .header-actions, .section-actions { width: 100%; }
    .header-actions .btn, .section-actions .btn { flex: 1 1 calc(50% - 6px); text-align: center; }
    .header-actions .btn.primary { order: -1; }
    .today-match-grid { grid-template-columns: 1fr; }
    .today-matches-card { padding: 14px; }
}
