:root {
    --ink: #27284f;
    --ink-soft: #4b4a78;
    --lime: #b6df2d;
    --lime-dark: #8eb51e;
    --paper: #f7f8fb;
    --line: #e2e5ef;
    --white: #ffffff;
    --danger: #b42318;
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }

main {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px max(16px, calc((100vw - 1120px) / 2));
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

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

.topbar nav {
    display: flex;
    gap: 8px;
}

.topbar nav a,
.btn {
    border: 0;
    border-radius: 8px;
    background: var(--ink);
    color: var(--white);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    font: inherit;
    font-weight: 700;
}

.topbar nav a.is-active,
.btn:hover {
    background: var(--lime);
    color: var(--ink);
}

.btn-secondary {
    background: #eef1f7;
    border: 1px solid var(--line);
    color: var(--ink-soft);
}

.btn-secondary:hover {
    background: #e5e9f2;
    color: var(--ink);
}

.ui-icon {
    flex: 0 0 auto;
    height: 18px;
    width: 18px;
}

.btn .ui-icon,
.topbar nav a .ui-icon,
.page-btn .ui-icon,
.link-danger .ui-icon {
    margin-right: 8px;
}

.page-btn .ui-icon:last-child {
    margin-left: 8px;
    margin-right: 0;
}

.admin-head .btn-secondary {
    min-height: 36px;
    padding: 0 16px;
}

.admin-actions {
    align-items: end;
    display: flex;
    gap: 10px;
}

.hero,
.admin-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 24px;
    padding: 34px 0 18px;
}

h1,
h2,
p { margin: 0; }

h1 { font-size: clamp(34px, 7vw, 72px); line-height: .95; letter-spacing: 0; }

.eyebrow {
    color: var(--lime-dark);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.sync {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    min-width: 170px;
}

.sync span,
.section-head span {
    display: block;
    color: var(--ink-soft);
    font-size: 13px;
}

.leaderboard {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.rank-row {
    display: grid;
    grid-template-columns: 44px 12px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    background: var(--white);
    border: 1px solid var(--line);
    border-left: 5px solid var(--lime);
    border-radius: 8px;
    padding: 16px;
}

.rank-number {
    font-size: 24px;
    font-weight: 900;
    color: var(--ink-soft);
}

.team-dot {
    width: 12px;
    height: 48px;
    border-radius: 8px;
}

.rank-main h2 { font-size: 22px; }
.rank-main p { color: var(--ink-soft); margin-top: 4px; }

.score {
    font-size: 42px;
    font-weight: 950;
    color: var(--lime-dark);
}

.panel,
.empty {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin-top: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.recent-panel {
    background:
        linear-gradient(135deg, rgba(182, 223, 45, .16), transparent 34%),
        linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
    overflow: hidden;
    padding: 0;
}

.matches-showcase-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: end;
    border-bottom: 1px solid var(--line);
    padding: 22px 22px 18px;
}

.matches-showcase-head h2 {
    font-size: 30px;
    line-height: 1;
}

.match-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(86px, 1fr));
    gap: 8px;
}

.match-stats div {
    background: rgba(255, 255, 255, .78);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 86px;
    padding: 10px 12px;
}

.match-stats span {
    color: var(--ink-soft);
    display: block;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.match-stats strong {
    display: block;
    font-size: 24px;
    line-height: 1;
    margin-top: 4px;
}

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

.matches-table {
    padding: 0 18px 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--ink-soft);
    font-size: 12px;
    text-transform: uppercase;
}

.matches-table table {
    border-collapse: separate;
    border-spacing: 0 8px;
    min-width: 820px;
}

.matches-table th {
    border: 0;
    padding: 12px 10px 4px;
}

.matches-table td {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
    padding: 12px 10px;
}

.matches-table td:first-child {
    border-left: 1px solid var(--line);
    border-radius: 8px 0 0 8px;
    width: 190px;
}

.matches-table td:last-child {
    border-right: 1px solid var(--line);
    border-radius: 0 8px 8px 0;
    width: 170px;
}

.matches-table tbody tr {
    transition: transform .16s ease, box-shadow .16s ease;
}

.matches-table tbody tr:hover {
    transform: translateY(-1px);
}

.matches-table tbody tr:hover td {
    box-shadow: 0 14px 28px rgba(39, 40, 79, .08);
}

.match-time {
    align-items: center;
    background: #f2f5fb;
    border-radius: 8px;
    display: inline-flex;
    gap: 8px;
    min-width: 112px;
    padding: 6px 9px;
}

.match-time span {
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 850;
}

.match-time strong {
    font-size: 15px;
}

.draw-mark {
    align-items: center;
    background: var(--lime);
    border-radius: 999px;
    color: var(--ink);
    display: inline-flex;
    font-size: 11px;
    font-weight: 950;
    height: 26px;
    justify-content: center;
    margin-right: 10px;
    width: 26px;
}

.matches-table td[data-label="Onderdeel"] strong {
    font-size: 16px;
}

.pill {
    border-radius: 999px;
    display: inline-flex;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
    background: #edf0f7;
}

.pill.completed {
    background: var(--lime);
}

.notice {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #eef8cf;
    border: 1px solid #d8eda0;
    font-weight: 700;
}

.notice.error {
    background: #fff1f0;
    border-color: #ffccc7;
    color: var(--danger);
}

.inline-status {
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 800;
    min-height: 20px;
    margin: -4px 0 12px;
}

.inline-status:empty {
    display: none;
}

.inline-status.success {
    color: #247a34;
}

.inline-status.error {
    color: var(--danger);
}

.search-field {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 8px;
    margin: -2px 0 10px;
    padding: 0 12px;
    background: var(--white);
}

.search-field:focus-within {
    border-color: var(--lime-dark);
    box-shadow: 0 0 0 3px rgba(182, 223, 45, .22);
}

.search-field input {
    border: 0;
    min-height: 44px;
    padding: 8px 0;
}

.search-field input:focus {
    outline: 0;
}

.search-icon {
    color: var(--ink-soft);
    flex: 0 0 auto;
    height: 18px;
    width: 18px;
}

.empty-search {
    color: var(--ink-soft);
    font-weight: 800;
    padding: 14px 0 0;
}

.pagination {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 14px;
}

.pagination[hidden],
.players-table tr[hidden] {
    display: none !important;
}

.page-btn {
    align-items: center;
    background: #eef1f7;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    font: inherit;
    font-weight: 800;
    min-height: 36px;
    padding: 0 12px;
}

.page-btn:disabled {
    cursor: default;
    opacity: .45;
}

.page-info {
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 850;
}

.page-numbers {
    display: flex;
    gap: 6px;
}

.page-number {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 850;
    height: 36px;
    min-width: 36px;
    padding: 0 10px;
}

.page-number[aria-current="page"] {
    background: var(--lime);
    border-color: var(--lime);
}

.team-form,
.team-card,
.team-edit-fields {
    display: grid;
    gap: 10px;
}

.team-form {
    grid-template-columns: minmax(180px, 1fr) 110px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    min-height: 40px;
    padding: 8px 10px;
    background: var(--white);
}

textarea {
    min-height: 84px;
    resize: vertical;
}

.player-picker {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.player-option {
    align-items: center;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
}

.player-option:hover,
.player-option:has(input:checked) {
    background: #f2f5fb;
}

.player-option input {
    accent-color: var(--lime);
    flex: 0 0 auto;
    height: 18px;
    min-height: 18px;
    padding: 0;
    width: 18px;
}

.player-option span {
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.team-form .player-picker,
.team-form textarea,
.team-form button {
    grid-column: 1 / -1;
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.team-card-shell,
.team-card {
    border: 1px solid var(--line);
    border-radius: 8px;
}

.team-card-shell {
    background: #fbfcff;
    overflow: hidden;
}

.team-card {
    border: 0;
    padding: 14px;
}

.team-card-head,
.split-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.team-card-head h3 {
    font-size: 20px;
    line-height: 1.1;
    margin: 0 0 4px;
}

.team-card-head strong {
    color: var(--lime-dark);
}

.team-summary {
    color: var(--ink-soft);
    display: grid;
    gap: 6px;
    line-height: 1.35;
}

.team-summary p {
    color: var(--ink);
    font-weight: 750;
}

.team-summary span {
    font-size: 14px;
}

.team-edit-fields[hidden],
.team-summary[hidden],
.team-edit-toggle[hidden],
.team-save[hidden],
.team-delete[hidden] {
    display: none !important;
}

.team-form[hidden] {
    display: none !important;
}

.runs-table[hidden] {
    display: none !important;
}

#runs-toggle .ui-icon,
#new-team-toggle .ui-icon {
    transition: transform .16s ease;
}

#runs-toggle.is-open .ui-icon,
#new-team-toggle.is-open .ui-icon {
    transform: rotate(90deg);
}

.team-delete {
    padding: 0 14px 14px;
}

.small { min-height: 36px; }
.tiny { min-height: 30px; padding: 0 10px; }
.mini { max-width: 90px; }

.link-danger {
    align-items: center;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    margin-bottom: 10px;
    padding: 0;
}

.players-table tr.is-dirty td {
    background: #fbfff0;
}

.floating-save {
    align-items: center;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    bottom: 18px;
    box-shadow: 0 18px 42px rgba(39, 40, 79, .18);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    left: 50%;
    min-width: min(420px, calc(100% - 32px));
    padding: 10px 12px;
    position: fixed;
    transform: translateX(-50%);
    z-index: 30;
}

.floating-save[hidden] {
    display: none;
}

.floating-save span {
    color: var(--ink-soft);
    font-weight: 850;
}

.floating-save .btn {
    min-height: 38px;
    padding: 0 18px;
}

.floating-save .btn:disabled {
    cursor: wait;
    opacity: .72;
}

@media (max-width: 720px) {
    main { width: min(100% - 20px, 1120px); }

    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        padding: 10px;
    }

    .hero,
    .admin-head {
        align-items: stretch;
        flex-direction: column;
    }

    .hero {
        gap: 12px;
        padding: 18px 0 2px;
    }

    .hero h1 {
        font-size: 42px;
        line-height: 1;
    }

    .hero .eyebrow {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .admin-head .sync {
        align-self: start;
        background: var(--white);
        border: 1px solid var(--line);
        min-width: 0;
        padding: 12px;
        width: 100%;
    }

    .admin-head {
        gap: 14px;
        padding: 22px 0 12px;
    }

    .admin-head h1 {
        font-size: 34px;
        line-height: 1.02;
    }

    .admin-head .eyebrow {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .admin-actions {
        width: 100%;
    }

    .admin-head .sync .btn,
    .admin-head .sync form {
        width: 100%;
    }

    .admin-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .brand {
        gap: 10px;
    }

    .brand img {
        height: 50px;
        width: 50px;
    }

    .brand span { font-size: 14px; }

    .topbar nav {
        width: 100%;
    }

    .topbar nav a {
        flex: 1;
        min-height: 38px;
    }

    .panel,
    .empty {
        margin-top: 12px;
        padding: 14px;
    }

    .leaderboard {
        margin: 8px 0 14px;
    }

    .section-head {
        align-items: baseline;
        margin-bottom: 10px;
    }

    .section-head h2 {
        font-size: 24px;
    }

    .matches-showcase-head {
        gap: 12px;
        grid-template-columns: 1fr;
        padding: 16px 14px 12px;
    }

    .matches-showcase-head h2 {
        font-size: 25px;
    }

    .match-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .match-stats div {
        min-width: 0;
        padding: 8px;
    }

    .match-stats strong {
        font-size: 20px;
    }

    .rank-row {
        grid-template-columns: 34px 8px minmax(0, 1fr) auto;
        gap: 10px;
        padding: 12px;
    }
    .rank-main h2 { font-size: 18px; }
    .rank-main p { font-size: 13px; }
    .score { font-size: 32px; }

    .team-form {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .player-picker {
        max-height: 310px;
        padding: 8px;
    }

    .player-option {
        min-height: 44px;
        padding: 8px 10px;
    }

    .pagination {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .page-info {
        grid-column: 1 / -1;
        order: -1;
        text-align: center;
    }

    .page-numbers {
        grid-column: 1 / -1;
        justify-content: center;
        order: -1;
    }

    .team-form textarea,
    .team-card textarea {
        min-height: 72px;
    }

    .team-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .team-card {
        padding: 12px;
    }

    .team-delete {
        padding: 0 12px 12px;
    }

    .link-danger {
        margin: 0 0 6px;
        min-height: 32px;
    }
}

@media (max-width: 860px) {
    .recent-panel {
        padding: 0;
    }

    .matches-table {
        overflow: visible;
        padding: 12px 14px 14px;
    }

    .matches-table table,
    .matches-table tbody,
    .matches-table tr,
    .matches-table td {
        display: block;
        width: 100%;
    }

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

    .matches-table thead {
        display: none;
    }

    .matches-table tbody {
        display: grid;
        gap: 10px;
    }

    .matches-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fbfcff;
    }

    .matches-table td {
        background: transparent;
        border: 0;
        padding: 0;
    }

    .matches-table td:first-child,
    .matches-table td:last-child {
        border: 0;
        border-radius: 0;
        width: auto;
    }

    .matches-table tbody tr:hover {
        transform: none;
    }

    .matches-table tbody tr:hover td {
        box-shadow: none;
    }

    .matches-table td[data-label="Datum"] {
        color: var(--ink-soft);
        font-size: 13px;
        font-weight: 800;
        grid-column: 1;
        grid-row: 1;
    }

    .matches-table td[data-label="Status"] {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .matches-table td[data-label="Onderdeel"] {
        font-size: 15px;
        font-weight: 850;
        grid-column: 1 / -1;
        line-height: 1.3;
        overflow-wrap: anywhere;
    }

    .matches-table td[data-label="Onderdeel"] strong {
        font-size: 15px;
    }

    .draw-mark {
        height: 22px;
        margin-right: 7px;
        width: 22px;
    }

    .match-time {
        background: transparent;
        min-width: 0;
        padding: 0;
    }

    .matches-table td[data-label="Ronde"] {
        color: var(--ink-soft);
        font-size: 13px;
        grid-column: 1 / -1;
    }

    .matches-table td[data-label="Ronde"]::before {
        content: attr(data-label) ": ";
        font-weight: 800;
    }

    .admin-table {
        overflow: visible;
    }

    .admin-table table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }

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

    .admin-table thead {
        display: none;
    }

    .admin-table tbody {
        display: grid;
        gap: 10px;
    }

    .admin-table tr {
        display: grid;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fbfcff;
    }

    .admin-table td {
        border: 0;
        padding: 0;
    }

    .admin-table td::before {
        content: attr(data-label);
        display: block;
        color: var(--ink-soft);
        font-size: 11px;
        font-weight: 900;
        margin-bottom: 4px;
        text-transform: uppercase;
    }

    .players-table tr {
        gap: 10px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
        padding: 10px;
    }

    .players-table td[data-label="Speler"] {
        grid-column: 1 / -1;
        font-weight: 800;
    }

    .players-table td[data-label="Speler"]::before {
        content: none;
    }

    .players-table .mini {
        max-width: none;
    }

    .floating-save {
        bottom: 10px;
        left: 10px;
        min-width: 0;
        right: 10px;
        transform: none;
    }

    .runs-table tr {
        grid-template-columns: 1fr 1fr;
    }

    .runs-table td[data-label="Melding"] {
        grid-column: 1 / -1;
        overflow-wrap: anywhere;
    }
}
