/* Player Rankings (under Public Data). Uses the colour/spacing variables from index.css, and duplicates a few
   small shared bits (page head, filter fields, credit line) per this codebase's per-page-CSS convention. */

.pr-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 56px var(--pad) 96px;
}

.page-head { margin-bottom: 28px; text-align: center; }

.eyebrow {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary);
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.01em;
    text-align: center;
}

.page-lead { margin: 10px auto 0; max-width: 640px; text-align: center; color: var(--text-dim); }

.notice--error {
    padding: 12px 16px;
    margin-bottom: 16px;
    background: rgba(255, 122, 122, 0.08);
    border: 1px solid rgba(255, 122, 122, 0.35);
    border-radius: var(--radius-sm);
    color: #ff7a7a;
    font-size: 14px;
    font-weight: 600;
}

/* ---------- filters ---------- */

.pr-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 24px;
}

.fld { display: flex; flex-direction: column; gap: 4px; }

.fld > span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.pr-filters select,
.pr-filters input {
    padding: 7px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color-scheme: dark;
    font-size: 13px;
}

.pr-search input { min-width: 190px; }
.pr-share .export-actions { margin: 0; }

/* ---------- tiles ---------- */

.pr-tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.pr-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 16px 8px 14px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
}

.pr-tile strong { font-family: var(--font-display); font-size: 32px; font-weight: 400; line-height: 1.1; color: var(--primary); }

.pr-tile span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* ---------- cards + layout ---------- */

.pr-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.pr-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.pr-card {
    min-width: 0;
    padding: 18px 18px 16px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.pr-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 14px;
}

.pr-card-head h3 {
    margin-right: auto;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.pr-card-actions { display: inline-flex; align-items: center; gap: 8px; }
/* (only the small "Download image" buttons in a card's heading: the one up with Share / embed is a normal small button like its neighbours) */
.pr-card-actions .pr-dl { padding: 5px 10px; font-size: 12px; }

.pr-note {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.pr-hint { margin-top: 12px; font-size: 11.5px; line-height: 1.5; color: var(--text-muted); }
.pr-empty { padding: 24px 0; text-align: center; }
.pr-more { display: flex; justify-content: center; margin-top: 12px; }

/* ---------- leaderboard ---------- */

.pr-board-wrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

.pr-board { width: 100%; border-collapse: collapse; font-size: 13px; }

.pr-board th {
    padding: 0 5px 8px;
    border-bottom: 1px solid var(--border-strong);
    text-align: left;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.pr-board td { padding: 7px 5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.pr-board tr:last-child td { border-bottom: 0; }
.pr-board .pr-c { text-align: center; }

.pr-row { cursor: pointer; transition: background var(--fast) var(--ease); }
.pr-row:hover, .pr-row:focus-visible { background: var(--surface-2); outline: none; }

.pr-pos { width: 34px; font-family: var(--font-display); font-size: 15px; color: var(--text-muted); }

.pr-player { display: flex; flex-direction: column; min-width: 0; max-width: 175px; }

.pr-player-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 0.01em;
}

.pr-player-name .flag { display: inline-block; height: 11px; width: auto; margin-right: 2px; vertical-align: baseline; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12); }
.pr-player-name .flag-code { margin-right: 2px; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: 4px; font-family: var(--font-body, inherit); font-size: 9px; color: var(--text-dim); }

.pr-player-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    color: var(--text-muted);
}

.pr-team { max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); font-size: 12px; }

/* the rank, in the ranks' own colours */
.pr-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 112px;
    padding: 3px 10px 3px 6px;
    border-radius: 99px;
    color: #14120a;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* the rank pictures are not square: they are fitted inside the box */
.pr-pill-icon { flex: none; width: 24px; height: 20px; object-fit: contain; }
.pr-pill--xl .pr-pill-icon { width: 44px; height: 36px; }

.pr-pill--est { border: 1px dashed rgba(20, 18, 10, 0.55); padding-top: 3px; padding-bottom: 3px; }

.pr-pill--xl { padding: 8px 22px; font-size: 16px; min-width: 150px; }

.pr-points strong { font-size: 14px; font-weight: 800; }
.pr-points sup { margin-left: 1px; color: var(--text-muted); }

.pr-delta { font-size: 11px; font-weight: 800; }
.pr-delta--up { color: #78d66f; }
.pr-delta--down { color: #ff7a7a; }
.pr-delta--0 { color: var(--text-muted); }

.pr-form { display: inline-flex; gap: 2px; }

.pr-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 3px;
    border-radius: 6px;
    font-style: normal;
    font-size: 9.5px;
    font-weight: 800;
    color: #0b1006;
    cursor: default;
}

.pr-chip--gold { background: #f2c14e; }
.pr-chip--top { background: #78d66f; }
.pr-chip--mid { background: #8db7d9; }
.pr-chip--low { background: #5b6477; color: #dfe5ef; }

/* ---------- players by rank ---------- */

.pr-rankbars { display: flex; align-items: stretch; gap: 6px; height: 240px; }

.pr-rankbar {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    cursor: pointer;
    border-radius: 6px;
    outline: none;
}

.pr-rankbar i {
    display: block;
    width: 100%;
    max-height: calc(100% - 74px);
    border-radius: 6px 6px 3px 3px;
    opacity: 0.8;
    transition: opacity var(--fast) var(--ease);
}

.pr-rankbar:hover i, .pr-rankbar.is-on i, .pr-rankbar:focus-visible i { opacity: 1; }
.pr-rankbar.is-on { box-shadow: 0 0 0 2px var(--primary); }

.pr-rankbar-icon { flex: none; width: 100%; max-width: 38px; height: 30px; object-fit: contain; }
.pr-ladder-icon { width: 24px; height: 20px; margin-right: 6px; vertical-align: middle; object-fit: contain; }

.pr-rankbar-n { height: 14px; font-size: 10.5px; font-weight: 700; color: var(--text-dim); }

.pr-rankbar-l {
    height: 14px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ---------- how it works ---------- */

.pr-how { margin: 0 0 14px; padding-left: 18px; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); }
.pr-how li { margin-bottom: 8px; }
.pr-how b { color: var(--text); }

.pr-ladder { display: flex; flex-direction: column; gap: 5px; padding-top: 12px; border-top: 1px solid var(--border); }
.pr-ladder-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 11.5px; }
.pr-ladder-name { font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; font-size: 10.5px; }
.pr-ladder-steps { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-muted); }
.pr-ladder-step b { color: var(--text-dim); }

/* ---------- a player ---------- */

.pr-dialog {
    width: min(760px, calc(100vw - 24px));
    /* (a phone browser's 100vh is taller than what is shown, with its address bar: the top of the popup was cut off and could not be scrolled to;
       dvh is the visible height) */
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.pr-dialog::backdrop { background: rgba(4, 6, 10, 0.72); }
.pr-dialog-body { padding: 22px 22px 20px; }

.pr-dhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.pr-dactions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.pr-dname { font-family: var(--font-display); font-size: 28px; font-weight: 400; line-height: 1.1; }
.pr-dsub { margin-top: 4px; font-size: 12px; color: var(--text-muted); }

.pr-drank {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px 16px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.pr-drank-points { display: flex; flex-direction: column; line-height: 1.15; }
.pr-drank-points strong { font-family: var(--font-display); font-size: 30px; font-weight: 400; }
.pr-drank-points span { font-size: 11px; color: var(--text-muted); }

.pr-progress { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.pr-progress i { display: block; height: 100%; border-radius: 99px; }
.pr-progress-text { grid-column: 1 / -1; font-size: 11px; color: var(--text-muted); }

.pr-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.pr-stat { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pr-stat strong { font-family: var(--font-display); font-size: 22px; font-weight: 400; }
.pr-stat span { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }

.pr-dgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; margin-bottom: 16px; }
.pr-dbox { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }

.pr-dbox h4, .pr-hist-title-h {
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.pr-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 12px; margin: 0; font-size: 12.5px; }
.pr-facts dt { color: var(--text-muted); }
.pr-facts dd { margin: 0; font-weight: 700; text-align: right; }
.pr-source { margin-top: 10px; font-size: 11px; line-height: 1.45; color: var(--text-muted); }

.pr-line-wrap { position: relative; padding-left: 38px; }
.pr-line { display: block; width: 100%; height: 130px; }
.pr-line-max, .pr-line-min { position: absolute; left: 0; font-size: 10px; color: var(--text-muted); }
.pr-line-max { top: 2px; }
.pr-line-min { bottom: 2px; }

.pr-hist { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

.pr-hist-row {
    padding: 6px 10px 7px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: background var(--fast) var(--ease);
}

.pr-hist-row:hover { background: var(--surface-3); }

/* the tournament itself: a link to it on the Matcherinos page */
.pr-hist-link {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 84px 58px 14px;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.pr-hist-link:hover .pr-hist-title { color: var(--primary); text-decoration: underline; }
.pr-hist-go { color: var(--text-muted); font-size: 12px; }
.pr-hist-date { color: var(--text-muted); font-size: 11px; line-height: 1.3; }
.pr-hist-date small { display: block; font-size: 10px; opacity: 0.8; }
.pr-hist-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pr-hist-place { white-space: nowrap; color: var(--text-muted); }
.pr-hist-place b { color: var(--text); }
.pr-hist-change { text-align: right; }

.pr-hist-facts { margin: 3px 0 0 62px; font-size: 10.5px; color: var(--text-muted); }

/* each match they played in it: round, result, what it moved */
.pr-matches { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 0 62px; }

.pr-match {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--surface-3);
    border-left: 3px solid var(--border-strong);
    font-size: 10.5px;
    cursor: default;
}

.pr-match i { font-style: normal; color: var(--text-muted); font-weight: 700; }
.pr-match b { font-weight: 800; }
.pr-match em { font-style: normal; font-weight: 700; color: var(--text-dim); }
.pr-match--w { border-left-color: #78d66f; }
.pr-match--w b { color: #8fdc86; }
.pr-match--l { border-left-color: #e06060; }
.pr-match--l b { color: #ff8f8f; }
.pr-match.is-upset { background: rgba(120, 214, 111, 0.14); }
.pr-match.is-bad { background: rgba(224, 96, 96, 0.14); }

.pr-dfoot { margin-top: 14px; text-align: right; font-size: 12.5px; font-weight: 700; }
.pr-dfoot a { color: var(--primary); }

.h2h-credit {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- smaller screens ---------- */

/* side by side only where the leaderboard has room for all its columns */
@media (max-width: 1279px) {
    .pr-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .pr-page { padding-top: 36px; }
    .pr-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .pr-card { padding: 14px 12px 12px; }
    .pr-hide-m { display: none; }
    .pr-pill { min-width: 98px; padding: 2px 7px 2px 4px; font-size: 9px; letter-spacing: 0.03em; gap: 3px; }
    .pr-pill-icon { width: 18px; height: 15px; }
    .pr-player { max-width: 120px; }
    .pr-board th, .pr-board td { padding-inline: 4px; }
    .pr-pos { width: 24px; }
    .pr-player-name { font-size: 15px; }
    .pr-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .pr-dgrid { grid-template-columns: minmax(0, 1fr); }
    .pr-drank { grid-template-columns: minmax(0, 1fr); justify-items: start; }
    .pr-hist-link { grid-template-columns: 46px minmax(0, 1fr) 62px 48px 12px; gap: 6px; }
    /* (a tournament's name wraps - two lines at most - instead of being cut to its first dozen letters) */
    .pr-hist-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow-wrap: anywhere; }
    .pr-matches, .pr-hist-facts { margin-left: 0; }
    .pr-dialog-body { padding: 16px 14px; }
    .pr-search input { min-width: 150px; }
}

/* a narrow phone: the name takes the whole row, and where they placed and what it moved go under it (beside it the name was left a few letters) */
@media (max-width: 420px) {
    .pr-hist-link { grid-template-columns: 40px minmax(0, 1fr) auto 12px; row-gap: 2px; }
    .pr-hist-date { grid-row: 1 / 3; align-self: start; }
    .pr-hist-title { grid-column: 2 / 4; }
    .pr-hist-place { grid-column: 2; grid-row: 2; }
    .pr-hist-change { grid-column: 3; grid-row: 2; }
    .pr-hist-go { grid-column: 4; grid-row: 1; }
}

/* a player who is on a team's roster here: photo, country, age, team and links (the Teams page's card) */
.pp-reg {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin: 4px 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
}
.pp-reg-photo { flex-shrink: 0; width: 64px; height: 64px; border-radius: 12px; object-fit: cover; object-position: top center; background: var(--surface-3); }
.pp-reg-photo.is-placeholder { object-fit: contain; padding: 10px; opacity: 0.7; }
.pp-reg-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pp-reg-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pp-reg-line b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.pp-reg-real { font-size: 12px; color: var(--text-dim); }
.pp-reg-team { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; font-weight: 700; }
.pp-reg-logo { flex-shrink: 0; width: 20px; height: 20px; object-fit: contain; }
.pp-reg-logo.is-placeholder { opacity: 0.6; }
.pp-reg-teamname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-reg-region { flex-shrink: 0; padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--region, var(--text-muted)) 20%, transparent); color: var(--region, var(--text-dim)); font-size: 10.5px; font-weight: 800; }
.pp-reg-socials { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; }
.pp-reg-sep { width: 1px; height: 14px; background: var(--border-strong); }
.pp-reg .social { display: inline-flex; color: var(--text-dim); }
.pp-reg .social svg { width: 16px; height: 16px; }
.pp-reg .social:hover { color: var(--primary); }
.pp-reg .flag { flex-shrink: 0; height: 12px; width: auto; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12); }
.pp-reg .flag-code { padding: 0 5px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 10px; color: var(--text-dim); }

/* a phone: each filter takes the full width instead of floating centred at its own width */
@media (max-width: 560px) {
    .pr-filters { gap: 10px; }
    .pr-filters .fld { flex: 1 1 calc(50% - 5px); min-width: 0; }
    .pr-filters .fld:has(input) { flex-basis: 100%; }
    /* (the buttons - Share / embed + Download, Compare - keep their own width and sit in centred rows, not squeezed into half a column each) */
    .pr-filters .fld.pr-share { flex: 0 1 auto; }
    .pr-filters select, .pr-filters input { width: 100%; max-width: none; }
    /* the leaderboard (#, player, rank, points) fits a phone's width with nothing to scroll sideways */
    .pr-pill { min-width: 84px; }
    .pr-player { max-width: clamp(108px, calc(100vw - 262px), 240px); } /* (a wider phone gives the name the room it has: "BIG | Melih..." was cut at 108px on every phone) */
    .pr-card { padding-inline: 8px; }
    /* (it scrolls sideways if a very narrow screen - 320px - still cannot hold the last column: hidden, that column was cut off for good) */
    .pr-board-wrap { overflow-x: auto; }
}
@media (max-width: 360px) {
    .pr-pill { min-width: 70px; }
    .pr-player { max-width: 84px; }
}
