:root {
    --bg: #f6f8fb;
    --ink: #162033;
    --muted: #667085;
    --panel: #ffffff;
    --line: #d9e2ec;
    --accent: #0f5f76;
    --accent-strong: #114d5e;
    --danger: #b42318;
    --warning: #f59e0b;
}

html.scroll-restore-pending body {
    visibility: hidden;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--accent-strong);
}

button,
.button-link {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font-weight: 700;
    padding: 0.75rem 1rem;
    text-decoration: none;
}

button:hover,
.button-link:hover {
    background: var(--accent-strong);
}

button.dirty-action {
    background: var(--danger);
}

button.dirty-action:hover {
    background: #8a1f16;
}

button.copied-action {
    background: var(--warning);
    color: var(--ink);
}

button.saved-action {
    background: #15803d;
}

button.error-action {
    background: var(--danger);
}

.danger-button {
    background: var(--danger);
}

.danger-button:hover {
    background: #8a1f16;
}

.outline-button {
    border: 1px solid var(--line);
    background: white;
    color: var(--accent);
}

.outline-button:hover {
    background: #e6f4f8;
    color: var(--accent-strong);
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    padding: 0.72rem 0.8rem;
}

label {
    display: grid;
    gap: 0.4rem;
    font-weight: 700;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 0.45rem;
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    padding: 0.7rem clamp(1rem, 4vw, 3rem);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.page {
    display: grid;
    gap: 1.2rem;
    margin: 0 auto;
    max-width: 1180px;
    padding: 1.2rem clamp(1rem, 4vw, 2rem) 3rem;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
    gap: 1rem;
    align-items: stretch;
    background: #e6eff2;
    border: 1px solid #c5d8e1;
    border-radius: 8px;
    padding: clamp(1.2rem, 4vw, 2rem);
}

.hero.compact {
    background: #edf4ff;
    border-color: #cdddf4;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2rem, 6vw, 4rem);
    letter-spacing: 0;
    line-height: 1;
}

.hero p {
    color: var(--muted);
    margin: 0.8rem 0 0;
    max-width: 58ch;
}

.eyebrow {
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 0.55rem;
    text-transform: uppercase;
}

.panel,
.quick-form,
.status-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 35px rgba(17, 24, 39, 0.06);
    padding: 1rem;
}

.quick-form,
.stacked {
    display: grid;
    gap: 0.75rem;
}

.quick-form h2,
.panel h2,
.stacked h2,
.stacked h3 {
    margin: 0;
}

.danger {
    border-color: #fecaca;
}

.danger button,
.confirm-form button {
    background: var(--danger);
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.section-heading h2 {
    margin: 0;
}

.section-heading span,
.muted,
.empty {
    color: var(--muted);
}

.period-nav {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    justify-content: center;
    margin: 0.85rem 0 1rem;
}

.period-nav strong {
    min-width: 210px;
    text-align: center;
}

.compact-period-nav {
    justify-content: flex-end;
    margin: 0;
}

.list,
.match-grid,
.rules {
    display: grid;
    gap: 0.75rem;
}

.compact-list {
    gap: 0.45rem;
}

.row-card,
.match-card,
.rules article {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.9rem;
}

.compact-row,
.rules article {
    min-height: 58px;
    padding: 0.55rem 0.65rem;
}

.row-card h3,
.match-card p {
    margin: 0.25rem 0;
}

.compact-row h3,
.compact-row p {
    margin: 0.1rem 0;
}

.small-link {
    display: inline-block;
    max-width: min(100%, 520px);
    overflow-wrap: anywhere;
    font-size: 0.86rem;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 44px;
    gap: 0.45rem;
    max-width: 280px;
    width: min(100%, 280px);
}

.icon-button {
    align-items: center;
    display: inline-flex;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0;
}

.compact-count {
    margin: -0.35rem 0 0.7rem;
}

.large-sport {
    display: inline-grid;
    font-size: 2rem;
    line-height: 1;
    min-width: 2.5rem;
    place-items: center;
}

.rule-form {
    margin-left: auto;
}

.rule-form input {
    max-width: 92px;
}

.full-panel {
    display: grid;
    gap: 0.75rem;
}

.full-panel {
    align-items: stretch;
}

.action-heading {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    justify-content: flex-end;
}

.add-participant-button {
    align-items: center;
    display: inline-flex;
    font-size: 1.25rem;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0;
    line-height: 1;
}

.admin-table {
    table-layout: fixed;
}

.admin-table th {
    background: var(--panel);
    position: sticky;
    top: 0;
    z-index: 2;
}

.header-filter {
    align-items: center;
    display: grid;
    gap: 0.4rem;
    grid-template-columns: auto minmax(120px, 1fr);
}

.header-filter input {
    padding: 0.45rem 0.55rem;
    text-transform: none;
}

.admin-table td {
    height: 64px;
    vertical-align: middle;
}

.admin-table input,
.admin-table select {
    min-width: 0;
}

.admin-table .action-cell {
    text-align: right;
    width: 104px;
}

.participants-table {
    min-width: 0;
}

.participants-table .participant-url-cell {
    width: auto;
}

.participants-table .participant-action-cell {
    width: 208px;
}

.participants-table th:nth-child(2),
.participants-table td:nth-child(2) {
    width: 132px;
}

.participants-table th:nth-child(4),
.participants-table td:nth-child(4) {
    width: 208px;
}

.weekly-events-heading {
    margin-top: 1rem;
}

.weekly-events-table {
    min-width: 920px;
}

.weekly-events-table th:first-child,
.weekly-events-table td:first-child {
    text-align: center;
    width: 72px;
}

.weekly-events-table input[type="checkbox"] {
    height: 20px;
    width: 20px;
}

.table-action-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.table-scroll {
    overflow-x: auto;
}

.table-scroll {
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 430px;
    overflow-y: auto;
}

.action-cluster {
    align-items: center;
    display: flex;
    gap: 0.45rem;
    justify-content: flex-end;
    min-height: 44px;
}

.action-cluster form {
    margin: 0;
}

.hidden {
    display: none;
}

.new-entry-row {
    background: #f8fafc;
}

.match-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.match-card {
    align-items: stretch;
    display: grid;
    position: relative;
}

.locked-match-card {
    cursor: pointer;
}

.locked-match-card:hover {
    border-color: var(--accent);
}

.outcome-hit-card {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.exact-hit-card {
    background: #ecfdf5;
    border-color: #86efac;
}

.missed-card {
    background: #fef2f2;
    border-color: #fecaca;
}

.trophy-corner {
    position: absolute;
    right: 0.75rem;
    top: 0.7rem;
}

.match-title {
    display: flex;
    gap: 0.55rem;
    align-items: center;
}

.score {
    font-size: 1.8rem;
    font-weight: 800;
}

.live-score {
    align-items: center;
    display: flex;
    gap: 0.6rem;
}

.live-score strong {
    font-size: 1.55rem;
}

.live-score span {
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 0.28rem 0.55rem;
}

.manual-final-form {
    border-top: 1px solid var(--line);
    padding-top: 0.65rem;
}

.prediction-form {
    align-items: center;
    display: grid;
    grid-template-columns: 72px auto 72px 104px;
    gap: 0.5rem;
}

.prediction-form button,
.manual-final-form button {
    min-width: 104px;
}

.prediction-form span {
    color: var(--muted);
    font-weight: 800;
    text-align: center;
}

.lock-line {
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-weight: 800;
    padding: 0.55rem 0.7rem;
}

.lock-line.locked {
    background: #f1f5f9;
    color: #475569;
}

.prediction-result {
    background: #e6f4f8;
    border-radius: 8px;
    padding: 0.7rem;
}

.prediction-dialog {
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(17, 24, 39, 0.24);
    max-width: min(92vw, 560px);
    padding: 1rem;
    width: 560px;
}

.prediction-dialog::backdrop {
    background: rgba(17, 24, 39, 0.38);
}

.dialog-heading {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.dialog-heading h2 {
    font-size: 1.1rem;
    margin: 0;
}

.status-panel {
    align-content: center;
    display: grid;
    text-align: center;
}

.status-panel strong {
    font-size: 4rem;
    line-height: 1;
}

.pill,
.ghost,
.ghost-link {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    color: var(--ink);
    padding: 0.55rem 0.8rem;
    text-decoration: none;
}

.alert {
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background: #f0f9ff;
    color: #075985;
    padding: 0.8rem 1rem;
}

.alert.error {
    border-color: #fecaca;
    background: #fef2f2;
    color: var(--danger);
}

.alert.warning {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-shell {
    width: min(100%, 520px);
}

.auth-panel {
    display: grid;
    gap: 1rem;
}

.auth-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    align-items: center;
    gap: 1rem;
}

.auth-heading h1 {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
    font-size: clamp(1.45rem, 5vw, 2rem);
}

.auth-heading .brand-title {
    color: var(--accent);
    white-space: nowrap;
}

.auth-logo {
    width: 100%;
    height: 140px;
    object-fit: contain;
}

summary {
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 800;
}

.management[open] summary {
    margin-bottom: 1rem;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero,
    .grid.two,
    .grid.three {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 2.35rem;
    }

    .row-card,
    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }

    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .period-nav,
    .compact-period-nav {
        justify-content: space-between;
    }

    .period-nav strong {
        min-width: 0;
    }

    .search-form {
        grid-template-columns: 1fr;
        max-width: none;
        width: 100%;
    }

    .rule-form {
        margin-left: 0;
    }

    .rule-form input {
        max-width: none;
    }

    .prediction-form {
        grid-template-columns: 1fr auto 1fr;
    }

    .prediction-form button {
        grid-column: 1 / -1;
    }

    .auth-heading {
        grid-template-columns: minmax(0, 1fr) 140px;
    }

    .auth-logo {
        height: 112px;
    }
}
