:root {
  color-scheme: light;
  --canvas: #f4f5f7;
  --panel: #ffffff;
  --panel-soft: #f8f9fb;
  --surface: #ffffff;
  --ink: #19212c;
  --line: #dde1e7;
  --text: #19212c;
  --muted: #667085;
  --accent: #1769aa;
  --accent-strong: #0f4c81;
  --accent-soft: #eaf4fc;
  --brand-navy: #1f3b66;
  --brand-gold: #c9a227;
  --brand-cream: #faf9f6;
  --gold: #8a6500;
  --gold-soft: #fff7dc;
  --danger: #a23b34;
  --shadow: 0 12px 36px rgba(21, 35, 52, 0.08);
  --hero-gradient: linear-gradient(180deg, rgba(244, 245, 247, 0.98) 82%, rgba(244, 245, 247, 0));
  --search-field: #ffffff;
  --search-field-focus: #ffffff;
  --search-field-shadow: 0 14px 40px rgba(21, 35, 52, 0.12);
}

[hidden] { display: none !important; }

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  min-width: 320px;
  background: var(--canvas);
}

body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--canvas);
  letter-spacing: 0;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(23, 105, 170, 0.34);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(1500px, 100%);
  height: 100dvh;
  margin: 0 auto;
}

.topbar {
  flex: 0 0 auto;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 24px;
  background: rgba(244, 245, 247, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px);
}

.topnav { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.topnav a { padding: 8px 10px; color: var(--muted); border-radius: 8px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.topnav a:hover { color: var(--accent-strong); background: var(--accent-soft); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; }

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(21, 35, 52, 0.04);
}

.theme-switcher button {
  display: grid;
  place-items: center;
  min-width: 31px;
  height: 29px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.theme-switcher button:hover { color: var(--text); background: var(--panel); }
.theme-switcher button[aria-pressed="true"] {
  color: var(--accent-strong);
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(21, 35, 52, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  padding: 5px;
  background: var(--brand-cream);
  border: 1px solid rgba(31, 59, 102, 0.14);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(31, 59, 102, 0.08);
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.search-box span {
  color: var(--accent);
  font-size: 20px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.search-box:focus-within {
  background: #fff;
  border-color: rgba(23, 105, 170, 0.6);
  box-shadow: 0 0 0 4px rgba(23, 105, 170, 0.09);
}

.search-box input::placeholder {
  color: #737a75;
}

.stage-tabs button,
.action-link,
.primary-action,
.tool-button {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stage-tabs button:hover,
.action-link:hover,
.tool-button:hover {
  border-color: var(--accent);
}

.primary-action {
  color: #ffffff;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  cursor: pointer;
}

.tool-button {
  cursor: pointer;
}

.primary-action:disabled,
.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  flex: 1 1 auto;
  gap: 20px;
  min-height: 0;
  overflow: hidden;
  padding: 22px 24px 32px;
}

.content-pane {
  position: static;
  min-width: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  align-self: stretch;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  letter-spacing: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.stage-tabs {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.stage-tab-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.stage-tab-row:last-child {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stage-tabs button {
  width: 100%;
  cursor: pointer;
}

.stage-tabs button[aria-selected="true"] {
  color: #ffffff;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.leaderboard-card {
  min-width: 0;
  overflow: hidden;
  padding: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: paneIn 360ms ease both;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.stage-title {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.stage-range {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.leaderboard-table tr {
  cursor: pointer;
}

.leaderboard-table tr + tr {
  border-top: 1px solid rgba(217, 216, 207, 0.82);
}

.leaderboard-table tr:hover {
  background: rgba(228, 242, 238, 0.7);
}

.leaderboard-table td {
  padding: 9px 4px;
  vertical-align: middle;
}

.rank-cell {
  width: 34px;
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  color: #ffffff;
  background: #1d1d1f;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.player-name {
  overflow-wrap: anywhere;
  font-weight: 650;
}

.player-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.rating-cell {
  width: 66px;
  text-align: right;
}

.rating-value {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.rating-kind {
  margin-top: 2px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.note-pill {
  display: inline-flex;
  margin-top: 6px;
  padding: 3px 7px;
  color: var(--gold);
  background: var(--gold-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}

.bar-track {
  position: relative;
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  background: rgba(0, 102, 204, 0.12);
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  width: var(--bar-width);
  background: var(--accent);
  border-radius: inherit;
  transform-origin: left center;
  animation: growBar 620ms ease-out both;
}

.ranking-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.search-results {
  margin-bottom: 20px;
}

.bulk-player-hit {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  color: var(--text);
  background: #edf8f5;
  border: 1px solid rgba(18, 119, 111, 0.22);
  border-radius: 8px;
}

.bulk-player-hit strong {
  font-size: 0.92rem;
}

.bulk-player-hit span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.static-player-hit {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  color: var(--text);
  background: #eef7ff;
  border: 1px solid rgba(42, 110, 178, 0.2);
  border-radius: 8px;
}

.static-player-hit strong,
.static-player-hit span {
  display: block;
}

.static-player-hit strong {
  font-size: 0.94rem;
}

.static-player-hit span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.pgn-package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.pgn-package-button {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  color: #174b7c;
  text-align: left;
  background: #fff;
  border: 1px solid rgba(42, 110, 178, 0.22);
  border-radius: 8px;
  cursor: pointer;
}

.pgn-package-button strong,
.pgn-package-button span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pgn-package-button strong {
  font-size: 0.82rem;
  font-weight: 650;
}

.pgn-package-button span {
  color: var(--muted);
  font-size: 0.76rem;
}

.pgn-package-button:hover {
  border-color: #2a6eb2;
}

.pgn-package-button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.pgn-package-button[aria-pressed="true"] span {
  color: rgba(255, 255, 255, 0.78);
}

.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.result-button {
  width: 100%;
  min-width: 0;
  padding: 12px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.result-button:hover {
  border-color: var(--accent);
}

.result-button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.same-name-context {
  display: inline-flex;
  margin-left: 0.45rem;
  padding: 0.12rem 0.42rem;
  color: var(--muted);
  background: var(--panel-soft);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.domestic-chip {
  color: #7a4c15;
  background: #fff4dc;
  border-color: #e6c98f;
}

.appearance-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin: 1.25rem 0 0.75rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}

.appearance-summary > div {
  display: grid;
  gap: 0.3rem;
  padding: 1rem;
  background: var(--panel);
}

.appearance-summary span,
.sighting-card span {
  color: var(--muted);
  font-size: 0.78rem;
}

.sighting-list {
  display: grid;
  gap: 0.65rem;
}

.sighting-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.sighting-card > div {
  display: grid;
  gap: 0.25rem;
}

.sighting-actions {
  display: flex !important;
  flex: none;
  align-items: center;
  gap: 0.7rem !important;
}

.sighting-card a,
.sighting-card button {
  flex: none;
  color: var(--accent);
  font-size: 0.8rem;
}

.sighting-card button {
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.search-result-group + .search-result-group,
.related-identities {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.search-result-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.search-result-group-title h3 { margin: 0; font-size: 0.92rem; }
.search-result-group-title span { color: var(--muted); font-size: 0.76rem; }
.player-search-list, .event-search-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.event-search-result { border-left: 3px solid var(--accent); }

.related-identities-note {
  margin-top: -0.3rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.related-identity-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.55rem; }
.related-identity {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem 0.9rem;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.related-identity:hover { border-color: var(--accent); }
.related-identity span { color: var(--muted); font-size: 0.76rem; }

.event-results-section {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.event-round-tabs {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.event-round-tabs button {
  flex: none;
  padding: 0.48rem 0.75rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
}

.event-round-tabs button[aria-selected="true"] {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}

.pairing-list {
  display: grid;
  gap: 0.45rem;
}

.pairing-row {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 4.2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.pairing-board {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pairing-result {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.event-side-name {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
  color: var(--text);
}

.event-side-name small {
  color: var(--muted);
  font-size: 0.68rem;
}

button.event-side-name {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

button.event-side-name:hover {
  color: var(--accent);
}

.pairing-pgn {
  padding: 0.38rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.72rem;
  white-space: nowrap;
}

button.pairing-pgn {
  cursor: pointer;
}

.pairing-pgn.available {
  color: #146b3a;
  border-color: #9ed6b5;
  background: #edf9f2;
  font-weight: 700;
}

.pairing-pgn.external {
  color: var(--accent);
  background: var(--accent-soft);
}

.pairing-pgn.missing {
  color: var(--muted);
  background: var(--panel-soft);
}

.standings-table-wrap {
  max-height: 34rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.standings-table th,
.standings-table td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.standings-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--panel-soft);
}

@media (max-width: 760px) {
  .pairing-row {
    grid-template-columns: 2rem minmax(0, 1fr) 3.7rem minmax(0, 1fr);
  }

  .pairing-pgn {
    grid-column: 2 / -1;
    justify-self: start;
  }
}

.detail-pane {
  align-self: stretch;
  min-width: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: paneIn 420ms ease both;
}

.detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-title h1 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.06;
  letter-spacing: 0;
}

.detail-title p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-cn-name {
  margin-top: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
}

.detail-title-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stage-chip {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  min-height: 30px;
  padding: 6px 9px;
  color: #ffffff;
  background: #1d1d1f;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.rating-card {
  min-width: 0;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rating-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.rating-card strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.icon-link {
  padding: 2px;
  line-height: 0;
}
.icon-link svg { display: block; }

/* --- community credits --------------------------------------------------- */
.credits-list { display: grid; gap: 10px; }
.credit-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.credit-howto {
  padding: 10px 12px;
  color: var(--muted, #64748b);
  font-size: 12.5px;
  line-height: 1.7;
  background: rgba(240, 247, 255, 0.6);
  border: 1px dashed rgba(0, 102, 204, 0.25);
  border-radius: 10px;
}
.credit-howto a { color: var(--accent-strong, #0866c6); font-weight: 650; }
.credit-howto .contribute-cta {
  display: inline-flex;
  margin: 0.35rem 0.45rem;
  padding: 0.36rem 0.62rem;
  color: #fff;
  background: var(--accent-strong);
  border-radius: 7px;
  text-decoration: none;
}
.credit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(145deg, #ffffff, #f0f7ff);
  border: 1px solid rgba(0, 102, 204, 0.16);
  border-radius: 999px;
}
.credit-chip a { color: var(--muted); font-size: 11px; font-weight: 500; text-decoration: none; }
.credit-chip a:hover { color: var(--accent); text-decoration: underline; }

/* --- browser contribution guide ---------------------------------------- */
.contribute-page { min-height: 100vh; background: var(--canvas); }
.contribute-shell { width: min(820px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 80px; }
.contribute-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.contribute-back { display: inline-flex; color: var(--muted); text-decoration: none; }
.contribute-head { margin-bottom: 1.5rem; }
.contribute-head h1 { margin: 0.45rem 0 0.65rem; font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -0.04em; }
.contribute-head p { max-width: 650px; color: var(--muted); line-height: 1.7; }
.contribute-head .tool-download-note { font-size: 0.86rem; }
.tool-download-note a { margin-left: 0.25em; color: var(--accent-strong); font-weight: 700; }
.contribution-form, .contribution-output {
  display: grid;
  gap: 1rem;
  padding: clamp(1.1rem, 4vw, 2rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.contribution-form label { display: grid; gap: 0.45rem; }
.contribution-form label > span { color: var(--muted); font-size: 0.82rem; font-weight: 650; }
.contribution-form input, .contribution-form select, .contribution-form textarea, #contributionPreview {
  width: 100%;
  box-sizing: border-box;
  padding: 0.78rem 0.85rem;
  color: var(--ink);
  font: inherit;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
}
.contribution-form input:focus, .contribution-form select:focus, .contribution-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.contribution-fields { display: grid; gap: 1rem; }
.contribution-fields.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.contribution-form .consent-row { display: flex; grid-column: 1 / -1; align-items: flex-start; gap: 0.65rem; }
.consent-row input { width: auto; margin-top: 0.2rem; }
.contribution-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
}
.primary-button { color: #fff; background: var(--accent-strong); border: 1px solid var(--accent-strong); }
.secondary-button { color: var(--ink); background: var(--panel); border: 1px solid var(--line); }
.contribution-output { margin-top: 1.25rem; }
.contribution-output > p { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.6; }
#contributionPreview { resize: vertical; font: 0.78rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.contribution-status { min-height: 1.3em; color: var(--accent-strong) !important; font-weight: 650; }
.device-authorization { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: var(--accent-soft); }
.device-authorization span { color: var(--muted); font-size: 0.82rem; }
.device-authorization strong { padding: 0.35rem 0.65rem; border-radius: 8px; background: var(--surface); font: 700 1.1rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; }

@media (max-width: 640px) {
  .sighting-card { align-items: flex-start; flex-direction: column; }
  .sighting-actions { width: 100%; justify-content: space-between; }
  .contribution-fields.two-column { grid-template-columns: 1fr; }
}




.download-status {
  margin-bottom: 12px;
  padding: 9px 10px;
  color: var(--muted);
  background: var(--panel-soft);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
}

.pgn-viewer {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  color: var(--text);
  background: #f5f5f7;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
}

.pgn-download-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 34px;
  overflow-wrap: anywhere;
  padding: 7px 10px;
  color: var(--accent-strong);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
}

.pgn-download-link:hover {
  border-color: var(--accent);
}

.pgn-viewer.is-empty,
.pgn-viewer.is-loading {
  min-height: 92px;
}

.pgn-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.pgn-viewer-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.pgn-viewer-head span {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.viewer-pulse {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin-top: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: viewerPulse 1.1s ease-in-out infinite;
}

.viewer-select {
  display: grid;
  gap: 6px;
}

.viewer-select span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.viewer-select select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.lichess-viewer-shell {
  min-width: 0;
  max-height: min(64vh, 560px);
  overflow: auto;
  overscroll-behavior: contain;
}

.viewer-playback-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(220px, 280px);
  gap: 12px;
  align-items: start;
}

.viewer-game-side {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.viewer-game-side h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

.viewer-game-side dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.viewer-game-side div {
  display: grid;
  gap: 2px;
}

.viewer-game-side dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.viewer-game-side dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.lichess-viewer-host {
  min-width: 0;
}

.lichess-viewer-shell .lpv {
  --c-lpv-bg: #f5f5f7;
  --c-lpv-bg-player: #ffffff;
  --c-lpv-bg-controls: #ffffff;
  --c-lpv-bg-movelist: #ffffff;
  --c-lpv-bg-variation: #f5f5f7;
  --c-lpv-bg-pane: #ffffff;
  --c-lpv-side-border: #e5e5ea;
  --c-lpv-border: #d8d8de;
  --c-lpv-font: #1d1d1f;
  --c-lpv-font-shy: #86868b;
  --c-lpv-font-bg: #d2d2d7;
  --c-lpv-accent: #0066cc;
  --c-lpv-accent-over: #ffffff;
  --c-lpv-current-move: #0066cc;
  --c-lpv-move-hover: #eaf3ff;
  width: 100%;
  border: 1px solid #d8d8de;
  border-radius: 8px;
  box-shadow: none;
}

.lichess-viewer-shell .lpv--players.lpv--moves-auto {
  grid-template-columns: minmax(220px, min(42vh, 400px)) minmax(210px, 1fr);
}

.lichess-viewer-shell .lpv--moves-false {
  width: min(100%, 430px);
  margin-inline: auto;
}

.lichess-viewer-shell .lpv__player,
.lichess-viewer-shell .lpv__controls {
  min-height: 34px;
}

.lichess-viewer-shell .lpv__moves {
  max-height: min(46vh, 420px);
  overflow: auto;
}

.lichess-viewer-shell .lpv__controls .lpv__fbt {
  color: var(--text);
}

.lichess-viewer-shell .lpv__controls .lpv__fbt:hover {
  color: #ffffff;
  background: var(--accent);
}

.viewer-select select:focus {
  border-color: var(--accent);
}

.viewer-flip {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  padding-inline: 8px;
}

.viewer-error,
.move-empty {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.viewer-error {
  margin-top: 0;
  padding: 10px;
  color: var(--danger);
  background: rgba(162, 59, 52, 0.08);
  border-radius: 8px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  min-height: 120px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

@keyframes growBar {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes viewerPulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.75);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes paneIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .viewer-playback-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .content-pane,
  .detail-pane,
  .event-pane {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 12px;
  }

  .workspace {
    padding: 14px 12px 24px;
  }

  .rating-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .leaderboard-grid,
  .result-list {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-title {
    flex-direction: column;
  }

  .detail-title > div:first-child,
  .detail-title-actions {
    width: 100%;
  }

  .detail-title-actions {
    justify-content: flex-start;
  }

  .dashboard-intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .dashboard-intro p {
    max-width: none;
  }

  .recent-event-card {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .recent-event-stats {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    text-align: left;
  }

  .lichess-viewer-shell {
    max-height: none;
  }

  .lichess-viewer-shell .lpv--players.lpv--moves-auto {
    grid-template-areas:
      "player-top"
      "board"
      "player-bot"
      "controls"
      "side";
    grid-template-columns: minmax(200px, min(82vw, 400px));
    grid-template-rows: 2em auto 2em var(--controls-height) 7.5em;
  }

  .lichess-viewer-shell .lpv--moves-false {
    width: min(100%, 400px);
  }
}

@media (max-width: 440px) {
  .rating-grid {
    grid-template-columns: 1fr;
  }

  .leaderboard-card,
  .detail-pane,
  .event-pane {
    padding: 14px;
  }

  .stage-title {
    font-size: 26px;
  }
}


/* --- dashboard --------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 9px;
  margin-bottom: 24px;
}
.stat-card {
  min-height: 76px;
  padding: 13px 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.stat-card .stat-value {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 650;
  line-height: 1.15;
}
.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--muted, #64748b);
  margin-top: 2px;
}
.dashboard-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 2px 0 20px; }
.dashboard-intro h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; }
.dashboard-intro .eyebrow { margin-bottom: 6px; }
.dashboard-intro p { max-width: 280px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.recent-events { margin: 0; }
.recent-event-list { display: grid; gap: 2px; }
.recent-event-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.recent-event-card:first-child { padding-top: 0; border-top: 0; }
.recent-event-main { min-width: 0; }
.recent-event-kicker { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.recent-event-kicker span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-event-kicker time { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.recent-event-title { display: block; max-width: 100%; padding: 0; overflow: hidden; color: var(--text); text-align: left; text-overflow: ellipsis; white-space: nowrap; background: transparent; border: 0; cursor: pointer; font: inherit; font-size: 14px; font-weight: 680; line-height: 1.35; }
.recent-event-title:hover { color: var(--accent-strong); }
.recent-event-links { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.player-chip, .player-chip-more { min-height: 24px; padding: 3px 7px; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid transparent; border-radius: 999px; font-size: 11px; line-height: 1; }
.player-chip { cursor: pointer; }.player-chip:hover { border-color: rgba(23, 105, 170, .32); background: #fff; }.player-chip-more { color: var(--muted); background: transparent; border-color: var(--line); }
.recent-event-stats { display: grid; align-content: start; gap: 5px; min-width: 78px; color: var(--muted); text-align: right; font-size: 11px; white-space: nowrap; }
.recent-event-stats strong { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }.recent-event-stats a { margin-top: 3px; color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }


/* --- main pane (right column: dashboard / search / detail) -------------- */
.main-pane {
  min-width: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  align-self: stretch;
}
.main-pane .detail-pane {
  max-height: none;
  overflow: visible;
}
.dashboard { animation: paneIn 420ms ease both; }
.dash-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}
.dash-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(21, 35, 52, .03);
  padding: 18px;
  min-width: 0;
}
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.changelog-list { font-size: 0.85rem; margin-bottom: 16px; }
.changelog-list .cl-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line, #e8edf4);
}
.changelog-list .cl-date { color: var(--muted, #64748b); white-space: nowrap; }
.age-overview .age-row {
  display: grid;
  grid-template-columns: 46px 1fr 62px;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.8rem;
}
.age-overview .age-bar-track {
  height: 8px;
  border-radius: 6px;
  background: var(--line, #e8edf4);
  overflow: hidden;
}
.age-overview .age-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--accent, #2563eb);
}
.age-overview .age-count { text-align: right; color: var(--muted, #64748b); }
.detail-back {
  margin-bottom: 10px;
}

/* --- event graph: event <-> player <-> game ---------------------------- */
.event-pane {
  align-self: stretch;
  min-width: 0;
  max-height: none;
  padding: 26px;
  overflow: visible;
  background: linear-gradient(150deg, rgba(255,255,255,.98), rgba(239,247,255,.94));
  border: 1px solid rgba(0,102,204,.18);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: paneIn 420ms ease both;
}
.eyebrow { display: block; margin-bottom: 8px; color: var(--accent-strong); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.event-source-name { max-width: 680px; line-height: 1.55; }
.event-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; margin: 20px 0; }
.event-facts > div { display: grid; gap: 5px; min-width: 0; padding: 12px; background: rgba(255,255,255,.78); border: 1px solid rgba(0,102,204,.13); border-radius: 10px; }
.event-facts span { color: var(--muted); font-size: 11px; font-weight: 650; }
.event-facts strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.event-roster { margin-top: 25px; }
.event-roster h3, .player-event-history h3 { margin: 0; font-size: 17px; }
.event-player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 8px; }
.event-player { display: grid; gap: 3px; min-width: 0; padding: 10px; text-align: left; background: #fff; border: 1px solid rgba(0,102,204,.16); border-radius: 10px; cursor: pointer; }
.event-player:hover { border-color: var(--accent); box-shadow: 0 5px 14px rgba(0,102,204,.12); transform: translateY(-1px); }
.event-player strong, .event-player span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-player strong { font-size: 13px; }.event-player span { color: var(--muted); font-size: 11px; }
.event-more, .event-provenance { color: var(--muted); font-size: 12px; line-height: 1.5; }
.event-provenance { margin-top: 24px; padding-top: 12px; border-top: 1px solid rgba(0,102,204,.13); }
.event-loading, .event-empty { min-height: 120px; padding: 26px; color: var(--muted); background: rgba(255,255,255,.7); border: 1px dashed rgba(0,102,204,.25); border-radius: 12px; }

.player-event-history { margin: 18px 0; padding: 14px; background: rgba(248,251,255,.9); border: 1px solid rgba(0,102,204,.13); border-radius: 12px; }
.player-event-list { display: grid; gap: 6px; }
.player-event-row { display: flex; justify-content: space-between; gap: 14px; width: 100%; padding: 9px 4px; color: var(--text); text-align: left; background: transparent; border: 0; border-top: 1px solid rgba(0,102,204,.1); cursor: pointer; }
.player-event-row:hover strong { color: var(--accent-strong); }.player-event-row span { display: grid; gap: 3px; min-width: 0; }.player-event-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }.player-event-row small, .player-event-row em { color: var(--muted); font-size: 11px; font-style: normal; }.player-event-row em { flex: 0 0 auto; align-self: center; }
.inline-player-link { padding: 0; color: var(--accent-strong); text-align: left; background: transparent; border: 0; border-bottom: 1px dotted currentColor; cursor: pointer; font: inherit; }
@media (max-width: 960px) {
  .main-pane { max-height: none; overflow: visible; }
  .event-pane { max-height: none; overflow: visible; }
}

/* --- identity language, disambiguation, coverage ----------------------- */
.identity-status, .data-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.2rem 0.48rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
}
.identity-status.verified, .data-status.cached { color: #17623b; background: #e9f7ef; border-color: #bfe5ce; }
.identity-status.presentation-high { color: #11578a; background: #ebf5fe; border-color: #badcfb; }
.identity-status.presentation-medium { color: #785517; background: #fff8e8; border-color: #ead6a7; }
.identity-status.pending, .data-status.compare { color: #845412; background: #fff6df; border-color: #ecd39a; }
.identity-status.same-name, .data-status.missing { color: #7a4350; background: #fff0f2; border-color: #e9c5cc; }
.eyebrow .identity-status, .eyebrow .data-status { margin-right: 0.35rem; }

.disambiguation-card { grid-column: 1 / -1; padding: 1rem; background: linear-gradient(145deg, #fff, #f8fbff); border: 1px solid rgba(23,105,170,.2); border-radius: 13px; }
.disambiguation-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.disambiguation-head > div { display: flex; align-items: center; flex-wrap: wrap; gap: 0.55rem; }
.disambiguation-head > div > strong { font-size: 1.08rem; }
.disambiguation-head small, .disambiguation-card > p { color: var(--muted); font-size: 0.76rem; }
.disambiguation-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.55rem; }
.disambiguation-options a { display: grid; gap: 0.3rem; padding: 0.75rem; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.disambiguation-options a:hover { border-color: var(--accent); }
.disambiguation-options span { color: var(--muted); font-size: 0.75rem; line-height: 1.45; }
.disambiguation-card > p { margin: 0.7rem 0 0; }

.gap-empty { display: grid; justify-items: start; gap: 0.5rem; }
.gap-empty span, .gap-empty small { color: var(--muted); }
.gap-empty .primary-button { margin-top: 0.25rem; }
.coverage-callout { display: flex; align-items: center; flex-wrap: wrap; gap: 0.65rem; margin: 0.8rem 0 1rem; padding: 0.75rem 0.85rem; color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; font-size: 0.8rem; }
.coverage-callout a { margin-left: auto; color: var(--accent-strong); font-weight: 700; }

.coverage-page { min-height: 100vh; overflow: auto; background: var(--canvas); }
.coverage-shell { width: min(1050px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 70px; }
.page-nav { display: flex; justify-content: space-between; margin-bottom: 2.5rem; color: var(--muted); font-size: 0.84rem; }
.coverage-head { margin-bottom: 1.5rem; }
.coverage-head h1 { margin: 0.35rem 0 0.65rem; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.045em; }
.coverage-head p { max-width: 700px; color: var(--muted); line-height: 1.7; }
.coverage-headline { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.coverage-headline > div { display: grid; gap: 0.25rem; padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.coverage-headline strong { font-size: clamp(1.3rem, 3vw, 2rem); }
.coverage-headline span { color: var(--muted); font-size: 0.76rem; }
.coverage-panel { padding: 1.1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(21,35,52,.03); }
.coverage-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; margin: 1rem 0; }
.stage-coverage { display: grid; gap: 0.75rem; }
.coverage-row { display: grid; grid-template-columns: 45px minmax(120px,1fr) minmax(150px,auto); align-items: center; gap: 0.7rem; font-size: 0.78rem; }
.coverage-row > span { color: var(--muted); text-align: right; }
.coverage-track { height: 9px; overflow: hidden; background: var(--line); border-radius: 99px; }
.coverage-track span { display: block; height: 100%; background: linear-gradient(90deg,var(--accent),#5ca5dc); border-radius: inherit; }
.mini-stat-row { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0.5rem; margin-bottom: 0.8rem; }
.mini-stat-row span { display: grid; gap: 0.2rem; padding: 0.65rem; color: var(--muted); background: var(--panel-soft); border-radius: 8px; font-size: 0.7rem; }
.mini-stat-row strong { color: var(--text); font-size: 1.05rem; }
.queue-list, .quality-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.queue-list li, .quality-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; padding: 0.65rem 0; border-top: 1px solid var(--line); }
.queue-list li > div, .quality-list li { min-width: 0; }
.queue-list strong, .queue-list span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-list strong { font-size: 0.8rem; }.queue-list span, .quality-list span { color: var(--muted); font-size: 0.7rem; }
.queue-list b { color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.quality-clear { padding: 1rem 0; color: #17623b; font-size: 0.82rem; }
.funnel-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.75rem; }
.funnel-step { padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.funnel-step span { display: block; color: var(--muted); font-size: 0.78rem; }
.funnel-step strong { display: block; margin-top: 0.35rem; font-size: 1.5rem; }
.coverage-note { color: var(--muted); font-size: 0.8rem; }
.status-language { display: grid; gap: 0.7rem; }
.status-language > div:not(.section-heading) { display: flex; align-items: center; gap: 0.75rem; }
.status-language p { margin: 0; color: var(--muted); font-size: 0.8rem; }
.privacy-foundation { margin: 1rem 0 0; padding: 1rem; color: var(--muted); background: #fffaf0; border: 1px solid #ead9ae; border-radius: 12px; font-size: 0.8rem; line-height: 1.7; }

/* Search-first homepage */
.search-workspace { display: block; width: min(1040px, 100%); margin: 0 auto; }
.search-main-pane { position: relative; overflow-y: auto; }
.search-command { position: sticky; top: 0; z-index: 7; display: grid; justify-items: center; padding: clamp(2rem, 7vh, 5rem) 1rem 1.25rem; text-align: center; background: var(--hero-gradient); }
.search-command h1 { max-width: 760px; margin: 0.35rem 0 1.25rem; font-size: clamp(1.55rem, 4vw, 2.25rem); letter-spacing: -0.035em; line-height: 1.15; }
.hero-search-form { display: grid; grid-template-columns: minmax(0, 720px) auto; width: min(820px, 92vw); gap: 0.65rem; }
.hero-search-box { height: 68px; padding-inline: 20px; background: var(--search-field); border-radius: 17px; box-shadow: var(--search-field-shadow); }
.hero-search-box:focus-within { background: var(--search-field-focus); }
.hero-search-box input { font-size: clamp(1rem, 2vw, 1.2rem); }
.hero-search-form > button { min-width: 84px; padding: 0 1.25rem; color: #fff; background: var(--accent-strong); border: 0; border-radius: 15px; cursor: pointer; font-weight: 720; }
.search-guidance { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.78rem; }
.search-command[data-mode="compact"] { padding: .7rem 1rem .85rem; }
.search-command[data-mode="compact"] > .eyebrow,
.search-command[data-mode="compact"] > h1,
.search-command[data-mode="compact"] > .search-guidance { display: none; }
.search-command[data-mode="compact"] .hero-search-form { width: min(760px, 92vw); }
.search-command[data-mode="compact"] .hero-search-box { height: 46px; border-radius: 13px; box-shadow: 0 8px 22px rgba(21,35,52,.09); }
.search-command[data-mode="compact"] .hero-search-form > button { min-height: 46px; border-radius: 12px; }
.search-home { display: grid; justify-items: center; align-content: start; min-height: min(34vh, 320px); padding: 0 1rem 3rem; text-align: center; }
.search-home p { margin: 0; color: var(--muted); line-height: 1.7; }
.search-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 1.2rem; }
.search-suggestions > span { align-self: center; color: var(--muted); font-size: 0.78rem; }
.search-suggestions button { padding: 0.45rem 0.75rem; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid transparent; border-radius: 999px; cursor: pointer; }
.search-suggestions button:hover { border-color: var(--accent); }
.search-main-pane > .search-results { width: min(960px, calc(100% - 32px)); margin: 0 auto 2rem; padding: 1rem; background: rgba(255,255,255,.98); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.search-limit-note { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.78rem; }
.player-name mark { padding: 0 .08em; color: inherit; background: #fff0a6; border-radius: 2px; }
.event-history-more { margin-top: 0.65rem; }
.event-history-more summary { padding: 0.7rem; color: var(--accent-strong); text-align: center; cursor: pointer; font-weight: 700; }
.player-event-row em { display: grid; justify-items: end; gap: 0.2rem; }
.player-event-row em b { color: var(--gold); font-style: normal; }
.viewer-keyboard-hint { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.76rem; }

/* Dedicated leaderboard page */
.leaderboard-page-shell { width: min(900px, calc(100% - 32px)); }
.leaderboard-filters { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; margin: 0 0 1rem; padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.leaderboard-filters > div { display: grid; gap: .45rem; }
.leaderboard-filters > div > span, .birth-year-filters > span, .stage-tab-section > span { color: var(--muted); font-size: .72rem; font-weight: 700; }
.filter-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.filter-chips button, .segmented-stage-tabs button { padding: .45rem .7rem; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.filter-chips button[aria-pressed="true"], .segmented-stage-tabs button[aria-selected="true"] { color: #fff; background: var(--accent-strong); border-color: var(--accent-strong); }
.filter-chips small, .segmented-stage-tabs small { margin-left: .2rem; opacity: .72; }
.filter-chips em { display: block; margin-top: .12rem; font-size: .58rem; font-style: normal; opacity: .75; }
.segmented-stage-tabs { display: grid; gap: .7rem; margin-bottom: 1rem; }
.stage-tab-section { display: grid; grid-template-columns: 5rem minmax(0,1fr); align-items: center; gap: .7rem; }
.stage-tab-section > div { display: flex; flex-wrap: wrap; gap: .4rem; }
.birth-year-filters { display: grid; gap: .5rem; margin: 0 0 1rem; padding: .85rem 1rem; background: var(--accent-soft); border-radius: 12px; }
.leaderboard-scope-note { margin: 0 0 1rem; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.single-page-grid { display: block; }
.leaderboard-page-card { padding: 1.2rem; }
.leaderboard-row-link { display: grid; grid-template-columns: 2.2rem minmax(0,1fr) auto; align-items: center; gap: 0.8rem; padding: 0.8rem 0; border-top: 1px solid var(--line); }
.leaderboard-row-link:first-of-type { border-top: 0; }
.leaderboard-row-link > span:nth-child(2) { display: grid; gap: 0.25rem; }
.leaderboard-row-link small { display: block; color: var(--muted); font-size: 0.72rem; }
.leaderboard-row-link .rating-value { display: grid; justify-items: end; font-size: 1.15rem; font-weight: 750; }

@media (max-width: 900px) {
  .topnav { justify-content: flex-start; }
}
@media (max-width: 680px) {
  .coverage-headline { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .coverage-grid { grid-template-columns: 1fr; }
  .coverage-row { grid-template-columns: 38px 1fr; }
  .coverage-row > span { grid-column: 2; text-align: left; }
  .disambiguation-head { flex-direction: column; }
  .topbar { grid-template-columns: 1fr; gap: 10px; padding: 10px 14px; }
  .top-actions { justify-content: space-between; }
  .topnav { min-width: 0; overflow-x: auto; }
  .theme-switcher { flex: none; }
  .search-workspace { padding: 12px; }
  .search-command { position: static; padding: 1.6rem 0.25rem 1rem; }
  .search-command[data-mode="compact"] { position: sticky; padding: .55rem 0 .7rem; }
  .hero-search-form { grid-template-columns: 1fr; width: 100%; }
  .hero-search-box { height: 62px; }
  .hero-search-form > button { min-height: 46px; }
  .search-home { min-height: 24vh; padding: 0 0.5rem 2rem; }
  .search-main-pane > .search-results { width: 100%; }
  .stage-tab-section { grid-template-columns: 1fr; }
}

/* U4: trust line under the search hero */
.search-trust { margin-top: 1.1rem; font-size: 0.82rem; color: var(--muted); }
.search-trust a { color: var(--accent-strong); text-decoration: none; }
.search-trust a:hover { text-decoration: underline; }

.site-footer { display: flex; flex: 0 0 auto; justify-content: center; gap: .7rem; padding: .75rem 1rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .75rem; }
.site-footer a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }

/* Homepage brand story. Search remains the entire first viewport; the story
   leaves the DOM flow whenever search results or a detail route is active. */
body.landing {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y proximity;
}
.landing .app-shell {
  min-height: 100svh;
  height: auto;
}
.landing .workspace {
  min-height: 0;
}
.landing .search-main-pane {
  overflow-y: visible;
}
.hero-brand-mark {
  width: clamp(88px, 10vw, 116px);
  height: clamp(88px, 10vw, 116px);
  margin-bottom: 0.35rem;
  padding: 8px;
  background: rgba(250, 249, 246, 0.86);
  border: 1px solid rgba(31, 59, 102, 0.12);
  border-radius: 28px;
  box-shadow: 0 18px 48px rgba(31, 59, 102, 0.1);
}
.search-command[data-mode="compact"] > .hero-brand-mark {
  display: none;
}
.scroll-cue {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  margin-top: clamp(1.8rem, 5vh, 3.2rem);
  color: var(--muted);
  font-size: 0.72rem;
}
.scroll-cue span:last-child {
  font-size: 1.25rem;
  animation: scrollCue 1.8s ease-in-out infinite;
}
.landing-active .brand-story,
.landing:not(.landing-active) .app-shell > .site-footer {
  display: none;
}
.brand-story {
  background: var(--brand-cream);
  color: var(--brand-navy);
}
.story-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  align-items: center;
  gap: clamp(2rem, 8vw, 8rem);
  min-height: 100svh;
  padding: clamp(5rem, 10vw, 9rem) max(6vw, calc((100vw - 1280px) / 2));
  overflow: hidden;
  scroll-snap-align: start;
}
.story-panel:nth-child(even) {
  background: #eef2f6;
}
.story-copy {
  max-width: 660px;
}
.story-kicker {
  display: inline-block;
  margin-bottom: 1.15rem;
  color: var(--brand-gold);
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0.2em;
}
.story-copy h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: clamp(2.3rem, 6vw, 5.4rem);
  letter-spacing: -0.055em;
  line-height: 0.98;
}
.story-copy > p:not(.story-number) {
  max-width: 590px;
  margin: 1.6rem 0 0;
  color: #53657d;
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  line-height: 1.75;
}
.story-scale {
  grid-template-columns: 1fr;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(circle at 50% 48%, rgba(201, 162, 39, 0.12), transparent 34%),
    var(--brand-cream);
}
.story-scale .story-copy {
  max-width: 920px;
}
.story-scale .story-copy > p:last-child {
  margin-inline: auto;
}
.story-number {
  margin: 0;
  color: var(--brand-navy);
  font-size: clamp(5.2rem, 19vw, 13rem);
  font-weight: 800;
  letter-spacing: -0.085em;
  line-height: 0.76;
  font-variant-numeric: tabular-nums;
}
.story-scale h2 {
  margin-top: 1.1rem;
  font-size: clamp(2rem, 5vw, 4.7rem);
}
.story-board {
  width: min(520px, 90vw);
  justify-self: center;
  filter: drop-shadow(0 28px 38px rgba(31, 59, 102, 0.2));
}
.story-rank-cards {
  display: grid;
  gap: 1rem;
  width: min(520px, 100%);
  justify-self: center;
}
.story-rank-cards article {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  padding: 1.3rem 1.5rem;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(31, 59, 102, 0.1);
  border-radius: 18px;
  box-shadow: 0 16px 42px rgba(31, 59, 102, 0.08);
}
.story-rank-cards article:nth-child(2) { transform: translateX(2rem); }
.story-rank-cards span,
.story-rank-cards small {
  color: #687990;
}
.story-rank-cards strong {
  grid-row: span 2;
  color: var(--brand-navy);
  font-size: 2.6rem;
}
.story-rank-cards small {
  margin-top: 0.35rem;
}
.story-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 2rem;
  padding: 0.8rem 1rem;
  color: var(--brand-navy);
  border: 1px solid rgba(31, 59, 102, 0.2);
  border-radius: 999px;
  font-weight: 720;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}
.story-cta:hover {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--brand-gold);
  transform: translateY(-2px);
}
.trust-rings {
  position: relative;
  width: min(510px, 86vw);
  aspect-ratio: 1;
  justify-self: center;
}
.trust-rings > span {
  position: absolute;
  display: grid;
  place-items: center;
  align-content: center;
  width: 47%;
  aspect-ratio: 1;
  color: var(--brand-navy);
  background: rgba(250, 249, 246, 0.86);
  border: 2px solid rgba(31, 59, 102, 0.17);
  border-radius: 50%;
  box-shadow: 0 18px 46px rgba(31, 59, 102, 0.09);
  font-size: clamp(1rem, 2.1vw, 1.45rem);
  font-weight: 760;
}
.trust-rings > span:nth-child(1) { left: 2%; top: 5%; }
.trust-rings > span:nth-child(2) { right: 2%; top: 5%; }
.trust-rings > span:nth-child(3) { left: 26.5%; bottom: 3%; }
.trust-rings small {
  margin-top: 0.4rem;
  color: #718097;
  font-size: 0.68em;
  font-weight: 600;
}
.story-community {
  grid-template-columns: 1fr;
  place-items: center;
  text-align: center;
  background: var(--brand-navy);
}
.story-community .story-copy {
  display: grid;
  justify-items: center;
  max-width: 900px;
}
.story-community .story-copy h2,
.story-community .story-copy > p {
  color: var(--brand-cream);
}
.story-community .story-copy > p {
  max-width: 680px;
}
.story-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}
.story-community .story-cta {
  color: var(--brand-cream);
  border-color: rgba(250, 249, 246, 0.35);
}
.story-community .story-cta:hover {
  background: rgba(250, 249, 246, 0.1);
  border-color: var(--brand-gold);
}
.story-community .story-cta-primary {
  color: var(--brand-navy);
  background: var(--brand-cream);
}
.story-community .story-cta-primary:hover {
  background: #fff;
}
.story-footer {
  position: absolute;
  right: 4vw;
  bottom: 1.5rem;
  left: 4vw;
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  color: rgba(250, 249, 246, 0.67);
  font-size: 0.75rem;
}
.story-footer a {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.compact-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: var(--text);
  font-weight: 720;
}
.compact-brand svg {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 4px;
  background: var(--brand-cream);
  border: 1px solid rgba(31, 59, 102, 0.13);
  border-radius: 9px;
}
:root[data-theme="dark"] .brand-story,
:root[data-theme="dark"] .story-panel {
  color: var(--brand-cream);
  background: #101923;
}
:root[data-theme="dark"] .story-panel:nth-child(even) {
  background: #162434;
}
:root[data-theme="dark"] .story-scale {
  background:
    radial-gradient(circle at 50% 48%, rgba(201, 162, 39, 0.16), transparent 34%),
    #101923;
}
:root[data-theme="dark"] .story-copy h2,
:root[data-theme="dark"] .story-number {
  color: var(--brand-cream);
}
:root[data-theme="dark"] .story-copy > p:not(.story-number) {
  color: #b9c6d4;
}
:root[data-theme="dark"] .story-rank-cards article,
:root[data-theme="dark"] .trust-rings > span {
  color: var(--brand-cream);
  background: rgba(31, 50, 70, 0.92);
  border-color: rgba(250, 249, 246, 0.13);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}
:root[data-theme="dark"] .story-rank-cards strong,
:root[data-theme="dark"] .trust-rings > span {
  color: var(--brand-cream);
}
:root[data-theme="dark"] .story-rank-cards span,
:root[data-theme="dark"] .story-rank-cards small,
:root[data-theme="dark"] .trust-rings small {
  color: #a9bacb;
}
:root[data-theme="dark"] .story-cta {
  color: var(--brand-cream);
  border-color: rgba(250, 249, 246, 0.24);
}
:root[data-theme="dark"] .story-community {
  background: #091421;
}
:root[data-theme="dark"] .story-community .story-cta-primary {
  color: var(--brand-navy);
}
.story-ready [data-reveal] {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 720ms ease, transform 720ms cubic-bezier(.2,.7,.2,1);
}
.story-ready [data-reveal].in-view {
  opacity: 1;
  transform: translateY(0);
}

@keyframes scrollCue {
  0%, 100% { transform: translateY(0); opacity: 0.58; }
  50% { transform: translateY(6px); opacity: 1; }
}

@media (max-width: 760px) {
  body.landing { scroll-snap-type: none; }
  .story-panel {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 3rem;
    min-height: 100svh;
    padding: 5rem 1.25rem;
  }
  .story-copy { text-align: center; }
  .story-copy > p:not(.story-number) { margin-inline: auto; }
  .story-rank-cards article:nth-child(2) { transform: none; }
  .story-board,
  .story-rank-cards,
  .trust-rings { max-width: 390px; }
  .story-footer { flex-direction: column; }
  .compact-brand span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  body.landing { scroll-behavior: auto; }
  .scroll-cue span:last-child { animation: none; }
  .story-ready [data-reveal],
  .story-cta {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Homepage narrative v2: search-only first viewport, then five restrained
   semantic chapters. These rules intentionally affect index.html only. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.landing:not(.landing-active) .workspace {
  display: flex;
  flex: 1;
  width: min(1120px, 100%);
}
.landing:not(.landing-active) .search-main-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  min-height: calc(100svh - 72px);
}
.landing:not(.landing-active) .search-command {
  position: relative;
  align-content: center;
  padding: clamp(4rem, 13vh, 8rem) 1.25rem 1rem;
  background: transparent;
}
.landing:not(.landing-active) .hero-search-form {
  display: block;
  width: min(780px, 92vw);
}
.landing:not(.landing-active) .hero-search-box {
  height: 64px;
  padding-inline: 22px;
  border-radius: 22px;
  box-shadow: 0 18px 54px rgba(31, 59, 102, 0.14), 0 2px 8px rgba(31, 59, 102, 0.08);
}
.landing:not(.landing-active) .hero-search-form > button {
  display: none;
}
.landing .search-command > .search-suggestions {
  margin-top: 1rem;
}
.landing:not(.landing-active) .search-home {
  min-height: auto;
  padding: 0 1rem clamp(1.25rem, 4vh, 2.75rem);
}
.landing:not(.landing-active) .scroll-cue {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  text-decoration: none;
}
.landing-active .search-command > .search-suggestions {
  display: none;
}
.brand-story {
  background: #f8f6f1;
}
.story-panel {
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  gap: clamp(2.5rem, 7vw, 7rem);
  background: #f8f6f1;
}
.story-panel:nth-child(even) {
  background: #eef2f5;
}
.story-copy h2 {
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 1.03;
}
.story-copy > p:not(.story-number) {
  margin-top: 1.5rem;
  font-size: clamp(1rem, 1.45vw, 1.2rem);
}
.story-copy > p strong {
  color: inherit;
  font-size: 1.08em;
  font-variant-numeric: tabular-nums;
}
.story-kicker {
  letter-spacing: 0.16em;
}
.fragment-field {
  position: relative;
  width: min(540px, 100%);
  min-height: 430px;
  justify-self: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 24%, rgba(201, 162, 39, 0.15), transparent 26%),
    radial-gradient(rgba(255, 255, 255, 0.09) 0.8px, transparent 0.8px),
    #111b27;
  background-size: auto, 6px 6px, auto;
  border-radius: 28px;
  box-shadow: 0 34px 80px rgba(17, 27, 39, 0.25);
}
.fragment-card {
  position: absolute;
  padding: 0.85rem 1rem;
  color: #e8edf3;
  background: rgba(35, 49, 65, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  font: 680 0.92rem/1 system-ui, sans-serif;
}
.fragment-a { top: 12%; left: 9%; transform: rotate(-7deg); }
.fragment-b { top: 24%; right: 7%; transform: rotate(5deg); }
.fragment-c { top: 49%; left: 18%; transform: rotate(3deg); }
.fragment-d { top: 62%; right: 15%; color: #ffaaa3; font-size: 1.5rem; transform: rotate(-5deg); }
.fragment-e { bottom: 8%; left: 8%; color: #d9c576; transform: rotate(2deg); }
.fragment-f { top: 7%; right: 29%; opacity: 0.58; transform: rotate(11deg); }
.fragment-field.in-view .fragment-card {
  animation: fragmentDrift 5s ease-in-out infinite alternate;
}
.fragment-field.in-view .fragment-b,
.fragment-field.in-view .fragment-d,
.fragment-field.in-view .fragment-f {
  animation-direction: alternate-reverse;
}
.identity-stack {
  position: relative;
  display: grid;
  place-items: center;
  width: min(520px, 100%);
  min-height: 430px;
  justify-self: center;
}
.identity-stack > span {
  position: absolute;
  padding: 0.8rem 1rem;
  color: #52657c;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(31, 59, 102, 0.13);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(31, 59, 102, 0.1);
  transition: opacity 620ms ease, transform 780ms cubic-bezier(.2,.75,.2,1);
}
.identity-stack > span:nth-child(1) { top: 6%; left: 4%; transform: rotate(-7deg); }
.identity-stack > span:nth-child(2) { top: 18%; right: 2%; transform: rotate(5deg); }
.identity-stack > span:nth-child(3) { bottom: 15%; left: 0; transform: rotate(4deg); }
.identity-stack > span:nth-child(4) { right: 6%; bottom: 5%; transform: rotate(-6deg); }
.identity-stack.in-view > span {
  opacity: 0;
  transform: translate(0, 20px) scale(0.84);
}
.identity-stack article {
  display: grid;
  width: min(380px, 84%);
  padding: 2rem;
  color: var(--brand-navy);
  background: #fff;
  border: 1px solid rgba(31, 59, 102, 0.12);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(31, 59, 102, 0.16);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 520ms 320ms ease, transform 720ms 320ms cubic-bezier(.2,.8,.2,1);
}
.identity-stack.in-view article {
  opacity: 1;
  transform: scale(1);
}
.identity-stack article small { color: var(--brand-gold); font-weight: 750; }
.identity-stack article strong { margin-top: 1rem; font-size: 2.2rem; }
.identity-stack article span { margin-top: 0.5rem; color: #65778e; }
.event-timeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: center;
  width: min(600px, 100%);
  min-height: 260px;
  justify-self: center;
}
.timeline-track {
  position: absolute;
  right: 5%;
  left: 5%;
  height: 3px;
  background: rgba(31, 59, 102, 0.15);
}
.event-timeline > span {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  justify-self: center;
  color: #718197;
  background: #fff;
  border: 2px solid rgba(31, 59, 102, 0.16);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 760;
  opacity: 0.55;
  transform: scale(0.82);
  transition: opacity 360ms calc(var(--step) * 120ms) ease, transform 360ms calc(var(--step) * 120ms) ease, border-color 360ms calc(var(--step) * 120ms) ease;
}
.event-timeline.in-view > span {
  opacity: 1;
  border-color: var(--brand-gold);
  transform: scale(1);
}
.event-timeline > strong {
  position: absolute;
  right: 0;
  bottom: 8%;
  padding: 0.62rem 0.82rem;
  color: #17623b;
  background: #e6f4ea;
  border: 1px solid #b9dec4;
  border-radius: 999px;
  font-size: 0.76rem;
}
.board-piece {
  font: 44px/1 Georgia, serif;
  text-anchor: middle;
}
.board-dark { fill: #17283d; }
.board-light { fill: #fffaf0; stroke: #1f3b66; stroke-width: 1.3px; }
.board-moved { opacity: 0; }
.story-board.in-view .board-moved { opacity: 1; }
.story-board.in-view .move { animation-duration: 800ms; animation-fill-mode: forwards; animation-timing-function: cubic-bezier(.2,.75,.2,1); }
.story-board.in-view .move-1 { animation-name: moveE4; animation-delay: 300ms; }
.story-board.in-view .move-2 { animation-name: moveE5; animation-delay: 1.15s; }
.story-board.in-view .move-3 { animation-name: moveNf3; animation-delay: 2s; }
.story-board.in-view .move-4 { animation-name: moveNc6; animation-delay: 2.85s; }
.story-board.in-view .move-origin {
  animation: hideOrigin 1ms forwards;
}
.story-board.in-view .origin-1 { animation-delay: 300ms; }
.story-board.in-view .origin-2 { animation-delay: 1.15s; }
.story-board.in-view .origin-3 { animation-delay: 2s; }
.story-board.in-view .origin-4 { animation-delay: 2.85s; }
.story-open,
.story-open:nth-child(even) {
  grid-template-columns: 1fr;
  place-items: center;
  text-align: center;
  color: var(--brand-cream);
  background: var(--brand-navy);
}
.story-open .story-copy {
  display: grid;
  justify-items: center;
  max-width: 940px;
}
.story-open .story-copy h2,
.story-open .story-copy > p {
  color: var(--brand-cream);
}
.story-open .story-copy > p {
  max-width: 720px;
}
.api-example {
  width: min(680px, 90vw);
  margin: 2rem auto 0;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  color: #dce8f3;
  background: #0c1724;
  border: 1px solid rgba(250, 249, 246, 0.18);
  border-radius: 16px;
  text-align: left;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  font: 0.88rem/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.story-open .story-cta {
  color: var(--brand-cream);
  border-color: rgba(250, 249, 246, 0.35);
}
.story-open .story-cta-primary {
  color: var(--brand-navy);
  background: var(--brand-cream);
}
.story-open .story-footer {
  align-items: center;
  color: rgba(250, 249, 246, 0.68);
}
:root[data-theme="dark"] .story-open,
:root[data-theme="dark"] .story-open:nth-child(even) {
  background: var(--brand-navy);
}
.story-full-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  color: var(--brand-cream);
}
.story-full-logo svg {
  width: 30px;
  height: 30px;
  padding: 3px;
  background: var(--brand-cream);
  border-radius: 8px;
}

@keyframes fragmentDrift {
  to { translate: 0 9px; }
}
@keyframes moveE4 { to { transform: translateY(-80px); } }
@keyframes moveE5 { to { transform: translateY(80px); } }
@keyframes moveNf3 { to { transform: translate(-40px, -80px); } }
@keyframes moveNc6 { to { transform: translate(40px, 80px); } }
@keyframes hideOrigin { to { opacity: 0; } }

@media (max-width: 760px) {
  .landing:not(.landing-active) .search-main-pane {
    min-height: calc(100svh - 126px);
  }
  .landing:not(.landing-active) .search-command {
    padding: 3rem 0 1rem;
  }
  .landing:not(.landing-active) .hero-search-form {
    width: 100%;
  }
  .landing:not(.landing-active) .hero-search-box {
    height: 62px;
    padding-inline: 17px;
    border-radius: 20px;
  }
  .landing:not(.landing-active) .hero-search-box input {
    font-size: 0.94rem;
  }
  .story-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.3rem;
    min-height: 100svh;
    padding: 5rem 1.25rem;
  }
  .story-panel > * {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }
  .story-copy h2 {
    font-size: clamp(2.25rem, 11vw, 3.5rem);
  }
  .fragment-field,
  .identity-stack {
    min-height: 330px;
  }
  .event-timeline {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem 0.5rem;
    min-height: 280px;
  }
  .timeline-track { display: none; }
  .event-timeline > strong {
    right: 50%;
    bottom: 0;
    transform: translateX(50%);
    white-space: nowrap;
  }
  .event-timeline > span {
    width: 48px;
  }
  .story-open {
    padding-bottom: 7rem;
  }
  .story-actions {
    display: grid;
    width: min(320px, 100%);
  }
  .story-actions .story-cta {
    justify-content: center;
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fragment-field.in-view .fragment-card,
  .story-board.in-view .move,
  .story-board.in-view .move-origin {
    animation: none;
  }
  .identity-stack > span {
    display: none;
  }
  .identity-stack article,
  .event-timeline > span {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .board-moved {
    display: none;
  }
}

/* U6: expandable leaderboard tail (rows 21+) */
.leaderboard-more > summary { padding: 0.7rem 0.4rem; color: var(--accent-strong); font-size: 0.85rem; cursor: pointer; list-style: none; text-align: center; }
.leaderboard-more > summary::-webkit-details-marker { display: none; }
.leaderboard-more[open] > summary { color: var(--muted); }

/* Foldable event-detail sections (概览常显，名单/逐轮/排名可折叠) */
details.event-fold > summary { cursor: pointer; list-style: none; }
details.event-fold > summary::-webkit-details-marker { display: none; }
details.event-fold > summary > span::after { content: " ▾"; opacity: .6; }
details.event-fold[open] > summary > span::after { content: " ▴"; opacity: .6; }

/* Theme selection is resolved before CSS loads by theme.js. "Auto" updates
   data-theme whenever the operating-system preference changes; the media
   query below remains a no-script fallback. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f141a;
  --panel: #182029;
  --panel-soft: #202a35;
  --surface: #182029;
  --ink: #edf3f8;
  --line: #344250;
  --text: #edf3f8;
  --muted: #a7b4c2;
  --accent: #67b9f4;
  --accent-strong: #8fd0ff;
  --accent-soft: #17374e;
  --gold: #f0c96b;
  --gold-soft: #3d3218;
  --danger: #ff9b94;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  --hero-gradient: linear-gradient(180deg, rgba(15, 20, 26, 0.99) 80%, rgba(15, 20, 26, 0));
  --search-field: #1b2530;
  --search-field-focus: #202c38;
  --search-field-shadow: 0 16px 44px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(143, 208, 255, 0.08);
}

:root[data-theme="dark"] .topbar { background: rgba(15, 20, 26, 0.9); }
:root[data-theme="dark"] .theme-switcher { background: #151c24; border-color: #344250; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28); }
:root[data-theme="dark"] .theme-switcher button:hover { background: #202a35; }
:root[data-theme="dark"] .theme-switcher button[aria-pressed="true"] { color: #d7efff; background: #294154; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.34); }
:root[data-theme="dark"] .search-box { background: var(--search-field); border-color: #405264; }
:root[data-theme="dark"] .search-box:focus-within { background: var(--search-field-focus); border-color: #67b9f4; box-shadow: 0 0 0 4px rgba(103, 185, 244, 0.13), var(--search-field-shadow); }
:root[data-theme="dark"] .search-box input::placeholder { color: #8f9eae; }
:root[data-theme="dark"] .hero-search-form > button { background: linear-gradient(180deg, #2582c3, #17669f); box-shadow: 0 10px 24px rgba(0, 84, 141, 0.28); }
:root[data-theme="dark"] .leaderboard-card,
:root[data-theme="dark"] .detail-pane { background: rgba(24, 32, 41, 0.95); }
:root[data-theme="dark"] .leaderboard-table tr + tr { border-top-color: var(--line); }
:root[data-theme="dark"] .leaderboard-table tr:hover { background: rgba(103, 185, 244, 0.1); }
:root[data-theme="dark"] .rank-badge,
:root[data-theme="dark"] .stage-chip { background: #303d4a; }
:root[data-theme="dark"] .bulk-player-hit { background: #18332f; border-color: #28544d; }
:root[data-theme="dark"] .static-player-hit { background: #172f45; border-color: #2a506e; }
:root[data-theme="dark"] .pgn-package-button,
:root[data-theme="dark"] .event-player,
:root[data-theme="dark"] .viewer-select select,
:root[data-theme="dark"] .viewer-game-side,
:root[data-theme="dark"] .pgn-download-link,
:root[data-theme="dark"] .disambiguation-options a { color: var(--text); background: var(--panel); border-color: var(--line); }
:root[data-theme="dark"] .pgn-package-button { color: var(--accent-strong); }
:root[data-theme="dark"] .domestic-chip { color: #f0c96b; background: #3d3218; border-color: #665527; }
:root[data-theme="dark"] .event-pane { background: linear-gradient(150deg, rgba(24,32,41,.98), rgba(20,39,54,.94)); border-color: #2b506c; }
:root[data-theme="dark"] .event-facts > div { background: rgba(32,42,53,.86); border-color: #2a4a61; }
:root[data-theme="dark"] .event-loading,
:root[data-theme="dark"] .event-empty { background: rgba(24,32,41,.78); border-color: #35566d; }
:root[data-theme="dark"] .player-event-history { background: rgba(23,36,48,.92); border-color: #2a4a61; }
:root[data-theme="dark"] .player-event-row { border-top-color: rgba(103,185,244,.16); }
:root[data-theme="dark"] .credit-howto { background: rgba(24,53,75,.6); border-color: #35566d; }
:root[data-theme="dark"] .credit-chip,
:root[data-theme="dark"] .disambiguation-card { background: linear-gradient(145deg, #1b242d, #172b3a); border-color: #34566f; }
:root[data-theme="dark"] .pgn-viewer { background: #141a20; border-color: var(--line); }
:root[data-theme="dark"] .search-main-pane > .search-results { background: rgba(24,32,41,.98); }
:root[data-theme="dark"] .player-chip:hover { background: var(--panel); }
:root[data-theme="dark"] .player-name mark { background: #66551e; }
:root[data-theme="dark"] .privacy-foundation { background: #332b1c; border-color: #5e5030; }
:root[data-theme="dark"] .identity-status.verified,
:root[data-theme="dark"] .data-status.cached { color: #9be2b8; background: #183626; border-color: #2d6041; }
:root[data-theme="dark"] .identity-status.presentation-high { color: #a8d7fa; background: #17354b; border-color: #315c78; }
:root[data-theme="dark"] .identity-status.presentation-medium,
:root[data-theme="dark"] .identity-status.pending,
:root[data-theme="dark"] .data-status.compare { color: #f0cf83; background: #3b311b; border-color: #66552c; }
:root[data-theme="dark"] .identity-status.same-name,
:root[data-theme="dark"] .data-status.missing { color: #f1b3bd; background: #40242a; border-color: #70404a; }
:root[data-theme="dark"] .pairing-pgn.available { color: #9be2b8; background: #183626; border-color: #2d6041; }
:root[data-theme="dark"] .quality-clear { color: #9be2b8; }
:root[data-theme="dark"] .lichess-viewer-shell {
  --c-lpv-bg: #141a20;
  --c-lpv-bg-player: #182029;
  --c-lpv-bg-controls: #182029;
  --c-lpv-bg-movelist: #182029;
  --c-lpv-bg-variation: #202a35;
  --c-lpv-bg-pane: #182029;
  --c-lpv-side-border: #344250;
  --c-lpv-border: #344250;
  --c-lpv-font: #edf3f8;
  --c-lpv-font-shy: #a7b4c2;
  --c-lpv-font-bg: #344250;
  --c-lpv-accent: #67b9f4;
  --c-lpv-accent-over: #0f141a;
  --c-lpv-current-move: #67b9f4;
  --c-lpv-move-hover: #17374e;
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --canvas: #0f141a;
    --panel: #182029;
    --panel-soft: #202a35;
    --surface: #182029;
    --ink: #edf3f8;
    --line: #344250;
    --text: #edf3f8;
    --muted: #a7b4c2;
    --accent: #67b9f4;
    --accent-strong: #8fd0ff;
    --accent-soft: #17374e;
    --hero-gradient: linear-gradient(180deg, rgba(15, 20, 26, 0.99) 80%, rgba(15, 20, 26, 0));
    --search-field: #1b2530;
    --search-field-focus: #202c38;
    --search-field-shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
  }
}
