/* ── GOAT · Who is the King of Football? ─────────────────────────────────────
   One stylesheet for the whole site. No frameworks, no build step.        */

:root {
  --gold:        #d8b46a;
  --gold-soft:   #f0d9a5;
  --magic:       #7aa2f7;
  --worldcup:    #6fcf97;
  --emotion:     #e07a9b;

  --bg:          #0c0d11;
  --bg-2:        #12141a;
  --panel:       #161923;
  --panel-2:     #1c202c;
  --line:        #262b38;
  --line-soft:   #1e2230;

  --text:        #e8e9ee;
  --text-2:      #a7adbe;
  --text-3:      #6d7488;

  --danger:      #e2685f;
  --warn:        #e0a95f;

  --radius:      12px;
  --radius-sm:   8px;
  --maxw:        1500px;
  --serif:       "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans:        ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  --mono:        ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow:      0 18px 50px rgba(0, 0, 0, .45);
}

:root[data-theme="light"] {
  --bg:        #f6f4ef;
  --bg-2:      #efece4;
  --panel:     #ffffff;
  --panel-2:   #f7f5f0;
  --line:      #ded8ca;
  --line-soft: #e9e4d9;
  --text:      #1b1c22;
  --text-2:    #565c6b;
  --text-3:    #838a9c;
  --gold:      #9a7526;
  --gold-soft: #7d5f1d;
  --magic:     #3f61b8;
  --worldcup:  #24855a;
  --emotion:   #b34a70;
  --shadow:    0 14px 40px rgba(60, 50, 30, .12);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 12% -12%, rgba(216, 180, 106, .07), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(122, 162, 247, .05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .2px; margin: 0 0 .4em; }
h1 { font-size: 2rem; line-height: 1.15; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px 80px; }
.narrow { max-width: 860px; }

/* ── header ─────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.site-header .bar {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 22px;
  padding: 12px 22px;
}
.brand { display: flex; align-items: baseline; gap: 10px; font-family: var(--serif); }
.brand b { font-size: 1.05rem; letter-spacing: .5px; color: var(--text); font-weight: 600; }
.brand span { font-size: .78rem; color: var(--text-3); letter-spacing: .09em; text-transform: uppercase; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  color: var(--text-2); padding: 7px 13px; border-radius: 999px;
  font-size: .87rem; border: 1px solid transparent;
}
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a.active { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 35%, transparent); background: color-mix(in srgb, var(--gold) 9%, transparent); }
.nav .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-left: 6px; vertical-align: middle; }

.icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--text-2);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: .95rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--gold); }

/* ── hero ───────────────────────────────────────────────────────────────── */

.hero { padding: 44px 0 26px; }
.hero .kicker {
  font-size: .74rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 12px;
}
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); max-width: 17ch; }
.hero p { color: var(--text-2); max-width: 68ch; font-size: 1.02rem; }

.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; margin: 26px 0 8px; }
.podium-card {
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; gap: 14px; align-items: center;
  position: relative; overflow: hidden;
}
.podium-card::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(var(--gold), transparent);
}
.podium-card .pos { font-family: var(--serif); font-size: 1.5rem; color: var(--gold); min-width: 1.4ch; }
.podium-card .who { font-weight: 600; }
.podium-card .score { font-family: var(--mono); color: var(--text-2); font-size: .85rem; }

/* ── panels / toolbar ───────────────────────────────────────────────────── */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head .spacer { margin-left: auto; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0 14px; }

input[type="text"], input[type="search"], input[type="number"], select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 11px; border-radius: var(--radius-sm); font: inherit; font-size: .9rem;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }
input[type="number"] { width: 92px; font-family: var(--mono); }
.search { min-width: 240px; flex: 0 1 320px; }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 15px; border-radius: var(--radius-sm); font: inherit; font-size: .88rem;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #17130a; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); color: #17130a; }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.solid-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.solid-danger:hover { filter: brightness(1.07); color: #fff; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: .8rem; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  background: var(--panel-2); border: 0; color: var(--text-2); font: inherit; font-size: .85rem;
  padding: 8px 13px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold-soft); }

.chk { display: inline-flex; align-items: center; gap: 7px; font-size: .87rem; color: var(--text-2); cursor: pointer; user-select: none; }
.chk input { accent-color: var(--gold); width: 15px; height: 15px; }

/* iOS-style on/off switch. The real checkbox stays in the DOM (keyboard + a11y)
 * and is only visually replaced by the track/knob. */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px;
  background: var(--line); border: 1px solid var(--line); transition: background .16s ease;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .35);
  transition: transform .16s ease;
}
.switch input:checked + .track { background: var(--worldcup); border-color: var(--worldcup); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch .switch-label { font-size: .85rem; color: var(--text-2); }

/* ── table ──────────────────────────────────────────────────────────────── */

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .875rem; }
table.data th, table.data td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
table.data th:first-child, table.data td:first-child,
table.data th.left, table.data td.left { text-align: left; }
table.data thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel-2); color: var(--text-2);
  font-weight: 600; font-size: .72rem; letter-spacing: .07em; text-transform: uppercase;
  cursor: pointer; user-select: none; border-bottom: 1px solid var(--line);
}
table.data thead th:hover { color: var(--gold); }
table.data thead th .arrow { color: var(--gold); font-size: .7rem; margin-left: 4px; }
table.data thead th.group-magic    { box-shadow: inset 0 2px 0 var(--magic); }
table.data thead th.group-worldcup { box-shadow: inset 0 2px 0 var(--worldcup); }
table.data thead th.group-emotion  { box-shadow: inset 0 2px 0 var(--emotion); }
table.data thead th.group-final    { box-shadow: inset 0 2px 0 var(--gold); }
table.data tbody tr:hover { background: color-mix(in srgb, var(--gold) 5%, transparent); }
table.data tbody tr.selected { background: color-mix(in srgb, var(--gold) 10%, transparent); }
table.data tbody tr.unscorable td { color: var(--text-3); }
table.data td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data td.final { font-family: var(--mono); font-weight: 600; color: var(--gold-soft); }
table.data .rank { color: var(--text-3); font-family: var(--mono); width: 46px; }
table.data .rank.top1 { color: var(--gold); }
.col-check { width: 38px; }

.player-cell { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: grid; place-items: center;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em; color: #10121a;
  font-family: var(--sans);
  position: relative; overflow: hidden;
}
/* the portrait covers the initials; if it 404s the <img> removes itself */
.avatar img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: inherit;
}
.avatar.lg { width: 62px; height: 62px; flex-basis: 62px; font-size: 1.15rem; }
.avatar.board { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--gold); }
.player-name { font-weight: 500; }
.player-name a { color: var(--text); }
.player-name a:hover { color: var(--gold); }

.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.mini-bar { width: 54px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; flex: 0 0 54px; }
.mini-bar i { display: block; height: 100%; border-radius: 3px; }
.mini-bar.magic i    { background: var(--magic); }
.mini-bar.worldcup i { background: var(--worldcup); }
.mini-bar.emotion i  { background: var(--emotion); }
.mini-bar.final i    { background: var(--gold); }

/* ── badges ─────────────────────────────────────────────────────────────── */

.tag {
  display: inline-block; font-size: .68rem; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--text-3); background: var(--panel-2); vertical-align: middle;
}
.tag.board   { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.tag.active  { color: var(--worldcup); border-color: color-mix(in srgb, var(--worldcup) 35%, transparent); }
.tag.warn    { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.tag.edited  { color: var(--magic); border-color: color-mix(in srgb, var(--magic) 40%, transparent); }
.tag.t1 { color: var(--emotion); border-color: color-mix(in srgb, var(--emotion) 40%, transparent); }
.tag.t2 { color: var(--text-2); }
.tag.t3 { color: var(--text-3); }

.hint { color: var(--text-3); font-size: .82rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.notice {
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: .87rem; color: var(--text-2);
  margin-bottom: 14px;
}
.notice b { color: var(--warn); }
.notice.info { border-color: color-mix(in srgb, var(--magic) 35%, transparent); background: color-mix(in srgb, var(--magic) 8%, transparent); }
.notice.info b { color: var(--magic); }

/* ── compare tray ───────────────────────────────────────────────────────── */

.tray {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%);
  background: var(--panel); border: 1px solid var(--gold); box-shadow: var(--shadow);
  border-radius: 999px; padding: 9px 10px 9px 18px;
  display: flex; align-items: center; gap: 14px; z-index: 60;
  transition: transform .22s ease;
}
.tray.show { transform: translate(-50%, 0); }
.tray .who { display: flex; gap: 7px; align-items: center; }
.tray .pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: .82rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px 3px 10px;
}
.tray .pill button { background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: .95rem; line-height: 1; padding: 0 2px; }
.tray .pill button:hover { color: var(--danger); }
.tray .tray-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin-right: 4px; flex: 0 0 auto;
  background: none; border: 0; border-radius: 999px;
  color: var(--text-3); cursor: pointer; font-size: 1.15rem; line-height: 1;
}
.tray .tray-close:hover { background: var(--panel-2); color: var(--danger); }

/* ── compare page ───────────────────────────────────────────────────────── */

.cmp-grid { display: grid; gap: 16px; }
.cmp-head { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cmp-card {
  background: linear-gradient(165deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center;
}
.cmp-card .avatar { margin: 0 auto 10px; }
.cmp-card .final { font-family: var(--mono); font-size: 1.9rem; color: var(--gold); }
.cmp-card.winner { border-color: var(--gold); box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 40%, transparent); }

.factor-row { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.factor-row:last-child { border-bottom: 0; }
.factor-row .label { font-size: .8rem; letter-spacing: .07em; text-transform: uppercase; color: var(--text-2); }
.factor-bars { display: grid; gap: 7px; }
.fbar { display: grid; grid-template-columns: 130px 1fr 74px; gap: 10px; align-items: center; font-size: .85rem; }
.fbar .track { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.fbar .track i { display: block; height: 100%; border-radius: 6px; }
.fbar .val { font-family: var(--mono); text-align: right; color: var(--text-2); }
.fbar.lead .val { color: var(--gold-soft); font-weight: 600; }

/* ── config page ────────────────────────────────────────────────────────── */

.cfg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
/* The rail itself is what sticks — a sticky element can only travel inside its
 * own parent's box, so pinning the panel while its wrapper hugged it left it
 * nowhere to go. The wrapper stretches to the row, so the board rides the scroll. */
.cfg-rail { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; }
.cfg-side { position: static; }
.field { display: grid; grid-template-columns: 1fr 108px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.field:last-child { border-bottom: 0; }
.field .name { font-size: .9rem; }
.field .name small { display: block; color: var(--text-3); font-size: .77rem; }
.field.slider { grid-template-columns: 1fr 150px 84px; }
input[type="range"] { accent-color: var(--gold); width: 100%; }

/* ── customised values ──────────────────────────────────────────────────────
 * A value the user moved off the official database wears the site's gold accent
 * — the same "this one is yours" signal as .btn.primary and the active nav. It
 * never collides with the three factor colours (blue / green / pink). */
.field.changed {
  background: color-mix(in srgb, var(--gold) 7%, transparent);
  box-shadow: inset 3px 0 0 var(--gold);
  padding-left: 11px; padding-right: 11px; margin: 0 -11px;
}
.field.changed .name { font-weight: 600; }
.field.changed input[type="text"], .field.changed input[type="number"] {
  border-color: var(--gold); color: var(--gold-soft);
}
tr.changed > td { background: color-mix(in srgb, var(--gold) 7%, transparent); }
tr.changed input[type="number"] { border-color: var(--gold); color: var(--gold-soft); }

/* Inline "put this one back" control, small enough to live inside a <small>. */
.undo {
  background: none; border: 0; padding: 0; margin-left: 7px; font: inherit; font-size: inherit;
  color: var(--gold); cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.undo:hover { color: var(--gold-soft); }

/* ── confirmation modal ─────────────────────────────────────────────────────
 * A <dialog>, so the backdrop, focus trap and Esc key are the platform's job. */
dialog.modal {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--panel); color: var(--text);
  box-shadow: var(--shadow); max-width: 430px; width: calc(100% - 32px);
}
dialog.modal::backdrop { background: rgb(0 0 0 / .58); backdrop-filter: blur(3px); }
dialog.modal .modal-body { padding: 22px 24px 18px; }
dialog.modal h3 { margin: 0 0 9px; font-size: 1.1rem; }
dialog.modal p { margin: 0 0 20px; color: var(--text-2); font-size: .9rem; line-height: 1.6; }
dialog.modal p b { color: var(--text); }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

dialog.modal.lightbox { max-width: 520px; }
dialog.modal.lightbox .modal-body { position: relative; padding: 16px 16px 14px; }
dialog.modal.lightbox img {
  display: block; width: 100%; height: auto; border-radius: var(--radius-sm);
  background: var(--panel-2);
}
dialog.modal.lightbox h3 { margin: 13px 0 4px; }
dialog.modal.lightbox p { margin: 0; }
.lightbox-close {
  position: absolute; top: 25px; right: 25px; z-index: 1;
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 1.2rem; line-height: 1;
  display: grid; place-items: center;
}
.lightbox-close:hover { background: rgb(0 0 0 / .78); }

/* the hero portrait on a player page is a button that opens the lightbox */
.avatar-zoom { background: none; border: 0; padding: 0; display: inline-flex; cursor: zoom-in; }
.avatar-zoom:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 50%; }

@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
dialog.modal[open] { animation: modal-in .17s cubic-bezier(.2, .8, .3, 1); }
dialog.modal[open]::backdrop { animation: backdrop-in .17s ease-out; }
@media (prefers-reduced-motion: reduce) {
  dialog.modal[open], dialog.modal[open]::backdrop { animation: none; }
}

/* Sticky running total of everything the user has changed, with the global reset. */
.cfg-status {
  position: sticky; top: 72px; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid color-mix(in srgb, var(--gold) 42%, transparent);
  background: color-mix(in srgb, var(--gold) 13%, var(--panel));
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; font-size: .87rem;
}
.cfg-status .spacer { margin-left: auto; }
.cfg-status b { color: var(--gold-soft); }
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.mini-list { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mini-list.tall { max-height: 520px; } /* 70 editions, and each row is two lines deep */
.mini-list table { width: 100%; }

/* ── the Ballon d'Or record ─────────────────────────────────────────────────
 * A podium place is a removable chip, and the empty slot at the end of each cell
 * is where the next name goes; cells wrap, since a podium can be shared.
 * Fixed layout, or a cell's chip + its "+ add" box would refuse to wrap and the
 * three podium columns would each grow to their widest name. */
table.data.bdo-table { table-layout: fixed; width: 100%; min-width: 640px; }
table.data.bdo-table td { white-space: normal; vertical-align: top; }
table.data.bdo-table th:first-child, table.data.bdo-table td:first-child { width: 78px; }
table.data.bdo-table th:last-child, table.data.bdo-table td:last-child { width: 94px; padding-left: 4px; }
table.data.bdo-table thead th .hint { font-size: .66rem; letter-spacing: 0; text-transform: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; margin: 2px 4px 2px 0;
  padding: 3px 5px 3px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel-2); font-size: .8rem; max-width: 100%;
}
.chip a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip a:hover { color: var(--gold); }
.chip .x {
  background: none; border: 0; padding: 0 3px; cursor: pointer; line-height: 1;
  color: var(--text-3); font-size: .95rem;
}
.chip .x:hover { color: var(--danger); }
tr.changed .chip { border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
input.bdo-add {
  width: 66px; padding: 4px 8px; font-size: .76rem; margin: 2px 0;
  background: transparent; border: 1px dashed var(--line); border-radius: 999px; color: var(--text);
}
input.bdo-add:focus { width: 148px; border-style: solid; border-color: var(--gold); }
.rank-preview li { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: .88rem; }
.rank-preview { list-style: none; margin: 0; padding: 0; }
.rank-preview .n { color: var(--text-3); font-family: var(--mono); width: 22px; }
.rank-preview .s { margin-left: auto; font-family: var(--mono); color: var(--gold-soft); }
.rank-preview .delta { font-family: var(--mono); font-size: .78rem; }
/* the player whose page this is, picked out of his own neighbourhood */
.rank-preview li.me {
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  box-shadow: inset 3px 0 0 var(--gold);
  margin: 0 -12px; padding-left: 15px; padding-right: 12px;
}
.rank-preview li.me .n { color: var(--gold); }
.up { color: var(--worldcup); } .down { color: var(--danger); }

/* ── player page ────────────────────────────────────────────────────────── */

.p-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding: 26px 0 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; }
.stat .k { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }
.stat .v { font-family: var(--mono); font-size: 1.25rem; margin-top: 3px; }
.formula {
  font-family: var(--mono); font-size: .84rem; color: var(--text-2);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0;
}
.formula b { color: var(--gold-soft); }

.prose p { color: var(--text-2); max-width: 74ch; }
.prose blockquote { border-left: 2px solid var(--gold); margin: 18px 0; padding: 2px 0 2px 16px; color: var(--text-2); font-family: var(--serif); font-size: 1.05rem; }

.footer { border-top: 1px solid var(--line-soft); margin-top: 40px; padding: 22px; color: var(--text-3); font-size: .82rem; text-align: center; }

@media (max-width: 900px) {
  /* minmax(0, …), not 1fr: a bare 1fr track lets wide tables blow the grid out */
  .cfg-layout { grid-template-columns: minmax(0, 1fr); }
  /* single column: the board sits in the flow, so nothing should pin or clip it */
  .cfg-rail { position: static; max-height: none; overflow-y: visible; }
  .fbar { grid-template-columns: 96px 1fr 62px; }
}

@media (max-width: 700px) {
  .wrap { padding: 0 14px 100px; }
  /* brand + theme on the first line, nav on its own scrollable second line */
  .site-header .bar { padding: 9px 14px; gap: 8px; flex-wrap: wrap; }
  .brand { white-space: nowrap; order: 1; margin-right: auto; }
  .brand b { font-size: .95rem; }
  .brand span { display: none; }
  .site-header .icon-btn { order: 2; }
  .nav {
    order: 3; flex: 1 1 100%; margin-left: 0; gap: 2px;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 6px 10px; font-size: .82rem; white-space: nowrap; }

  .hero { padding: 26px 0 18px; }
  .hero h1 { max-width: none; }
  .field, .field.slider { grid-template-columns: 1fr; gap: 6px; }
  .field.slider input[type="number"] { width: 100%; }
  .cmp-head { grid-template-columns: 1fr 1fr; }
  .factor-row { grid-template-columns: 1fr; gap: 6px; }
  .toolbar .search { flex: 1 1 100%; }

  /* the tray is a bar, not a pill, once the screen is narrow */
  .tray {
    left: 12px; right: 12px; bottom: 12px; transform: translateY(160%);
    border-radius: var(--radius); padding: 10px 12px; flex-wrap: wrap; gap: 8px;
  }
  .tray.show { transform: translateY(0); }
  .tray .who { flex-wrap: wrap; gap: 6px; }
  .tray .pill { font-size: .78rem; }
  .tray .btn { flex: 1 1 100%; justify-content: center; }
  /* the full-width Compare button owns its row, so the × sits in the corner
   * instead of being pushed onto a line of its own */
  .tray { padding-right: 42px; }
  .tray .tray-close { position: absolute; top: 6px; right: 6px; margin-right: 0; }
}
