:root {
    color-scheme: light;
    --bg: #eef1ed;
    --felt: #0f6b4f;
    --felt-dark: #084333;
    --rail: #5d351e;
    --rail-dark: #2d1a12;
    --panel: #ffffff;
    --panel-soft: #f8faf7;
    --ink: #111d1b;
    --muted: #63706c;
    --line: #d8dfda;
    --gold: #d8a63a;
    --red: #b73532;
    --blue: #246eb9;
    --accent: #147a5b;
    --accent-strong: #07523d;
    --warn-bg: #fff4d8;
    --warn-ink: #704800;
    --shadow: 0 18px 45px rgba(17, 29, 27, .11);
    --control-height: 42px;
    --control-radius: 6px;
    --control-padding: 10px 14px;
    --button-width: 132px;
    --button-width-small: 116px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 18% 5%, rgba(216, 166, 58, .16), transparent 28%),
        linear-gradient(180deg, #f7f5ef 0, var(--bg) 360px);
    color: var(--ink);
    font-family: Inter, Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.35;
    overflow-x: hidden;
}

a {
    color: var(--accent-strong);
    font-weight: 800;
    text-decoration: none;
}

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

.topbar {
    align-items: center;
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
    background: rgba(255, 255, 255, .78);
    border-bottom: 1px solid rgba(216, 223, 218, .8);
    box-shadow: 0 10px 30px rgba(17, 29, 27, .06);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 14px clamp(16px, 4vw, 48px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    align-items: center;
    color: var(--ink);
    display: flex;
    gap: 10px;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.05;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.brand-mark,
.mini-ball {
    align-items: center;
    background: radial-gradient(circle at 32% 28%, #ffffff 0 9%, #151515 10% 100%);
    border-radius: 50%;
    color: white;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 900;
    height: 34px;
    justify-content: center;
    width: 34px;
}

nav a {
    align-items: center;
    background: #edf5f1;
    border: 1px solid #d6e7df;
    border-radius: var(--control-radius);
    display: inline-flex;
    justify-content: center;
    min-height: var(--control-height);
    min-width: 98px;
    padding: var(--control-padding);
    text-align: center;
    transition: filter .15s ease;
}

nav a.nav-active {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: white;
}

nav a.nav-active:hover {
    color: white;
    filter: brightness(.9);
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    min-width: 0;
}

.logout-form {
    margin: 0;
}

.logout-form button {
    min-height: var(--control-height);
    padding: var(--control-padding);
    white-space: nowrap;
    width: var(--button-width-small);
}

.page {
    display: grid;
    gap: 24px;
    margin: 0 auto;
    max-width: 1220px;
    min-width: 0;
    padding: 30px clamp(16px, 4vw, 48px) 64px;
    width: 100%;
}

.page > *,
.panel,
.topbar > * {
    min-width: 0;
}

.site-footer {
    color: #8b9692;
    font-size: 13px;
    font-weight: 800;
    margin: 0 auto;
    max-width: 1220px;
    padding: 0 clamp(16px, 4vw, 48px) 28px;
    text-align: center;
}

.page > section {
    margin: 0;
}

.hero,
.title-row {
    align-items: stretch;
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 440px);
}

.hero > div:first-child,
.tournament-hero > div:first-child {
    align-content: center;
    background:
        linear-gradient(135deg, rgba(15, 107, 79, .96), rgba(8, 67, 51, .96)),
        var(--felt);
    border: 10px solid var(--rail);
    border-radius: 16px;
    box-shadow: var(--shadow);
    color: white;
    display: grid;
    min-height: 260px;
    padding: clamp(24px, 5vw, 54px);
    position: relative;
    overflow: hidden;
}

.hero > div:first-child::before,
.tournament-hero > div:first-child::before {
    background: linear-gradient(100deg, transparent 0 52%, rgba(255, 255, 255, .18) 53% 54%, transparent 55%);
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.hero h1,
.title-row h1 {
    font-size: clamp(38px, 6vw, 72px);
    line-height: .95;
    margin: 6px 0 0;
    max-width: 780px;
    position: relative;
}

.lede {
    color: var(--muted);
    font-size: clamp(16px, 2vw, 20px);
    line-height: 1.45;
    margin: 14px 0 0;
    max-width: 610px;
    position: relative;
}

.hero > div:first-child .lede,
.tournament-hero > div:first-child .lede {
    color: rgba(255, 255, 255, .84);
}

.eyebrow {
    color: var(--gold);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .12em;
    margin: 0;
    position: relative;
    text-transform: uppercase;
}

.pool-table {
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .08), transparent 42%),
        linear-gradient(135deg, #13805f, #084333);
    border: 14px solid var(--rail);
    border-radius: 28px;
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .12), var(--shadow);
    min-height: 260px;
    overflow: hidden;
    position: relative;
}

.pocket {
    background: #101412;
    border-radius: 50%;
    height: 42px;
    position: absolute;
    width: 42px;
    z-index: 2;
}

.top-left { left: -11px; top: -11px; }
.top-right { right: -11px; top: -11px; }
.bottom-left { bottom: -11px; left: -11px; }
.bottom-right { bottom: -11px; right: -11px; }

.cue {
    background: linear-gradient(90deg, #f4d28a, #8b5b2c 54%, #f6dfaa);
    border-radius: 999px;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .22);
    height: 9px;
    left: 12%;
    position: absolute;
    top: 58%;
    transform: rotate(-23deg);
    transform-origin: left center;
    width: 76%;
}

.ball {
    align-items: center;
    border-radius: 50%;
    box-shadow: inset -8px -10px 16px rgba(0, 0, 0, .22), 0 9px 20px rgba(0, 0, 0, .2);
    color: white;
    display: flex;
    font-weight: 900;
    height: 52px;
    justify-content: center;
    position: absolute;
    width: 52px;
}

.ball::before {
    background: rgba(255, 255, 255, .82);
    border-radius: 50%;
    content: "";
    height: 16px;
    left: 11px;
    position: absolute;
    top: 9px;
    width: 16px;
}

.ball-one {
    background: var(--gold);
    right: 28%;
    top: 28%;
}

.ball-eight {
    background: #151515;
    right: 17%;
    top: 47%;
}

.ball-nine {
    background: var(--blue);
    right: 32%;
    top: 61%;
}

.grid {
    display: grid;
    gap: 18px;
}

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

.groups {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.admin-title .eyebrow {
    color: var(--accent-strong);
}

.panel {
    background: linear-gradient(180deg, #ffffff, var(--panel-soft));
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(17, 29, 27, .07);
    padding: clamp(16px, 2.5vw, 22px);
}

.login-shell {
    align-items: center;
    display: grid;
    min-height: calc(100vh - 210px);
}

.login-panel {
    border-top: 6px solid var(--accent);
    justify-self: center;
    max-width: 440px;
    width: min(100%, 440px);
}

.login-panel h1 {
    font-size: clamp(32px, 7vw, 48px);
    line-height: 1;
    margin: 4px 0 0;
}

.login-panel .brand-mark {
    height: 44px;
    width: 44px;
}

.management-panel {
    overflow-x: auto;
}

.feature-panel {
    border-top: 4px solid var(--accent);
}

.tournament-panel {
    border-left: 7px solid var(--gold);
}

.panel-heading {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel h2,
.panel h3,
.panel-heading h2 {
    color: var(--ink);
    line-height: 1.15;
    margin: 0;
}

.panel > table + h3 {
    margin-top: 18px;
}

.stack {
    display: grid;
    gap: 14px;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    font-weight: 800;
    gap: 6px;
}

label small {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
}

input,
select,
button {
    border: 1px solid var(--line);
    border-radius: var(--control-radius);
    font: inherit;
    min-height: var(--control-height);
    padding: var(--control-padding);
    width: 100%;
}

input,
select {
    background: white;
    color: var(--ink);
}

input[type="checkbox"] {
    appearance: none;
    background: white;
    border: 2px solid #bfd9cf;
    border-radius: 5px;
    display: inline-grid;
    flex: 0 0 auto;
    height: 18px;
    min-height: 18px;
    padding: 0;
    place-content: center;
    width: 18px;
}

input[type="checkbox"]::after {
    border: solid white;
    border-width: 0 2px 2px 0;
    content: "";
    height: 8px;
    opacity: 0;
    transform: rotate(45deg) translate(-1px, -1px);
    width: 4px;
}

input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

input[type="checkbox"]:checked::after {
    opacity: 1;
}

input[type="checkbox"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(20, 122, 91, .14);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(20, 122, 91, .14);
    outline: none;
}

button {
    align-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: var(--accent-strong);
    box-shadow: 0 8px 18px rgba(20, 122, 91, .22);
    color: white;
    cursor: pointer;
    display: inline-flex;
    font-weight: 900;
    justify-content: center;
    line-height: 1.15;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: normal;
    text-align: center;
    transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
    white-space: normal;
    word-break: normal;
}

button[data-fit-text] {
    padding-inline: 8px;
}

button:hover {
    filter: brightness(.95);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    cursor: progress;
    filter: grayscale(.2) opacity(.72);
}

.async-message {
    background: var(--accent-strong);
    border-radius: 999px;
    bottom: 22px;
    box-shadow: 0 16px 40px rgba(17, 29, 27, .22);
    color: white;
    font-weight: 900;
    left: 50%;
    max-width: min(520px, calc(100vw - 28px));
    padding: 12px 16px;
    position: fixed;
    text-align: center;
    transform: translateX(-50%);
    z-index: 50;
}

.async-message-error {
    background: var(--red);
}

.secondary-button {
    background: #edf5f1;
    border-color: #cde2d9;
    box-shadow: none;
    color: var(--accent-strong);
}

.secondary-button:hover {
    color: var(--accent-strong);
}

.danger-button {
    background: linear-gradient(135deg, var(--red), #7f1e1b);
    border-color: #7f1e1b;
    box-shadow: 0 8px 18px rgba(183, 53, 50, .18);
    color: white;
}

.inline-form {
    margin: 0;
}

.inline-form button {
    min-height: var(--control-height);
    padding: var(--control-padding);
}

.table-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    min-width: calc(var(--button-width-small) * 2 + 8px);
}

.table-actions .inline-form {
    flex: 0 0 var(--button-width-small);
}

.action-button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    box-sizing: border-box;
    display: inline-flex;
    font-size: 14px;
    font-weight: 900;
    justify-content: center;
    line-height: 1.15;
    min-height: var(--control-height);
    min-width: 0;
    padding: var(--control-padding);
    text-decoration: none;
    white-space: nowrap;
    width: var(--button-width-small);
}

.open-action {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: var(--accent-strong);
    box-shadow: 0 8px 18px rgba(20, 122, 91, .18);
    color: white;
}

.table-actions .inline-form button {
    min-height: var(--control-height);
    padding: var(--control-padding);
    white-space: nowrap;
    width: var(--button-width-small);
}

fieldset {
    background: #fbfcfa;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 0;
    padding: 14px;
}

legend {
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 900;
}

.checks {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.checks label {
    align-items: center;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: grid;
    gap: 8px;
    grid-template-columns: 18px minmax(0, 1fr);
    line-height: 1.25;
    min-height: 46px;
    padding: 10px 12px;
}

.checks input {
    justify-self: start;
}

.checks label:hover {
    border-color: #bfd9cf;
    background: #f7fbf8;
}

.settings-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
}

.settings-grid label {
    align-content: start;
}

.tournament-estimate {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 6px;
    padding: 14px 16px;
}

.tournament-estimate .eyebrow {
    margin: 0;
}

.estimate-body {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.estimate-time {
    color: var(--accent-strong);
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
}

.estimate-detail {
    font-size: 13px;
}

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

.admin-password-note {
    background: #fff7e2;
    border-left: 7px solid var(--gold);
}

.admin-password-note p {
    margin: 0;
}

.admin-password-note strong {
    color: var(--warn-ink);
}

.admin-danger-panel {
    align-items: center;
    border-left: 7px solid var(--red);
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
}

.admin-danger-panel h2,
.admin-danger-panel p {
    margin: 0;
}

.admin-danger-panel .eyebrow {
    color: var(--red);
    margin-bottom: 6px;
}

.toggle-row {
    align-items: center;
    background: #fbfcfa;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: flex;
    gap: 10px;
    justify-content: space-between;
    min-height: 48px;
    padding: 10px 12px;
}

.toggle-row button {
    flex: 0 0 auto;
    width: var(--button-width-small);
}

.toggle-row label {
    align-items: center;
    color: var(--ink);
    display: grid;
    flex: 1 1 auto;
    gap: 10px;
    grid-template-columns: 18px minmax(0, 1fr);
}

.toggle-row input {
    justify-self: start;
}

.exclusion-panel {
    display: block;
}

.exclusion-toggle-card {
    align-items: center;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    margin-top: 8px;
    min-height: 58px;
    padding: 12px;
}

.exclusion-toggle-card label {
    align-items: center;
    color: var(--ink);
    display: grid;
    flex: 1 1 auto;
    gap: 10px;
    grid-template-columns: 18px minmax(0, 1fr);
    min-width: 0;
}

.exclusion-toggle-card input {
    justify-self: start;
}

.exclusion-toggle-card small {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-top: 2px;
}

.exclusion-actions {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.exclusion-count {
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.exclusion-edit-btn {
    min-width: 130px;
    width: auto;
}

.modal-overlay {
    align-items: center;
    background: rgba(17, 29, 27, .45);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: clamp(14px, 4vw, 32px);
    position: fixed;
    z-index: 30;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-panel {
    background: linear-gradient(180deg, #ffffff, var(--panel-soft));
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(17, 29, 27, .28);
    display: grid;
    gap: 14px;
    max-height: min(760px, 88vh);
    max-width: 860px;
    overflow-y: auto;
    padding: 18px;
    width: 100%;
}

.modal-panel > .panel-heading {
    background: linear-gradient(180deg, #ffffff, var(--panel-soft));
    margin: -18px -18px 0;
    padding: 18px 18px 12px;
    position: sticky;
    top: -18px;
    z-index: 2;
}

.modal-panel > .panel-heading .secondary-button {
    width: var(--button-width);
}

.confirm-modal-panel {
    max-width: 460px;
}

.confirm-modal-panel .panel-heading {
    margin-bottom: 0;
}

.confirm-modal-error {
    color: var(--red);
    font-weight: 900;
    margin: -4px 0 0;
}

.confirm-modal-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.confirm-modal-actions button {
    width: 100%;
}

.exclusion-tools {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr);
}

.player-exclusion-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.player-exclusion {
    align-items: center;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 10px;
    min-height: 52px;
    padding: 10px;
    width: 100%;
}

.player-exclusion:hover {
    border-color: #bfd9cf;
    background: #f7fbf8;
}

.player-exclusion small {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-top: 2px;
}

.player-exclusion input {
    accent-color: var(--red);
    flex: 0 0 auto;
    min-height: auto;
    width: auto;
}

.info-grid,
.example-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.info-panel {
    display: grid;
    gap: 14px;
}

.info-panel p {
    color: var(--muted);
    line-height: 1.55;
    margin: 0;
}

.setting-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.setting-list dt {
    color: var(--accent-strong);
    font-weight: 900;
    margin: 0;
}

.setting-list dd {
    color: var(--muted);
    line-height: 1.5;
    margin: 4px 0 0;
}

.example-grid {
    margin-bottom: 0;
}

.example-grid > div {
    background: white;
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: 8px;
    padding: 14px;
}

.example-grid h3 {
    margin: 0;
}

.ruleset-guide {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.ruleset-guide article {
    background: white;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 16px;
}

.ruleset-guide h3 {
    margin: 0;
}

.ruleset-guide p,
.ruleset-guide ul {
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
}

.ruleset-guide ul {
    padding-left: 20px;
}

.ruleset-guide li + li {
    margin-top: 6px;
}

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

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

.compact-table th,
.compact-table td {
    padding: 7px 6px;
}

.compact-table {
    font-size: 13px;
}

.compact-table td + td,
.compact-table th + th {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.qualifier-row {
    background: rgba(20, 122, 91, .05);
}

.qualifier-row td:first-child {
    border-left: 3px solid var(--accent);
    padding-left: 5px;
}

.qualifier-divider td {
    border-bottom: 2px dashed rgba(20, 122, 91, .3);
    padding-bottom: 4px;
}

.stats-summary {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.stat-card {
    display: grid;
    gap: 4px;
    min-height: 108px;
}

.stat-value {
    color: var(--accent-strong);
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 900;
    line-height: 1;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.stats-panel {
    overflow-x: auto;
}

.stats-panel > p {
    margin: 0 0 16px;
}

.stats-filters {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    margin-bottom: 16px;
}

.yearly-filter {
    grid-template-columns: minmax(160px, 240px) minmax(160px, 220px);
}

.stats-table {
    min-width: 980px;
}

.stats-table td:first-child,
.stats-table th:first-child,
.stats-table td:nth-child(2),
.stats-table th:nth-child(2) {
    text-align: left;
}

.ranking-table {
    min-width: 680px;
}

.insight-grid {
    align-items: start;
}

.mini-stats-table {
    min-width: 420px;
}

.mini-stats-table td:first-child,
.mini-stats-table th:first-child {
    text-align: left;
}

.form-strip {
    background: #f4f8f6;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--accent-strong);
    display: inline-flex;
    font-family: Consolas, monospace;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    padding: 5px 8px;
}

.player-search-panel {
    display: grid;
    gap: 14px;
}

.player-search-controls {
    max-width: 520px;
}

.player-search-result {
    display: grid;
    gap: 16px;
}

.player-stat-header {
    align-items: center;
    background: #f7fbf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 14px;
}

.player-stat-header h3,
.player-stat-header p {
    margin: 0;
}

.player-stat-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

.player-stat-grid span {
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 3px;
    min-height: 76px;
    padding: 12px;
}

.player-stat-grid strong {
    color: var(--accent-strong);
    font-size: 21px;
    line-height: 1;
}

.player-stat-grid small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.player-form-line {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.player-h2h-table {
    min-width: 560px;
}

.ranking-table td:first-child,
.ranking-table th:first-child {
    text-align: center;
}

.rank-pill {
    align-items: center;
    background: #fff7e2;
    border: 1px solid #efd58b;
    border-radius: 999px;
    color: #7b570b;
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    height: 28px;
    justify-content: center;
    min-width: 28px;
    padding: 0 8px;
}

.pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-top: 14px;
}

.pagination-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.secondary-link-button,
.page-count {
    align-items: center;
    border-radius: var(--control-radius);
    display: inline-flex;
    font-size: 13px;
    font-weight: 900;
    justify-content: center;
    min-height: var(--control-height);
    min-width: var(--button-width-small);
    padding: var(--control-padding);
    text-align: center;
    white-space: normal;
}

.secondary-link-button {
    background: #edf5f1;
    border: 1px solid #cde2d9;
    color: var(--accent-strong);
}

.secondary-link-button:hover {
    color: var(--accent-strong);
    filter: brightness(.97);
}

.disabled-link {
    color: #9ca7a3;
    cursor: default;
    opacity: .68;
}

.page-count {
    background: white;
    border: 1px solid var(--line);
    color: var(--muted);
    min-width: 128px;
}

.stats-graph-panel {
    background: linear-gradient(145deg, #ffffff 0%, #f6faf7 62%, #fff8e7 100%);
    display: grid;
    gap: 18px;
    overflow: hidden;
}

.graph-controls {
    display: grid;
    gap: 14px;
}

.segmented-control {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.graph-toggle {
    background: #edf5f1;
    border-color: #cde2d9;
    box-shadow: none;
    color: var(--accent-strong);
    flex: 0 0 var(--button-width);
    font-size: 13px;
    min-height: var(--control-height);
    padding: var(--control-padding);
    width: var(--button-width);
}

.graph-toggle.selected-toggle {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border-color: var(--accent-strong);
    box-shadow: 0 8px 18px rgba(20, 122, 91, .18);
    color: white;
}

.story-control {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.story-toggle {
    align-items: flex-start;
    background: rgba(255, 255, 255, .88);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(17, 29, 27, .06);
    color: var(--ink);
    display: grid;
    gap: 4px;
    justify-items: start;
    min-height: 82px;
    padding: 13px;
    text-align: left;
    width: 100%;
    white-space: normal;
}

.story-toggle strong {
    font-size: 15px;
    line-height: 1.15;
}

.story-toggle span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
}

.story-toggle.selected-toggle {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    box-shadow: 0 16px 30px rgba(20, 122, 91, .2);
    color: white;
}

.story-toggle.selected-toggle span {
    color: rgba(255, 255, 255, .78);
}

.performance-stage {
    display: grid;
    gap: 16px;
}

.performance-copy {
    align-items: end;
    display: grid;
    gap: 4px;
}

.performance-copy h3 {
    font-size: clamp(20px, 2.5vw, 28px);
    line-height: 1.05;
    margin: 0;
}

.performance-copy p {
    margin: 0;
}

.performance-spotlight {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.spotlight-card {
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(17, 29, 27, .07);
    display: grid;
    gap: 4px;
    min-height: 112px;
    padding: 14px;
}

.spotlight-rank {
    color: var(--gold);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.spotlight-card strong {
    font-size: 18px;
    line-height: 1.15;
}

.spotlight-card small {
    color: var(--muted);
    font-weight: 800;
    text-transform: uppercase;
}

.spotlight-card b {
    color: var(--accent-strong);
    font-size: 28px;
    line-height: 1;
}

.chart-container {
    min-height: 260px; /* Ensure charts have space */
}

.bar-chart {
    display: grid;
    gap: 10px;
}

.leaderboard-chart {
    background: rgba(255, 255, 255, .78);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.bar-row {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(140px, 220px) minmax(120px, 1fr) minmax(48px, auto);
}

.bar-label {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.bar-label strong,
.bar-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.bar-track {
    background: #e8efeb;
    border-radius: 999px;
    height: 20px;
    overflow: hidden;
}

.bar-fill {
    background: linear-gradient(90deg, var(--accent), var(--gold));
    border-radius: inherit;
    display: block;
    height: 100%;
}

.bar-value {
    color: var(--accent-strong);
    font-weight: 900;
    text-align: right;
}

.line-chart {
    background: rgba(255, 255, 255, .8);
    border: 1px solid var(--line);
    border-radius: 8px;
    gap: 12px;
    padding: 16px;
}

.timeline-svg {
    display: block;
    min-height: 260px;
    width: 100%;
}

.timeline-grid-line {
    stroke: #dfe9e4;
    stroke-width: 1;
}

.timeline-axis-label {
    fill: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.timeline-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 4;
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.timeline-legend span {
    align-items: center;
    color: var(--ink);
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    gap: 7px;
}

.timeline-legend i {
    border-radius: 999px;
    display: inline-block;
    height: 10px;
    width: 10px;
}

.qualifier-legend {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    margin: 4px 0 0;
}

.table-section-header td {
    background: var(--panel-soft);
    border-top: 2px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    padding: 8px 10px 6px;
    text-transform: uppercase;
}

td {
    overflow-wrap: anywhere;
}

td:last-child,
th:last-child {
    text-align: right;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

tbody tr:hover {
    background: rgba(20, 122, 91, .055);
}

.muted {
    color: var(--muted);
}

.alert {
    background: var(--warn-bg);
    border: 1px solid #efca7d;
    border-radius: 8px;
    color: var(--warn-ink);
    padding: 12px 14px;
}

.form-alert[hidden] {
    display: none;
}

.rule-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.rule-strip span {
    background: white;
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(17, 29, 27, .05);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    padding: 8px 11px;
}

.rule-strip strong {
    color: var(--accent-strong);
}

.selected-rules-panel {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.selected-rules-panel h2 {
    margin: 0;
}

.playoff-in-progress-panel {
    align-items: center;
    border-left: 7px solid var(--accent);
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.playoff-in-progress-panel .eyebrow {
    margin-bottom: 6px;
}

.playoff-in-progress-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
}

.playoff-in-progress-detail span {
    background: #e5f2ed;
    border: 1px solid #cbe4d9;
    border-radius: 999px;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 700;
    padding: 5px 10px;
}

.playoff-in-progress-panel .secondary-button {
    white-space: nowrap;
    width: auto;
}

.group-balance-warning {
    align-items: center;
    border-left: 7px solid var(--red);
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.group-balance-warning h2,
.group-balance-warning p {
    margin: 0;
}

.group-balance-warning .eyebrow {
    color: var(--red);
    margin-bottom: 6px;
}

.group-balance-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.group-balance-list span {
    background: #fff7e2;
    border: 1px solid #efd58b;
    border-radius: 999px;
    color: #7b570b;
    font-size: 12px;
    font-weight: 900;
    padding: 7px 10px;
}

.group-balance-warning form {
    margin: 0;
}

.group-balance-warning button {
    width: auto;
}

.table-plan-panel {
    display: grid;
    gap: 18px;
    overflow: hidden;
}

.table-plan-panel > .panel-heading {
    align-items: end;
}

.table-plan-panel > p {
    margin: -6px 0 0;
}

.table-count-form {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-count-form label {
    min-width: 112px;
}

.table-count-form input,
.table-count-form select,
.table-count-form button {
    min-height: var(--control-height);
}

.table-count-form input,
.table-count-form select {
    width: 112px;
}

.table-count-form button {
    width: var(--button-width-small);
}

.reorganise-table-form {
    margin: 0;
}

.reorganise-table-form button {
    min-height: var(--control-height);
    width: var(--button-width);
}

.table-plan-toggle {
    min-height: var(--control-height);
    width: var(--button-width);
}

.table-plan-body {
    display: grid;
    gap: 18px;
}

.table-plan-body > p {
    margin: -6px 0 0;
}

.table-plan-limit-note {
    background: #f7fbf8;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.table-plan-collapsed {
    gap: 0;
}

.table-plan-summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.prize-panel {
    display: grid;
    gap: 14px;
}

.prize-summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.prize-summary > div {
    background: #f7fbf8;
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    padding: 12px 14px;
}

.prize-summary strong {
    color: var(--accent-strong);
    font-size: 22px;
}

.prize-summary span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.prize-summary em {
    color: var(--ink);
    font-style: normal;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.table-plan-summary > div {
    background:
        linear-gradient(180deg, #ffffff, #f7fbf8);
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: 8px;
    display: grid;
    gap: 4px;
    min-height: 88px;
    padding: 14px;
}

.table-plan-summary strong {
    color: var(--accent-strong);
    font-size: 34px;
    line-height: 1;
}

.table-plan-summary span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.table-plan-section {
    background: linear-gradient(180deg, #ffffff, #fbfcfa);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    padding: 14px;
}

.table-plan-section-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.table-plan-section-heading h3 {
    color: var(--accent-strong);
    font-size: 18px;
    margin: 0;
}

.table-plan-section-heading span {
    background: #fff7e2;
    border: 1px solid #efd58b;
    border-radius: 999px;
    color: #7b570b;
    font-size: 12px;
    font-weight: 900;
    padding: 5px 9px;
}

.table-plan-timeline {
    display: grid;
    gap: 12px;
}

.table-plan-slot-card {
    align-items: stretch;
    display: grid;
    gap: 12px;
    grid-template-columns: 96px minmax(0, 1fr);
}

.table-plan-slot-marker {
    align-content: center;
    background:
        radial-gradient(circle at 50% 18%, rgba(255, 255, 255, .18), transparent 35%),
        linear-gradient(180deg, var(--accent), var(--accent-strong));
    border-radius: 8px;
    color: white;
    display: grid;
    justify-items: center;
    min-height: 120px;
    padding: 12px;
    text-align: center;
}

.table-plan-slot-marker span,
.table-plan-slot-marker small {
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.table-plan-slot-marker strong {
    font-size: 42px;
    line-height: .95;
}

.table-plan-slot-marker small {
    color: rgba(255, 255, 255, .76);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.table-plan-tables {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(var(--table-count), minmax(190px, 1fr));
    overflow-x: auto;
}

.table-card {
    background: white;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(17, 29, 27, .06);
    display: grid;
    gap: 10px;
    min-height: 138px;
    min-width: 190px;
    padding: 12px;
}

.table-card-complete {
    border-left-color: var(--gold);
}

.table-card-in-play {
    border-left-color: var(--gold);
    box-shadow: 0 10px 24px rgba(216, 166, 58, .18);
}

.table-card-free {
    background: repeating-linear-gradient(135deg, #f7faf8, #f7faf8 10px, #eef4f1 10px, #eef4f1 20px);
    border-left-color: #a8b6b1;
    color: var(--muted);
}

.table-card-topline {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.table-card-topline span {
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.table-card-topline small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.table-card-matchup {
    align-items: center;
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.table-card-matchup strong {
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.table-card-matchup span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.table-card p,
.table-card-empty p {
    color: var(--muted);
    margin: 0;
}

.table-card p {
    font-size: 12px;
    font-weight: 900;
}

.table-card-empty {
    align-content: center;
    display: grid;
    gap: 4px;
    min-height: 76px;
}

.table-plan-empty {
    align-items: center;
    background: #f7fbf8;
    border: 1px dashed #bfd9cf;
    border-radius: 8px;
    display: flex;
    gap: 14px;
    padding: 16px;
}

.table-plan-empty h3,
.table-plan-empty p {
    margin: 0;
}

.status,
.count-pill {
    background: #e5f2ed;
    border: 1px solid #cbe4d9;
    border-radius: 999px;
    color: var(--accent-strong);
    display: inline-block;
    font-size: 12px;
    font-weight: 900;
    padding: 4px 9px;
    text-transform: capitalize;
    white-space: nowrap;
    word-break: keep-all;
}

.status-group {
    background: #e8eef8;
    border-color: #b8cce8;
    color: #1a4a8a;
}

.status-knockout {
    background: #fff7e2;
    border-color: #efd58b;
    color: #7b570b;
}

.status-complete {
    background: #e5f2ed;
    border-color: #cbe4d9;
    color: var(--accent-strong);
}

.progress-bar {
    background: var(--line);
    border-radius: 999px;
    height: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    background: linear-gradient(90deg, var(--accent), var(--gold));
    border-radius: 999px;
    height: 100%;
    min-width: 4px;
    transition: width .4s ease;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.card-meta span {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    font-size: 12px;
    padding: 2px 7px;
}

.card-meta strong {
    color: var(--ink);
    font-weight: 900;
}

.card-progress {
    display: grid;
    gap: 5px;
    margin-top: auto;
}

.card-progress-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.tournament-cards {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tournament-card {
    background: linear-gradient(180deg, #ffffff, var(--panel-soft));
    border: 1px solid var(--line);
    border-left: 6px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(17, 29, 27, .07);
    color: var(--ink);
    display: grid;
    gap: 14px;
    min-height: 190px;
    padding: 20px;
}

.tournament-card:hover {
    border-left-color: var(--gold);
    transform: translateY(-1px);
}

.tournament-card h2 {
    font-size: 24px;
    line-height: 1.15;
    margin: 0;
}

.tournament-search-panel {
    padding-block: 14px;
}

.tournament-search-form {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(220px, 1fr) var(--button-width) var(--button-width-small);
}

.admin-search-form {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(220px, 1fr) var(--button-width) var(--button-width-small);
    margin-bottom: 14px;
}

.clear-search-link {
    min-height: var(--control-height);
    width: var(--button-width-small);
}

.tournament-pagination {
    margin-top: -6px;
}

.open-link,
.button-link {
    align-items: center;
    align-self: end;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border: 1px solid var(--accent-strong);
    border-radius: var(--control-radius);
    box-shadow: 0 8px 18px rgba(20, 122, 91, .18);
    color: white;
    display: inline-flex;
    font-weight: 900;
    justify-content: center;
    min-height: var(--control-height);
    min-width: 0;
    padding: var(--control-padding);
    text-align: center;
    transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
    white-space: normal;
}

.open-link {
    width: 100%;
}

.open-link:hover,
.button-link:hover,
.open-action:hover {
    color: white;
    filter: brightness(.95);
}

.empty-state {
    max-width: 520px;
}

.back-link {
    align-items: center;
    background: #edf5f1;
    border: 1px solid #cde2d9;
    border-radius: var(--control-radius);
    color: var(--accent-strong);
    display: inline-flex;
    font-size: 13px;
    font-weight: 900;
    margin-bottom: 10px;
    min-height: var(--control-height);
    max-width: 100%;
    padding: var(--control-padding);
    position: relative;
    text-decoration: none;
    white-space: normal;
    width: fit-content;
    z-index: 1;
}

.back-link:hover {
    color: var(--accent-strong);
    filter: brightness(.93);
}

.count-pill {
    background: #fff7e2;
    border-color: #efd58b;
    color: #7b570b;
}

.inactive-status {
    background: #f7e8e8;
    border-color: #e8bfc0;
    color: #8e2421;
}

.winner {
    align-items: center;
    align-self: center;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: var(--accent-strong);
    display: flex;
    font-weight: 900;
    gap: 10px;
    padding: 14px 16px;
}

.winner-inline {
    color: var(--accent-strong);
    font-weight: 900;
}

.winner-celebration {
    align-items: center;
    background:
        radial-gradient(circle at 50% 34%, rgba(216, 166, 58, .28), transparent 34%),
        rgba(17, 29, 27, .62);
    display: grid;
    inset: 0;
    justify-items: center;
    overflow: hidden;
    padding: 18px;
    position: fixed;
    z-index: 80;
}

.winner-celebration-stage {
    animation: winnerStagePop .5s ease both;
    background: linear-gradient(180deg, #ffffff, #f7fbf8);
    border: 2px solid rgba(216, 166, 58, .72);
    border-radius: 8px;
    box-shadow: 0 26px 80px rgba(17, 29, 27, .32);
    display: grid;
    gap: 10px;
    justify-items: center;
    max-width: min(520px, 100%);
    padding: clamp(22px, 5vw, 42px);
    position: relative;
    text-align: center;
    z-index: 2;
}

.winner-celebration-stage h2 {
    color: var(--accent-strong);
    font-size: clamp(38px, 8vw, 70px);
    line-height: .95;
    margin: 0;
}

.winner-celebration-stage p {
    color: var(--muted);
    font-weight: 900;
    margin: 0;
}

.winner-celebration-stage button {
    margin-top: 8px;
    width: auto;
}

.winner-crown {
    align-items: center;
    background: radial-gradient(circle at 32% 28%, #ffffff 0 9%, #151515 10% 100%);
    border: 5px solid var(--gold);
    border-radius: 50%;
    color: white;
    display: inline-flex;
    font-size: 28px;
    font-weight: 900;
    height: 78px;
    justify-content: center;
    width: 78px;
}

.winner-confetti {
    animation: winnerConfettiFall 4s linear forwards;
    border-radius: 2px;
    height: 18px;
    position: absolute;
    top: -28px;
    width: 8px;
    z-index: 1;
}

.winner-celebration-closing {
    animation: winnerOverlayOut .25s ease forwards;
}

@keyframes winnerStagePop {
    from {
        opacity: 0;
        transform: translateY(18px) scale(.88);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes winnerConfettiFall {
    0% {
        opacity: 0;
        transform: translateY(-40px) rotate(0deg);
    }
    10% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(110vh) rotate(540deg);
    }
}

@keyframes winnerOverlayOut {
    to {
        opacity: 0;
    }
}

.locked-result {
    background: #f4f1ea;
    border: 1px solid #ded5c4;
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 900;
    justify-content: center;
    padding: 7px 10px;
}

.match-list,
.knockout {
    display: grid;
    gap: 12px;
}

.group-panel {
    align-content: start;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.group-panel .panel-heading {
    margin-bottom: 0;
}

.group-panel .mini-ball {
    height: 28px;
    width: 28px;
}

.group-panel h2 {
    font-size: 20px;
}

.group-panel h3 {
    font-size: 14px;
    margin-top: 2px;
}

.group-match-list {
    gap: 8px;
}

.group-history-panel {
    display: grid;
    gap: 16px;
}

.group-history-panel .panel-heading {
    margin-bottom: 0;
}

.group-history-toggle {
    min-height: var(--control-height);
    width: var(--button-width);
}

.group-history-body {
    display: grid;
    gap: 14px;
}

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

.group-history-card {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.group-history-table td {
    text-align: left;
    vertical-align: middle;
}

.group-history-table th {
    text-align: left;
}

.group-history-table td:first-child {
    width: 100%;
}

.history-game-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.history-game-cell strong {
    overflow-wrap: anywhere;
}

.history-vs {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.history-score-cell {
    text-align: center;
    white-space: nowrap;
    width: 1%;
    padding-left: 12px !important;
    padding-right: 12px !important;
}

.history-status-cell {
    white-space: nowrap;
    width: 1%;
    padding-left: 12px !important;
}

.history-score {
    color: var(--accent-strong);
    font-size: 15px;
    font-weight: 900;
    white-space: nowrap;
}

.bracket-panel {
    overflow: visible;
}

.journey-panel {
    display: grid;
    gap: 18px;
}

.journey-panel > p {
    margin: -6px 0 0;
}

.journey-stage {
    display: grid;
    gap: 14px;
}

.bracket {
    align-items: center;
    display: grid;
    gap: clamp(12px, 1.8vw, 20px);
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px) minmax(0, 1fr);
    padding: 10px 0 4px;
}

.bracket-side {
    align-items: stretch;
    display: grid;
    gap: clamp(10px, 1.6vw, 18px);
    min-width: 0;
}

.bracket-left {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
}

.bracket-right {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
}

.bracket-round {
    align-content: center;
    display: grid;
    gap: 12px;
    min-width: 0;
    position: relative;
}

.bracket-round h3,
.final-label h3 {
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 900;
    margin: 0;
    text-align: center;
    text-transform: uppercase;
}

.bracket-stack {
    display: grid;
    gap: clamp(14px, 3vw, 34px);
    min-width: 0;
}

.bracket-round::after,
.bracket-round::before {
    background: #c9ddd4;
    content: "";
    position: absolute;
    top: 50%;
}

.bracket-left .bracket-round::after {
    height: 2px;
    right: calc(clamp(10px, 1.6vw, 18px) * -1);
    width: clamp(10px, 1.6vw, 18px);
}

.bracket-right .bracket-round::before {
    height: 2px;
    left: calc(clamp(10px, 1.6vw, 18px) * -1);
    width: clamp(10px, 1.6vw, 18px);
}

.bracket-final {
    align-content: center;
    background:
        radial-gradient(circle at 50% 0, rgba(216, 166, 58, .22), transparent 48%),
        linear-gradient(180deg, #ffffff, #f7fbf8);
    border: 2px solid rgba(216, 166, 58, .72);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(17, 29, 27, .12);
    display: grid;
    gap: 14px;
    min-height: 260px;
    min-width: 0;
    padding: 16px;
    position: relative;
}

.bracket-final::before,
.bracket-final::after {
    background: #c9ddd4;
    content: "";
    height: 2px;
    position: absolute;
    top: 50%;
    width: 18px;
}

.bracket-final::before {
    left: -20px;
}

.bracket-final::after {
    right: -20px;
}

.consolation-final {
    border-color: #cde2d9;
    background:
        radial-gradient(circle at 50% 0, rgba(20, 122, 91, .14), transparent 48%),
        linear-gradient(180deg, #ffffff, #f7fbf8);
}

.grand-final-list {
    display: grid;
    margin: 0 auto;
    max-width: 520px;
}

.final-label {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.match {
    align-items: center;
    background: white;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    padding: 12px;
}

.match-in-play {
    border-left-color: var(--gold);
    box-shadow: 0 10px 24px rgba(216, 166, 58, .14);
}

.status-in-play {
    background: #fff7df;
    border-color: #efd18a;
    color: #7a5208;
}

.match-in-play-form {
    margin: 0;
}

.match-in-play-form button {
    min-height: 40px;
    width: var(--button-width);
}

.table-card-in-play-form button {
    min-height: 36px;
    width: 100%;
}

.table-card-winner-buttons {
    gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-card-winner-buttons button {
    min-height: 40px;
}

.table-card-score-form {
    gap: 6px;
    grid-template-columns: minmax(56px, 1fr) minmax(56px, 1fr) minmax(64px, auto);
    justify-content: stretch;
}

.table-card-score-form input,
.table-card-score-form button {
    font-size: 14px;
    height: 40px;
    min-height: 40px;
}

.table-card-score-form button {
    padding-inline: 10px;
    width: auto;
}

.groups .match {
    border-left-width: 4px;
    gap: 8px;
    padding: 9px;
}

.groups .match-main {
    gap: 6px;
}

.groups .status {
    font-size: 11px;
    padding: 3px 7px;
}

.groups .winner-buttons {
    gap: 6px;
}

.groups .winner-buttons button,
.groups .score-form button,
.groups .score-form input {
    font-size: 13px;
    min-height: 40px;
}

.groups .score-form {
    gap: 6px;
    grid-template-columns: minmax(48px, 1fr) minmax(48px, 1fr) minmax(64px, auto);
}

.groups .score-player-label {
    font-size: 9px;
}

.bracket .match {
    border-left-color: var(--gold);
    box-shadow: 0 10px 24px rgba(17, 29, 27, .08);
    grid-template-columns: 1fr;
    min-height: 136px;
}

.bracket .match-main {
    align-items: flex-start;
}

.journey-match {
    min-height: 0;
}

.journey-match .locked-result {
    justify-self: start;
}

.bracket .winner-buttons {
    grid-template-columns: 1fr;
}

.bracket .score-form {
    grid-template-columns: minmax(74px, 1fr) minmax(74px, 1fr);
    justify-content: stretch;
}

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

.match-main {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.match-main strong {
    overflow-wrap: anywhere;
}

.score-form {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(90px, 112px) minmax(90px, 112px) minmax(88px, auto);
    justify-content: end;
    min-width: 0;
}

.score-input-wrap {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.score-player-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .05em;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.match-final-score {
    align-items: center;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    font-variant-numeric: tabular-nums;
    gap: 8px;
    padding: 8px 18px;
}

.match-final-score .score-num {
    color: var(--accent-strong);
    font-size: 20px;
    font-weight: 900;
    line-height: 1;
}

.match-final-score .score-sep {
    color: var(--muted);
    font-size: 16px;
    font-weight: 300;
}

.score-form input {
    font-size: 20px;
    font-weight: 900;
    min-height: 54px;
    min-width: 0;
    text-align: center;
}

.score-form button {
    height: 54px;
    min-height: 54px;
    padding-inline: 16px;
    width: var(--button-width-small);
}

.winner-buttons {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
}

.winner-buttons form {
    margin: 0;
    min-width: 0;
}

.winner-buttons button {
    display: inline-flex;
    min-height: 54px;
    min-width: 0;
    overflow: visible;
    padding-block: 10px;
    padding-inline: 10px;
    white-space: normal;
    width: 100%;
    word-break: break-word;
}

.winner-buttons .selected-winner {
    background: linear-gradient(135deg, var(--gold), #9d6b08);
    border-color: #8d5f04;
    box-shadow: 0 8px 18px rgba(216, 166, 58, .24);
}

@media (max-width: 860px) {
    .hero,
    .title-row,
    .two {
        grid-template-columns: 1fr;
    }

    .pool-table,
    .hero > div:first-child,
    .tournament-hero > div:first-child {
        min-height: 220px;
    }

    .bracket {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .bracket-side,
    .bracket-left,
    .bracket-right {
        grid-auto-flow: row;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        order: 1;
    }

    .bracket-final {
        min-height: 0;
        order: 2;
    }

    .bracket-right {
        order: 3;
    }

    .bracket-round::before,
    .bracket-round::after,
    .bracket-final::before,
    .bracket-final::after {
        display: none;
    }

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

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

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

    .page {
        padding-inline: clamp(12px, 4vw, 24px);
    }
}

@media (max-width: 620px) {
    .page {
        gap: 16px;
        padding-bottom: 40px;
        padding-top: 20px;
    }

    .topbar {
        align-items: flex-start;
        gap: 12px;
        padding: 12px 16px;
    }

    .brand {
        width: 100%;
    }

    nav {
        display: grid;
        gap: 6px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    nav a {
        font-size: 12px;
        justify-content: center;
        min-width: 0;
        padding: 8px 6px;
        width: 100%;
    }

    .logout-form {
        grid-column: span 2;
        min-width: 0;
    }

    .logout-form button {
        font-size: 12px;
        padding: 8px 6px;
        width: 100%;
    }

    .pool-table,
    .hero > div:first-child,
    .tournament-hero > div:first-child {
        min-height: 190px;
    }

    .groups,
    .match {
        grid-template-columns: 1fr;
    }

    .tournament-cards,
    .tournament-search-form,
    .admin-search-form {
        grid-template-columns: 1fr;
    }

    .tournament-search-form button,
    .admin-search-form button,
    .clear-search-link {
        width: 100%;
    }

    .pagination {
        align-items: stretch;
    }

    .pagination > .muted,
    .pagination-actions {
        width: 100%;
    }

    .pagination-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(96px, auto) minmax(0, 1fr);
    }

    .secondary-link-button,
    .page-count {
        min-width: 0;
        width: 100%;
    }

    .selected-rules-panel {
        align-items: stretch;
        display: grid;
    }

    .selected-rules-panel .button-link {
        width: 100%;
    }

    .table-plan-panel .panel-heading,
    .group-history-panel .panel-heading {
        align-items: stretch;
        display: grid;
    }

    .table-plan-toggle,
    .group-history-toggle {
        width: 100%;
    }

    .table-card-matchup {
        gap: 2px;
        grid-template-columns: minmax(0, 1fr);
    }

    .table-card-matchup strong,
    .history-game-cell strong,
    .match-main strong {
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
        overflow-wrap: normal;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-card-matchup span {
        font-size: 10px;
    }

    .group-history-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .group-history-table {
        table-layout: fixed;
    }

    .group-history-table td:first-child {
        max-width: 0;
        overflow: hidden;
        width: auto;
    }

    .group-history-table th:nth-child(2),
    .group-history-table td:nth-child(2) {
        width: 46px;
    }

    .group-history-table th:nth-child(3),
    .group-history-table td:nth-child(3) {
        width: 82px;
    }

    .group-history-table td:nth-child(3) {
        padding-left: 4px !important;
    }

    .history-status-cell .status,
    .history-status-cell .locked-result {
        display: block;
        font-size: 10px;
        overflow: hidden;
        padding: 4px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .group-panel > .compact-table {
        table-layout: fixed;
    }

    .group-panel > .compact-table th:not(:first-child),
    .group-panel > .compact-table td:not(:first-child) {
        padding-inline: 3px;
        width: 30px;
    }

    .group-panel > .compact-table td:first-child {
        overflow: hidden;
        overflow-wrap: normal;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-count-form {
        display: grid;
        grid-template-columns: 1fr;
    }

    .table-count-form label,
    .table-count-form input,
    .table-count-form select,
    .table-count-form button {
        width: 100%;
    }

    .reorganise-table-form button {
        width: 100%;
    }

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

    .admin-danger-panel form,
    .admin-danger-panel button {
        width: 100%;
    }

    .playoff-in-progress-panel,
    .group-balance-warning {
        grid-template-columns: 1fr;
    }

    .playoff-in-progress-panel .secondary-button,
    .group-balance-warning button {
        width: 100%;
    }

    .hero h1,
    .title-row h1 {
        font-size: 40px;
    }

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

    .toggle-row {
        align-items: stretch;
        display: grid;
    }

    .toggle-row button {
        width: 100%;
    }

    .score-form {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        justify-content: stretch;
        width: 100%;
    }

    .score-form button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .score-form input,
    .score-form button {
        height: 58px;
        min-height: 58px;
    }

    .winner-buttons button {
        min-height: 58px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        word-break: normal;
    }

    .winner-buttons {
        grid-template-columns: 1fr;
    }

    .exclusion-tools {
        grid-template-columns: 1fr;
    }

    .exclusion-toggle-card {
        align-items: stretch;
        display: grid;
    }

    .exclusion-actions {
        justify-content: flex-start;
    }

    th,
    td {
        padding: 9px 5px;
    }

    table,
    .compact-table {
        font-size: 14px;
    }

    label {
        font-size: 14px;
    }

    legend {
        font-size: 14px;
    }

    .panel {
        padding: 14px;
    }

    .management-panel {
        overflow-x: visible;
    }

    .admin-management-table,
    .admin-management-table tbody {
        display: grid;
        gap: 10px;
        min-width: 0;
        width: 100%;
    }

    .admin-management-table thead {
        display: none;
    }

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

    .admin-management-table td,
    .admin-management-table td:last-child {
        border: 0;
        padding: 0;
        text-align: left;
        white-space: normal;
    }

    .player-management-table tr {
        align-items: center;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .player-management-table td:nth-child(1) {
        font-size: 16px;
        font-weight: 900;
    }

    .player-management-table td:nth-child(2) {
        color: var(--muted);
        font-size: 13px;
    }

    .player-management-table td:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
    }

    .player-management-table td:nth-child(4) {
        grid-column: 2;
        grid-row: 2;
    }

    .player-management-table button {
        min-width: 94px;
        white-space: nowrap;
        width: 94px;
    }

    .tournament-management-table td {
        display: grid;
        gap: 2px;
    }

    .tournament-management-table td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 11px;
        font-weight: 900;
        letter-spacing: .04em;
        text-transform: uppercase;
    }

    .tournament-management-table td:first-child {
        font-size: 18px;
        font-weight: 900;
    }

    .tournament-management-table td:first-child::before {
        display: none;
    }

    .tournament-management-table .table-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .table-actions {
        justify-content: flex-start;
        min-width: 0;
    }

    .table-actions .inline-form {
        flex: 1 1 var(--button-width-small);
    }

    .table-actions .inline-form button,
    .action-button {
        width: 100%;
    }

    .stats-filters,
    .yearly-filter {
        grid-template-columns: 1fr;
    }

    .table-plan-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .table-plan-summary strong {
        font-size: 24px;
    }

    .table-plan-slot-card {
        grid-template-columns: 1fr;
    }

    .table-plan-slot-marker {
        align-items: center;
        display: flex;
        justify-content: space-between;
        min-height: 72px;
        text-align: left;
    }

    .table-plan-tables {
        grid-template-columns: 1fr;
        overflow-x: visible;
    }

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

    .story-control,
    .performance-spotlight {
        grid-template-columns: 1fr;
    }

    .bar-row {
        grid-template-columns: 1fr auto;
    }

    .bar-track {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .group-balance-list span {
        max-width: 100%;
    }
}
