:root {
  --bg: #100d09;
  --bg-deep: #0a0806;
  --panel: rgba(29, 22, 15, 0.92);
  --panel-soft: rgba(42, 31, 20, 0.72);
  --line: rgba(222, 178, 105, 0.18);
  --line-strong: rgba(222, 178, 105, 0.34);
  --text: #f4ead8;
  --muted: #b9aa93;
  --gold: #d9a95e;
  --gold-bright: #f0c878;
  --rust: #9b4b2d;
  --rust-bright: #c96f43;
  --green: #79a778;
  --red: #d17468;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --shell: min(1120px, calc(100% - 32px));
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 80% -10%, rgba(184, 102, 49, 0.18), transparent 38%),
    radial-gradient(circle at 15% 0%, rgba(218, 169, 94, 0.08), transparent 28%),
    linear-gradient(180deg, #17110c 0%, var(--bg) 46%, var(--bg-deep) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.01) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

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

.shell { width: var(--shell); margin-inline: auto; }

.sand-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px max(20px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(13, 10, 7, .82);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  letter-spacing: .12em;
}
.brand-logo {
  width: 74px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
}
.brand strong { display: block; font-size: .78rem; color: var(--gold-bright); white-space: nowrap; }
.brand small { display: block; margin-top: 1px; font-size: .64rem; letter-spacing: .08em; color: var(--muted); }

.main-nav { display: flex; align-items: center; gap: 6px; }
.main-nav a {
  padding: 9px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-size: .9rem;
  transition: .18s ease;
}
.main-nav a:hover,
.main-nav a.is-active { color: var(--text); background: rgba(217,169,94,.1); }
.nav-toggle { display: none; }

.view[hidden] { display: none !important; }

.hero {
  min-height: 570px;
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  align-items: center;
  gap: 56px;
  padding-block: 72px 60px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 500; line-height: 1.05; }
h1 { font-size: clamp(2.7rem, 6vw, 5.5rem); letter-spacing: -.045em; }
h1 em { color: var(--gold-bright); font-weight: 400; }
h2 { font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.03em; }
h3 { font-size: 1.25rem; }

.hero-text { max-width: 650px; margin: 24px 0 0; color: var(--muted); font-size: 1.08rem; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #211207; background: linear-gradient(135deg, var(--gold-bright), #c8893f); box-shadow: 0 8px 32px rgba(201,137,63,.18); }
.button-secondary { color: var(--text); border-color: var(--line-strong); background: rgba(255,255,255,.025); }
.button-danger { color: #fff4f2; border-color: rgba(209,116,104,.4); background: rgba(133,42,31,.28); }

.hero-art {
  position: relative;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 220px 220px 26px 26px;
  background:
    radial-gradient(circle at 50% 36%, rgba(196, 72, 35, .18), transparent 38%),
    linear-gradient(180deg, rgba(49, 19, 12, .82), rgba(12, 9, 6, .42));
  box-shadow: var(--shadow);
}
.hero-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 213, 134, .12), transparent 34%),
    linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .34));
}
.hero-art img {
  position: relative;
  z-index: 1;
  width: min(88%, 480px);
  max-height: 370px;
  object-fit: contain;
  filter: drop-shadow(0 22px 35px rgba(0, 0, 0, .35));
}

.section-block { padding-block: 48px 84px; }
.section-page { min-height: 72vh; padding-block: 64px 90px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.section-heading p:not(.eyebrow) { margin: 10px 0 0; color: var(--muted); max-width: 720px; }
.section-heading-page { align-items: center; }
.info-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: 0 0 auto; }
.text-button { border: 0; padding: 0; background: none; color: var(--gold-bright); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }

.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.summary-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}
.summary-card span { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; }
.summary-card strong { display: block; margin-top: 8px; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 500; color: var(--gold-bright); }
.summary-card small { display: block; margin-top: 3px; color: var(--muted); }

.tab-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.stat-tab {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.stat-tab.is-active { color: #201307; background: var(--gold); border-color: var(--gold); font-weight: 700; }

.leader-chart-panel {
  margin: 0 0 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 13, 9, .72);
}
.leader-chart-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.leader-chart-header h3 { font-size: 1.75rem; text-transform: uppercase; letter-spacing: .03em; }
.leader-chart-header p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); }
.chart-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.02);
}
.chart-toggle-button {
  padding: 7px 12px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
}
.chart-toggle-button.is-active { color: #1d1007; background: var(--gold-bright); }
.leader-chart-scroll { overflow-x: auto; padding: 10px 2px 2px; }
.leader-chart {
  display: grid;
  grid-template-columns: repeat(18, minmax(48px, 1fr));
  align-items: end;
  gap: 7px;
  min-width: 930px;
  height: 270px;
  padding: 16px 10px 0;
  border-left: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background-image: repeating-linear-gradient(to top, transparent 0, transparent 66px, rgba(222,178,105,.09) 67px);
}
.leader-chart-item {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  justify-items: center;
  min-width: 0;
}
.leader-chart-bar-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
}
.leader-chart-bar {
  position: relative;
  width: min(26px, 68%);
  min-height: 2px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--gold-bright), var(--rust-bright));
}
.leader-chart-value {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  color: var(--gold-bright);
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
}
.leader-avatar {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-top: -1px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--gold-bright);
  background: #24170f;
  font-family: Georgia, serif;
  font-size: .68rem;
}
.leader-avatar img { width: 100%; height: 100%; object-fit: cover; }
.leader-chart-label {
  width: 100%;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: .63rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart-note { margin: 14px 0 0; color: var(--muted); font-size: .78rem; }
.seat-tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.seat-table-group h3 { margin: 0 0 10px; color: var(--gold-bright); font-size: 1.5rem; }
.seat-table-group .table-shell { height: calc(100% - 36px); }
.seat-table-group table { min-width: 540px; }

.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(17,13,9,.62); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 15px 16px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .11em; background: rgba(217,169,94,.04); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s ease; }
tbody tr[data-player] { cursor: pointer; }
tbody tr:hover { background: rgba(217,169,94,.045); }
.rank-cell { width: 64px; color: var(--gold); font-family: Georgia, serif; font-size: 1.1rem; }
.player-name-cell strong { display: block; }
.player-name-cell small { color: var(--muted); }
.rating-cell { font-family: Georgia, serif; font-size: 1.18rem; color: var(--gold-bright); }
.delta { font-size: .78rem; margin-left: 7px; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }

.empty-state { padding: 36px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; }

.filters { display: grid; grid-template-columns: 1fr 220px; gap: 14px; margin-bottom: 22px; }
label { display: block; color: var(--muted); font-size: .82rem; font-weight: 700; letter-spacing: .02em; }
input, select {
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  background: rgba(9,7,5,.72);
  outline: none;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,169,94,.1); }
select option { background: #17110c; color: var(--text); }

.games-list { display: grid; gap: 14px; }
.game-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel-soft);
}
.game-card-header { display: flex; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.game-card-header p { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.game-card-actions { display: flex; align-items: center; gap: 12px; }
.game-count { color: var(--gold); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; }
.icon-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; }
.icon-button:hover { color: var(--red); }
.game-results { display: grid; }
.game-result-row {
  display: grid;
  grid-template-columns: 52px minmax(130px, 1fr) minmax(150px, 1fr) 100px 100px;
  gap: 12px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(222,178,105,.1);
}
.game-result-row:last-child { border-bottom: 0; }
.finish-medal { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--gold-bright); font-family: Georgia, serif; }
.result-meta { color: var(--muted); font-size: .85rem; }
.result-rating { text-align: right; font-variant-numeric: tabular-nums; }

.record-form {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.form-grid { display: grid; gap: 14px; }
.form-grid-meta { grid-template-columns: 1fr 1fr 2fr; margin-bottom: 26px; }
.form-span-two { grid-column: auto; }
.optional { color: #796b59; font-weight: 500; }
.player-entry-header,
.player-entry {
  display: grid;
  grid-template-columns: 70px minmax(150px, 1.15fr) minmax(170px, 1.25fr) minmax(130px, .8fr);
  gap: 12px;
  align-items: center;
}
.player-entry-header { padding: 0 12px 8px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.player-entries { display: grid; gap: 9px; }
.player-entry { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.player-entry input, .player-entry select { margin-top: 0; }
.placement-badge { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(217,169,94,.12); color: var(--gold-bright); font-family: Georgia, serif; font-size: 1.1rem; }
.mobile-label { display: none; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.form-message { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.form-error { color: #ffd7d2; border-color: rgba(209,116,104,.4); background: rgba(139,45,34,.2); }
.form-success { color: #d8f3d7; border-color: rgba(121,167,120,.4); background: rgba(54,105,53,.2); }

.data-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-soft); }
.panel h2 { font-size: 1.6rem; }
.panel p { color: var(--muted); }
.panel-danger { border-color: rgba(209,116,104,.28); }
.file-label { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; color: var(--text); }
.file-label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.site-footer { border-top: 1px solid var(--line); background: rgba(6,5,4,.55); }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; padding-block: 24px; color: var(--muted); font-size: .78rem; }
.footer-inner p { margin: 0; }

.dialog {
  width: min(620px, calc(100% - 28px));
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: #17110c;
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 12px; right: 14px; border: 0; background: none; color: var(--muted); font-size: 1.8rem; cursor: pointer; }
.dialog p { color: var(--muted); }
.dialog ul { color: var(--muted); }
.formula-box { margin: 18px 0; padding: 14px; border-left: 3px solid var(--gold); background: rgba(217,169,94,.07); overflow-x: auto; }
.formula-box code { color: var(--gold-bright); }
.placement-example-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.placement-example-grid > div { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); }
.placement-example-grid strong,
.placement-example-grid span { display: block; }
.placement-example-grid strong { margin-bottom: 7px; color: var(--gold-bright); }
.placement-example-grid span { color: var(--muted); }
.player-dialog { width: min(760px, calc(100% - 28px)); }
.player-profile-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; padding-right: 30px; }
.player-rating-large { color: var(--gold-bright); font-family: Georgia, serif; font-size: 2rem; text-align: right; }
.profile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.profile-stat { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.profile-stat span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.profile-stat strong { display: block; margin-top: 5px; color: var(--gold-bright); font-family: Georgia, serif; font-size: 1.25rem; }
.profile-list { display: grid; gap: 8px; }
.profile-list-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.profile-list-row:last-child { border-bottom: 0; }

@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 54px; }
  .hero-art { min-height: 320px; max-width: 560px; width: 100%; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .seat-tables { grid-template-columns: 1fr; }
  .form-grid-meta { grid-template-columns: 1fr 1fr; }
  .form-span-two { grid-column: 1 / -1; }
  .game-result-row { grid-template-columns: 44px 1fr 1fr 80px; }
  .game-result-row .result-rating-before { display: none; }
  .profile-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  :root { --shell: min(100% - 22px, 1120px); }
  .site-header { padding-inline: 12px; }
  .nav-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; color: var(--text); background: transparent; }
  .main-nav { position: absolute; top: calc(100% + 1px); right: 10px; display: none; width: 190px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: #17110c; box-shadow: var(--shadow); }
  .main-nav.is-open { display: grid; }
  .main-nav a { border-radius: 9px; }
  .brand small { display: none; }
  .brand-logo { width: 56px; height: 38px; }
  .brand strong { font-size: .67rem; letter-spacing: .08em; }
  .hero { gap: 34px; }
  .hero-art { min-height: 260px; }
  .section-heading { display: block; }
  .info-actions { align-items: flex-start; margin-top: 16px; }
  .section-heading .button { margin-top: 16px; }
  .leader-chart-header { display: block; }
  .chart-toggle { margin-top: 14px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr; }
  .game-card-header { align-items: flex-start; }
  .game-result-row { grid-template-columns: 40px 1fr auto; gap: 10px; }
  .game-result-row .leader-name { grid-column: 2; }
  .game-result-row .result-meta { grid-column: 2; }
  .result-rating { grid-column: 3; grid-row: 1 / span 3; }
  .record-form { padding: 16px; }
  .form-grid-meta { grid-template-columns: 1fr; }
  .form-span-two { grid-column: auto; }
  .player-entry-header { display: none; }
  .player-entry { grid-template-columns: 48px 1fr; align-items: start; }
  .placement-badge { grid-row: 1 / span 3; }
  .player-entry label { grid-column: 2; }
  .mobile-label { display: block; margin-bottom: 5px; }
  .footer-inner { display: grid; }
  .profile-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
  h1 { font-size: 2.55rem; }
  .summary-grid { grid-template-columns: 1fr; }
  .placement-example-grid { grid-template-columns: 1fr; }
  .hero-actions .button, .form-actions .button { width: 100%; }
  .player-profile-head { display: block; }
  .player-rating-large { margin-top: 12px; text-align: left; }
}

/* Leader portrait enhancements */
.leader-chart-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: .8rem;
}
.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 7px;
  border-radius: 3px;
  vertical-align: -1px;
}
.legend-swatch-picks { background: linear-gradient(180deg, #f49b2f, #cc6d12); }
.legend-swatch-win { background: linear-gradient(180deg, #f3ca8d, #dca85f); }
.leader-chart {
  grid-template-columns: repeat(18, minmax(54px, 1fr));
  min-width: 990px;
  height: 282px;
  padding-bottom: 6px;
}
.leader-chart-item {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
.leader-chart-item:hover .leader-avatar,
.leader-chart-item:focus-visible .leader-avatar {
  box-shadow: 0 0 0 2px rgba(255,255,255,.07), 0 0 0 4px rgba(217,169,94,.22);
}
.leader-chart-bars {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
}
.leader-chart-bar {
  width: min(18px, 34%);
  min-height: 2px;
  opacity: .72;
  transition: opacity .15s ease, transform .15s ease;
}
.leader-chart-bar.is-emphasis {
  opacity: 1;
  transform: translateY(-1px);
}
.leader-chart-bar-picks { background: linear-gradient(180deg, #f49b2f, #cc6d12); }
.leader-chart-bar-win { background: linear-gradient(180deg, #f3ca8d, #dca85f); }
.leader-chart-value { font-size: .67rem; }
.leader-avatar img {
  object-position: center 24%;
}
.leader-avatar--small { width: 38px; height: 38px; font-size: .74rem; }
.leader-avatar--tiny { width: 24px; height: 24px; font-size: .56rem; }
.leader-avatar--large { width: 74px; height: 74px; font-size: 1rem; }
.leader-avatar--preview { width: 42px; height: 42px; font-size: .82rem; }
.leader-avatar--empty {
  color: var(--muted);
  background: rgba(255,255,255,.03);
}
.entity-with-avatar,
.profile-entry-label,
.leader-name-inline,
.leader-profile-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.leader-name-inline { color: var(--text); }
.leader-profile-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding-right: 30px;
}
.leader-rating-large {
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 2rem;
  text-align: right;
}
.leader-submetric {
  color: var(--muted);
  font-size: .78rem;
  font-family: Inter, system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.player-name-cell .entity-with-avatar strong,
.player-name-cell .entity-with-avatar small {
  display: block;
}
tbody tr[data-leader] { cursor: pointer; }
.leader-select-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}
.leader-select-wrap select { min-width: 0; }
.game-result-row .leader-name { color: var(--muted); }

@media (max-width: 680px) {
  .leader-chart-legend { margin-top: 10px; }
  .leader-profile-head { display: block; }
  .leader-rating-large { margin-top: 12px; text-align: left; }
  .leader-select-wrap { grid-template-columns: 1fr; }
  .leader-select-preview { margin-top: 8px; }
}

/* Responsive statistics layout fixes */
[hidden] { display: none !important; }

.leader-chart-scroll {
  overflow: hidden;
  padding-inline: 0;
}

.leader-chart {
  width: 100%;
  min-width: 0;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  gap: clamp(1px, .45vw, 7px);
  padding-inline: clamp(2px, .8vw, 10px);
}

.leader-chart-bars {
  gap: clamp(1px, .22vw, 4px);
}

.leader-chart-bar {
  width: min(18px, 42%);
}

.leader-chart-item .leader-avatar {
  width: min(32px, calc(100% - 2px));
  height: auto;
  aspect-ratio: 1;
}

.leader-chart-label {
  font-size: clamp(.42rem, .68vw, .63rem);
}

.seat-tables {
  width: 100%;
  align-items: start;
}

.seat-table-group {
  min-width: 0;
}

.seat-table-group h3 {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.seat-table-group h3 span {
  color: var(--muted);
  font-family: Inter, system-ui, sans-serif;
  font-size: .8rem;
  font-weight: 500;
}

.seat-table-group .seat-table-shell {
  width: 100%;
  height: auto;
  overflow: hidden;
}

.seat-table-group .seat-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.seat-table th,
.seat-table td {
  padding: 15px clamp(8px, 1.2vw, 16px);
}

.seat-table th:first-child,
.seat-table td:first-child {
  width: 37%;
}

.seat-table th:not(:first-child),
.seat-table td:not(:first-child) {
  width: 21%;
}

@media (max-width: 680px) {
  .leader-chart-panel { padding-inline: 12px; }
  .leader-chart { height: 245px; }
  .leader-chart-value { font-size: .56rem; }
  .seat-table th, .seat-table td { padding: 12px 7px; font-size: .78rem; }
  .seat-table th { font-size: .61rem; letter-spacing: .06em; }
}

/* Shared account and sync controls */
.account-area { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.sync-status { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.sync-status[data-state="online"]::before { content: "●"; color: var(--green); margin-right: 5px; }
.sync-status[data-state="offline"]::before { content: "●"; color: var(--gold); margin-right: 5px; }
.sync-status[data-state="error"]::before { content: "●"; color: var(--red); margin-right: 5px; }
.sync-status[data-state="syncing"]::before { content: "◌"; color: var(--gold); margin-right: 5px; }
.account-button {
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,.025);
  cursor: pointer;
}
.account-button:disabled { cursor: default; opacity: .75; }
.auth-dialog { width: min(520px, calc(100% - 28px)); }
.auth-tabs { display: flex; gap: 8px; margin: 18px 0; }
.auth-tab {
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.auth-tab.is-active { color: #201307; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.auth-form { display: grid; gap: 14px; }
.auth-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
button:disabled { opacity: .58; cursor: wait; }

@media (max-width: 760px) {
  .sync-status { display: none; }
  .account-area { margin-left: 0; }
  .account-button { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Final shared UI refinements */
.auth-dialog {
  width: min(520px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: none;
  overflow: hidden;
}

.leader-chart-bar-wrap {
  padding-bottom: 10px;
}

/* Mobile usability refinements */
@media (max-width: 680px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .site-header {
    inset-inline: 0;
    width: 100%;
    min-width: 100%;
    max-width: none;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .leader-chart-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .leader-chart {
    width: 200%;
    min-width: 200%;
    grid-template-columns: repeat(18, minmax(0, 1fr));
    gap: 4px;
    padding-inline: 5px;
  }

  .leader-chart-item {
    scroll-snap-align: start;
  }

  .leader-chart-bar-wrap {
    padding-bottom: 18px;
  }

  .leader-chart-item .leader-avatar {
    width: min(34px, calc(100% - 4px));
  }

  .leader-chart-label {
    font-size: .52rem;
  }
}

/* Mobile header fit and 6.5-leader chart viewport */
@media (max-width: 680px) {
  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }

  .brand {
    min-width: 0;
    gap: 6px;
    overflow: hidden;
  }

  .brand-logo {
    width: 48px;
    height: 34px;
  }

  .brand > span {
    min-width: 0;
  }

  .brand strong {
    max-width: 100%;
    font-size: clamp(.5rem, 2.25vw, .61rem);
    line-height: 1.18;
    letter-spacing: .055em;
    white-space: normal;
  }

  .account-area {
    min-width: 0;
    margin-left: 0;
  }

  .account-button {
    width: auto;
    max-width: 84px;
    min-height: 36px;
    padding: 7px 10px;
    font-size: .82rem;
  }

  .nav-toggle {
    min-width: 60px;
    justify-content: center;
    padding: 7px 9px;
    font-size: .82rem;
    white-space: nowrap;
  }

  .main-nav {
    right: max(8px, env(safe-area-inset-right));
  }

  .leader-chart-scroll {
    scrollbar-width: none;
  }

  .leader-chart-scroll::-webkit-scrollbar {
    display: none;
  }

  .leader-chart {
    width: 276.923%;
    min-width: 276.923%;
  }
}

@media (max-width: 370px) {
  .site-header {
    gap: 4px;
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
  }

  .brand-logo {
    width: 43px;
    height: 31px;
  }

  .brand strong {
    font-size: .48rem;
    letter-spacing: .04em;
  }

  .account-button {
    max-width: 76px;
    padding-inline: 8px;
    font-size: .77rem;
  }

  .nav-toggle {
    min-width: 56px;
    padding-inline: 7px;
    font-size: .77rem;
  }
}

/* Final leaderboard column order and compact mobile tables */
@media (max-width: 680px) {
  #standings-table {
    min-width: 620px;
  }

  #standings-table th,
  #standings-table td {
    padding: 10px 8px;
    font-size: .72rem;
    line-height: 1.25;
  }

  #standings-table th {
    font-size: .56rem;
    letter-spacing: .055em;
    white-space: normal;
  }

  #standings-table .rank-cell {
    width: 38px;
    font-size: .9rem;
  }

  #standings-table .rating-cell {
    font-size: .94rem;
    white-space: nowrap;
  }

  #standings-table .delta {
    margin-left: 4px;
    font-size: .62rem;
  }

  #standings-table .player-name-cell strong {
    font-size: .76rem;
  }

  #standings-table .player-name-cell small {
    display: block;
    margin-top: 2px;
    max-width: 132px;
    font-size: .59rem;
    line-height: 1.2;
  }

  #standings-table .leader-avatar--small {
    width: 30px;
    height: 30px;
  }

  #standings-table .entity-with-avatar {
    gap: 7px;
  }
}

@media (max-width: 390px) {
  #standings-table {
    min-width: 585px;
  }

  #standings-table th,
  #standings-table td {
    padding-inline: 6px;
  }
}
