/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(145deg, #0f0f1e 0%, #1a1a2e 40%, #16213e 100%);
    background-attachment: fixed;
    color: #e8e8ed;
    min-height: 100vh;
    padding: 1.5rem 1rem 3rem;
    -webkit-font-smoothing: antialiased;
}

main { width: 100%; max-width: 720px; margin: 0 auto; }

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
    width: 100%;
    max-width: 720px;
    margin: 0 auto 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
}

h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #c0c0d0;
    margin-bottom: 0.85rem;
}

/* ── Nav ──────────────────────────────────────────────────────── */
.nav-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    font-size: 0.88rem;
}

.nav-links a {
    color: #6a9fc4;
    text-decoration: none;
    transition: color 0.15s ease;
}

.nav-links a:hover { color: #8bbde0; }
.nav-links a.active { color: #e8e8ed; font-weight: 600; }

.signed-in {
    color: #8888a0;
    font-size: 0.8rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
    background: linear-gradient(135deg, rgba(22, 33, 62, 0.8), rgba(15, 25, 50, 0.6));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ── Toolbar (scheme toggle + updated) ────────────────────────── */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: #8888a0;
}

.scheme-toggle { display: flex; gap: 0.6rem; align-items: baseline; }
.scheme-toggle strong { color: #e8e8ed; }
.scheme-toggle a { color: #6a9fc4; text-decoration: none; }
.scheme-toggle a:hover { color: #8bbde0; }

.sort-toggle { display: flex; gap: 0.5rem; align-items: baseline; }
.sort-toggle a { color: #6a9fc4; text-decoration: none; }
.sort-toggle a:hover { color: #8bbde0; }
.sort-toggle a.active { color: #e8e8ed; font-weight: 600; text-decoration: underline; }

/* ── Leaderboard ──────────────────────────────────────────────── */
.leaderboard { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }

.lb-row {
    display: grid;
    grid-template-columns: 2.2rem 1fr auto auto;
    grid-template-areas: "rank name gd points" "rank teams teams teams";
    align-items: center;
    gap: 0.3rem 0.85rem;
    padding: 0.8rem 1rem;
}

.lb-gd {
    grid-area: gd;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.85rem;
    font-weight: 600;
    color: #b0b0c0;
    white-space: nowrap;
}
.lb-gd small { font-size: 0.6rem; color: #8888a0; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }

.rank {
    grid-area: rank;
    font-size: 1.2rem;
    font-weight: 700;
    color: #8888a0;
    text-align: center;
}
.rank-1 { color: #f0c040; }
.rank-2 { color: #c0c8d0; }
.rank-3 { color: #cd7f4d; }

.lb-name {
    grid-area: name;
    font-weight: 600;
    font-size: 1.05rem;
    color: #e8e8ed;
    text-decoration: none;
}
.lb-name:hover { color: #8bbde0; }

.lb-points {
    grid-area: points;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.05rem;
    white-space: nowrap;
}
/* Non-active figures are compact context; the active sort figure is the
   headline number that drives the ranking. */
.lb-points .stat { font-size: 0.78rem; color: #8888a0; font-weight: 500; }
.lb-points .stat small { font-size: 0.85em; margin-left: 0.15rem; }
.lb-points .stat.active { font-size: 1.35rem; font-weight: 700; color: #fff; }
.lb-points .stat.active small { font-size: 0.52em; color: #8888a0; }

.lb-teams {
    grid-area: teams;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.team-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.12rem 0.5rem 0.12rem 0.3rem;
    background: rgba(15, 52, 96, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    font-size: 0.72rem;
    color: #c0c0d0;
}
.chip-name { line-height: 1; }

.crest {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
    border-radius: 2px;
}

/* ── Participant detail table ─────────────────────────────────── */
.participant-name { font-size: 1.5rem; color: #fff; margin-bottom: 0.1rem; }
.subtitle { color: #8888a0; font-size: 0.9rem; margin-bottom: 1.25rem; }

.teams-table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    font-size: 0.85rem;
}
.teams-table th, .teams-table td {
    padding: 0.55rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.teams-table th { color: #8888a0; font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.teams-table th.left, .teams-table td.left { text-align: left; }
.teams-table tbody tr:last-child td { border-bottom: none; }
.teams-table .team-cell { text-align: left; font-weight: 600; white-space: nowrap; }
.teams-table .team-cell .crest { margin-right: 0.4rem; }
.teams-table .pts { font-weight: 700; color: #fff; }

/* ── Fixtures ─────────────────────────────────────────────────── */
.hide-finished-toggle { display: flex; gap: 0.4rem; align-items: center; cursor: pointer; user-select: none; }
.hide-finished-toggle input { cursor: pointer; }

.fixture {
    padding: 0.7rem 1rem;
    margin-bottom: 0.55rem;
}
.fixture.live { border-color: rgba(233, 69, 96, 0.4); }

#fixtures.hide-finished .fixture.finished { display: none; }

.fx-stage { font-size: 0.7rem; color: #8888a0; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem; }

.fx-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
}
.fx-team { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; font-size: 0.95rem; }
.fx-team.home { justify-content: flex-end; text-align: right; }
.fx-team.away { justify-content: flex-start; }
.fx-team .crest { width: 22px; height: 22px; }
.fx-team.home .crest { order: 2; }

.fx-team-label { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.fx-team.home .fx-team-label { align-items: flex-end; }
.fx-team.away .fx-team-label { align-items: flex-start; }
.fx-owner { font-size: 0.72rem; font-weight: 500; color: #8888a0; }

.fx-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    min-width: 3rem;
    text-align: center;
}

.fx-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.45rem;
    font-size: 0.74rem;
    color: #8888a0;
}
.fx-status { font-weight: 600; }
.fx-status.live { color: #e94560; }
.fx-status.ft { color: #6fae6f; }

/* ── Admin ────────────────────────────────────────────────────── */
.admin-card { padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.muted { color: #8888a0; font-weight: 400; font-size: 0.82rem; }
.warn { color: #e9a045; font-size: 0.85rem; }
.warn code, code { background: rgba(0,0,0,0.3); padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.85em; }

.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.6rem; }
.inline-form input[type="text"], .inline-form select { flex: 1; min-width: 140px; }

.result-line { margin-top: 0.6rem; font-size: 0.82rem; min-height: 1rem; }
.saved, .sync-status.ok { color: #6fae6f; }
.sync-status.error { color: #e94560; }

.participant-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.participant-item:last-child { border-bottom: none; }
.participant-item a { color: #6a9fc4; text-decoration: none; }
.participant-item a:hover { color: #8bbde0; }

.alloc-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.alloc-table td { padding: 0.4rem 0.4rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
.alloc-table tr:last-child td { border-bottom: none; }
.alloc-table .team-cell { font-weight: 600; white-space: nowrap; }
.alloc-table .team-cell .crest { margin-right: 0.4rem; }
.alloc-table .grp { color: #8888a0; font-weight: 400; }
.row-status { font-size: 0.75rem; color: #6fae6f; white-space: nowrap; }

/* ── Forms ────────────────────────────────────────────────────── */
input[type="text"], select {
    padding: 0.5rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(22, 33, 62, 0.6);
    color: #e8e8ed;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input[type="text"]:focus, select:focus {
    border-color: rgba(85, 132, 172, 0.5);
    box-shadow: 0 0 0 3px rgba(85, 132, 172, 0.15);
}
input[type="text"]::placeholder { color: #555570; }

button {
    padding: 0.5rem 1.05rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #0f3460, #1a5276);
    color: #e8e8ed;
    font-size: 0.88rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
button:hover { background: linear-gradient(135deg, #1a5276, #217dbb); box-shadow: 0 2px 8px rgba(15, 52, 96, 0.4); }
button:active { transform: scale(0.98); }
button[disabled] { opacity: 0.6; cursor: default; }

button.btn-danger {
    background: linear-gradient(135deg, #5c1a1a, #7a2222);
    font-size: 0.78rem;
    padding: 0.25rem 0.7rem;
}
button.btn-danger:hover { background: linear-gradient(135deg, #7a2222, #922828); }

/* ── Misc ─────────────────────────────────────────────────────── */
.back-link { margin-bottom: 1rem; font-size: 0.85rem; }
.back-link a { color: #6a9fc4; text-decoration: none; }
.back-link a:hover { color: #8bbde0; }

.empty-state {
    text-align: center;
    color: #666680;
    padding: 1.5rem;
    font-size: 0.9rem;
}
.updated { white-space: nowrap; }

@media (max-width: 480px) {
    .lb-teams .chip-name { display: none; }
    .team-chip { padding: 0.2rem; }
}
