:root {
    --blue: #002f6c;
    --deep: #07182f;
    --cyan: #00a3e0;
    --green: #00a859;
    --gold: #f7c948;
    --paper: #f6f8fb;
    --text: #132033;
    --muted: #64748b;
    --line: #dbe3ef;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--paper);
}
a { color: var(--blue); text-decoration: none; font-weight: 700; }
.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--blue);
    color: white;
}
.topbar a, .topbar button { color: white; }
.brand { font-size: 20px; }
nav, .actions, .inline { display: flex; align-items: center; gap: 12px; }
.container { width: min(1180px, calc(100% - 32px)); margin: 28px auto; }
.hero {
    min-height: 360px;
    display: flex;
    align-items: center;
    padding: 48px;
    color: white;
    background: linear-gradient(135deg, var(--blue), #0057a8 55%, var(--green));
    border-radius: 8px;
}
.hero h1 { max-width: 760px; font-size: clamp(34px, 5vw, 62px); line-height: 1; margin: 0 0 16px; }
.hero p { max-width: 680px; font-size: 18px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0; color: var(--cyan); font-weight: 800; margin: 0 0 6px; }
.panel, .auth-card, .mini-panel, .card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.auth-card { max-width: 520px; margin: 48px auto; }
.button, button {
    border: 0;
    border-radius: 6px;
    background: var(--gold);
    color: var(--deep);
    padding: 11px 16px;
    font-weight: 800;
    cursor: pointer;
}
.button.ghost, .topbar .button.small {
    background: rgba(255,255,255,.14);
    color: inherit;
    border: 1px solid rgba(255,255,255,.25);
}
.button.ghost.dark { color: var(--blue); border-color: var(--line); }
.button.danger {
    background: #feeceb;
    color: #b42318;
    border: 1px solid #f4b4ae;
}
.button.compact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 5px;
    font-size: 13px;
    line-height: 1;
}
.table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    white-space: normal;
}
.icon-button {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px;
    max-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    padding: 0;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    line-height: 1;
}
.icon-button span { display: block; line-height: 1; }
.icon-button.view {
    color: var(--blue);
    background: #e9f2ff;
    border-color: #b9d1ee;
}
.icon-button.download {
    color: #05603a;
    background: #e6f8ee;
    border-color: #addfc6;
}
.icon-button:hover { transform: translateY(-1px); }
.flag-icon {
    display: inline-block;
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .12);
    vertical-align: -3px;
    margin-right: 6px;
}
.flag-local {
    position: relative;
    overflow: hidden;
}
.flag-england { background: #fff; }
.flag-england::before,
.flag-england::after {
    content: "";
    position: absolute;
    background: #ce1124;
}
.flag-england::before {
    top: 0;
    bottom: 0;
    left: 10px;
    width: 4px;
}
.flag-england::after {
    top: 7px;
    right: 0;
    left: 0;
    height: 4px;
}
.flag-scotland {
    background:
        linear-gradient(37deg, transparent 42%, #fff 43%, #fff 57%, transparent 58%),
        linear-gradient(-37deg, transparent 42%, #fff 43%, #fff 57%, transparent 58%),
        #0065bd;
}
.topbar form button { background: transparent; padding: 0; }
label { display: grid; gap: 6px; font-weight: 700; margin-bottom: 14px; }
input, select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}
.grid { display: grid; gap: 16px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.page-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 20px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { display: grid; gap: 8px; margin: 0; color: inherit; }
.muted { color: var(--muted); }
.rules { columns: 2; line-height: 1.8; }
.row-form { display: flex; gap: 10px; align-items: end; }
.admin-row-form { margin: 14px 0; }
.admin-row-form label { min-width: 260px; margin-bottom: 0; }
.admin-assign-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
}
.admin-assign-form label { margin-bottom: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #e9f2ff; color: var(--blue); font-weight: 700; }
.deadline-closed { background: #fff8df; color: #7a5700; }
.danger-link {
    padding: 0;
    background: transparent;
    color: #b42318;
}
.alert { padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; font-weight: 700; }
.success { background: #e6f8ee; color: #05603a; }
.error { background: #feeceb; color: #b42318; }
.sync-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.settings-panel,
.cleanup-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.settings-form {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.toggle-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 800;
}
.toggle-row input {
    width: auto;
    margin: 0;
}
.sync-panel h2 { margin-top: 0; }
.sync-panel form, .cleanup-panel form { flex: 0 0 auto; }
.sync-panel button:disabled { opacity: .55; cursor: not-allowed; }
.sync-status { margin-bottom: 0; }
.result-source {
    width: max-content;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}
.result-source.api { background: #e9f2ff; color: var(--blue); }
.result-source.manual { background: #fff8df; color: #7a5700; }
.match-status {
    width: max-content;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef1f5;
    color: #52606d;
    font-size: 11px;
    font-weight: 800;
}
.match-status.in_play,
.match-status.extra_time,
.match-status.penalty_shootout {
    background: #e6f8ee;
    color: #05603a;
}
.match-status.paused { background: #fff8df; color: #7a5700; }
.match-status.finished,
.match-status.awarded { background: #e9f2ff; color: var(--blue); }
.match-status.suspended,
.match-status.postponed,
.match-status.cancelled { background: #feeceb; color: #b42318; }
.match-row {
    display: grid;
    grid-template-columns: 170px 1fr 64px 20px 64px 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.public-result-row {
    display: grid;
    grid-template-columns: 170px minmax(150px, 1fr) 44px 16px 44px minmax(150px, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.public-score { text-align: center; color: var(--blue); }
.public-winner { color: var(--muted); font-size: 13px; }
.match-meta { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.team-name { min-width: 0; font-weight: 700; }
.score-input { text-align: center; }
.versus { text-align: center; color: var(--muted); }
.standings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.group-standings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
    gap: 16px;
}
.standings-card { margin-bottom: 0; }
.standings-card h2 { margin-top: 0; }
.compact-standings { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); }
.compact-standings .mini-panel { margin-bottom: 0; }
.compact-standings h3 { margin-top: 0; color: var(--blue); }
.standings-scroll { overflow-x: auto; }
.full-standings { min-width: 500px; }
.full-standings th,
.full-standings td {
    padding: 9px 7px;
    text-align: center;
}
.full-standings th:nth-child(2),
.full-standings td:nth-child(2) { text-align: left; }
.standings-team { min-width: 155px; font-weight: 700; }
.third-places-panel { margin-top: 18px; }
.third-places-table { min-width: 760px; }
.third-places-table th:nth-child(3),
.third-places-table td:nth-child(3) { text-align: left; }
.status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.status-chip.success {
    background: #dff7ea;
    color: #05603a;
}
.status-chip.muted {
    background: #eef2f7;
    color: var(--muted);
}
.live-indicator {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    color: #05603a;
    background: #e6f8ee;
    font-size: 12px;
    font-weight: 800;
}
.qualified td { background: #e6f8ee; }
.third td { background: #fff8df; }
.team-select { margin-bottom: 8px; }
.collapsible-panel {
    overflow: hidden;
}
.collapsible-summary,
.phase-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.collapsible-summary::-webkit-details-marker,
.phase-summary::-webkit-details-marker {
    display: none;
}
.collapsible-summary::after,
.phase-summary::after {
    content: '+';
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    color: var(--blue);
    font-weight: 900;
}
.collapsible-panel[open] > .collapsible-summary::after,
.phase-panel[open] > .phase-summary::after {
    content: '-';
}
.collapsible-summary h2,
.phase-summary h3 {
    margin: 0;
}
.collapsible-panel:not([open]) {
    padding-bottom: 18px;
}
.collapsible-panel[open] > .collapsible-summary {
    margin-bottom: 14px;
}
.phase-panel {
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
    margin-top: 16px;
}
.phase-panel h3 { color: var(--blue); }
.phase-panel > h3 { margin: 0 0 12px; }
.phase-panel[open] > .phase-summary {
    margin-bottom: 12px;
}
.phase-panel:not([open]) {
    padding-bottom: 10px;
}
.knockout-choice, .readonly-pick {
    display: grid;
    grid-template-columns: 1fr 42px 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}
.knockout-choice .match-status { grid-column: 1 / -1; justify-self: center; }
.pick-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}
.pick-card.selected {
    border-color: var(--green);
    background: #e6f8ee;
}
.pick-card input { width: auto; min-height: auto; }
.bonus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.bonus-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}
.bonus-item strong { color: var(--muted); }
.bonus-item .hit, .hit { color: var(--green); }
.readonly-pick {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.readonly-pick strong { text-align: center; color: var(--blue); }
.readonly-points {
    display: grid;
    gap: 2px;
    min-width: 46px;
    justify-items: center;
    padding: 5px 8px;
    border-radius: 6px;
    background: #e9f2ff;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
}
.readonly-points span {
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
}
.readonly-pick-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr) minmax(220px, .8fr) 54px;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.readonly-team {
    min-width: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.readonly-vs {
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}
.readonly-winner {
    min-width: 0;
    color: var(--blue);
    overflow-wrap: anywhere;
}
.readonly-winner strong { display: block; }
.sticky-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px;
    background: rgba(246,248,251,.94);
    border-top: 1px solid var(--line);
}
.check { display: flex; grid-auto-flow: column; align-items: center; gap: 6px; margin: 0; }
.check input { width: auto; min-height: auto; }
.inline-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 3px 4px 3px 0;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
}
.inline-chip button {
    padding: 3px 6px;
    background: #feeceb;
    color: #b42318;
    font-size: 12px;
}
@media (max-width: 850px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
    }
    .topbar nav {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px 14px;
    }
    .container { width: min(100% - 20px, 1180px); margin: 18px auto; }
    .hero { min-height: auto; padding: 28px 22px; }
    .panel, .auth-card, .mini-panel, .card { padding: 16px; }
    .auth-card { margin: 24px auto; }
    .two, .three { grid-template-columns: 1fr; }
    .page-head, .row-form { flex-direction: column; align-items: stretch; }
    .admin-assign-form { grid-template-columns: 1fr; }
    .admin-row-form label { min-width: 0; }
    .rules { columns: 1; }
    .group-standings-grid { grid-template-columns: 1fr; }
    .compact-standings { grid-template-columns: 1fr; }
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    th, td { padding: 9px 8px; }
    td .inline { display: inline-flex; margin-left: 0; }
    .table-actions { min-width: 74px; }
    .match-row { grid-template-columns: 1fr 54px 16px 54px 1fr; }
    .match-meta { grid-column: 1 / -1; }
    .match-row.readonly .readonly-points { grid-column: 1 / -1; justify-self: end; }
    .public-result-row {
        grid-template-columns: minmax(0, 1fr) 38px 12px 38px minmax(0, 1fr);
        gap: 6px;
    }
    .public-result-row .match-meta,
    .public-result-row .public-winner { grid-column: 1 / -1; }
    .knockout-choice, .readonly-pick { grid-template-columns: 1fr; }
    .knockout-choice .versus { display: none; }
    .readonly-pick-card { grid-template-columns: 1fr; }
    .readonly-vs { text-align: left; }
    .sync-panel, .settings-panel, .cleanup-panel { align-items: stretch; flex-direction: column; }
}

@media (max-width: 520px) {
    .brand { font-size: 18px; }
    .hero h1 { font-size: 36px; }
    .hero p { font-size: 16px; }
    .g-recaptcha {
        width: 304px;
        max-width: 100%;
        transform: scale(.88);
        transform-origin: left top;
        margin-bottom: -8px;
    }
    .match-row { grid-template-columns: minmax(0, 1fr) 48px 12px 48px minmax(0, 1fr); gap: 6px; }
    .flag-icon { display: block; margin: 0 0 4px; }
    .team-name { font-size: 13px; overflow-wrap: anywhere; }
    .sticky-actions { justify-content: stretch; }
    .sticky-actions .button, .sticky-actions button { flex: 1; }
}
