/* ============================
   Global
   ============================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

/* ============================
   Header
   ============================ */
header {
    display: block;
    width: 100%;
    max-height: 15vh;
    overflow: hidden;
    background-color: white;
    padding: calc(15vh * 0.05);
    box-sizing: border-box;
}

header a {
    display: block;
    width: 100%;
    height: calc(15vh * 0.9);
}

header img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

/* ============================
   Navigation
   ============================ */
nav {
    background-color: rgb(0, 84, 164);
    width: 100%;
    position: relative;
}

.nav-inner {
    display: flex;
    align-items: center;
    overflow: visible;
    width: 100%;
    position: relative;
}

.nav-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 0;
}

.nav-list li {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
    flex: 0 1 auto;
}

/* White dot separator */
.nav-list li + li::before {
    content: '·';
    color: white;
    padding: 0 0.3em;
    font-size: 1.2em;
    line-height: 1;
}

.nav-list a {
    color: white;
    text-decoration: none;
    text-transform: uppercase;
    padding: 0.75em 0.8em;
    display: block;
    font-size: 0.95em;
    letter-spacing: 0.03em;
    font-weight: bold;
    text-align: center;
}

.nav-list a:hover {
    text-decoration: underline;
}

/* ============================
   "More" button & dropdown
   ============================ */
.nav-more {
    display: none;
    flex-shrink: 0;
    align-items: center;
    position: relative;
}

.nav-more.visible {
    display: flex;
}

.nav-more-btn {
    background: none;
    border: 2px solid white;
    color: white;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    text-transform: uppercase;
    padding: 0.4em 0.8em;
    margin: 0.4em 0.6em;
    cursor: pointer;
    letter-spacing: 0.05em;
    border-radius: 2px;
}

.nav-more-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: rgb(0, 84, 164);
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: 180px;
    z-index: 100;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.nav-dropdown.open {
    display: block;
}

.nav-dropdown li {
    display: block;
}

.nav-dropdown a {
    color: white;
    text-decoration: none;
    text-transform: uppercase;
    padding: 0.7em 1em;
    display: block;
    font-size: 0.95em;
    font-weight: bold;
    letter-spacing: 0.03em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-dropdown a:hover {
    text-decoration: underline;
    background-color: rgba(255, 255, 255, 0.1);
}

/* ============================
   Content & Ad bar
   ============================ */
.content,
.adbar {
    max-width: 100vh;
    margin: 0 auto;
    width: 100%;
    padding: 1em;
}

.content {
    min-height: 60vh;
    background-color: white;
}

.adbar {
    border-top: 1px solid #ddd;
    padding: 0.75em 1em;
    min-height: 3em;
    background-color: #fff;
}

/* ============================
   Archer page
   ============================ */
.archer-page {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

/* --- Filters --- */
.archer-filters {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex-wrap: nowrap;
    padding: 0.75em 0;
    border-bottom: 1px solid #ddd;
}

.archer-filters-right {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex-wrap: nowrap;
    margin-left: auto;
}

/* Name field */
.filter-name-wrap {
    display: flex;
    align-items: center;
    position: relative;
    flex: 0 0 auto;
}

.filter-search-icon {
    position: absolute;
    left: 0.5em;
    font-size: 1em;
    pointer-events: none;
    color: #666;
}

.filter-name-input {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    padding: 0.45em 0.6em 0.45em 2em;
    border: 1px solid #ccc;
    border-radius: 3px;
    outline: none;
    width: 200px;
    transition: border-color 0.15s;
}

.filter-name-input:focus {
    border-color: rgb(0, 84, 164);
    box-shadow: 0 0 0 2px rgba(0, 84, 164, 0.15);
}

/* Shared filter input */
.filter-input {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    padding: 0.45em 0.6em;
    border: 1px solid #ccc;
    border-radius: 3px;
    outline: none;
    background-color: #fff;
    cursor: pointer;
    transition: border-color 0.15s;
}

.filter-input:focus {
    border-color: rgb(0, 84, 164);
    box-shadow: 0 0 0 2px rgba(0, 84, 164, 0.15);
}

/* Filter group (input + clear btn) */
.filter-group {
    display: flex;
    align-items: center;
    gap: 0.25em;
}

.filter-clear-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 1.4em;
    height: 1.4em;
    font-size: 0.75em;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.filter-clear-btn:hover {
    background-color: #eee;
}

/* Club custom dropdown */
.club-dropdown-wrap {
    position: relative;
}

.club-dropdown-wrap .filter-input {
    width: 180px;
}

.club-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 3px 3px;
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 200;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.club-dropdown-list.open {
    display: block;
}

.club-option {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.4em 0.7em;
    cursor: pointer;
    font-size: 0.85em;
    white-space: nowrap;
}

.club-option:hover {
    background-color: rgba(0, 84, 164, 0.08);
}

.club-option-flag {
    height: 18px;
    width: auto;
    flex-shrink: 1;
}

/* Mobile: stack filters */
@media (max-width: 768px) {
    .archer-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .archer-filters-right {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
    }

    .filter-name-wrap,
    .filter-group,
    .club-dropdown-wrap,
    .club-dropdown-wrap .filter-input,
    .filter-input {
        width: 100%;
    }
}

/* --- Archer results --- */
.archer-results-msg {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-top: 2em;
}

/* Grid: photo | name | club | category | bowtype — aligned across all cards */
.archer-list {
    display: grid;
    grid-template-columns: auto 1fr 1fr auto auto;
    column-gap: 1em;
}

.archer-card {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: center;
    padding: 0.75em 0;
    border-bottom: 2px solid grey;
}

.archer-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid lightgrey;
    object-fit: cover;
    object-position: top;
    justify-self: start;
}

/* .archer-details becomes transparent to the grid */
.archer-details {
    display: contents;
}

.archer-name {
    min-width: 0;
}

.archer-name a {
    color: inherit;
    text-decoration: none;
    font-size: 0.95em;
}

.archer-name a:hover {
    text-decoration: underline;
}

.archer-club {
    display: flex;
    align-items: center;
    gap: 0.4em;
    font-size: 0.85em;
    color: #444;
    min-width: 0;
}

.archer-club-flag {
    height: 32px;
    width: auto;
    flex-shrink: 0;
}

.archer-category {
    font-size: 0.85em;
    color: #444;
}

.archer-bowtype {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
}

.archer-bowtype div {
    font-size: 0.78em;
    color: #fff;
    background-color: #7b2d8b;
    padding: 0.4em 0.6em;
    border-radius: 1em;
    white-space: nowrap;
}

/* Narrow: switch back to flex — photo left, details stacked */
@media (max-width: 560px) {
    .archer-list {
        display: flex;
        flex-direction: column;
    }

    .archer-card {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 0.75em;
    }

    .archer-photo {
        width: 28vw;
        height: 28vw;
        max-width: 100px;
        max-height: 100px;
        flex-shrink: 0;
    }

    .archer-details {
        display: flex;
        flex-direction: column;
        gap: 0.3em;
        align-items: flex-start;
        min-width: 0;
    }
}

/* Club members section (Zawodnicy) — 4-column grid without club column */
.club-members-section {
    display: flex;
    flex-direction: column;
    gap: 1em;
    padding: 1em 0;
}

.club-members-filter {
    display: flex;
    justify-content: flex-end;
}

.archer-list--no-club {
    grid-template-columns: auto auto auto auto 1fr;
}

/* ============================
   Tournament page
   ============================ */
.tournament-page {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

/* --- Filters --- */
.tournament-filters {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex-wrap: wrap;
    padding: 0.75em 0;
    border-bottom: 1px solid #ddd;
}

/* Multi-select wrapper */
.multiselect-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
}

.multiselect-btn {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    padding: 0.45em 0.8em;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s;
}

.multiselect-btn.restricted {
    border-color: rgb(0, 84, 164);
    background-color: rgba(0, 84, 164, 0.1);
    font-weight: bold;
}

.multiselect-btn:hover,
.multiselect-btn.open {
    border-color: rgb(0, 84, 164);
}

.multiselect-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    min-width: 200px;
    z-index: 200;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 0.4em 0;
}

.multiselect-option {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.4em 0.8em;
    font-size: 0.85em;
    cursor: pointer;
    white-space: nowrap;
}

.multiselect-option:hover {
    background-color: rgba(0, 84, 164, 0.08);
}

.multiselect-option input[type="checkbox"] {
    cursor: pointer;
    accent-color: rgb(0, 84, 164);
}

.multiselect-reset {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 1em;
    padding: 0.25em 0.4em;
    cursor: pointer;
    color: #555;
    line-height: 1;
}

.multiselect-reset:hover {
    background-color: #eee;
}

.year-select {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    padding: 0.45em 0.6em;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.year-select:focus {
    border-color: rgb(0, 84, 164);
    box-shadow: 0 0 0 2px rgba(0, 84, 164, 0.15);
}

/* --- Tournament results --- */
.tournament-results-msg {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-top: 2em;
}

.tournament-list {
    display: flex;
    flex-direction: column;
}

.tournament-card {
    display: grid;
    grid-template-columns: 90px 1fr;
    align-items: center;
    gap: 1em;
    padding: 0.75em 0;
    border-bottom: 1px solid #e8e8e8;
}

.tournament-logo {
    width: 90px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tournament-logo img {
    max-width: 100%;
    max-width: 90px;
    max-height: 70px;
    object-fit: contain;
}

.tournament-details {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
    min-width: 0;
}

.tournament-name a {
    color: inherit;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95em;
}

.tournament-name a:hover {
    text-decoration: underline;
}

.tournament-place {
    display: flex;
    align-items: center;
    gap: 0.4em;
    font-size: 0.85em;
    color: #444;
}

.tournament-place-flag {
    height: 18px;
    width: auto;
    border-radius: 3px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.tournament-date {
    font-size: 0.85em;
    color: #666;
}

/* ============================
   Club page
   ============================ */
.club-page {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

/* --- Filters --- */
.club-filters {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex-wrap: wrap;
    padding: 0.75em 0;
    border-bottom: 1px solid #ddd;
}

/* Region custom dropdown */
.region-dropdown-wrap {
    position: relative;
}

.region-dropdown-wrap .filter-input {
    width: 180px;
}

.region-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 3px 3px;
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 200;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.region-dropdown-list.open {
    display: block;
}

.region-option {
    display: flex;
    align-items: center;
    padding: 0.4em 0.7em;
    cursor: pointer;
    font-size: 0.85em;
    white-space: nowrap;
}

.region-option:hover {
    background-color: rgba(0, 84, 164, 0.08);
}

/* Mobile: stack filters */
@media (max-width: 768px) {
    .club-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-name-wrap,
    .filter-group,
    .region-dropdown-wrap,
    .region-dropdown-wrap .filter-input {
        width: 100%;
    }
}

/* --- Club results --- */
.club-results-msg {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-top: 2em;
}

.club-list {
    display: flex;
    flex-direction: column;
}

.club-card {
    display: grid;
    grid-template-columns: 70px 1fr;
    align-items: center;
    gap: 1em;
    padding: 0.75em 0;
    border-bottom: 1px solid #e8e8e8;
}

.club-logo {
    width: 70px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.club-logo img {
    max-width: 70px;
    max-height: 50px;
    object-fit: contain;
}

.club-details {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    min-width: 0;
}

.club-name a {
    color: inherit;
    text-decoration: none;
    font-size: 0.95em;
}

.club-name a:hover {
    text-decoration: underline;
}

.club-region {
    font-size: 0.85em;
    color: #444;
}

/* ============================
   Archer Data page
   ============================ */
.archer-data-page {
    display: flex;
    flex-direction: column;
}

.archer-banner {
    background-size: cover;
    background-position: center;
    background-color: rgb(0, 84, 164);
    position: relative;
}

.archer-banner-inner {
    display: flex;
    align-items: center;
    gap: 1.25em;
    padding: 1.25em 1.25em 0.75em;
}

.archer-banner-photo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 3px solid lightgrey;
    flex-shrink: 0;
    background-color: #ccc;
}

.archer-banner-info {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    min-width: 0;
}

.archer-banner-name {
    font-size: 1.3em;
    letter-spacing: 0.03em;
}

.archer-banner-country {
    display: flex;
    align-items: center;
    gap: 0.4em;
    font-size: 0.95em;
}

@media (min-width: 900px) {
    .archer-banner-name    { font-size: 1.8em; }
    .archer-banner-country { font-size: 1.15em; }
}

.archer-banner-flag {
    height: 18px;
    width: auto;
    border-radius: 2px;
    border: 1px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}

.archer-banner-category {
    font-size: 0.9em;
    opacity: 0.9;
}

/* Profile nav tabs */
.archer-profile-nav {
    display: flex;
    align-items: stretch;
    background-color: rgba(0,0,0,0.25);
    margin-top: 0.75em;
    padding: 0.4em 0.4em 0;
    gap: 0.6em;
    position: relative;
}

.archer-profile-nav-list {
    display: flex;
    flex: 1 1 auto;
    overflow: hidden;
    min-width: 0;
    gap: 0.6em;
}

.archer-profile-nav-btn {
    flex: 1 1 0;
    min-width: 160px;
    background-color: lightgrey;
    border: none;
    border-radius: 0;
    color: rgb(0, 84, 164);
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.65em 0.8em;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s;
}

.archer-profile-nav-btn:hover {
    background-color: #e0e0e0;
    color: hsl(209, 100%, 32%);
}

.archer-profile-nav-btn--active {
    background-color: lightgray;
    color: rgb(0, 84, 164);
    font-weight: bold;
}

.archer-profile-nav-more {
    display: none;
    flex-shrink: 0;
    position: relative;
}

.archer-profile-nav-more.visible {
    display: flex;
}

.archer-profile-nav-more-btn {
    background-color: lightgrey;
    border: none;
    border-radius: 0;
    color: rgb(0, 84, 164);
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 1.1em;
    padding: 0.65em 0.9em;
    cursor: pointer;
    line-height: 1;
}

.archer-profile-nav-more-btn:hover {
    background-color: #e0e0e0;
}

.archer-profile-nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    background-color: lightgrey;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.archer-profile-nav-dropdown.open {
    display: block;
}

.archer-profile-nav-dropdown .archer-profile-nav-btn {
    display: block;
    width: 100%;
    flex: none;
    text-align: left;
    border-radius: 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    border-left: none;
    border-right: none;
    border-top: none;
}

/* Archer data filters */
.archer-data-filters {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex-wrap: wrap;
    padding: 0.75em 1em;
    border-bottom: 1px solid #ddd;
    background-color: #fff;
}

.archer-filter-select {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    padding: 0.45em 0.6em;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
    min-width: 140px;
}

.archer-filter-select:focus {
    border-color: rgb(0, 84, 164);
    box-shadow: 0 0 0 2px rgba(0, 84, 164, 0.15);
}

/* Archer data generic message */
.archer-data-msg {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2em 1em;
}

/* ============================
   Podsumowanie — stat circles
   ============================ */
.stat-circles {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5em;
    padding: 1.5em 1em;
    justify-content: center;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
}

.stat-circle-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
    flex: 0 0 auto;
    width: 140px;
}

.stat-circle-svg {
    width: 130px;
    height: 130px;
}

@media (min-width: 768px) {
    .stat-circles     { flex-wrap: nowrap; }
    .stat-circle-wrap { flex: 1 1 0; width: auto; max-width: 200px; }
    .stat-circle-svg  { width: 100%; max-width: 190px; height: auto; aspect-ratio: 1; }
    .stat-circle-text { font-size: 13px; }
}

.stat-circle-bg {
    fill: none;
    stroke: #dde4f0;
    stroke-width: 10;
}

.stat-circle-fg {
    fill: none;
    stroke: rgb(0, 84, 164);
    stroke-width: 10;
    stroke-linecap: butt;
    transition: stroke-dashoffset 0.5s ease;
}

.stat-circle-text {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 11px;
    font-weight: bold;
    fill: #222;
    text-anchor: middle;
    dominant-baseline: middle;
}

.stat-circle-title {
    font-size: 0.78em;
    font-weight: bold;
    text-align: center;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.3;
}

/* ============================
   Podsumowanie — medals
   ============================ */
.medal-section {
    padding: 1em;
    background: #fff;
}

.medal-filter-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 1em;
}

.medal-filter-select {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.85em;
    padding: 0.4em 0.6em;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.medal-filter-select:focus {
    border-color: rgb(0, 84, 164);
    box-shadow: 0 0 0 2px rgba(0, 84, 164, 0.15);
}

.medal-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 270px));
    gap: 1em;
    justify-content: center;
}

.medal-box {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 0.75em 1em;
    background: #fafafa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.medal-box-title {
    font-size: 0.78em;
    font-weight: bold;
    color: #333;
    margin-bottom: 0.6em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.3;
    text-align: center;
}

.medal-items {
    display: flex;
    gap: 0.75em;
    align-items: flex-end;
    justify-content: center;
}

.medal-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2em;
}

.medal-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.medal-count {
    font-size: 0.95em;
    font-weight: bold;
    color: #222;
}

/* ============================
   Statystyki section
   ============================ */
.stats-table-wrap {
    padding: 1em;
    background: #fff;
    overflow-x: auto;
    border-bottom: 1px solid #e8e8e8;
}

.stats-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85em;
}

.stats-table th,
.stats-table td {
    border: 1px solid #ddd;
    padding: 0.4em 0.7em;
    text-align: center;
    white-space: nowrap;
}

.stats-table th {
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-weight: bold;
}

.stats-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.stats-table tbody tr:hover {
    background-color: rgba(0, 84, 164, 0.05);
}

.stats-table-total td {
    font-weight: bold;
    background-color: #dce6f4 !important;
}

.stats-table small {
    font-size: 0.82em;
    color: #666;
    margin-left: 0.2em;
}

.stats-chart-wrap {
    padding: 1em;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
}

@media (min-width: 768px) {
    .stats-chart-wrap canvas {
        width: 80% !important;
        display: block;
        margin: 0 auto;
    }
}

/* ============================
   Pojedynki — archer matches list
   ============================ */
.archer-match-list {
    display: flex;
    flex-direction: column;
    background: #fff;
}

.archer-match-card {
    display: grid;
    grid-template-columns: 9em 1fr 1fr;
    align-items: center;
    gap: 1em;
    padding: 0.75em 0.75em;
    border-bottom: 1px solid #e0e0e0;
}

/* Column 1 — score + badge */
.archer-match-col1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35em;
    text-align: center;
}

.archer-match-phase {
    font-size: 0.78em;
    font-weight: bold;
    color: rgb(0, 84, 164);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.archer-match-score {
    font-size: 1em;
    font-weight: bold;
    white-space: nowrap;
}

.archer-match-win,
.archer-match-loss {
    min-width: 6em;
    padding: 0.3em 0.75em;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
    white-space: nowrap;
    text-align: center;
}

.archer-match-win  { background-color: #2e7d32; color: #fff; }
.archer-match-loss { background-color: #c62828; color: #fff; }

/* Column 2 — opponent */
.archer-match-col2 {
    display: flex;
    align-items: center;
    gap: 0.75em;
    min-width: 0;
}

.archer-match-opp-photo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid lightgrey;
    object-fit: cover;
    object-position: top;
    flex-shrink: 0;
}

.archer-match-opp-name {
    font-size: 0.88em;
    min-width: 0;
}

.archer-match-opp-link {
    color: inherit;
    text-decoration: none;
}

.archer-match-opp-link:hover {
    text-decoration: underline;
}

/* Column 3 — tournament */
.archer-match-col3 {
    display: flex;
    align-items: center;
    gap: 0.75em;
    min-width: 0;
}

.archer-match-tour-logo {
    flex-shrink: 0;
    width: 60px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.archer-match-tour-logo img {
    max-width: 60px;
    max-height: 48px;
    object-fit: contain;
}

.archer-match-tour-info {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
    min-width: 0;
    font-size: 0.85em;
}

.archer-match-tour-name {
    font-weight: bold;
    line-height: 1.3;
}

.archer-match-tour-link {
    color: inherit;
    text-decoration: none;
}

.archer-match-tour-link:hover {
    text-decoration: underline;
}

.archer-match-tour-place {
    display: flex;
    align-items: center;
    gap: 0.35em;
    color: #444;
}

.archer-match-tour-flag {
    height: 14px;
    width: auto;
    border-radius: 2px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.archer-match-tour-date {
    color: #666;
}

@media (max-width: 640px) {
    .archer-match-card {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }

    .archer-match-col1 {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .archer-match-col3 {
        grid-column: 1 / -1;
    }
}

/* ============================
   Zawody — archer competition list
   ============================ */
.archer-comp-list {
    display: flex;
    flex-direction: column;
    background: #fff;
}

.archer-comp-card {
    border-bottom: 1px solid #e0e0e0;
}

.archer-comp-header {
    display: flex;
    align-items: stretch;
    gap: 1em;
    padding: 0.75em 0.5em;
}

.archer-comp-left {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex: 0 0 260px;
    min-width: 0;
}

.archer-comp-logo {
    flex-shrink: 0;
    width: 70px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.archer-comp-logo img {
    max-width: 70px;
    max-height: 55px;
    object-fit: contain;
}

.archer-comp-info {
    display: flex;
    flex-direction: column;
    gap: 0.2em;
    min-width: 0;
}

.archer-comp-name {
    font-weight: bold;
    font-size: 0.9em;
    line-height: 1.3;
}

.archer-comp-name a {
    color: inherit;
    text-decoration: none;
}

.archer-comp-name a:hover {
    text-decoration: underline;
}

.archer-comp-place {
    display: flex;
    align-items: center;
    gap: 0.35em;
    font-size: 0.82em;
    color: #444;
}

.archer-comp-flag {
    height: 16px;
    width: auto;
    border-radius: 2px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.archer-comp-date {
    font-size: 0.82em;
    color: #666;
}

.archer-comp-events-list {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    min-width: 0;
}

.archer-comp-ev {
    display: flex;
    flex-direction: column;
    gap: 0.1em;
    font-size: 0.83em;
    border-left: 3px solid rgb(0, 84, 164);
    padding-left: 0.5em;
}

.archer-comp-ev-name {
    font-weight: bold;
}

.archer-comp-ev-rank {
    color: #333;
}

.archer-comp-ev-qual {
    color: #555;
}

.archer-comp-expand-btn {
    flex-shrink: 0;
    align-self: center;
    background: none;
    border: 1px solid rgb(0, 84, 164);
    color: rgb(0, 84, 164);
    border-radius: 50%;
    width: 1.8em;
    height: 1.8em;
    font-size: 0.85em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background-color 0.15s;
}

.archer-comp-expand-btn:hover {
    background-color: rgba(0, 84, 164, 0.1);
}

/* Details expand area */
.archer-comp-details {
    display: none;
    border-top: 1px solid #d0d8e8;
    background-color: #f4f7fb;
}

.archer-comp-details.open {
    display: block;
    margin-left: 10%;
    width: fit-content;
    max-width: 90%;
    padding: 0.5em 1em;
}

.archer-comp-event-detail {
    border-bottom: 2px solid rgb(0, 84, 164);
    margin: 0 auto 0.5em;
    max-width: 90%;
}

.archer-comp-detail-bar {
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-size: 0.85em;
    font-weight: bold;
    padding: 0.4em 0.75em;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.archer-comp-detail-bar--event {
    background-color: #003d7a;
    font-size: 0.9em;
}

.archer-comp-detail-content {
    padding: 0.5em 0.75em;
    overflow-x: auto;
}

/* Qual table */
.archer-comp-qual-wrap {
    overflow-x: auto;
}

.archer-comp-qual-table {
    border-collapse: collapse;
    font-size: 0.83em;
    width: auto;
}

.archer-comp-qual-table th,
.archer-comp-qual-table td {
    border: 1px solid #ccc;
    padding: 0.3em 0.5em;
    text-align: center;
    white-space: nowrap;
    min-width: 2.5em;
}

.archer-comp-qual-table th {
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-weight: bold;
}

.archer-comp-qual-rank {
    font-size: 0.82em;
    color: #555;
}

/* Matches */
.archer-comp-matches {
    display: grid;
    grid-template-columns: 3em 1fr 7em auto;
    align-items: center;
    column-gap: 0.75em;
}

.archer-comp-match {
    display: contents;
}

.archer-comp-match > * {
    padding: 0.35em 0;
    border-bottom: 1px solid #e4e8f0;
    font-size: 0.85em;
}

.archer-comp-match-phase {
    font-weight: bold;
    color: rgb(0, 84, 164);
    text-align: center;
}

.archer-comp-match-players {
    min-width: 0;
}

.archer-comp-win,
.archer-comp-loss {
    min-width: 6em;
    padding: 0.3em 0.75em;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: bold;
    white-space: nowrap;
    text-align: center;
}

.archer-comp-win {
    background-color: #2e7d32;
    color: #fff;
}

.archer-comp-loss {
    background-color: #c62828;
    color: #fff;
}

.archer-comp-match-score {
    font-weight: bold;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .archer-comp-header {
        flex-wrap: wrap;
    }

    .archer-comp-left {
        flex: 0 0 100%;
    }

    .archer-comp-events-list {
        flex: 0 0 100%;
    }

    .archer-comp-expand-btn {
        margin-left: auto;
    }
}

/* ============================
   Tournament Data page
   ============================ */
.tournament-data-page {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

/* --- Banner --- */
.tour-banner {
    width: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgb(0, 84, 164);
    /* Fallback color if image missing */
    min-height: 160px;
    position: relative;
    overflow: hidden;
    /* Pull out of .content padding to go full width */
    margin: -1em -1em 0 -1em;
    width: calc(100% + 2em);
}

.tour-banner-inner {
    display: flex;
    align-items: center;
    gap: 1.5em;
    padding: 1.5em 2em;
    background: linear-gradient(to right, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.3) 100%);
    min-height: 160px;
}

.tour-banner-logo {
    flex-shrink: 0;
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tour-banner-logo img {
    max-width: 90px;
    max-height: 90px;
    object-fit: contain;
}

.tour-banner-info {
    display: flex;
    flex-direction: column;
    gap: 0.35em;
    color: #fff;
    min-width: 0;
}

.tour-banner-name {
    font-size: 1.4em;
    font-weight: bold;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.tour-banner-dates {
    font-size: 0.95em;
    opacity: 0.9;
}

.tour-banner-place {
    display: flex;
    align-items: center;
    gap: 0.5em;
    font-size: 0.95em;
    opacity: 0.9;
}

.tour-banner-flag {
    height: 20px;
    width: auto;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}

/* --- Filters --- */
.tour-data-filters {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1em;
    flex-wrap: wrap;
    padding: 0.75em 0;
    border-bottom: 1px solid #ddd;
}



/* --- Results table-like cards --- */
.tour-data-table {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.tour-data-table--narrow {
    width: fit-content;
    min-width: 320px;
    margin: 0 auto;
}

.tour-data-header,
.tour-data-row {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5em 0.4em;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.88em;
}

.tour-data-header {
    font-weight: bold;
    background-color: rgb(0, 84, 164);
    color: #fff;
    border-bottom: none;
    border-radius: 3px 3px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.tour-data-row:nth-child(even) {
    background-color: #f9f9f9;
}

.tour-data-row:hover {
    background-color: rgba(0, 84, 164, 0.06);
}

/* Column widths */
.col-rank    { flex: 0 0 2.5em;  text-align: center; }
.col-name    { flex: 2 1 160px;  min-width: 0; }
.col-club    { flex: 2 1 160px;  min-width: 0; display: flex; align-items: center; gap: 0.4em; }
.col-score   { flex: 0 0 4em;    text-align: right; }
.col-tb      { flex: 0 0 3.5em;  text-align: right; }
.col-dist    { flex: 0 0 4.5em;  text-align: right; }
.col-details { flex: 0 0 2em;    text-align: center; }
.col-members { flex: 1 1 100px;  min-width: 0; }
.col-scores  { flex: 0 1 40px;  min-width: 0; }

.col-club img {
    height: 20px;
    width: auto;
    border-radius: 2px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.col-members-block {
    display: flex;
    flex-direction: column;
    gap: 0.1em;
    font-size: 0.9em;
}

/* Details expand button */
.details-btn {
    background: none;
    border: 1px solid rgb(0, 84, 164);
    color: rgb(0, 84, 164);
    border-radius: 50%;
    width: 1.6em;
    height: 1.6em;
    font-size: 0.9em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.details-btn:hover {
    background-color: rgba(0, 84, 164, 0.1);
}

/* Qual detail table */
.qual-detail-wrap {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 1em;
    padding: 0.5em 0.4em 1em 0.4em;
    background-color: #f0f4fa;
    border-bottom: 2px solid rgb(0, 84, 164);
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s ease;
}

.qual-detail-table {
    border-collapse: collapse;
    font-size: 0.82em;
    width: auto;
    margin-top: 0.5em;
    margin-bottom: 0;
    flex-shrink: 0;
}

.qual-detail-table th,
.qual-detail-table td {
    border: 1px solid #ccc;
    padding: 0.25em 0.4em;
    text-align: center;
    white-space: nowrap;
    min-width: 2em;
}

.qual-detail-table .col-wide {
    min-width: 3.5em;
}

.qual-detail-table th {
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-weight: bold;
}

.qual-detail-table .row-end-num {
    font-weight: bold;
    background-color: #e8eef8;
}

.qual-detail-table .row-total td {
    font-weight: bold;
    background-color: #dce6f4;
}

/* ============================
   Club Data page
   ============================ */
.club-data-page {
    display: flex;
    flex-direction: column;
}

.club-banner-flag {
    height: 80px;
    width: auto;
    border-radius: 8px;
    border: 2px solid lightgrey;
    flex-shrink: 0;
    object-fit: cover;
}

/* Club competitions */
.club-comp-results-summary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3em;
    flex: 1 1 0;
    padding: 0 0.5em;
    font-size: 0.85em;
}

.club-comp-result-line {
    color: #333;
}

.club-comp-medals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em;
    align-items: center;
    margin-top: 0.2em;
}

.club-comp-medal-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85em;
    font-weight: bold;
}

.club-comp-medal-icon {
    height: 24px;
    width: auto;
}

.club-comp-event-section {
    margin-bottom: 0.5em;
}

.club-comp-event-header {
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-weight: bold;
    font-size: 0.85em;
    padding: 0.35em 0.7em;
}

.club-comp-event-results {
    border: 1px solid #e0e0e0;
    border-top: none;
}

.club-comp-result-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5em;
    padding: 0.35em 0.7em;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85em;
}

@media (min-width: 768px) {
    .club-comp-result-row {
        flex-wrap: nowrap;
    }

    .club-comp-res-name {
        min-width: 0;
    }
}

.club-comp-result-row:last-child {
    border-bottom: none;
}

.club-comp-res-rank {
    min-width: 2em;
    font-weight: bold;
    color: rgb(0, 84, 164);
    flex-shrink: 0;
}

.club-comp-res-name {
    flex: 2 1 200px;
}

.club-comp-res-name a {
    color: inherit;
    text-decoration: none;
}

.club-comp-res-name a:hover {
    text-decoration: underline;
}

.club-comp-res-team {
    flex: 1 1 120px;
    color: #555;
    font-size: 0.9em;
}

.club-comp-res-qual {
    color: #555;
    font-size: 0.9em;
    flex-shrink: 0;
}

.club-stats-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    justify-content: center;
    padding: 1em;
}

.club-stats-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    padding: 1.2em 2em;
    flex: 1 1 140px;
    max-width: 220px;
    min-width: 140px;
}

.club-stats-value {
    font-size: 2em;
    font-weight: bold;
    color: rgb(0, 84, 164);
}

.club-stats-desc {
    font-size: 0.85em;
    font-weight: bold;
    text-transform: uppercase;
    color: #555;
    margin-top: 0.3em;
    text-align: center;
}

/* ============================
   Bracket page
   ============================ */
.bracket-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.88em;
}

.bracket-table thead th {
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-weight: bold;
    padding: 0.4em 0.6em;
    text-align: center;
    white-space: nowrap;
}

.bracket-row td {
    padding: 0.45em 0.6em;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.bracket-row:hover td {
    background-color: rgba(0, 84, 164, 0.05);
}

.bracket-phase {
    font-weight: bold;
    color: rgb(0, 84, 164);
    font-size: 0.9em;
    text-align: center;
}

.bracket-rank {
    color: #666;
    font-size: 0.85em;
    white-space: nowrap;
    text-align: center;
}

.bracket-athlete {
    min-width: 140px;
}

.bracket-athlete-right {
    text-align: right;
}

.bracket-archer-link {
    color: inherit;
    text-decoration: none;
}

.bracket-archer-link:hover {
    text-decoration: underline;
}

.bracket-country {
    display: flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.82em;
    color: #555;
    margin-top: 0.15em;
}

.bracket-athlete-right .bracket-country {
    justify-content: flex-end;
}

.bracket-flag {
    height: 16px;
    width: auto;
    border-radius: 2px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.bracket-flag--team {
    height: 28px;
}

.bracket-country--team {
    font-size: 1.15em;
    gap: 0.5em;
}

.bracket-score {
    text-align: center;
    white-space: nowrap;
    min-width: 3em;
}

.bracket-winner {
    color: rgb(0, 84, 164);
}

.bracket-details-cell {
    text-align: center;
    width: 2em;
}

.bracket-phase-sep td {
    padding: 0.4em 0.6em;
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-weight: bold;
    font-size: 0.9em;
}

/* Match detail row */
.match-detail-row td {
    padding: 0.5em 0.4em 1em;
    background-color: #f0f4fa;
    border-bottom: 2px solid rgb(0, 84, 164);
}

.match-detail-table {
    border-collapse: collapse;
    font-size: 0.82em;
    width: 100%;
    margin-top: 0.4em;
}

.match-detail-table th,
.match-detail-table td {
    border: 1px solid #ccc;
    padding: 0.25em 0.4em;
    text-align: center;
    white-space: nowrap;
    min-width: 2em;
}

.match-detail-table th {
    background-color: rgb(0, 84, 164);
    color: #fff;
    font-weight: bold;
}

.match-detail-table .row-end-num {
    font-weight: bold;
    background-color: #e8eef8;
}

.match-avg-row td {
    font-style: italic;
    background-color: #dce6f4;
}

/* Tiebreak sub-table */
.tb-inner-table {
    border-collapse: collapse;
    font-size: 0.9em;
    margin: 0 auto;
}

.tb-inner-table td {
    border: 1px solid #aaa;
    padding: 0.2em 0.4em;
    text-align: center;
}

.tb-label {
    font-weight: bold;
    background-color: #e8eef8;
    font-size: 0.85em;
}

.qual-detail-table .row-mismatch td {
    text-decoration: line-through;
    color: #c00;
    background-color: #fff0f0;
}

/* Mobile: qual individual — hidden by default, shown on mobile */
.qi-mob-club  { display: none; }
.qi-mob-dists { display: none; }

/* Mobile: qual team — hidden by default, shown on mobile */
.qt-mob-members { display: none; }

/* Compact mode (applied via JS when columns don't fit) */
.tour-data-table--qual-ind.tour-data-table--compact .col-club,
.tour-data-table--qual-ind.tour-data-table--compact .col-dist { display: none; }

.tour-data-table--qual-ind.tour-data-table--compact .qi-mob-club {
    display: flex;
    align-items: center;
    gap: 0.3em;
    font-size: 0.85em;
    color: #555;
    margin-top: 0.15em;
}

.tour-data-table--qual-ind.tour-data-table--compact .qi-mob-dists {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em;
    font-size: 0.85em;
    color: #333;
    margin-top: 0.15em;
}

.tour-data-table--qual-team.tour-data-table--compact .col-members,
.tour-data-table--qual-team.tour-data-table--compact .col-scores { display: none; }

.tour-data-table--qual-team.tour-data-table--compact .qt-mob-members {
    display: block;
    font-size: 0.85em;
    color: #555;
    margin-top: 0.15em;
    padding-right: 0.5em;
}

@media (max-width: 600px) {
    /* Qual individual: hide club and dist columns, show inline */
    .tour-data-table--qual-ind .col-club,
    .tour-data-table--qual-ind .col-dist { display: none; }

    .qi-mob-club {
        display: flex;
        align-items: center;
        gap: 0.3em;
        font-size: 0.85em;
        color: #555;
        margin-top: 0.15em;
    }

    .qi-mob-dists {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4em;
        font-size: 0.85em;
        color: #333;
        margin-top: 0.15em;
    }

    .qi-mob-dist {
        white-space: nowrap;
    }

    /* Qual team: hide members/scores columns, show members below club */
    .tour-data-table--qual-team .col-members,
    .tour-data-table--qual-team .col-scores { display: none; }

    .qt-mob-members {
        display: block;
        font-size: 0.85em;
        color: #555;
        margin-top: 0.15em;
        padding-right: 0.5em;
    }

    /* Bracket: reflow into stacked layout */
    .bracket-table,
    .bracket-table tbody { display: block; width: 100%; }

    .bracket-table > thead { display: none; }

    /* Match detail row: restore full-width block so inner table isn't squeezed */
    .match-detail-row,
    .match-detail-row > td { display: block !important; width: 100%; box-sizing: border-box; overflow-x: auto; }

    /* Match detail table: restore proper table layout and shrink font */
    .match-detail-table              { display: table;              font-size: 0.75em; }
    .match-detail-table thead        { display: table-header-group; }
    .match-detail-table tbody        { display: table-row-group;    }
    .match-detail-table tr           { display: table-row;          }
    .match-detail-table th,
    .match-detail-table td           { display: table-cell;         }

    .bracket-phase-sep,
    .bracket-phase-sep td { display: block; }

    .bracket-row {
        display: grid !important;
        grid-template-columns: auto auto 1fr auto auto;
        grid-template-rows: auto auto;
        border-bottom: 2px solid #ccc;
        padding-bottom: 0.4em;
        margin-bottom: 0.4em;
    }

    .bracket-row td { border-bottom: none; }

    /* Phase — col 1, spans both athlete rows */
    .bracket-row td:nth-child(1) { grid-column: 1; grid-row: 1 / 3; align-self: center; min-width: 4em; }
    /* Left rank — row 1, col 2 */
    .bracket-row td:nth-child(2) { grid-column: 2; grid-row: 1; }
    /* Left athlete — row 1, col 3 */
    .bracket-row td:nth-child(3) { grid-column: 3; grid-row: 1; text-align: left; }
    /* Left score — row 1, col 4 */
    .bracket-row td:nth-child(4) { grid-column: 4; grid-row: 1; }
    /* Right score — row 2, col 4 */
    .bracket-row td:nth-child(5) { grid-column: 4; grid-row: 2; }
    /* Right athlete — row 2, col 3 */
    .bracket-row td:nth-child(6) { grid-column: 3; grid-row: 2; text-align: left; }
    /* Right rank — row 2, col 2 */
    .bracket-row td:nth-child(7) { grid-column: 2; grid-row: 2; }
    /* Details — col 5, spans both athlete rows */
    .bracket-row td:nth-child(8) { grid-column: 5; grid-row: 1 / 3; align-self: center; }

    /* Right athlete: override right-align for flag/country on mobile */
    .bracket-row td:nth-child(6) .bracket-country { justify-content: flex-start; }
    .bracket-row td:nth-child(6) .bracket-archer-link { text-align: left; }
}

/* ============================
   Ranking page
   ============================ */
.ranking-page {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.ranking-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    padding: 0.75em 0;
    border-bottom: 1px solid #ddd;
}

.ranking-filters-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75em;
    flex-wrap: wrap;
    width: 100%;
}

.ranking-filters-row--dropdowns .filter-group {
    flex: 1 1 0;
    min-width: 0;
}

.ranking-filters-row--dropdowns .filter-group .filter-input {
    width: 100%;
}

.ranking-filters-row--dropdowns .filter-group--checkbox {
    flex: 0 0 auto;
}

.ranking-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
}

.ranking-filters .filter-group label {
    font-size: 0.78em;
    font-weight: bold;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ranking-filters .filter-group--checkbox {
    flex-direction: column;
    gap: 0.25em;
}

.ranking-filters .filter-group--checkbox label {
    font-size: 0.78em;
    font-weight: bold;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.ranking-filters .filter-group--checkbox input[type="checkbox"] {
    width: 1.5em;
    height: 1.5em;
    cursor: pointer;
    accent-color: rgb(0, 84, 164);
}

.ranking-generate-btn {
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 0.9em;
    font-weight: bold;
    padding: 0.55em 1.2em;
    background-color: rgb(0, 84, 164);
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: background-color 0.15s;
    white-space: nowrap;
}

.ranking-generate-btn:hover {
    background-color: rgb(0, 64, 130);
}

/* Ranking results table */
.ranking-table {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.ranking-row {
    display: grid;
    grid-template-columns: 3em 3fr 3fr 5em;
    align-items: start;
    gap: 0.75em;
    padding: 0.6em 0.4em;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.88em;
}

.ranking-row:nth-child(even) {
    background-color: #f9f9f9;
}

.ranking-row:hover {
    background-color: rgba(0, 84, 164, 0.06);
}

.ranking-cell {
    min-width: 0;
    line-height: 1.4;
}

.ranking-cell--rank {
    text-align: center;
    font-size: 1.05em;
}

.ranking-cell--score {
    text-align: right;
    font-size: 1.05em;
}

.ranking-cell a {
    color: inherit;
    text-decoration: none;
}

.ranking-cell a:hover {
    text-decoration: underline;
}

.ranking-flag {
    height: 16px;
    width: auto;
    border-radius: 2px;
    border: 1px solid #ccc;
    vertical-align: middle;
    margin-right: 0.25em;
}

.ranking-loading,
.ranking-empty,
.ranking-error {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-top: 2em;
}

.ranking-error {
    color: #c62828;
}

@media (max-width: 640px) {
    .ranking-filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ranking-filters-row .filter-group,
    .ranking-filters-row--dropdowns .filter-group,
    .ranking-filters-row--dropdowns .filter-group--checkbox {
        flex: 1 1 auto;
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .ranking-filters .filter-group label {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .ranking-filters .filter-group .filter-input,
    .ranking-filters .filter-group input[type="checkbox"] {
        flex: 0 0 50%;
        width: 50%;
        box-sizing: border-box;
    }

    .ranking-filters-row--dropdowns .filter-group .filter-input {
        width: 50%;
    }

    .ranking-row {
        grid-template-columns: 2.5em 1fr 4em;
        grid-template-rows: auto auto;
    }

    .ranking-cell--rank  { grid-column: 1; grid-row: 1 / 3; align-self: center; }
    .ranking-cell--archer { grid-column: 2; grid-row: 1; }
    .ranking-cell--tour   { grid-column: 2; grid-row: 2; }
    .ranking-cell--score  { grid-column: 3; grid-row: 1 / 3; align-self: center; text-align: right; }
}

/* ============================
   National team page
   ============================ */
.col-licence    { flex: 0 0 7em;  text-align: center; }
.col-birthyear  { flex: 0 0 5em;  text-align: center; }

.nt-row .col-name a,
.nt-row .col-club a {
    color: inherit;
    text-decoration: none;
}

.nt-row .col-name a:hover,
.nt-row .col-club a:hover {
    text-decoration: underline;
}

.nt-row .col-club a {
    display: flex;
    align-items: center;
    gap: 0.4em;
    min-width: 0;
}

/* Expandable details area under each row */
.nt-details {
    display: none;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f4f7fb;
}

.nt-details.open {
    display: block;
    padding: 0.5em 1em;
}

.nt-details-msg {
    color: #666;
    font-style: italic;
    padding: 0.5em 0;
}

.nt-comp-card {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    align-items: center;
    gap: 1em;
    padding: 0.6em 0;
    border-bottom: 1px solid #e0e0e0;
}

.nt-comp-card:last-child {
    border-bottom: none;
}

.nt-comp-score {
    font-size: 1.1em;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 700px) {
    .nt-row .col-licence,
    .nt-row .col-birthyear { display: none; }
}

@media (max-width: 640px) {
    .nt-comp-card {
        grid-template-columns: 60px 1fr;
    }

    .nt-comp-score {
        grid-column: 1 / -1;
        text-align: left;
    }
}

/* ============================
   Creator page
   ============================ */
.creator-section {
    margin-bottom: 1.5em;
}

.creator-page h2 {
    margin-top: 2.5em;
    padding-top: 1em;
    border-top: 2px solid rgb(0, 84, 164);
}

.creator-section-cols {
    display: flex;
    gap: 2em;
    align-items: flex-start;
}

.creator-section-text {
    flex: 1;
}

.creator-section-img {
    flex: 0 0 50%;
}

.creator-section-img img {
    width: 100%;
    height: auto;
    display: block;
}

@media (max-width: 767px) {
    .creator-section-cols {
        flex-direction: column;
    }

    .creator-section-img {
        flex: none;
        width: 80%;
        margin: 0 auto;
    }
}

/* ============================
   Homepage
   ============================ */
.home-page {
    background: #fff;
}

