:root {
    --ink: #17211d;
    --muted: #66736c;
    --paper: #f6f7f2;
    --surface: #ffffff;
    --line: #dfe4dc;
    --green: #155f46;
    --green-light: #dcefe5;
    --lime: #d8ed6f;
    --orange: #dd6b3d;
    --red: #a83b32;
    --shadow: 0 18px 50px rgba(29, 49, 39, .08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--paper);
    color: var(--ink);
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 8% 10%, rgba(216, 237, 111, .16), transparent 28rem),
        var(--paper);
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    border-bottom: 1px solid rgba(223, 228, 220, .85);
    background: rgba(246, 247, 242, .92);
    backdrop-filter: blur(14px);
}

.nav-shell {
    width: min(1180px, calc(100% - 32px));
    min-height: 76px;
    margin: auto;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    margin-right: auto;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: white;
    background: var(--green);
    font-family: Georgia, serif;
    font-size: 1.35rem;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 1px;
    color: var(--muted);
    font-size: .72rem;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.nav-shell nav {
    display: flex;
    align-items: center;
    gap: 22px;
}

.nav-shell nav a {
    color: #3e4b44;
    font-size: .94rem;
    font-weight: 650;
    text-decoration: none;
}

.nav-shell nav a:hover {
    color: var(--green);
}

.status-pill,
.large-status {
    border: 1px solid #bdd3c5;
    border-radius: 999px;
    background: var(--green-light);
    color: var(--green);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .03em;
    padding: 8px 12px;
    text-transform: uppercase;
}

.page-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 54px 0 80px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 24px;
    margin-bottom: 36px;
}

.page-heading h1 {
    margin: 3px 0 8px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.4rem, 7vw, 4.5rem);
    font-weight: 500;
    letter-spacing: -.04em;
    line-height: .98;
}

.page-heading p:not(.eyebrow) {
    margin: 0;
    color: var(--muted);
}

.compact-heading h1 {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
}

.eyebrow {
    margin: 0;
    color: var(--green);
    font-size: .76rem;
    font-weight: 850;
    letter-spacing: .17em;
    text-transform: uppercase;
}

.round-card,
.table-card,
.form-card,
.lifecycle-card,
.result-card {
    margin-bottom: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.round-header {
    min-height: 72px;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    background: var(--green);
}

.round-header > div {
    display: flex;
    align-items: baseline;
    gap: 18px;
}

.round-header > span {
    color: #cbe1d5;
    font-size: .8rem;
    font-weight: 700;
}

.round-number {
    font-family: Georgia, serif;
    font-size: 1.55rem;
}

.date-range {
    color: #cbe1d5;
    font-size: .85rem;
}

.date-range span {
    margin: 0 5px;
}

.match-row {
    position: relative;
    display: grid;
    grid-template-columns: 48px minmax(170px, 1fr) minmax(160px, auto) minmax(170px, 1fr);
    align-items: center;
    min-height: 82px;
    padding: 15px 24px;
    border-top: 1px solid var(--line);
}

.match-row:first-child {
    border-top: 0;
}

.match-row.is-played {
    background: linear-gradient(90deg, rgba(220, 239, 229, .45), transparent 35%);
}

.match-id {
    color: #849088;
    font-size: .77rem;
    font-weight: 750;
}

.team {
    font-weight: 720;
}

.team-one {
    text-align: right;
}

.team-two {
    text-align: left;
}

.score {
    padding: 0 22px;
    text-align: center;
}

.score div {
    display: flex;
    gap: 7px;
}

.score div span {
    min-width: 42px;
    padding: 7px 8px;
    border-radius: 8px;
    background: var(--ink);
    color: white;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.pending-label {
    display: inline-block;
    border: 1px dashed #bbc4bd;
    border-radius: 999px;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 750;
    padding: 6px 10px;
    text-transform: uppercase;
}

.match-notes {
    grid-column: 2 / -1;
    margin: 9px 0 0;
    color: var(--muted);
    font-size: .86rem;
    font-style: italic;
    text-align: center;
}

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

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

th,
td {
    padding: 15px 13px;
    border-bottom: 1px solid var(--line);
    text-align: center;
    white-space: nowrap;
}

th {
    color: var(--muted);
    background: #f0f3ed;
    font-size: .73rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #fafbf7;
}

.player-column {
    min-width: 170px;
    text-align: left;
    font-weight: 750;
}

.points-column {
    color: var(--green);
    font-weight: 850;
}

.position {
    display: inline-grid;
    place-items: center;
    width: 31px;
    height: 31px;
    border-radius: 50%;
    background: var(--green-light);
    color: var(--green);
    font-weight: 850;
}

.table-footnote {
    margin: 0;
    padding: 16px 20px;
    color: var(--muted);
    font-size: .78rem;
}

.empty-state {
    padding: 70px 24px;
    border: 1px dashed #cbd2ca;
    border-radius: var(--radius);
    text-align: center;
}

.empty-state h2 {
    margin: 8px 0;
    font-family: Georgia, serif;
    font-weight: 500;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

.empty-icon {
    color: var(--green);
    font-size: 2.5rem;
}

.admin-page {
    padding-top: 28px;
}

.admin-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 44px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--line);
}

.admin-tabs a,
.admin-tabs .link-button {
    display: inline-flex;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 700;
    padding: 9px 12px;
    text-decoration: none;
}

.admin-tabs a:hover,
.admin-tabs .link-button:hover {
    background: white;
    color: var(--green);
}

.admin-tabs form {
    margin-left: auto;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 22px;
    align-items: start;
}

.form-card,
.lifecycle-card,
.result-card {
    padding: 26px;
}

.card-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 24px;
}

.card-heading h2,
.lifecycle-card h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 1.55rem;
    font-weight: 500;
}

.card-heading p {
    margin: 0;
    color: var(--muted);
    font-size: .85rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.full-span {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 7px;
    color: #3e4b44;
    font-size: .84rem;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cdd4cd;
    border-radius: 10px;
    outline: 0;
    background: white;
    color: var(--ink);
    padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(21, 95, 70, .12);
}

input:disabled,
select:disabled,
textarea:disabled {
    background: #eef0eb;
    color: #79837d;
}

.field-hint {
    color: var(--muted);
    font-size: .73rem;
    font-weight: 450;
}

.field-error,
.result-errors {
    color: var(--red);
    font-size: .75rem;
    font-weight: 650;
}

.field-error:empty {
    display: none;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 43px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
    padding: 10px 17px;
    text-decoration: none;
}

.button-primary {
    background: var(--green);
    color: white;
}

.button-primary:hover {
    background: #0e4c37;
}

.button-secondary {
    border-color: #b9d1c2;
    background: var(--green-light);
    color: var(--green);
}

.button-ghost {
    border-color: var(--line);
    background: white;
    color: var(--ink);
}

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

.button-full {
    width: 100%;
}

.button-small {
    min-height: 38px;
    padding: 7px 12px;
    font-size: .8rem;
}

.lifecycle-card form,
.lifecycle-card > .button {
    margin-top: 11px;
}

.schedule-form {
    display: grid;
    gap: 11px;
}

.lifecycle {
    margin: 22px 0 28px;
    padding: 0;
    list-style: none;
    counter-reset: stage;
}

.lifecycle li {
    position: relative;
    min-height: 39px;
    margin-left: 15px;
    border-left: 2px solid var(--line);
    color: var(--muted);
    padding: 2px 0 16px 25px;
    counter-increment: stage;
}

.lifecycle li::before {
    position: absolute;
    left: -13px;
    top: -3px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: white;
    content: counter(stage);
    font-size: .7rem;
    font-weight: 800;
}

.lifecycle li.current {
    color: var(--green);
    font-weight: 850;
}

.lifecycle li.current::before {
    border-color: var(--green);
    background: var(--green);
    color: white;
}

.seed {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: .74rem;
    overflow-wrap: anywhere;
}

.alert {
    margin: 0 0 20px;
    border: 1px solid;
    border-radius: 11px;
    padding: 12px 15px;
    font-size: .88rem;
    font-weight: 650;
}

.alert p {
    margin: 0;
}

.alert-success {
    border-color: #acd0ba;
    background: #e4f4e9;
    color: #14553d;
}

.alert-error {
    border-color: #e0aaa5;
    background: #fae7e5;
    color: #8d3029;
}

.locked-message {
    margin: 0;
    border-radius: 10px;
    background: #eef0eb;
    color: var(--muted);
    padding: 13px;
    font-size: .82rem;
}

.inline-add-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: end;
}

.player-list {
    margin-top: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: white;
}

.player-row {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 14px;
    align-items: center;
    min-height: 66px;
    padding: 10px 18px;
    border-top: 1px solid var(--line);
}

.player-row:first-child {
    border-top: 0;
}

.player-order {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border-radius: 50%;
    background: #eef2eb;
    color: var(--green);
    font-size: .8rem;
    font-weight: 850;
}

.player-edit-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.icon-button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--red);
    cursor: pointer;
    font-size: 1.45rem;
}

.icon-button:hover {
    background: #fae7e5;
}

.small-empty {
    border: 0;
    padding: 45px 20px;
}

.result-card {
    max-width: 760px;
}

.match-selector {
    margin-bottom: 28px;
}

.result-form {
    display: grid;
    gap: 24px;
}

.set-grid {
    display: grid;
    grid-template-columns: minmax(90px, 1.2fr) repeat(3, minmax(65px, 1fr));
    gap: 10px;
    align-items: center;
}

.set-grid > strong {
    font-size: .82rem;
    text-align: center;
}

.set-grid > strong:nth-of-type(4),
.set-grid > strong:nth-of-type(5) {
    text-align: left;
}

.set-grid input {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 800;
}

.result-errors p {
    margin: 4px 0;
}

.clear-result-form {
    margin-top: 15px;
}

.link-button {
    border: 0;
    background: none;
    cursor: pointer;
    text-decoration: underline;
}

.danger-link {
    color: var(--red);
}

.login-shell {
    width: min(440px, calc(100% - 32px));
    margin: 0 auto;
    padding: 80px 0;
}

.login-card {
    border: 1px solid var(--line);
    border-radius: 22px;
    background: white;
    box-shadow: var(--shadow);
    padding: 34px;
}

.login-card h1 {
    margin: 5px 0 9px;
    font-family: Georgia, serif;
    font-size: 2.5rem;
    font-weight: 500;
}

.login-card > p:not(.eyebrow) {
    margin: 0 0 26px;
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 18px;
}

@media (max-width: 820px) {
    .nav-shell {
        flex-wrap: wrap;
        padding: 12px 0;
        gap: 12px;
    }

    .brand {
        margin-right: 0;
    }

    .nav-shell nav {
        order: 3;
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .status-pill {
        margin-left: auto;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .lifecycle-card {
        grid-row: 1;
    }

    .match-row {
        grid-template-columns: 35px 1fr;
        gap: 8px;
        padding: 16px;
    }

    .team-one,
    .team-two {
        grid-column: 2;
        min-width: 0;
        width: 100%;
        text-align: left;
    }

    .score {
        grid-column: 2;
        padding: 3px 0;
        text-align: left;
    }

    .match-notes {
        grid-column: 2;
        text-align: left;
    }
}

@media (max-width: 580px) {
    .page-shell {
        width: min(100% - 20px, 1120px);
        padding-top: 36px;
    }

    .page-heading {
        display: block;
    }

    .large-status {
        display: inline-block;
        margin-top: 15px;
    }

    .settings-grid,
    .inline-add-form {
        grid-template-columns: 1fr;
    }

    .admin-tabs {
        overflow-x: auto;
    }

    .round-header,
    .round-header > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .round-header > span {
        display: none;
    }

    .form-card,
    .lifecycle-card,
    .result-card {
        padding: 19px;
    }

    .set-grid {
        grid-template-columns: 78px repeat(3, 1fr);
        gap: 7px;
    }
}
