/* ── 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;
  color: inherit; text-decoration: none; transition: border-color .15s;
}
.podium-card:hover { border-color: var(--gold); }
.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; }
.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.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); }

/* The manual-weights escape hatch: one button per factor, plus the proportional
 * option. Each prints the value it would produce, so the arrow is the label's
 * real payload and stays bold in the factor's own colour. */
.weight-fix .fix-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.weight-fix .fix-lead { color: var(--text-3); font-size: .82rem; }
.weight-fix .btn b { font-weight: 600; }
.weight-fix .btn:disabled { color: var(--text-3) !important; }

/* ── 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); }
/* the avatar + name double as a link to his own page, without wearing link-blue
 * the rest of the card doesn't — only a hover/focus says so. The anchor itself
 * must stay text-decoration:none even on hover — the site's own generic `a:hover`
 * rule underlines in the inherited text colour, and that line would sit right
 * behind the h3's own gold one, reading as two stacked underlines, one black. */
.cmp-who, .cmp-who:hover, .cmp-who:focus-visible { display: block; color: inherit; text-decoration: none; border-radius: var(--radius-sm); }
.cmp-who:hover h3, .cmp-who:focus-visible h3 { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.cmp-who:hover .avatar, .cmp-who:focus-visible .avatar { box-shadow: 0 0 0 2px var(--gold); }
.cmp-who:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* the "Pelé ×" pill above the cards: the name links out, the × stays a plain
 * remove button right beside it */
.pill-link { color: inherit; text-decoration: none; }
.pill-link:hover, .pill-link:focus-visible { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; }

.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%; }

/* The player screen's dials carry selects and a link out to Customise rather than
 * bare numbers, so they get a wider control column — 108px truncates a label. */
.dials .field { grid-template-columns: 1fr 154px; }
.dials .field select { width: 100%; }
.dials .field > .btn { justify-content: center; }
.dials .field.stacked { grid-template-columns: 1fr; gap: 8px; }

/* One World Cup final, added or taken away, per row: the reader turns this dial in
 * finals and the points follow — nobody thinks in "8 World Cup points". */
.role-steps { display: grid; gap: 7px; }
.role-step { display: grid; grid-template-columns: 1fr 28px 30px 28px; gap: 8px; align-items: center; font-size: .87rem; }
.role-step .lbl small { color: var(--text-3); margin-left: 6px; font-size: .77rem; }
.role-step .n { font-family: var(--mono); text-align: center; color: var(--text); }
.step-btn {
  width: 28px; height: 28px; padding: 0; line-height: 1; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font: inherit; font-size: 1rem; cursor: pointer;
}
.step-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-soft); }
.step-btn:disabled { opacity: .35; cursor: not-allowed; }
.role-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  border-top: 1px solid var(--line-soft); padding-top: 8px; font-size: .87rem; color: var(--text-2);
}
.role-total b { color: var(--gold); }

/* Arriving from a player's dial: say which panel answered the click. */
@keyframes panel-flash {
  from { box-shadow: 0 0 0 2px var(--gold); }
  to { box-shadow: 0 0 0 2px transparent; }
}
.panel.flash { animation: panel-flash 1.8s ease-out; }
/* …and, inside it, the one field, chip or card that answered the click. Table rows
 * ignore box-shadow in most engines, so those are marked on their cells instead. */
@keyframes target-flash {
  0%, 62% { box-shadow: 0 0 0 2px var(--gold); background: color-mix(in srgb, var(--gold) 16%, transparent); }
  to { box-shadow: 0 0 0 2px transparent; background: transparent; }
}
@keyframes target-flash-cell {
  0%, 62% { background: color-mix(in srgb, var(--gold) 24%, transparent); }
  to { background: transparent; }
}
.flash-target { animation: target-flash 2.2s ease-out; border-radius: var(--radius-sm); }
tr.flash-target { animation: none; }
tr.flash-target > td { animation: target-flash-cell 2.2s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .panel.flash, .flash-target, tr.flash-target > td { animation: none; }
}

/* ── 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 — THE single source of truth for every
 * "↺ reset" on the site. It declares its own type rather than inheriting it, so
 * the same control reads identically whether it sits under a field label, inside
 * a monospace table cell, or anywhere else. Never restyle it locally: if a reset
 * link needs to look different, the difference belongs here or nowhere. */
.undo {
  background: none; border: 0; padding: 0; margin-left: 7px;
  font-family: var(--sans); font-size: .77rem; font-weight: 600; line-height: 1.55;
  color: var(--gold); cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
  white-space: nowrap;
}
.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; }

/* ── the itemised list of changes ───────────────────────────────────────────
 * A modal, not something that unfolds under the "N changes" bar: that bar is
 * sticky, and a sticky element that grows to hold forty rows would swallow the
 * page it is describing. Wider than a confirmation, and the list scrolls inside
 * itself so the two buttons at the bottom never leave the screen. */
dialog.modal.wide { max-width: 680px; }
.chg-list {
  max-height: min(54vh, 460px); overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2);
  margin-bottom: 18px;
}
.chg-group + .chg-group { border-top: 1px solid var(--line); }
.chg-group-head {
  position: sticky; top: 0; z-index: 1;
  padding: 7px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line-soft);
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
}
.chg-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
}
.chg-row:last-child { border-bottom: 0; }
.chg-what { flex: 1 1 240px; min-width: 0; }
.chg-label { font-size: .9rem; font-weight: 600; }
.chg-detail b { color: var(--gold-soft); }
.chg-acts { display: flex; gap: 7px; margin-left: auto; flex: 0 0 auto; }
.modal-actions .spacer { margin-left: auto; }
/* ── "this number is not the database's any more" ───────────────────────────
 * On the compare page every value is checked against the untouched board, and one
 * that moved wears the official value underneath it as a button: it opens the list
 * above, scoped to the changes behind THAT number. Same gold as every other "this
 * one is yours" mark on the site. */
.why-btn {
  display: block; width: 100%; margin-top: 2px; text-align: inherit;
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--sans); font-size: .72rem; line-height: 1.35; font-weight: 400;
  color: var(--gold); text-decoration: underline; text-underline-offset: 2px;
}
.why-btn:hover { color: var(--gold-soft); }
.why-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
/* inside a sentence or a table cell that already has content beside it */
.why-btn.inline { display: inline; width: auto; margin: 0 0 0 7px; }
table.data td.changed { background: color-mix(in srgb, var(--gold) 8%, transparent); }
.cmp-card .why-btn { text-align: center; margin-top: 6px; }
/* the sample of the marker, shown inside the bar that explains it */
.why-sample { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }

/* a button that has to read as a link, inside a sentence */
.link-btn {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--gold); cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--gold-soft); }

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.
 * The live-board rail (.cfg-side) sits sticky on the page too, so it shares this
 * same gold-tinted "floating over the page" treatment rather than the plain
 * .panel look the rest of the page uses — one glance says "these two follow you". */
.cfg-status, .panel.cfg-side {
  border: 1px solid color-mix(in srgb, var(--gold) 42%, transparent);
  background: color-mix(in srgb, var(--gold) 13%, var(--panel));
}
.cfg-status {
  position: sticky; top: 72px; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  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; }
/* Wide enough for "1957 ↺ reset" on one line — the row's undo lives with the year,
 * same as every other single-value reset on this screen. Its type comes from
 * `.undo` alone; nothing here restyles it. */
table.data.bdo-table th:first-child, table.data.bdo-table td:first-child { width: 132px; }
.bdo-year { white-space: nowrap; }
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%;
  cursor: grab;
}
.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); }
/* Dragging a chip to another podium spot (or another year) — same "×" rule applies:
 * a cell that already holds this player refuses the drop. */
.chip.dragging { opacity: .4; }
.bdo-cell.drag-over { background: color-mix(in srgb, var(--gold) 12%, transparent); border-radius: var(--radius-sm); }
/* Hovering a specific chip (not empty cell space) means "swap with this one" —
 * a different signal from "add alongside what's here", so it gets its own ring. */
.chip.swap-target { box-shadow: 0 0 0 2px var(--magic); background: color-mix(in srgb, var(--magic) 18%, var(--panel-2)); }
/* Typing a player's name into the search box picks him out everywhere he appears
 * in the record, not just in the rows that survive the filter — a solid fill
 * reads faster across a scrolling table than another thin outline would. */
.chip.search-match {
  background: var(--gold); border-color: var(--gold); color: #17130a;
}
.chip.search-match a, .chip.search-match .x { color: #17130a; }
.chip.search-match .x:hover { color: var(--danger); }
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); }

/* ── emotional placements: three drag-and-drop columns ─────────────────────
 * Same chip look as the Ballon d'Or podium, but there's no "record" underneath
 * to swap places in — a drop just moves the dragged player into that column. */
.tier-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 720px) { .tier-columns { grid-template-columns: 1fr; } }
.tier-col {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2); min-width: 0;
}
.tier-col-head {
  padding: 8px 10px; font-weight: 600; font-size: .84rem;
  border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 6px;
}
.tier-col-body {
  padding: 8px; min-height: 64px; max-height: 420px; overflow: auto;
}
.tier-col.drag-over { box-shadow: inset 0 0 0 2px var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--panel-2)); }
.chip.edited { border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.chip .reset {
  background: none; border: 0; padding: 0 3px; cursor: pointer; line-height: 1;
  color: var(--gold); font-size: .9rem;
}
.chip .reset:hover { color: var(--gold-soft); }
.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; }

/* ── What-If: World Cup finals ─────────────────────────────────────────────
 * One card per final: a pair of clickable team pills to flip the result, then
 * two rosters of chips underneath. Same "mini-list.tall" scroller as the
 * Ballon d'Or record, since this is a 23-year-long list for the same reason. */
.wc-final { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.wc-final:last-child { border-bottom: 0; }
.wc-final.changed { background: color-mix(in srgb, var(--worldcup) 6%, transparent); }
.wc-final-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.wc-final-head .spacer { margin-left: auto; }
.wc-teams { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.wc-teams .vs { color: var(--text-3); font-size: .8rem; }
.team-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2);
  color: var(--text); font-size: .87rem; font-family: var(--sans); cursor: pointer;
}
.team-pill:hover:not(:disabled) { border-color: var(--worldcup); color: var(--worldcup); }
.team-pill:disabled { cursor: default; }
.team-pill.winner {
  border-color: color-mix(in srgb, var(--worldcup) 55%, transparent);
  background: color-mix(in srgb, var(--worldcup) 14%, var(--panel-2));
  font-weight: 600;
}
.team-pill .flag { font-size: 1.05em; line-height: 1; }
.team-pill .trophy { font-size: .85em; }
.wc-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
@media (max-width: 720px) { .wc-roles { grid-template-columns: 1fr; } }
.wc-side-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); margin-bottom: 4px; }
.chip.wc-chip { padding-right: 4px; }
/* Billing is marked, not shouted. The star does the work — it is the one thing a
 * co-adjuvant never has — so the pill around it stays a whisper of gold instead of
 * a solid block of it. The filled version this replaces was the same flat --gold as
 * the search highlight below, which left one colour carrying two unrelated meanings
 * ("this man was the axis" and "this is the name you searched for"). */
.role-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .68rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; border: 1px solid transparent;
}
.role-tag .star { font-size: .82em; line-height: 1; }
.role-tag.protagonist {
  background: color-mix(in srgb, var(--gold) 11%, transparent);
  border-color: color-mix(in srgb, var(--gold) 32%, transparent);
  color: var(--gold-soft);
}
.role-tag.protagonist .star { color: var(--gold); }
/* --text-2, not the fainter --text-3: at 10px this label still has to be read, and
 * it is already carrying no star and no fill to set it apart. */
.role-tag.coadjuvant { color: var(--text-2); border-color: var(--line-soft); }
/* What the billing is worth, printed on the tag itself, on both sides: the same two
 * words are priced differently depending on which side won, so every chip states its
 * own price rather than making the reader hold the rule in their head. Dimmer than
 * the label it trails, never larger. */
.role-tag .worth {
  font-size: .86em; font-weight: 500; color: var(--text-3);
  padding-left: 5px; margin-left: 1px; border-left: 1px solid var(--line-soft);
}
/* Every role tag carries data-wc-toggle now (see roleChip in app-config.js) and is
 * meant to be clicked/tabbed to like the ⇄ button beside it. */
.role-tag[data-wc-toggle] { cursor: pointer; }
.role-tag[data-wc-toggle]:hover { border-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.role-tag[data-wc-toggle]:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.role-toggle {
  background: none; border: 0; padding: 0 3px; cursor: pointer; line-height: 1;
  color: var(--worldcup); font-size: .9rem;
}
.role-toggle:hover { color: var(--gold-soft); }
/* Deliberately softer than the Ballon d'Or record's solid fill further up: those
 * chips are bare names in a long scrolling table, where a block of colour is what
 * catches the eye fastest. These carry a role badge inside them, so the hit marker
 * has to sit BEHIND that badge rather than swallow it — a ring plus a light wash
 * marks the row just as clearly and leaves both the star and the label legible. */
.chip.wc-chip.search-match {
  background: color-mix(in srgb, var(--gold) 15%, var(--panel-2));
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
  color: var(--text);
}
.chip.wc-chip.search-match a { color: var(--text); }
.chip.wc-chip.search-match a:hover { color: var(--gold-soft); }
/* The same "you searched for this name" mark, for a dropped player who no longer
 * has a chip to wear it on — he only survives in the "No longer credited" line. */
.text-hit {
  background: color-mix(in srgb, var(--gold) 15%, var(--panel-2));
  border: 1px solid var(--gold); border-radius: 5px; padding: 0 4px; color: var(--text);
}
.text-hit:hover { color: var(--gold-soft); }
.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, .dials .field { grid-template-columns: 1fr; gap: 6px; }
  .field.slider input[type="number"] { width: 100%; }
  .dials .field > .btn { justify-self: start; }
  .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; }
}
