:root {
    --background: #f4f7f9;
    --surface: #ffffff;
    --surface-soft: #edf4f2;
    --text: #17202a;
    --muted: #68757f;
    --line: #dce4e8;
    --primary: #087f5b;
    --primary-dark: #056647;
    --accent: #f59f00;
    --danger: #c92a2a;
    --shadow: 0 12px 32px rgba(17, 39, 32, 0.08);
    --radius: 16px;
}

html {
    font-size: 16px;
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--primary);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
}

h2 {
    font-size: 1.25rem;
    font-weight: 750;
}

.btn {
    border-radius: 10px;
    font-weight: 700;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--primary);
    border-color: var(--primary);
}

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.site-header-inner {
    width: min(1600px, calc(100% - 40px));
    min-height: 72px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

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

.brand-mark,
.auth-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    letter-spacing: -0.04em;
}

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

.brand strong {
    font-size: 1.05rem;
}

.brand small {
    color: var(--muted);
    font-size: 0.74rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-actions form {
    margin: 0;
}

.nav-link-public {
    margin-right: 6px;
    color: var(--text);
    font-weight: 650;
    text-decoration: none;
}

.page-shell {
    width: min(1600px, calc(100% - 40px));
    min-height: calc(100vh - 150px);
    margin: 0 auto;
    padding: 28px 0 64px;
}

.site-footer {
    width: min(1600px, calc(100% - 40px));
    margin: 0 auto;
    padding: 22px 0;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.88rem;
}

.club-banner {
    min-height: 220px;
    overflow: hidden;
    border-radius: 22px;
    background: #12352c;
    box-shadow: var(--shadow);
}

.club-banner img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: cover;
}

.banner-placeholder {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    background:
        radial-gradient(circle at 18% 25%, rgba(255, 255, 255, 0.13), transparent 27%),
        radial-gradient(circle at 82% 70%, rgba(245, 159, 0, 0.25), transparent 24%),
        linear-gradient(135deg, #075e47, #12352c);
    color: white;
}

.banner-placeholder span {
    font-size: clamp(2rem, 6vw, 4.5rem);
    font-weight: 900;
    letter-spacing: -0.04em;
}

.banner-placeholder small {
    color: rgba(255, 255, 255, 0.7);
}

.live-heading,
.admin-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 28px;
    padding: 38px 2px 24px;
}

.live-heading h1,
.admin-heading h1 {
    margin: 7px 0 0;
}

.live-heading p,
.admin-heading p {
    margin-bottom: 5px;
    color: var(--muted);
}

.live-label,
.eyebrow,
.section-heading > span {
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
    background: #20c997;
    box-shadow: 0 0 0 5px rgba(32, 201, 151, 0.15);
}

.tournament-layout {
    display: grid;
    grid-template-columns: minmax(380px, 0.8fr) minmax(0, 2fr);
    align-items: start;
    gap: 22px;
}

.groups-grid {
    min-width: 0;
    display: grid;
    gap: 22px;
}

.panel,
.form-card,
.admin-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 4px 18px rgba(17, 39, 32, 0.045);
}

.player-overview {
    position: sticky;
    top: 96px;
}

.panel-heading {
    min-height: 64px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, var(--surface-soft), #fff);
}

.panel-heading h2 {
    margin: 0;
}

.panel-heading > span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

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

.table {
    margin: 0;
    vertical-align: middle;
}

.standings-table {
    min-width: 590px;
}

.player-overview .standings-table {
    min-width: 500px;
}

.table > :not(caption) > * > * {
    padding: 0.78rem 0.8rem;
    border-bottom-color: #edf0f2;
}

.table thead th {
    border-bottom-width: 1px;
    background: #fafcfc;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover {
    background: #fbfdfc;
}

.player-name {
    min-width: 130px;
    font-weight: 750;
}

.points {
    color: var(--primary) !important;
    font-size: 1.08rem;
    font-weight: 900;
}

.group-badge,
.place-badge,
.result-badge {
    display: inline-grid;
    min-width: 30px;
    min-height: 30px;
    padding: 3px 9px;
    place-items: center;
    border-radius: 9px;
    background: #dff3ec;
    color: var(--primary-dark);
    font-weight: 850;
}

.place-badge {
    background: #f0f2f4;
    color: var(--text);
}

.standings-table tbody tr:first-child .place-badge {
    background: #fff1c2;
    color: #8a5a00;
}

.result-badge {
    min-width: 54px;
    background: #12352c;
    color: #fff;
    font-size: 1rem;
}

.empty-state,
.empty-table {
    color: var(--muted);
    text-align: center;
}

.empty-state {
    padding: 70px 24px;
    border: 1px dashed #b9c7cb;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.6);
}

.empty-state h2 {
    color: var(--text);
}

.sponsors {
    margin-top: 52px;
    padding-top: 36px;
    border-top: 1px solid var(--line);
}

.section-heading {
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 5px 0 0;
    font-size: 1.8rem;
}

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

.sponsor-card {
    min-height: 110px;
    display: grid;
    padding: 16px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.sponsor-card img {
    max-width: 100%;
    max-height: 76px;
    object-fit: contain;
}

.sponsor-placeholder {
    border-style: dashed;
    color: #8a969d;
    font-weight: 750;
}

.auth-shell {
    min-height: calc(100vh - 230px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(100%, 440px);
    padding: 36px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-icon {
    width: 58px;
    height: 58px;
    margin-bottom: 22px;
    font-size: 1.25rem;
}

.auth-card h1 {
    margin-bottom: 10px;
    font-size: 2rem;
}

.auth-card > p {
    margin-bottom: 26px;
    color: var(--muted);
}

.auth-card .back-link {
    display: block;
    margin-top: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.88rem;
    font-weight: 750;
}

.form-control,
.form-select {
    min-height: 46px;
    border-color: #cdd7dc;
    border-radius: 10px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(8, 127, 91, 0.15);
}

.field-validation-error,
.validation-summary {
    color: var(--danger);
    font-size: 0.84rem;
}

.field-validation-error {
    display: block;
    margin-top: 5px;
}

.validation-summary ul {
    margin-bottom: 20px;
    padding: 14px 18px 14px 36px;
    border-radius: 10px;
    background: #fff0f0;
}

.input-validation-error {
    border-color: var(--danger);
}

.admin-heading {
    align-items: center;
    padding-top: 18px;
}

.admin-heading.compact {
    padding-bottom: 28px;
}

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

.admin-card {
    padding: 26px;
    color: var(--text);
    text-decoration: none;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.admin-card:hover {
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.admin-card-count {
    display: block;
    margin-bottom: 26px;
    color: var(--primary);
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 1;
}

.admin-card h2 {
    font-size: 1.5rem;
}

.admin-card p {
    min-height: 48px;
    color: var(--muted);
}

.card-link {
    color: var(--primary);
    font-weight: 750;
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.management-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    align-items: start;
    gap: 22px;
}

.form-card {
    padding: 26px;
}

.form-card h1,
.form-card h2 {
    margin-bottom: 20px;
}

.form-card > p {
    margin-top: -10px;
    margin-bottom: 28px;
    color: var(--muted);
}

.management-list.full-width {
    width: 100%;
}

.admin-table {
    min-width: 650px;
}

.matches-table {
    min-width: 820px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.actions form {
    display: inline;
    margin: 0;
}

.locked-action {
    color: var(--muted);
    font-size: 0.78rem;
}

.narrow-page {
    width: min(100%, 760px);
    margin: 20px auto;
}

.match-page {
    width: min(100%, 900px);
}

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

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

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

.versus {
    padding-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
}

.set-entry {
    margin-top: 10px;
    padding: 22px;
    border-radius: 14px;
    background: #f7faf9;
}

.set-entry-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.set-entry-heading h2 {
    margin-bottom: 3px;
}

.set-entry-heading p,
.form-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.score-labels {
    display: grid;
    grid-template-columns: 80px 80px;
    gap: 24px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
    text-align: center;
}

.set-list {
    display: grid;
    gap: 9px;
}

.set-row {
    min-height: 58px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 20px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.set-score {
    display: flex;
    align-items: center;
    gap: 8px;
}

.set-score .form-control {
    width: 80px;
    min-height: 40px;
    text-align: center;
    font-size: 1.08rem;
    font-weight: 800;
}

.form-hint {
    margin-top: 13px;
}

.match-details {
    padding: 28px;
}

.match-details-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: var(--muted);
}

.match-scoreboard {
    margin: 38px 0 18px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 20px;
}

.match-scoreboard > div {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
}

.match-scoreboard > div.reverse {
    justify-content: flex-start;
}

.match-scoreboard strong {
    font-size: 1.35rem;
}

.match-scoreboard > div > span,
.score-separator {
    font-size: 3rem;
    font-weight: 900;
}

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

.winner-line {
    color: var(--primary);
    text-align: center;
}

.set-details {
    margin: 28px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 9px;
}

.set-details div {
    padding: 12px;
    border-radius: 10px;
    background: var(--surface-soft);
    text-align: center;
}

.set-details span,
.set-details strong {
    display: block;
}

.set-details span {
    color: var(--muted);
    font-size: 0.74rem;
}

.set-details strong {
    margin-top: 3px;
    font-size: 1.15rem;
}

.alert {
    border: 0;
    border-radius: 12px;
}

@media (min-width: 1380px) {
    .groups-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1050px) {
    .tournament-layout,
    .management-layout {
        grid-template-columns: 1fr;
    }

    .player-overview {
        position: static;
    }

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

    .admin-card p {
        min-height: auto;
    }
}

@media (max-width: 720px) {
    .site-header-inner,
    .page-shell,
    .site-footer {
        width: min(100% - 24px, 1600px);
    }

    .site-header-inner {
        min-height: 64px;
    }

    .brand small,
    .nav-link-public,
    .header-actions .btn-outline-primary {
        display: none;
    }

    .header-actions {
        gap: 6px;
    }

    .club-banner,
    .club-banner img,
    .banner-placeholder {
        min-height: 160px;
        height: 160px;
    }

    .banner-placeholder small {
        display: none;
    }

    .live-heading,
    .admin-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .live-heading p {
        font-size: 0.82rem;
    }

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

    .player-grid .versus {
        display: none;
    }

    .form-card,
    .auth-card,
    .match-details {
        padding: 20px;
    }

    .set-entry {
        padding: 14px;
    }

    .score-labels {
        display: none;
    }

    .match-scoreboard {
        gap: 8px;
    }

    .match-scoreboard strong {
        font-size: 1rem;
    }

    .match-scoreboard > div > span,
    .score-separator {
        font-size: 2rem;
    }

    .site-footer {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .sponsor-grid,
    .form-grid,
    .player-grid {
        grid-template-columns: 1fr;
    }

    .sponsor-card {
        min-height: 80px;
    }

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

    .set-score {
        width: 100%;
    }

    .set-score .form-control {
        width: 100%;
    }

    .actions {
        white-space: normal;
    }
}
