/*
 * PBN Results — modern default stylesheet
 *
 * All rules are scoped under `.pbn-results` so the stylesheet can be dropped
 * into any host page without bleeding into surrounding markup.
 *
 * Theming: override any of the `--pbn-*` custom properties below on
 * `.pbn-results` (or a parent) to recolor or restyle.
 */

.pbn-results {
    --pbn-fg: #1f2937;
    --pbn-muted: #6b7280;
    --pbn-bg: #ffffff;
    --pbn-row-alt: #f7f8fa;
    --pbn-hover: #eef2ff;
    --pbn-border: #e5e7eb;
    --pbn-border-strong: #d1d5db;
    --pbn-accent: #1d4ed8;
    --pbn-accent-contrast: #ffffff;
    --pbn-me: #065f46;
    --pbn-opp: #b91c1c;
    --pbn-suit-spade: #000000;
    --pbn-suit-heart: #e32b1f;
    --pbn-suit-diamond: #e18f00;
    --pbn-suit-club: #008000;
    --pbn-radius: 8px;
    --pbn-pad: 10px 12px;
    --pbn-pad-tight: 6px 10px;

    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 15px;
    line-height: 1.4;
    color: var(--pbn-fg);
    background: var(--pbn-bg);
}

/* ------------------------------------------------------------------ */
/* Topbar — view toggle (Resultat/Bricka) + board pagination           */

.pbn-topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0 0 12px;
}

.pbn-topbar .pbn-nav,
.pbn-topbar .pbn-mode-toggle,
.pbn-topbar .pbn-sort-toggle,
.pbn-topbar .pbn-session-sort-toggle {
    margin: 0;
}

/* PDF download link — sits inline after the other topbar controls */
.pbn-pdf-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border: 1px solid var(--pbn-border-strong);
    border-radius: var(--pbn-radius);
    background: var(--pbn-bg);
    color: var(--pbn-fg);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.pbn-pdf-link:hover {
    background: var(--pbn-accent);
    color: var(--pbn-accent-contrast);
}

.pbn-pdf-link:focus-visible {
    outline: 2px solid var(--pbn-accent);
    outline-offset: -2px;
}

/* Secondary navigation line below the ranking topbar: session nav and the
   Total/Omgång + HCP/Scratch toggles flowing together (no "Sortering" label). */
.pbn-subbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0 0 12px;
}

.pbn-subbar .pbn-session-nav,
.pbn-subbar .pbn-session-sort-toggle,
.pbn-subbar .pbn-mode-toggle {
    margin: 0;
}

.pbn-view-toggle {
    display: inline-flex;
    border: 1px solid var(--pbn-border-strong);
    border-radius: var(--pbn-radius);
    overflow: hidden;
    background: var(--pbn-bg);
}

.pbn-view-toggle__btn {
    padding: 8px 18px;
    background: var(--pbn-bg);
    color: var(--pbn-fg);
    border: none;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.pbn-view-toggle__btn + .pbn-view-toggle__btn {
    border-left: 1px solid var(--pbn-border-strong);
}

.pbn-view-toggle__btn:hover:not(.pbn-view-toggle__btn--active) {
    background: var(--pbn-hover);
}

.pbn-view-toggle__btn:focus-visible {
    outline: 2px solid var(--pbn-accent);
    outline-offset: -2px;
}

.pbn-view-toggle__btn--active {
    background: var(--pbn-accent);
    color: var(--pbn-accent-contrast);
    cursor: default;
}

/* ------------------------------------------------------------------ */
/* Toggle group — wraps a toggle nav with a leading label              */

.pbn-toggle-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pbn-toggle-label {
    font-weight: 600;
    color: var(--pbn-muted);
}

/* ------------------------------------------------------------------ */
/* HCP / Scratch mode toggle (above summary on ranking view)           */
/* Total / Omgång session-sort toggle (multi-session ranking view)     */

.pbn-mode-toggle,
.pbn-session-sort-toggle {
    display: inline-flex;
    margin: 0 0 12px;
    border: 1px solid var(--pbn-border-strong);
    border-radius: var(--pbn-radius);
    overflow: hidden;
    background: var(--pbn-bg);
}

.pbn-mode-toggle__btn,
.pbn-session-sort-toggle__btn {
    padding: 6px 16px;
    background: var(--pbn-bg);
    color: var(--pbn-fg);
    border: none;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.pbn-mode-toggle__btn + .pbn-mode-toggle__btn,
.pbn-session-sort-toggle__btn + .pbn-session-sort-toggle__btn {
    border-left: 1px solid var(--pbn-border-strong);
}

.pbn-mode-toggle__btn:hover:not(.pbn-mode-toggle__btn--active),
.pbn-session-sort-toggle__btn:hover:not(.pbn-session-sort-toggle__btn--active) {
    background: var(--pbn-hover);
}

.pbn-mode-toggle__btn:focus-visible,
.pbn-session-sort-toggle__btn:focus-visible {
    outline: 2px solid var(--pbn-accent);
    outline-offset: -2px;
}

.pbn-mode-toggle__btn--active,
.pbn-session-sort-toggle__btn--active {
    background: var(--pbn-accent);
    color: var(--pbn-accent-contrast);
    cursor: default;
}

/* ------------------------------------------------------------------ */
/* Bricka / Rond sort toggle (pair-detail view)                        */

.pbn-sort-toggle {
    display: inline-flex;
    margin: 0 0 12px;
    border: 1px solid var(--pbn-border-strong);
    border-radius: var(--pbn-radius);
    overflow: hidden;
    background: var(--pbn-bg);
}

.pbn-sort-toggle__btn {
    padding: 6px 16px;
    background: var(--pbn-bg);
    color: var(--pbn-fg);
    border: none;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.pbn-sort-toggle__btn + .pbn-sort-toggle__btn {
    border-left: 1px solid var(--pbn-border-strong);
}

.pbn-sort-toggle__btn:hover:not(.pbn-sort-toggle__btn--active) {
    background: var(--pbn-hover);
}

.pbn-sort-toggle__btn:focus-visible {
    outline: 2px solid var(--pbn-accent);
    outline-offset: -2px;
}

.pbn-sort-toggle__btn--active {
    background: var(--pbn-accent);
    color: var(--pbn-accent-contrast);
    cursor: default;
}

/* ------------------------------------------------------------------ */
/* Session nav (multi-session competitions, below the topbar)          */

.pbn-session-nav {
    display: inline-flex;
    flex-wrap: wrap;
    margin: 0 0 12px;
    border: 1px solid var(--pbn-border-strong);
    border-radius: var(--pbn-radius);
    overflow: hidden;
    background: var(--pbn-bg);
}

.pbn-session-nav__btn {
    padding: 6px 14px;
    background: var(--pbn-bg);
    color: var(--pbn-fg);
    border: none;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.pbn-session-nav__btn + .pbn-session-nav__btn {
    border-left: 1px solid var(--pbn-border-strong);
}

.pbn-session-nav__btn:hover:not(.pbn-session-nav__btn--active) {
    background: var(--pbn-hover);
}

.pbn-session-nav__btn:focus-visible {
    outline: 2px solid var(--pbn-accent);
    outline-offset: -2px;
}

.pbn-session-nav__btn--active {
    background: var(--pbn-accent);
    color: var(--pbn-accent-contrast);
    cursor: default;
}

/* ------------------------------------------------------------------ */
/* Summary heading (above ranking)                                     */

.pbn-summary {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--pbn-border);
    border-radius: var(--pbn-radius);
    background: var(--pbn-row-alt);
}

.pbn-summary__row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 24px;
    align-items: baseline;
}

.pbn-summary__row--top {
    justify-content: space-between;
    font-size: 0.95em;
    color: var(--pbn-muted);
    margin-bottom: 4px;
}

.pbn-summary__row--top > * {
    flex: 0 1 auto;
}

.pbn-summary__row--top > *:nth-child(2) {
    text-align: center;
    flex-grow: 1;
}

.pbn-summary__row--top > *:last-child {
    text-align: right;
}

.pbn-summary__row--bottom {
    justify-content: center;
    text-align: center;
    gap: 2px 24px;
    color: var(--pbn-fg);
}

.pbn-summary__format {
    font-weight: 500;
}

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

@media (max-width: 600px) {
    .pbn-summary__row--top > * {
        flex: 1 1 100%;
        text-align: left;
    }
    .pbn-summary__row--top > *:nth-child(2),
    .pbn-summary__row--top > *:last-child {
        text-align: left;
    }
}

/* ------------------------------------------------------------------ */
/* Tables — shared                                                     */

.pbn-results table {
    width: 100%;
    border-collapse: collapse;
    background: var(--pbn-bg);
}

.pbn-results thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--pbn-bg);
    color: var(--pbn-fg);
    font-weight: 600;
    text-align: left;
    padding: var(--pbn-pad);
    box-shadow: inset 0 -2px 0 var(--pbn-accent);
    white-space: nowrap;
}

.pbn-results tbody td {
    padding: var(--pbn-pad);
    border-bottom: 1px solid var(--pbn-border);
    vertical-align: middle;
}

.pbn-results tbody tr:nth-child(even) td {
    background: var(--pbn-row-alt);
}

.pbn-results tbody tr.pbn-clickable {
    cursor: pointer;
    transition: background-color 0.1s ease-in-out;
}

.pbn-results tbody tr.pbn-clickable:hover td,
.pbn-results tbody tr.pbn-clickable:focus-within td {
    background: var(--pbn-hover);
}

.pbn-results tbody tr:last-child td {
    border-bottom: none;
}

/* Numeric cells use tabular figures so columns line up */
.pbn-results .pbn-num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* Score and percent columns center their header and values */
.pbn-results .pbn-col-score,
.pbn-results .pbn-col-acc,
.pbn-results .pbn-col-perc,
.pbn-results .pbn-col-single-perc,
.pbn-results .pbn-col-acc-perc,
.pbn-results .pbn-col-percent-combined {
    text-align: center;
}

/* ------------------------------------------------------------------ */
/* Ranking table                                                       */

.pbn-ranking {
    border: 1px solid var(--pbn-border);
    border-radius: var(--pbn-radius);
}

.pbn-ranking .pbn-col-rank {
    text-align: center;
    font-weight: 600;
    width: 3em;
    white-space: nowrap;
}

/* Per-session rank shown in parentheses after the total rank in the "Total"
   sort of a multi-session ranking. Muted and lighter so the total rank stays
   the primary value. */
.pbn-rank-session {
    color: var(--pbn-muted);
    font-weight: 400;
    font-size: 0.9em;
}

.pbn-ranking .pbn-col-names,
.pbn-ranking .pbn-col-club {
    text-align: left;
}

/* Separate table with just the highlighted rows, rendered above the full
   ranking (or board results) via data-highlight-position="above". */
.pbn-ranking--highlight,
.pbn-board-results--highlight {
    margin-bottom: 1.5rem;
}

/* Highlighted pair (data-highlight-mid): a tinted row, used in both the ranking
   table and the board-results table (the row the matched pair played). */
.pbn-row--mid td {
    background: var(--pbn-hover) !important;
    box-shadow: inset 3px 0 0 0 var(--pbn-accent);
    font-weight: 600;
}

/* Stacked name/club rendering via separator spans */
.pbn-names,
.pbn-clubs {
    display: inline;
}

.pbn-names__sep,
.pbn-clubs__sep {
    color: var(--pbn-muted);
}

.pbn-names__br,
.pbn-clubs__br {
    display: none;
}

/* ------------------------------------------------------------------ */
/* Detail view (per-pair round-by-round)                               */

.pbn-detail {
    border: 1px solid var(--pbn-border);
    border-radius: var(--pbn-radius);
    margin-top: 16px;
}

.pbn-detail__round td {
    background: var(--pbn-row-alt) !important;
    font-weight: 600;
    color: var(--pbn-muted);
    padding: var(--pbn-pad);
    border-top: 1px solid var(--pbn-border-strong);
    border-bottom: 1px solid var(--pbn-border-strong);
    text-align: left !important;
    white-space: normal;
}

.pbn-detail tbody tr.pbn-clickable td {
    background: var(--pbn-bg);
}

.pbn-detail__round:first-child td {
    border-top: none;
}

.pbn-detail .pbn-col-board {
    text-align: center;
    font-weight: 600;
    width: 3em;
}

.pbn-detail .pbn-col-contract,
.pbn-detail .pbn-col-declarer,
.pbn-detail .pbn-col-lead {
    text-align: center;
    white-space: nowrap;
}

.pbn-detail .pbn-col-result {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pbn-detail .pbn-col-result .pbn-half-left,
.pbn-detail .pbn-col-result .pbn-half-right {
    display: inline-block;
    width: 30%;
    box-sizing: border-box;
    text-align: right;
}

.pbn-detail .pbn-col-result .pbn-half--filled {
    width: 70%;
}

.pbn-detail .pbn-col-result .pbn-half-left {
    padding-right: 6px;
}

.pbn-detail .pbn-col-result .pbn-half-right {
    padding-left: 6px;
}

/* Walkover / frirond: single centred label, no 70/30 split */
.pbn-results .pbn-col-result .pbn-frirond {
    display: inline-block;
    width: 100%;
    text-align: center;
    color: var(--pbn-muted);
    font-style: italic;
}

.pbn-detail .pbn-half--me {
    color: var(--pbn-opp);
    font-weight: 600;
}

.pbn-detail__declarer--me {
    color: var(--pbn-opp);
    font-weight: 600;
}

.pbn-detail .pbn-col-hand {
    font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo,
        monospace;
    font-size: 0.92em;
    color: var(--pbn-muted);
    white-space: nowrap;
}

.pbn-detail .pbn-col-hand__line {
    display: inline-block;
}

.pbn-detail .pbn-col-hand__line + .pbn-col-hand__line {
    margin-left: 14px;
}

/* ------------------------------------------------------------------ */
/* Board view                                                          */

.pbn-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.pbn-nav__btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: var(--pbn-bg);
    color: var(--pbn-fg);
    border: 1px solid var(--pbn-border-strong);
    border-radius: var(--pbn-radius);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.1s, border-color 0.1s;
}

.pbn-nav__btn:hover:not(:disabled):not(.disabled) {
    background: var(--pbn-hover);
    border-color: var(--pbn-accent);
}

.pbn-nav__btn:focus-visible {
    outline: 2px solid var(--pbn-accent);
    outline-offset: 2px;
}

.pbn-nav__btn--primary {
    background: var(--pbn-accent);
    color: var(--pbn-accent-contrast);
    border-color: var(--pbn-accent);
}

.pbn-nav__btn--primary:hover:not(:disabled):not(.disabled) {
    background: var(--pbn-fg);
    border-color: var(--pbn-fg);
    color: var(--pbn-accent-contrast);
}

.pbn-nav__btn:disabled,
.pbn-nav__btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pbn-hint {
    display: block;
    color: var(--pbn-muted);
    font-size: 0.9em;
    margin: 8px 0;
}

/* Hand diagram — CSS grid */
.pbn-board {
    display: grid;
    grid-template-columns: auto auto auto;
    justify-content: center;
    grid-template-areas:
        "meta north  opt "
        "west info   east"
        ".    south  dd  ";
    gap: 12px;
    padding: 16px;
    margin: 12px 0;
    border: 1px solid var(--pbn-border);
    border-radius: var(--pbn-radius);
    background: var(--pbn-bg);
    font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo,
        monospace;
}

.pbn-board__meta {
    grid-area: meta;
    justify-self: start;
    align-self: start;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 6px 10px;
    border: 1px solid var(--pbn-border-strong);
    border-radius: 6px;
    background: var(--pbn-row-alt);
    font-family: system-ui, sans-serif;
    font-size: 0.85em;
    line-height: 1.2;
    white-space: nowrap;
}

.pbn-board__meta-line {
    color: var(--pbn-fg);
}

.pbn-board__meta-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pbn-muted);
    margin-right: 4px;
}

.pbn-board__optimum {
    grid-area: opt;
    justify-self: end;
    align-self: start;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding: 6px 10px;
    border: 1px solid var(--pbn-border-strong);
    border-radius: 6px;
    background: var(--pbn-row-alt);
    font-family: system-ui, sans-serif;
    font-size: 0.85em;
    line-height: 1.2;
    white-space: nowrap;
}

.pbn-board__optimum-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pbn-muted);
}

.pbn-board__optimum-row {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    white-space: nowrap;
}

.pbn-board__optimum-contract {
    font-weight: 600;
    color: var(--pbn-fg);
}

.pbn-board__optimum-score {
    font-variant-numeric: tabular-nums;
    color: var(--pbn-accent);
    font-weight: 600;
}

/* Double-dummy result table (PBN OptimumResultTable) */
.pbn-dd {
    grid-area: dd;
    justify-self: end;
    align-self: end;
    display: flex;
    justify-content: flex-end;
    zoom: 0.9;
}

.pbn-dd__table {
    display: grid;
    grid-template-columns: auto repeat(5, minmax(2.4em, auto));
    border: 1px solid var(--pbn-border-strong);
    border-radius: 6px;
    overflow: hidden;
    background: var(--pbn-row-alt);
    font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo,
        monospace;
    font-size: 0.9em;
    font-variant-numeric: tabular-nums;
}

.pbn-dd__row {
    display: contents;
}

.pbn-dd__cell {
    padding: 3px 8px;
    text-align: center;
    border-right: 1px solid var(--pbn-border);
    border-bottom: 1px solid var(--pbn-border);
}

.pbn-dd__row > .pbn-dd__cell:last-child {
    border-right: none;
}

.pbn-dd__table > .pbn-dd__row:last-child > .pbn-dd__cell {
    border-bottom: none;
}

.pbn-dd__cell--corner,
.pbn-dd__cell--head,
.pbn-dd__cell--label {
    background: var(--pbn-bg);
    font-weight: 600;
    color: var(--pbn-muted);
}

.pbn-hand {
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--pbn-row-alt);
    line-height: 1.6;
    white-space: nowrap;
    text-align: left;
}

.pbn-hand__suit {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.pbn-hand__suit-sym {
    display: inline-block;
    min-width: 1em;
    text-align: center;
}

.pbn-hand__suit-cards {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.pbn-hand--n {
    grid-area: north;
    justify-self: center;
}
.pbn-hand--e {
    grid-area: east;
    justify-self: start;
    align-self: center;
}
.pbn-hand--s {
    grid-area: south;
    justify-self: center;
}
.pbn-hand--w {
    grid-area: west;
    justify-self: end;
    align-self: center;
}

.pbn-board__info {
    grid-area: info;
    justify-self: center;
    align-self: center;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    grid-template-areas:
        ".  n  ."
        "w  c  e"
        ".  s  .";
    place-items: center;
    width: 140px;
    aspect-ratio: 1 / 1;
    padding: 8px;
    border: 1px solid var(--pbn-border-strong);
    border-radius: var(--pbn-radius);
    background: var(--pbn-bg);
    text-align: center;
    font-family: system-ui, sans-serif;
}

.pbn-board__info-num {
    grid-area: c;
    font-size: 1.6em;
    font-weight: 700;
    color: var(--pbn-accent);
}

.pbn-board__info-dir {
    font-size: 0.85em;
    color: var(--pbn-muted);
}
.pbn-board__info-dir--n { grid-area: n; }
.pbn-board__info-dir--e { grid-area: e; writing-mode: vertical-rl; }
.pbn-board__info-dir--s { grid-area: s; }
.pbn-board__info-dir--w { grid-area: w; writing-mode: vertical-rl; }

.pbn-board__info-dir.dealer {
    font-weight: 700;
    text-transform: uppercase;
}

.pbn-board__info-dir.vulnerable {
    color: var(--pbn-opp);
    font-weight: 600;
}

/* Board results table */
.pbn-board-results {
    border: 1px solid var(--pbn-border);
    border-radius: var(--pbn-radius);
}

.pbn-all-boards {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-top: 16px;
}

.pbn-all-boards__section {
    scroll-margin-top: 64px;
}

.pbn-all-boards__heading {
    margin: 0 0 8px;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--pbn-fg);
    border-bottom: 1px solid var(--pbn-border);
    padding-bottom: 4px;
}

.pbn-board-results .pbn-col-contract,
.pbn-board-results .pbn-col-declarer,
.pbn-board-results .pbn-col-lead {
    text-align: center;
    white-space: nowrap;
}

.pbn-board-results .pbn-half-left,
.pbn-board-results .pbn-half-right {
    display: inline-block;
    width: 50%;
    box-sizing: border-box;
    text-align: right;
}

.pbn-board-results .pbn-half-left {
    padding-right: 6px;
}

.pbn-board-results .pbn-half-right {
    padding-left: 6px;
}

/* Result column: give the half holding the score 70% (other columns stay 50/50) */
.pbn-board-results .pbn-col-result .pbn-half-left,
.pbn-board-results .pbn-col-result .pbn-half-right {
    width: 30%;
}

.pbn-board-results .pbn-col-result .pbn-half--filled {
    width: 70%;
}

.pbn-player-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--pbn-accent);
    cursor: pointer;
    font: inherit;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pbn-player-link:hover,
.pbn-player-link:focus-visible {
    color: var(--pbn-fg);
}

/* Player name linked to that player's own page (data-player-link-base) */
.pbn-name-link {
    color: var(--pbn-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pbn-name-link:hover,
.pbn-name-link:focus-visible {
    color: var(--pbn-fg);
}

.pbn-dde-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed var(--pbn-muted);
}

.pbn-dde-link:hover,
.pbn-dde-link:focus-visible {
    color: var(--pbn-accent);
    border-bottom-color: var(--pbn-accent);
}

/* ------------------------------------------------------------------ */
/* Suit symbols                                                        */

/*
 * Suits are inline SVGs (see SUITS in pbn-results.js). A single fixed size
 * keeps all four identical; colour flows in via `currentColor` from the
 * per-suit colour rules below. Tune --pbn-suit-size to scale every suit.
 */
.pbn-results {
    --pbn-suit-size: 0.95em;
}

.pbn-results .pbn-suit-icon {
    width: var(--pbn-suit-size);
    height: var(--pbn-suit-size);
    vertical-align: -0.13em;
}

.pbn-results .suit_S {
    color: var(--pbn-suit-spade);
}

.pbn-results .suit_H {
    color: var(--pbn-suit-heart);
}

.pbn-results .suit_D {
    color: var(--pbn-suit-diamond);
}

.pbn-results .suit_C {
    color: var(--pbn-suit-club);
}

/* ------------------------------------------------------------------ */
/* Loading / error states                                              */

.pbn-results__loading,
.pbn-results__error {
    padding: 20px;
    border-radius: var(--pbn-radius);
    text-align: center;
}

.pbn-results__loading {
    color: var(--pbn-muted);
    background: var(--pbn-row-alt);
    border: 1px solid var(--pbn-border);
}

.pbn-results__error {
    text-align: left;
    color: #7f1d1d;
    background: #fef2f2;
    border: 1px solid #fca5a5;
}

/* Competition exists but no result has been reported yet (HTTP 404) */
.pbn-results__not-reported {
    padding: 24px 20px;
    border-radius: var(--pbn-radius);
    text-align: center;
    background: var(--pbn-row-alt);
    border: 1px solid var(--pbn-border);
}

.pbn-results__not-reported p {
    margin: 6px 0;
}

.pbn-not-reported__title {
    margin: 0 0 12px;
    font-size: 1.2em;
    color: var(--pbn-muted);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */

/* Medium screens: stack names/clubs inside a cell */
@media (max-width: 768px) {
    .pbn-results {
        font-size: 14px;
    }

    .pbn-names__sep,
    .pbn-clubs__sep {
        display: none;
    }

    .pbn-names__br,
    .pbn-clubs__br {
        display: inline;
    }
}

/* Medium screens: stack the own/partner hands in their shared column */
@media (max-width: 1024px) {
    .pbn-detail .pbn-col-hand__line {
        display: block;
    }

    .pbn-detail .pbn-col-hand__line + .pbn-col-hand__line {
        margin-left: 0;
    }
}

/* Narrow screens: hide lower-priority columns */
@media (max-width: 640px) {
    .pbn-results thead th,
    .pbn-results tbody td {
        padding: var(--pbn-pad-tight);
    }

    .pbn-col-hcp,
    .pbn-col-club,
    .pbn-detail .pbn-col-hand {
        display: none;
    }
}

@media (max-width: 480px) {
    /* The ranking's % column stays: with Hcp and Klubb already gone above,
       Plac / Poäng / % / Namn fits a phone. Only the per-board percentages,
       which share space with contract and score columns, drop out. */
    .pbn-detail .pbn-col-single-perc,
    .pbn-detail .pbn-col-acc-perc,
    .pbn-board-results .pbn-col-percent-combined {
        display: none;
    }

    /* Compact the hand diagram so the compass (West / North / East / South
       around the centre square) keeps its cross layout on phones instead of
       stacking: smaller centre square, tighter gap and padding. The meta,
       optimum and double-dummy boxes move out of the corners into a single
       centred stack below the compass. */
    .pbn-board {
        gap: 6px;
        padding: 8px;
        grid-template-areas:
            ".    north  .   "
            "west info   east"
            ".    south  .   "
            "meta meta   meta"
            "opt  opt    opt "
            "dd   dd     dd  ";
    }

    .pbn-board__info {
        width: 100px;
        padding: 6px;
    }

    .pbn-board__meta,
    .pbn-board__optimum,
    .pbn-dd {
        justify-self: center;
        align-self: center;
    }
}

/* Only on the narrowest screens does the diagram stack into a single column;
   tables get horizontal scroll. */
@media (max-width: 360px) {
    .pbn-results {
        overflow-x: auto;
    }

    .pbn-board {
        grid-template-columns: 1fr;
        grid-template-areas:
            "info"
            "meta"
            "opt"
            "north"
            "west"
            "east"
            "south"
            "dd";
    }

    .pbn-hand--n,
    .pbn-hand--e,
    .pbn-hand--s,
    .pbn-hand--w {
        justify-self: stretch;
    }

    .pbn-board__info,
    .pbn-board__meta,
    .pbn-board__optimum,
    .pbn-dd {
        justify-self: center;
    }
}

