:root {
    --bg: #0e1320;
    --bg-soft: #141b2b;
    --card: #171f31;
    --card-2: #1b2438;
    --line: #27324b;
    --text: #e9eef8;
    --muted: #93a0bb;
    --muted-2: #6d7a96;
    --accent: #4ade80;
    --warn: #f0b34a;
    --error: #ef6b6b;
    --radius: 14px;
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background:
        radial-gradient(1200px 600px at 15% -5%, #1b2742 0%, transparent 55%),
        radial-gradient(900px 500px at 100% 0%, #16263a 0%, transparent 50%),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    min-height: 100vh;
}

.wrap {
    max-width: 1420px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}

code {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 0.86em;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 5px;
}

/* ------------------------------------------------------------- header --- */

.site-header {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.brand h1 {
    margin: 0;
    font-size: clamp(26px, 4vw, 38px);
    letter-spacing: .5px;
}

.brand h1::after {
    content: "";
    display: block;
    width: 60px;
    height: 3px;
    margin-top: 8px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), #38bdf8);
}

.subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.updated { color: var(--muted); font-size: 13px; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(74, 222, 128, .12);
    border: 1px solid rgba(74, 222, 128, .45);
    color: #b8f5cd;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s ease;
}

.btn:hover { background: rgba(74, 222, 128, .22); }

/* ------------------------------------------------------------- legend --- */

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 30px;
    padding: 14px 16px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.legend-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.legend-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted-2);
    margin-right: 4px;
}

/* --------------------------------------------------------- contestant --- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 11px 3px 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    font-size: 12.5px;
    white-space: nowrap;
}

.chip-name { color: var(--text); }

.avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--c, var(--muted));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.avatar-initial {
    background: var(--c, var(--muted));
    color: #0e1320;
    font-size: 11px;
    font-weight: 800;
    border: none;
    line-height: 1;
}

.tier-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .03);
    font-size: 12.5px;
}

.tier-chip em { color: var(--muted); font-style: normal; font-size: 11.5px; }

.tier-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tier, var(--muted));
    box-shadow: 0 0 8px var(--tier, transparent);
}

/* ----------------------------------------------------------- notices --- */

.notice {
    margin: 0 0 14px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .03);
    color: var(--muted);
}

.notice.warn { border-color: rgba(240, 179, 74, .5); background: rgba(240, 179, 74, .09); color: #f4d7a3; }

/* --------------------------------------------------------- league grid --- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(470px, 1fr));
    gap: 18px;
    align-items: start;
}

.card {
    background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
}

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .02);
}

.league-badge {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: .5px;
    color: #dfe7f7;
    background: linear-gradient(145deg, #2b3a5c, #1d2740);
    border: 1px solid #38466a;
}

.league-badge img { width: 26px; height: 26px; object-fit: contain; }

.card-title { flex: 1 1 auto; min-width: 0; }

.card-title h2 { margin: 0; font-size: 17px; letter-spacing: .2px; }

.card-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.card-tiers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .015);
    font-size: 11.5px;
}

.card-tiers .tier-chip { padding: 2px 10px; font-size: 11.5px; }

.source {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 11px;
    color: var(--muted-2);
    text-align: right;
    white-space: nowrap;
}

.source.is-stale { color: var(--warn); }

/* ------------------------------------------------------------ table --- */

table.standings {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.standings thead th {
    padding: 9px 9px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .11em;
    color: var(--muted-2);
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
}

.standings .col-rank,
.standings .col-pts { text-align: center; }
.standings .col-owner { text-align: right; }

.standings td {
    padding: 8px 9px;
    border-bottom: 1px solid rgba(39, 50, 75, .55);
    vertical-align: middle;
}

.standings tr:last-child td { border-bottom: none; }

.row { border-left: 3px solid var(--tier, var(--line)); }
.row:hover { background: rgba(255, 255, 255, .025); }
.row.leader { background: linear-gradient(90deg, rgba(74, 222, 128, .10), transparent 70%); }
.row.missing { opacity: .75; }

td.tier { width: 48px; }

.tier-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--tier, var(--muted));
    border: 1px solid var(--tier, var(--line));
    background: rgba(255, 255, 255, .04);
}

td.trank { width: 30px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }

td.team { min-width: 0; }

.team-main { display: flex; align-items: center; gap: 10px; min-width: 0; }

.crest {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    object-fit: contain;
}

.crest-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px dashed var(--line);
    color: var(--muted-2);
    font-size: 12px;
}

.crest-lg { width: 40px; height: 40px; }

.team-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.star { color: var(--accent); font-size: 12px; }

.team-meta {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--muted-2);
    display: flex;
    align-items: center;
    gap: 8px;
}

td.pts {
    width: 54px;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

td.owner { width: 134px; text-align: right; }

.tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid var(--line);
    color: var(--muted);
}

.tag.warn { color: var(--warn); border-color: rgba(240, 179, 74, .5); }
.tag.error { color: var(--error); border-color: rgba(239, 107, 107, .5); }
.tag.manual { color: #8fd3ff; border-color: rgba(143, 211, 255, .45); }

/* ------------------------------------------------------------- form --- */

.form {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.form-label { margin-right: 2px; }

.f {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9.5px;
    font-weight: 800;
    line-height: 1;
}

.f-w { color: #0d2417; background: var(--accent); }
.f-d { color: var(--muted); background: rgba(147, 160, 187, .22); border: 1px solid var(--line); }
.f-l { color: #2b0d0d; background: var(--error); }

.empty { padding: 18px 16px; margin: 0; color: var(--muted); font-size: 13.5px; }

/* ------------------------------------------------------------ duels --- */

.duels { margin-top: 30px; }

.section-title {
    margin: 0 0 14px;
    font-size: 20px;
    letter-spacing: .4px;
}

.section-title::after {
    content: "";
    display: block;
    width: 44px;
    height: 3px;
    margin-top: 7px;
    border-radius: 3px;
    background: linear-gradient(90deg, #38bdf8, var(--accent));
}

.duel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

.duel {
    background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px 16px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .25);
}

.duel-title {
    margin: 0 0 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    font-weight: 600;
}

.duel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.duel-type {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    color: #cfe9ff;
    border: 1px solid rgba(143, 211, 255, .45);
    background: rgba(143, 211, 255, .08);
}

.duel-league-name {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .04em;
}

.duel-body {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.duel-side {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    padding: 12px 8px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .02);
    position: relative;
}

.duel-side .chip { font-size: 11.5px; }

.duel-side.win {
    border-color: rgba(74, 222, 128, .6);
    background: linear-gradient(180deg, rgba(74, 222, 128, .12), rgba(74, 222, 128, .03));
    box-shadow: 0 0 0 1px rgba(74, 222, 128, .25), 0 8px 20px rgba(74, 222, 128, .08);
}

.duel-side.lose { opacity: .62; }

.duel-side.tie { border-color: rgba(240, 179, 74, .55); background: rgba(240, 179, 74, .07); }

.duel-vs {
    align-self: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted-2);
}

.duel-name { font-weight: 600; font-size: 14px; }

.duel-points { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }

.duel-side.win .duel-points { color: var(--accent); }

.duel-league { font-size: 11px; color: var(--muted-2); }

.duel-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
    min-height: 13px;
}

.duel-side.win .duel-tag { color: var(--accent); }
.duel-side.tie .duel-tag { color: var(--warn); }

/* ------------------------------------------------------------ footer --- */

.site-footer {
    margin-top: 34px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted-2);
    font-size: 12.5px;
}

.site-footer p { margin: 0; }

/* -------------------------------------------------------- responsive --- */

@media (max-width: 560px) {
    .wrap { padding: 18px 12px 44px; }
    .grid, .duel-grid { grid-template-columns: 1fr; }
    .card { overflow-x: auto; }

    /* Phones: drop the form strip and the owner's name (the avatar colour still
       identifies the contestant) and tighten the columns so a row fits. */
    table.standings { min-width: 0; font-size: 13.5px; }
    .standings thead th,
    .standings td { padding: 7px 6px; }
    td.tier { width: 36px; }
    .tier-badge { padding: 2px 7px; font-size: 10.5px; }
    td.trank { width: 20px; }
    .team-main { gap: 8px; }
    .team-name { white-space: normal; }
    .team .crest { width: 20px; height: 20px; }
    .team-meta { font-size: 10.8px; gap: 6px; }
    .form { display: none; }
    td.pts { width: 38px; font-size: 16px; }
    td.owner { width: 34px; }
    td.owner .chip { padding: 3px; gap: 0; }
    td.owner .chip-name { display: none; }
}

/* Very small phones (≈320 px): tighten once more so nothing scrolls sideways. */
@media (max-width: 380px) {
    .wrap { padding: 16px 8px 40px; }
    .card-head { padding: 11px 12px; gap: 8px; }
    .card-title h2 { font-size: 15.5px; }
    .source { font-size: 10px; white-space: normal; }
    .card-tiers { padding: 8px 12px; gap: 6px; }
    table.standings { font-size: 13px; }
    .standings thead th,
    .standings td { padding: 6px 4px; }
    td.tier { width: 32px; }
    .tier-badge { padding: 2px 5px; font-size: 10px; }
    td.trank { width: 16px; }
    .team-main { gap: 6px; }
    .team .crest { width: 18px; height: 18px; }
    .team-meta { font-size: 10.4px; }
    td.pts { width: 32px; font-size: 15px; }
    td.owner { width: 30px; }

    /* Duel cards: stack the two sides so long club names fit. */
    .duel-body { flex-direction: column; }
}
